ceTe Software Help Library for Java August - 2020
DynamicPDF Merger for Java / Programming with Merger for Java / Merge Options
In This Topic
    Merge Options
    In This Topic

    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.

    Using the Static MergeOptions

    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:

    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" );
    

    Defining Custom MergeOptions

    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" );
    
    See Also