Delete PDF Pages programmatically

You can delete pages from a PDF file using Aspose.PDF for C++. 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 C++.
void DeletePDFPages() {
    String _dataDir("C:\\Samples\\");
    String inputFileName("DeleteParticularPage.pdf");

    // Open document
    auto document = MakeObject<Document>(_dataDir + inputFileName);

    // Delete a particular page

    // Save updated PDF
    document->Save(_dataDir + inputFileName);