MergeFiles

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

 

Syntax

DLL:

BOOL MergeFiles(LPCSTR file1, LPCSTR file2, LPCSTR file3, long Options)

 

Parameters

file1

Full path of the first file containing the watermark.

file2

Full path of the second file to which file1 should be merged.

file3

Full path of the destination or output file.

Options

Options for merging files.

 

Option

Value

Description

Repeat first pages

1

The first pages of the second document are repeated in the first document.

Second document above first

2

The contents of the second document are printed above the contents of the first document.

 

 

Return Value

The return value is True if the files were merged, False otherwise.

 

Remarks

This function is not guaranteed to process files created from PDF generation tools other than the Amyuni PDF Converter, or Amyuni PDF Creator. It will however work with files coming from most applications.

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:

 

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;

 

enum MERGEOPTIONS

        {

            No_Repeat = 0,

            Repeat = 1,

            Above = 2

        };

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "Amyuni PDF Converter Evaluation"

    #define strActivationCode "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"

 

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

 

    // Merge LetterHead to test document

    MergeFiles( "c:\\temp\\letterhead.pdf", "c:\\temp\\test.pdf", "c:\\temp\\Merged.pdf", MERGEOPTIONS::Repeat);   

 

    return 0;

}