org.apache.pdfbox.util
Class PDFMergerUtility

java.lang.Object
  extended by org.apache.pdfbox.util.PDFMergerUtility

public class PDFMergerUtility
extends Object

This class will take a list of pdf documents and merge them, saving the result in a new document.

Version:
$Revision: 1.3 $
Author:
Ben Litchfield

Constructor Summary
PDFMergerUtility()
          Instantiate a new PDFMergerUtility.
 
Method Summary
 void addSource(File source)
          Add a source file to the list of files to merge.
 void addSource(InputStream source)
          Add a source to the list of documents to merge.
 void addSource(String source)
          Add a source file to the list of files to merge.
 void addSources(List<InputStream> sources)
          Add a list of sources to the list of documents to merge.
 void appendDocument(PDDocument destination, PDDocument source)
          append all pages from source to destination.
 String getDestinationFileName()
          Get the name of the destination file.
 OutputStream getDestinationStream()
          Get the destination OutputStream.
 void mergeDocuments()
          Merge the list of source documents, saving the result in the destination file.
 void setDestinationFileName(String destination)
          Set the name of the destination file.
 void setDestinationStream(OutputStream destinationStream)
          Set the destination OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFMergerUtility

public PDFMergerUtility()
Instantiate a new PDFMergerUtility.

Method Detail

getDestinationFileName

public String getDestinationFileName()
Get the name of the destination file.

Returns:
Returns the destination.

setDestinationFileName

public void setDestinationFileName(String destination)
Set the name of the destination file.

Parameters:
destination - The destination to set.

getDestinationStream

public OutputStream getDestinationStream()
Get the destination OutputStream.

Returns:
Returns the destination OutputStream.

setDestinationStream

public void setDestinationStream(OutputStream destinationStream)
Set the destination OutputStream.

Parameters:
destination - The destination to set.

addSource

public void addSource(String source)
Add a source file to the list of files to merge.

Parameters:
source - Full path and file name of source document.

addSource

public void addSource(File source)
Add a source file to the list of files to merge.

Parameters:
source - File representing source document

addSource

public void addSource(InputStream source)
Add a source to the list of documents to merge.

Parameters:
source - InputStream representing source document

addSources

public void addSources(List<InputStream> sources)
Add a list of sources to the list of documents to merge.

Parameters:
source - List of InputStream objects representing source documents

mergeDocuments

public void mergeDocuments()
                    throws IOException,
                           COSVisitorException
Merge the list of source documents, saving the result in the destination file.

Throws:
IOException - If there is an error saving the document.
COSVisitorException - If an error occurs while saving the destination file.

appendDocument

public void appendDocument(PDDocument destination,
                           PDDocument source)
                    throws IOException
append all pages from source to destination.

Parameters:
destination - the document to receive the pages
source - the document originating the new pages
Throws:
IOException - If there is an error accessing data from either document.


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.