Delete PDF Pages programmatically
Contents
[
Hide
]
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
- Call the Delete method and specify the page’s index
- 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
document->get_Pages()->Delete(2);
// Save updated PDF
document->Save(_dataDir + inputFileName);
}