Package org.apache.pdfbox.examples.util
Class PDFMergerExample
java.lang.Object
org.apache.pdfbox.examples.util.PDFMergerExample
This example demonstrates the use of the new methods
PDFMergerUtility.setDestinationDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation) and PDFMergerUtility.setDestinationMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) that were added in April 2016. These allow to control the meta data in a merge without having
to reopen the result file.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate PDDocumentInformationcreatePDFDocumentInfo(String title, String creator, String subject) private PDFMergerUtilitycreatePDFMergerUtility(List<RandomAccessRead> sources, ByteArrayOutputStream mergedPDFOutputStream) private PDMetadatacreateXMPMetadata(COSStream cosStream, String title, String creator, String subject) merge(List<RandomAccessRead> sources) Creates a compound PDF document from a list of input documents.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
PDFMergerExample
public PDFMergerExample()
-
-
Method Details
-
merge
Creates a compound PDF document from a list of input documents.The merged document is PDF/A-1b compliant, provided the source documents are as well. It contains document properties title, creator and subject, currently hard-coded.
- Parameters:
sources- list of source PDF documents as RandomAccessRead.- Returns:
- compound PDF document as a readable input stream.
- Throws:
IOException- if anything goes wrong during PDF merge.
-
createPDFMergerUtility
private PDFMergerUtility createPDFMergerUtility(List<RandomAccessRead> sources, ByteArrayOutputStream mergedPDFOutputStream) -
createPDFDocumentInfo
-
createXMPMetadata
private PDMetadata createXMPMetadata(COSStream cosStream, String title, String creator, String subject) throws BadFieldValueException, TransformerException, IOException
-