Package org.apache.pdfbox.util
Class PDFMergerUtility
java.lang.Object
org.apache.pdfbox.util.PDFMergerUtility
This class will take a list of pdf documents and merge them, saving the
result in a new document.
- Author:
- Ben Litchfield
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Add a source file to the list of files to merge.void
addSources
(List<InputStream> sourcesList) 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.Get the name of the destination file.Get the destination OutputStream.boolean
Indicates if acroform errors are ignored or not.void
Merge the list of source documents, saving the result in the destination file.void
mergeDocumentsNonSeq
(RandomAccess scratchFile) Merge the list of source documents with the non sequential parser, saving the result in the destination file.void
setDestinationFileName
(String destination) Set the name of the destination file.void
setDestinationStream
(OutputStream destStream) Set the destination OutputStream.void
setIgnoreAcroFormErrors
(boolean ignoreAcroFormErrorsValue) Set to true to ignore acroform errors.
-
Constructor Details
-
PDFMergerUtility
public PDFMergerUtility()Instantiate a new PDFMergerUtility.
-
-
Method Details
-
getDestinationFileName
Get the name of the destination file.- Returns:
- Returns the destination.
-
setDestinationFileName
Set the name of the destination file.- Parameters:
destination
- The destination to set.
-
getDestinationStream
Get the destination OutputStream.- Returns:
- Returns the destination OutputStream.
-
setDestinationStream
Set the destination OutputStream.- Parameters:
destStream
- The destination to set.
-
addSource
Add a source file to the list of files to merge.- Parameters:
source
- Full path and file name of source document.
-
addSource
Add a source file to the list of files to merge.- Parameters:
source
- File representing source document
-
addSource
Add a source to the list of documents to merge.- Parameters:
source
- InputStream representing source document
-
addSources
Add a list of sources to the list of documents to merge.- Parameters:
sourcesList
- List of InputStream objects representing source documents
-
mergeDocuments
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.
-
mergeDocumentsNonSeq
Merge the list of source documents with the non sequential parser, saving the result in the destination file.- Parameters:
scratchFile
- location to store temp PDFBox data for this output document, can be null if temp data is to be stored in memory- Throws:
IOException
- If there is an error saving the document.COSVisitorException
- If an error occurs while saving the destination file.
-
appendDocument
append all pages from source to destination.- Parameters:
destination
- the document to receive the pagessource
- the document originating the new pages- Throws:
IOException
- If there is an error accessing data from either document.
-
isIgnoreAcroFormErrors
public boolean isIgnoreAcroFormErrors()Indicates if acroform errors are ignored or not.- Returns:
- true if acroform errors are ignored
-
setIgnoreAcroFormErrors
public void setIgnoreAcroFormErrors(boolean ignoreAcroFormErrorsValue) Set to true to ignore acroform errors.- Parameters:
ignoreAcroFormErrorsValue
- true if acroform errors should be ignored
-