There are many flexible options when merging or appending a document using our MergeOptions object. MergeOptions is used to specify exactly what information you would like preserved from the PDF file that you are merging or appending.
Because there are a few common cases in which a user would typically need certain MergeOptions set, we have defined three static MergeOptions that could commonly be used:
- MergeOptions.getAll() - Used when you want all the MergeOptions properties to propagate from the PDF document being merged or appended.
- MergeOptions.getAppend() - Typically used when appending PDF documents.
- MergeOptions.getNone() - Used when none of the PDF document's MergeOptions are wanted on the final PDF.
Note: If MergeOptions is not specified in a MergeDocument constructor than the MergeOptions.All will be used. Alternatively, if MergeOptions is not specified in the Append method than the MergeOptions.Append will be used.
This example shows how some of these static MergeOptions might typically be used:
[Java]
MergeDocument document = new MergeDocument( "[PhysicalPath]\Doucment1.pdf", MergeOptions.getAll() );
document.append( "[PhysicalPath]\Doucment2.pdf", MergeOptions.getAppend() );
document.draw( "[PhysicalPath]\MyDocument.pdf" );
A MergeOptions object can also be instantiated and defined giving you complete control over the different parts of the document that will or will not be merged into the final PDF. When a MergeOptions object is instantiated, by default all it’s properties are set to true.
The following example displays how to create a MergeOptions object and define certain properties:
[Java]
MergeOptions options = new MergeOptions( false );
options.setPageAnnotations(false);
options.setOutlines(false);
options.setDocumentInfo(false);
MergeDocument document = new MergeDocument( "[PhysicalPath]\Doucment1.pdf", MergeOptions.getAll() );
document.append( "[PhysicalPath]\Doucment2.pdf", options );
document.draw( "[PhysicalPath]\MyDocument.pdf" );