org.pdfbox.util

Class PDFMergerUtility


public class PDFMergerUtility
extends java.lang.Object

This class will take a list of pdf documents and merge them, saving the result in a new document.
Version:
$Revision: 1.2 $
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 mere.
void
addSource(String source)
Add a source file to the list of files to merge.
void
appendDocument(PDDocument destination, PDDocument source)
append all pages from source to destination.
String
getDestinationFileName()
Get the name of the destination file.
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.

Constructor Details

PDFMergerUtility

public PDFMergerUtility()
Instantiate a new PDFMergerUtility.

Method Details

addSource

public void addSource(File source)
Add a source file to the list of files to mere.
Parameters:
source - File representing source document

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.

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

getDestinationFileName

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

mergeDocuments

public void mergeDocuments()
            throws IOException,
                   COSVisitorException
Merge the list of source documents, saving the result in the destination file.
Throws:
COSVisitorException - If an error occurs while saving the destination file.

setDestinationFileName

public void setDestinationFileName(String destination)
Set the name of the destination file.
Parameters:
destination - The destination to set.