Merge Options

When merging PDFs, often information such as JavaScript, a PDF's properties, metadata, form fields, and other content wish to be excluded from an existing PDF to be merged. Use the MergeOptions class to customize what is merged from an existing PDF.

MergeOptions

The MergeOptions class customizes how documents are merged. The MergeOptions class has numerous properties that customize which content from a PDF is merged.

Properties

Property Description
All Gets a MergeOptions object with all options set to true.
AllOtherData Gets or sets a value indicating if all other document data should be imported.
Append Gets a MergeOptions object that you would typically use when appending documents.
DocumentInfo Gets or sets a value indicating if document information should be imported.
DocumentJavaScript Gets or sets a value indicating if document level JavaScript should be imported.
DocumentProperties Gets or sets a value indicating if document properties should be imported.
EmbeddedFiles Gets or sets a value indicating if the Embedded files should be imported.
FormFields Gets or sets a value indicating if form fields should be imported.
FormsXfaData Gets or sets a value indicating if form XFA data should be imported.
LogicalStructure Gets or Sets the value indicating if logical structure should be imported.
None Gets a MergeOptions object with all options set to false.
OpenAction Gets or sets a value indicating if the documents opening action (initial page and zoom settings) should be imported.
OptionalContentInfo Gets or sets the Output Content should be imported.
Outlines Gets or sets a value indicating if outlines and bookmarks should be imported.
OutputIntent Gets or Sets a value indication if OutputIntent should be imported.
PageAnnotations Gets or sets a value indicating if annotations should be imported.
PageLabelsAndSections Gets or sets a value indicating if page labels and sections should be imported.
RootFormField Gets or sets the root form field for imported form fields.
RootOutline Gets or sets the root outline for imported outlines.
XmpMetadata Gets or sets a value indicating if Xmp Metadata should be imported.

Using MergeOptions Statically

To simplify merging, there are three defined static MergeOptions properties that do not require a user to specify numerous properties needlessly when merging.

By default, if a MergeDocument instance's constructor omits specifying MergeOptions, then it uses the MergeOptions.All as the merge options. When using a MergeDocument instance's Append method, if the method omits specifying merge options, then it uses MergeOptions.Append as the merge options.

The following example illustrates using MergeOptions statically.

MergeDocument document = new MergeDocument( pdfFilePath, MergeOptions.All );
document.Append( pdfFilePath, MergeOptions.Append );
document.Draw(pdfFilePath);        
Dim MyDocument As MergeDocument = New MergeDocument( pdfFilePath, MergeOptions.All )
MyDocument.Append( pdfFilePath, MergeOptions.Append )
MyDocument.Draw(pdfFilePath)   

Using MergeOptions

Instantiate a MergeOptions instance - rather than use one of its static methods - for complete control over the document parts that are merged into the final PDF.

A MergeOptions instance sets all properties as true by default.

The following example illustrates creating a MergeOptions instance and defining several of its properties.

MergeOptions options = new MergeOptions( false );
options.PageAnnotations = false;
options.Outlines = false;
options.DocumentInfo = false;
MergeDocument document = new MergeDocument( pdfFilePath, MergeOptions.All );
document.Append( pdfFilePath, options );
document.Draw(pdfFilePath);       
Dim options As MergeOptions = New MergeOptions( False )
options.PageAnnotations = False
options.Outlines = False
options.DocumentInfo = False
Dim MyDocument As MergeDocument = New MergeDocument( pdfFilePath, MergeOptions.All )
MyDocument.Append( pdfFilePath, options )
MyDocument.Draw(pdfFilePath)

Refer to the MergeOptions API documentation for a complete example.

In this topic