Skip to content

Merge the Whole PDF

Youna edited this page Mar 8, 2023 · 3 revisions

ComPDFKit PDF SDK allows you to instantiate multiple CPDFDocument, and you can use the CPDFDocument API to merge two or more PDF files into a single one.

See all details here.

To merge PDF documents into one file, please use the following method:

1. Create a blank PDF document.

CPDFDocument document = CPDFDocument.CreateDocument();

2. Open the PDF documents that contain the pages you want to merge.

// File path CPDFDocument document1 = CPDFDocument.InitWithFilePath("filePath");

// File path CPDFDocument document2 = CPDFDocument.InitWithFilePath("filePath2");

  1. Merge all the pages from the documents you just opened, and import them into the blank PDF document.

document.ImportPagesAtIndex(document1,"",document.PageCount); document.(document2,"",document.PageCount);

  1. Save the document.

// Save path document.WriteToFilePath("savePath");