亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? overlay.java

?? 非常有用的操作pdf文件的java源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * Copyright (c) 2003, www.pdfbox.org
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. Neither the name of pdfbox; nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * http://www.pdfbox.org
 *
 */
package org.pdfbox;

import org.pdfbox.cos.COSArray;
import org.pdfbox.cos.COSBase;
import org.pdfbox.cos.COSDictionary;
import org.pdfbox.cos.COSName;
import org.pdfbox.cos.COSStream;
import org.pdfbox.cos.COSInteger;
import org.pdfbox.exceptions.COSVisitorException;
import org.pdfbox.pdfparser.PDFParser;
import org.pdfbox.pdfwriter.COSWriter;

import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.pdmodel.PDDocumentCatalog;
import org.pdfbox.pdmodel.PDPage;
import org.pdfbox.pdmodel.PDResources;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.Map;

/**
 * Overlay on document with another one.<br>
 * e.g. Overlay an invoice with your company layout<br>
 * <br>
 * How it (should) work:<br>
 * If the document has 10 pages, and the layout 2 the following is the result:<br>
 * <pre>
 * Document: 1234567890
 * Layout  : 1212121212
 * </pre>
 * <br>
 *
 * @author Mario Ivankovits (mario@ops.co.at)
 * @author <a href="ben@benlitchfield.com">Ben Litchfield</a>
 *
 * @version $Revision: 1.6 $
 */
public class Overlay
{
    /**
     * COSName constant.
     */
    public static final COSName XOBJECT = COSName.getPDFName("XObject");
    /**
     * COSName constant.
     */
    public static final COSName PROC_SET = COSName.getPDFName("ProcSet");
    /**
     * COSName constant.
     */
    public static final COSName EXT_G_STATE = COSName.getPDFName("ExtGState" );

    private List layoutPages = new ArrayList(10);

    private PDDocument pdfOverlay;
    private PDDocument pdfDocument;
    private int pageCount = 0;
    private COSStream saveGraphicsStateStream;
    private COSStream restoreGraphicsStateStream;

    /**
     * This will overlay a document and write out the results.<br/><br/>
     *
     * usage: java org.pdfbox.Overlay &lt;overlay.pdf&gt; &lt;document.pdf&gt; &lt;result.pdf&gt;
     *
     * @param args The command line arguments.
     *
     * @throws IOException If there is an error reading/writing the document.
     * @throws COSVisitorException If there is an error writing the document.
     */
    public static void main( String[] args ) throws IOException, COSVisitorException
    {
        if( args.length != 3 )
        {
            usage();
            System.exit(1);
        }
        else
        {
            PDDocument overlay = null;
            PDDocument pdf = null;

            try
            {
                overlay = getDocument( args[0] );
                pdf = getDocument( args[1] );
                Overlay overlayer = new Overlay();
                overlayer.overlay( overlay, pdf );
                writeDocument( pdf, args[2] );
            }
            finally
            {
                if( overlay != null )
                {
                    overlay.close();
                }
                if( pdf != null )
                {
                    pdf.close();
                }
            }
        }
    }

    private static void writeDocument( PDDocument pdf, String filename ) throws IOException, COSVisitorException
    {
        FileOutputStream output = null;
        COSWriter writer = null;
        try
        {
            output = new FileOutputStream( filename );
            writer = new COSWriter( output );
            writer.write( pdf );
        }
        finally
        {
            if( writer != null )
            {
                writer.close();
            }
            if( output != null )
            {
                output.close();
            }
        }
    }

    private static PDDocument getDocument( String filename ) throws IOException
    {
        FileInputStream input = null;
        PDFParser parser = null;
        PDDocument result = null;
        try
        {
            input = new FileInputStream( filename );
            parser = new PDFParser( input );
            parser.parse();
            result = parser.getPDDocument();
        }
        finally
        {
            if( input != null )
            {
                input.close();
            }
        }
        return result;
    }

    private static void usage()
    {
        System.err.println( "usage: java " + Overlay.class.getName() + "<overlay.pdf> <document.pdf> <result.pdf>" );
    }

    /**
     * Private class.
     */
    private static class LayoutPage
    {
        private final COSBase contents;
        private final COSDictionary res;
        private final Map objectNameMap;

        /**
         * Constructor.
         *
         * @param contentsValue The contents.
         * @param resValue The resource dictionary
         * @param objectNameMapValue The map
         */
        public LayoutPage(COSBase contentsValue, COSDictionary resValue, Map objectNameMapValue)
        {
            contents = contentsValue;
            res = resValue;
            objectNameMap = objectNameMapValue;
        }
    }

    /**
     * This will overlay two documents onto each other.  The overlay document is
     * repeatedly overlayed onto the destination document for every page in the
     * destination.
     *
     * @param overlay The document to copy onto the destination
     * @param destination The file that the overlay should be placed on.
     *
     * @return The destination pdf, same as argument passed in.
     *
     * @throws IOException If there is an error accessing data.
     */
    public PDDocument overlay( PDDocument overlay, PDDocument destination ) throws IOException
    {
        pdfOverlay = overlay;
        pdfDocument = destination;

        PDDocumentCatalog overlayCatalog = pdfOverlay.getDocumentCatalog();
        collectLayoutPages( overlayCatalog.getAllPages() );

        COSDictionary saveGraphicsStateDic = new COSDictionary();
        saveGraphicsStateStream = new COSStream( saveGraphicsStateDic, pdfDocument.getDocument().getScratchFile() );
        OutputStream saveStream = saveGraphicsStateStream.createUnfilteredStream();
        saveStream.write( " q\n".getBytes() );
        saveStream.flush();

        restoreGraphicsStateStream = new COSStream( saveGraphicsStateDic, pdfDocument.getDocument().getScratchFile() );
        OutputStream restoreStream = restoreGraphicsStateStream.createUnfilteredStream();
        restoreStream.write( " Q\n".getBytes() );
        restoreStream.flush();


        PDDocumentCatalog pdfCatalog = pdfDocument.getDocumentCatalog();
        processPages( pdfCatalog.getAllPages() );

        return pdfDocument;
    }

    private void collectLayoutPages( List pages) throws IOException
    {
        Iterator pagesIter = pages.iterator();
        while( pagesIter.hasNext() )
        {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲裸体xxx| 日韩欧美国产三级电影视频| 精品一二三四区| 日韩高清中文字幕一区| 亚洲不卡av一区二区三区| 午夜精品福利一区二区蜜股av| 亚洲国产另类av| 老司机精品视频导航| 精品系列免费在线观看| 国产激情精品久久久第一区二区| 久久国产精品区| 丁香婷婷综合色啪| 91丨porny丨最新| 欧美美女喷水视频| 精品久久久久久无| 国产精品国产馆在线真实露脸 | 琪琪一区二区三区| 国模无码大尺度一区二区三区| 国产成人一区在线| 色综合久久综合网| 欧美va亚洲va在线观看蝴蝶网| 国产亚洲精久久久久久| 亚洲乱码国产乱码精品精小说 | 久久久久久久久久美女| 国产精品美女久久久久久久久久久| 亚洲色图欧洲色图| 欧美aaa在线| av一区二区久久| 制服丝袜在线91| 国产日产欧美一区| 五月婷婷激情综合| 成人激情视频网站| 制服丝袜亚洲精品中文字幕| 国产农村妇女精品| 肉丝袜脚交视频一区二区| 国产精品99久| 在线不卡中文字幕| 国产精品福利一区二区| 丝袜诱惑制服诱惑色一区在线观看 | 久久精品欧美一区二区三区不卡| 日韩一区日韩二区| 久久精品国产一区二区三| 99re热视频这里只精品| 欧美va在线播放| 亚洲一区免费视频| 成人免费高清视频在线观看| 欧美一区永久视频免费观看| 亚洲欧洲一区二区三区| 国产原创一区二区三区| 宅男噜噜噜66一区二区66| 国产精品久久网站| 国内精品久久久久影院色| 欧美日韩精品是欧美日韩精品| 国产精品久久久久久亚洲毛片 | 亚洲综合色自拍一区| 成人一区在线看| 日韩欧美一二三| 婷婷综合五月天| 欧美视频日韩视频在线观看| 国产精品福利av| 成人午夜电影久久影院| 久久精品亚洲乱码伦伦中文| 精品一区二区三区免费| 日韩久久免费av| 免费视频最近日韩| 91精品国产综合久久婷婷香蕉| 亚洲日本一区二区| 91麻豆视频网站| 中文字幕在线不卡国产视频| 北岛玲一区二区三区四区| 日本一区二区动态图| 国产精品18久久久| 久久久久88色偷偷免费| 国产精品123区| 日本电影欧美片| 三级欧美在线一区| 波多野结衣在线aⅴ中文字幕不卡| 蜜桃av一区二区三区| 欧美优质美女网站| 亚洲二区视频在线| 欧美日本在线一区| 蜜桃视频在线一区| 久久免费国产精品| 成人av片在线观看| 亚洲精品少妇30p| 欧美三区免费完整视频在线观看| 亚洲美女淫视频| 欧洲av一区二区嗯嗯嗯啊| 亚洲一级二级三级| 日韩一区二区三区免费看| 九色porny丨国产精品| 久久精品人人做人人爽97| jlzzjlzz国产精品久久| 亚洲一二三专区| 日韩一区二区精品在线观看| 亚洲男人天堂一区| 亚洲成人免费影院| av男人天堂一区| 亚洲成av人片www| 欧美精品一区二区三区蜜桃| 成人一二三区视频| 亚洲综合丁香婷婷六月香| 欧美电视剧免费全集观看| 成人教育av在线| 日韩精品91亚洲二区在线观看| www久久精品| 在线免费不卡电影| 久久97超碰色| 亚洲一区二区三区小说| 精品成人私密视频| 欧洲国产伦久久久久久久| 国产一区二区三区电影在线观看| 综合精品久久久| 精品日韩一区二区三区| 91小宝寻花一区二区三区| 蜜桃视频第一区免费观看| 国产精品久久久久一区二区三区共| 欧美挠脚心视频网站| 国产精品中文欧美| 亚洲不卡av一区二区三区| 国产精品麻豆久久久| 日韩欧美一级特黄在线播放| 91精品办公室少妇高潮对白| 国产精品一区免费在线观看| 午夜精品视频在线观看| 亚洲摸摸操操av| 中文av字幕一区| 日韩欧美高清一区| 欧美日韩精品欧美日韩精品| 99国产精品久| 成人免费视频国产在线观看| 久久成人综合网| 日韩在线播放一区二区| 亚洲永久精品国产| 1区2区3区国产精品| 国产目拍亚洲精品99久久精品 | 亚洲18女电影在线观看| 亚洲欧美视频一区| 欧美国产视频在线| 国产亚洲精品精华液| 久久色成人在线| 欧美本精品男人aⅴ天堂| 欧美电影在线免费观看| 欧美日韩一区二区三区四区五区| 99精品国产99久久久久久白柏| 国产精品中文欧美| 国产黄色91视频| 国产91色综合久久免费分享| 国产成人亚洲精品青草天美| 国产一区二区三区日韩| 激情六月婷婷综合| 豆国产96在线|亚洲| 国产高清视频一区| 成人午夜大片免费观看| 成人激情午夜影院| 一本色道久久加勒比精品| 一本色道久久综合亚洲aⅴ蜜桃 | 国产一区二区三区四区五区美女| 美女任你摸久久| 久久99精品久久久久婷婷| 8v天堂国产在线一区二区| 91色综合久久久久婷婷| 欧美综合一区二区三区| 蜜桃av噜噜一区| 日韩av电影免费观看高清完整版在线观看| 亚洲午夜视频在线| 午夜电影一区二区三区| 麻豆国产精品一区二区三区| 精品一区二区影视| 国产91精品入口| 一本色道久久综合亚洲aⅴ蜜桃 | 久久久久久久综合狠狠综合| 欧美激情一区二区三区全黄| 亚洲色图视频免费播放| 视频一区二区国产| 国产成人免费视| 欧洲精品一区二区三区在线观看| 这里只有精品99re| 亚洲国产精品二十页| 亚洲午夜精品在线| 精品一区二区精品| 色综合色综合色综合| 性做久久久久久免费观看 | 精品久久久久久久久久久久久久久| 精品视频在线看| 久久免费国产精品| 一区二区三区四区av| 精品中文av资源站在线观看| 99久久精品国产观看| 欧美一级日韩免费不卡| 欧美激情一区二区三区蜜桃视频| 亚洲丰满少妇videoshd| 丁香天五香天堂综合| 91精品国产欧美一区二区18 | 一区二区三区在线播| 国产在线麻豆精品观看| 在线观看免费亚洲| 欧美国产综合一区二区| 蜜臀国产一区二区三区在线播放 | 午夜免费久久看|