Delete PDF Pages programmatically Python

You can delete pages from a PDF file using Aspose.PDF for Python via .NET. To delete a particular page from the PageCollection collection.

Delete Page from PDF File

  1. Call the delete() method and specify the page’s index
  2. Call the save() method to save the updated PDF file The following code snippet shows how to delete a particular page from the PDF file using Python.

    import aspose.pdf as ap

    # Open document
    document = ap.Document(input_pdf)

    # Delete a particular page
    document.pages.delete(2)

    # Save updated PDF
    document.save(output_pdf)