Remove Specific PDF Pages

To remove single or multiple pages from a PDF document, please use the removePage method. The edited PDF document can then be exported using the saveAs method of IronPDF, a powerful PDF library for .NET that allows you to create, edit, and manipulate PDF files programmatically. You can learn more about the features of IronPDF on the IronPDF official website.

Explanation:

  • IronPdf: The code utilizes IronPdf, a .NET library for PDF manipulation. Make sure to have this library installed in your project.

  • PdfDocument.FromFile(inputPath): This loads the PDF from the given file path into a PdfDocument object.

  • RemovePage(0): This method is called on the PdfDocument object to remove the first page of the PDF. Page numbering starts with 0, so 0 represents the first page.

  • SaveAs(outputPath): Any changes made to the PdfDocument object are saved to a new file specified by outputPath.

  • Console.WriteLine: Prints a completion message to the console, indicating the location of the modified PDF.

Keep in mind to replace "input.pdf" and "output.pdf" with your actual file paths.

Access our GitHub repository for hands-on examples of removing pages from PDFs using IronPDF in Node.js!

Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?