public class PDFMergerUtility extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PDFMergerUtility.AcroFormMergeMode
The mode to use when merging AcroForm between documents:
PDFMergerUtility.AcroFormMergeMode.JOIN_FORM_FIELDS_MODE fields with the same fully qualified name
will be merged into one with the widget annotations of the merged fields
becoming part of the same field. |
static class |
PDFMergerUtility.DocumentMergeMode
The mode to use when merging documents:
PDFMergerUtility.DocumentMergeMode.OPTIMIZE_RESOURCES_MODE Optimizes resource handling such as
closing documents early. |
| Constructor and Description |
|---|
PDFMergerUtility()
Instantiate a new PDFMergerUtility.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSource(File source)
Add a source file to the list of files to merge.
|
void |
addSource(org.apache.pdfbox.io.RandomAccessRead 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<org.apache.pdfbox.io.RandomAccessRead> 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.
|
PDFMergerUtility.AcroFormMergeMode |
getAcroFormMergeMode()
Get the merge mode to be used for merging AcroForms between documents
PDFMergerUtility.AcroFormMergeMode |
PDDocumentInformation |
getDestinationDocumentInformation()
Get the destination document information that is to be set in
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction). |
String |
getDestinationFileName()
Get the name of the destination file.
|
PDMetadata |
getDestinationMetadata()
Set the destination metadata that is to be set in
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction). |
OutputStream |
getDestinationStream()
Get the destination OutputStream.
|
PDFMergerUtility.DocumentMergeMode |
getDocumentMergeMode()
Get the merge mode to be used for merging documents
PDFMergerUtility.DocumentMergeMode |
boolean |
isIgnoreAcroFormErrors()
Indicates if acroform errors are ignored or not.
|
void |
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction)
Merge the list of source documents, saving the result in the destination file.
|
void |
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction,
CompressParameters compressParameters)
Merge the list of source documents, saving the result in the destination file.
|
void |
setAcroFormMergeMode(PDFMergerUtility.AcroFormMergeMode theAcroFormMergeMode)
Set the merge mode to be used for merging AcroForms between documents
PDFMergerUtility.AcroFormMergeMode |
void |
setDestinationDocumentInformation(PDDocumentInformation info)
Set the destination document information that is to be set in
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction). |
void |
setDestinationFileName(String destination)
Set the name of the destination file.
|
void |
setDestinationMetadata(PDMetadata meta)
Set the destination metadata that is to be set in
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction). |
void |
setDestinationStream(OutputStream destStream)
Set the destination OutputStream.
|
void |
setDocumentMergeMode(PDFMergerUtility.DocumentMergeMode theDocumentMergeMode)
Set the merge mode to be used for merging documents
PDFMergerUtility.DocumentMergeMode |
void |
setIgnoreAcroFormErrors(boolean ignoreAcroFormErrorsValue)
Set to true to ignore acroform errors.
|
public PDFMergerUtility.AcroFormMergeMode getAcroFormMergeMode()
PDFMergerUtility.AcroFormMergeModepublic void setAcroFormMergeMode(PDFMergerUtility.AcroFormMergeMode theAcroFormMergeMode)
PDFMergerUtility.AcroFormMergeModetheAcroFormMergeMode - AcroFormMergeMode to be usedpublic PDFMergerUtility.DocumentMergeMode getDocumentMergeMode()
PDFMergerUtility.DocumentMergeModepublic void setDocumentMergeMode(PDFMergerUtility.DocumentMergeMode theDocumentMergeMode)
PDFMergerUtility.DocumentMergeModetheDocumentMergeMode - DocumentMergeMode to be usedpublic String getDestinationFileName()
public void setDestinationFileName(String destination)
destination - The destination to set.public OutputStream getDestinationStream()
public void setDestinationStream(OutputStream destStream)
destStream - The destination to set.public PDDocumentInformation getDestinationDocumentInformation()
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction).
The default is null, which means that it is ignored.public void setDestinationDocumentInformation(PDDocumentInformation info)
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction).
The default is null, which means that it is ignored.info - The destination document information.public PDMetadata getDestinationMetadata()
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction).
The default is null, which means that it is ignored.public void setDestinationMetadata(PDMetadata meta)
mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction).
The default is null, which means that it is ignored.meta - The destination metadata.public void addSource(String source) throws FileNotFoundException
source - Full path and file name of source document.FileNotFoundException - If the file doesn't existpublic void addSource(File source) throws FileNotFoundException
source - File representing source documentFileNotFoundException - If the file doesn't existpublic void addSource(org.apache.pdfbox.io.RandomAccessRead source)
source - RandomAccessRead representing source documentpublic void addSources(List<org.apache.pdfbox.io.RandomAccessRead> sourcesList)
sourcesList - List of RandomAccessRead objects representing source documentspublic void mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction)
throws IOException
appendDocument(org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.PDDocument).streamCacheCreateFunction - a function to create an instance of a stream cache; in case of null
unrestricted main memory is usedIOException - If there is an error saving the document.public void mergeDocuments(org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction,
CompressParameters compressParameters)
throws IOException
appendDocument(org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.PDDocument).streamCacheCreateFunction - a function to create an instance of a stream cache; in case of null
unrestricted main memory is usedcompressParameters - defines if compressed object streams are enabledIOException - If there is an error saving the document.public void appendDocument(PDDocument destination, PDDocument source) throws IOException
destination - the document to receive the pagessource - the document originating the new pagesIOException - If there is an error accessing data from either
document.public boolean isIgnoreAcroFormErrors()
public void setIgnoreAcroFormErrors(boolean ignoreAcroFormErrorsValue)
ignoreAcroFormErrorsValue - true if acroform errors should be
ignoredCopyright © 2002–2022 The Apache Software Foundation. All rights reserved.