Skip to content
Guides

Replace Pages

The steps to replace pages are as follows:

  1. Remove the pages in the target file that need to be replaced.
  2. Insert the replacement pages into the location where the original document was deleted.

This example shows how to replace pages:

C#
List<int> pageList = new List<int>() { 0 }; 
// Remove the first page from the document.
document.RemovePages(pageList.ToArray());
CPDFDocument documentForInsert = CPDFDocument.InitWithFilePath("OtherPDF.pdf");
// Insert the first page of another document into the original document's first-page position to complete the replacement.
document.ImportPagesAtIndex(documentForInsert, "1", 0);