Remove Specific PDF Pages
IronPDF for Python can remove one or more pages from an existing PDF document using the RemovePages method, returning a modified PdfDocument with the specified pages deleted.
Getting Started
Create or load a PdfDocument, then call RemovePages with the zero-based indexes of the pages you want to delete. The remaining pages are renumbered automatically and the modified document can be saved with SaveAs.
Understanding the Code
RenderHtmlAsPdf(html): Creates a multi-page PDF from HTML. Thepage-break-after: alwaysCSS rule separates the content into individual pages.RemovePages(start, end): Removes pages from the document. Arguments are zero-based page indexes. In this example,RemovePages(1, 2)removes the second and third pages, leaving only pages 1 and 4.SaveAs(path): Saves the modified document — with the specified pages removed — to the given file path.
Zero-Based Page Indexing
All page operations in IronPDF use zero-based indexes. To remove the second page of a document, pass index 1. To remove the last page, pass pdf.PageCount - 1.
Removing Non-Contiguous Pages
To remove pages that are not in a contiguous range, call RemovePages multiple times or build a list of specific page indexes to remove. Start from the highest index to avoid index shifting after each removal.






