A GdPicturePDF object. The first PDF document to merge.
A GdPicturePDF object. The second PDF document to merge.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / Merge2Documents Method / Merge2Documents(GdPicturePDF,GdPicturePDF) Method

Merge2Documents(GdPicturePDF,GdPicturePDF) Method

In This Topic
Merges two PDF documents loaded within the two GdPicturePDF objects. The resulting PDF document is created and stored within the new GdPicturePDF object as well.

If both source documents are PDF/A compliant, the resulting document will also be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of both source documents.

Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents. The feature is available in both 32-bit and 64-bit mode by default.

Syntax
'Declaration
 
Public Overloads Function Merge2Documents( _
   ByVal SrcDoc1 As GdPicturePDF, _
   ByVal SrcDoc2 As GdPicturePDF _
) As GdPicturePDF
public function Merge2Documents( 
    SrcDoc1: GdPicturePDF;
    SrcDoc2: GdPicturePDF
): GdPicturePDF; 
public function Merge2Documents( 
   SrcDoc1 : GdPicturePDF,
   SrcDoc2 : GdPicturePDF
) : GdPicturePDF;

Parameters

SrcDoc1
A GdPicturePDF object. The first PDF document to merge.
SrcDoc2
A GdPicturePDF object. The second PDF document to merge.

Return Value

A newly created GdPicturePDF object which stores the merged PDF document. The GetStat method can be subsequently used to determine if this method has been successful.

All pages of the first source document are cloned to the destination document and then all pages of the second source document are cloned to the destination document as well.

Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

The last page in each of used documents is set as the current document's page after the merging process.

This method requires the Document Editor component to run.

Example
How to merge two PDF documents from the two GdPicturePDF objects into a new GdPicturePDF object.
Dim gdpicturePDF1 As New GdPicturePDF()
Dim gdpicturePDF2 As New GdPicturePDF()
If (gdpicturePDF1.LoadFromFile("test1.pdf", False) = GdPictureStatus.OK) AndAlso (gdpicturePDF2.LoadFromFile("test2.pdf", False) = GdPictureStatus.OK) Then
    Dim oNewGdPicturePDF As GdPicturePDF = gdpicturePDF1.Merge2Documents(gdpicturePDF1, gdpicturePDF2)
    'You can use also gdpicturePDF2 object to call the Merge2Documents method.
    Dim status As GdPictureStatus = gdpicturePDF1.GetStat()
    If status = GdPictureStatus.OK Then
        oNewGdPicturePDF.SetAuthor("I'm the author of the merged document.")
        If oNewGdPicturePDF.GetStat() = GdPictureStatus.OK Then
            If oNewGdPicturePDF.SaveToFile("test_merged.pdf") = GdPictureStatus.OK Then
                oNewGdPicturePDF.CloseDocument()
                MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents")
            Else
                MessageBox.Show("The SaveToFile() method has failed.", "Example: Merge2Documents")
            End If
        End If
    Else
        MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents")
    End If
    oNewGdPicturePDF.Dispose()
    gdpicturePDF1.CloseDocument()
    gdpicturePDF2.CloseDocument()
Else
    MessageBox.Show("Loading of the source documents has failed.", "Example: Merge2Documents")
End If
gdpicturePDF1.Dispose()
gdpicturePDF2.Dispose()
GdPicturePDF gdpicturePDF1 = new GdPicturePDF();
GdPicturePDF gdpicturePDF2 = new GdPicturePDF();
if ((gdpicturePDF1.LoadFromFile("test1.pdf", false) == GdPictureStatus.OK) &&
    (gdpicturePDF2.LoadFromFile("test2.pdf", false) == GdPictureStatus.OK))
{
    GdPicturePDF oNewGdPicturePDF = gdpicturePDF1.Merge2Documents(gdpicturePDF1, gdpicturePDF2);
    //You can use also gdpicturePDF2 object to call the Merge2Documents method.
    GdPictureStatus status = gdpicturePDF1.GetStat();
    if (status == GdPictureStatus.OK)
    {
        oNewGdPicturePDF.SetAuthor("I'm the author of the merged document.");
        if (oNewGdPicturePDF.GetStat() == GdPictureStatus.OK)
        {
            if (oNewGdPicturePDF.SaveToFile("test_merged.pdf") == GdPictureStatus.OK)
            {
                oNewGdPicturePDF.CloseDocument();
                MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents");
            }
            else
            {
                MessageBox.Show("The SaveToFile() method has failed.", "Example: Merge2Documents");
            }
        }
    }
    else
    {
        MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents");
    }
    oNewGdPicturePDF.Dispose();
    gdpicturePDF1.CloseDocument();
    gdpicturePDF2.CloseDocument();
}
else
{
    MessageBox.Show("Loading of the source documents has failed.", "Example: Merge2Documents");
}
gdpicturePDF1.Dispose();
gdpicturePDF2.Dispose();
See Also