Package com.tom_roush.pdfbox.multipdf
Class PDFMergerUtility
- java.lang.Object
-
- com.tom_roush.pdfbox.multipdf.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.
-
-
Constructor Summary
Constructors Constructor Description PDFMergerUtility()Instantiate a new PDFMergerUtility.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSource(File source)Add a source file to the list of files to merge.voidaddSource(InputStream source)Add a source to the list of documents to merge.voidaddSource(String source)Add a source file to the list of files to merge.voidaddSources(List<InputStream> sourcesList)Add a list of sources to the list of documents to merge.voidappendDocument(PDDocument destination, PDDocument source)append all pages from source to destination.StringgetDestinationFileName()Get the name of the destination file.OutputStreamgetDestinationStream()Get the destination OutputStream.booleanisIgnoreAcroFormErrors()Indicates if acroform errors are ignored or not.voidmergeDocuments(boolean useScratchFiles)Merge the list of source documents, saving the result in the destination file.voidsetDestinationFileName(String destination)Set the name of the destination file.voidsetDestinationStream(OutputStream destStream)Set the destination OutputStream.voidsetIgnoreAcroFormErrors(boolean ignoreAcroFormErrorsValue)Set to true to ignore acroform errors.
-
-
-
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 destStream)
Set the destination OutputStream.- Parameters:
destStream- The destination to set.
-
addSource
public void addSource(String source) throws FileNotFoundException
Add a source file to the list of files to merge.- Parameters:
source- Full path and file name of source document.- Throws:
FileNotFoundException- If the file doesn't exist
-
addSource
public void addSource(File source) throws FileNotFoundException
Add a source file to the list of files to merge.- Parameters:
source- File representing source document- Throws:
FileNotFoundException- If the file doesn't exist
-
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> sourcesList)
Add a list of sources to the list of documents to merge.- Parameters:
sourcesList- List of InputStream objects representing source documents
-
mergeDocuments
public void mergeDocuments(boolean useScratchFiles) throws IOExceptionMerge the list of source documents, saving the result in the destination file.- Parameters:
useScratchFiles- enables the usage of a scratch file if set to true- Throws:
IOException- If there is an error saving the document.
-
appendDocument
public void appendDocument(PDDocument destination, PDDocument source) throws IOException
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
-
-