Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created May 13, 2024 10:30
Show Gist options
  • Save conholdate-gists/7027f9de9e56bb986dc7b95d1b4c92c8 to your computer and use it in GitHub Desktop.
Save conholdate-gists/7027f9de9e56bb986dc7b95d1b4c92c8 to your computer and use it in GitHub Desktop.
Add or Delete Pages in PDF using C# | Insert Remove Pages in PDF
// Load the input PDF document
Document document = new Document("Sample.pdf");
// Delete the Page Number Two - The 2nd Page
document.Pages.Delete(1);
// Save output PDF file
document.Save("Page_Deleted.pdf");
// Load the input PDF document
Document document = new Document("Sample.pdf");
// Add an empty page at the end of document
Page page = document.Pages.Add();
// Save output PDF file
document.Save("Page_Added.pdf");
// Load the input PDF document
Document document = new Document("Sample.pdf");
// Add an empty page after 2 pages
document.Pages.Insert(2);
// Save output PDF file
document.Save("Page_Inserted.pdf");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment