DocMerge

The DocMerge method merges two PDF documents by combining the contents of every page of the first document with a page from the second document.

 

DLL

Syntax:

int DocMerge(EXTDOCHANDLE edhDocument, EXTDOCHANDLE edhSource, int fRepeat, BOOL fAbove)

Parameters:

edhDocument

Handle Returned by DocOpen.

edhSource

Handle Returned by DocOpen for the second PDF file to merge with edhDocument.

fRepeat

The contents of the current document are repeated on all pages.

fRepeat

Name

Description

0

No Repeat

The source file merges without repetition.

1

Repeat

Option 1

The contents of the current document are repeated on all pages.

2

Repeat Option 2  

The first N-1 pages of an N page document will be merged over the right-side document's pages, the Nth (last page of left-side document) will repeat over all remaining pages of right-side document.

 

fAbove

The contents of the current document are above the document specified.

 

Return Value

The return value is zero if the DocMerge method succeed. If the DocMerge method fails, a negative value will returned.

 

Remarks

If the documents do not have the same number of pages, say file1 has N1 pages and file2 has N2 pages where N1 < N2, then the developer can choose to:

 

E.g.: if file1 contains the company’s letterhead in PDF format as one page, file2 is a two page invoice in PDF format generated with the accounting package, one can call:

DocMerge(file1_handle, file2_handle, true, false)  // repeat the company’s 
 letterhead on all the invoice pages

or

DocMerge(file1_handle, file2_handle, false, false)  // to insert the company’s 
 letterhead on the first page only.

 

Member of CDIntfEx.Document.

 

Example

// PDF Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment (lib, "CDIntf.lib")

 

using namespace std;

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  (LPCSTR)"Amyuni PDF Converter Evaluation"

    #define strActivationCode (LPCSTR)"07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

    // Declare a new cdintfex document if it does not exist in the form.

    EXTDOCHANDLE pdfDoc;

    EXTDOCHANDLE LetterHead;

 

    // The SetLicenseKey method should be called after creating an object of type 

    // CDIntfEx.Document to activate the advanced methods that require the object 

    // activation code to work properly

    SetLicenseKeyA(strLicenseTo, strActivationCode);

 

    // Open the document

    LPBYTE passWord = nullptr;

    DocOpenA(&pdfDoc, (LPCSTR)"c:\\temp\\test.pdf", passWord);

    DocOpenA(&LetterHead, (LPCSTR)"c:\\temp\\LetterHead.pdf", passWord);

 

    // Merge LetterHead to test document

    DocMerge(LetterHead, pdfDoc, 1, false);

 

    // Save the document

    DocSaveA(LetterHead, (LPCSTR)"c:\\temp\\Merged.pdf");

 

    // Destroy pdfDoc object

    DocClose(pdfDoc);

    pdfDoc = nullptr;

    DocClose(LetterHead);

    LetterHead = nullptr;

 

    return 0;

}