Delete PDF Pages with Rust via C++
Contents
[
Hide
]
You can delete pages from a PDF file using Aspose.PDF for Rust via C++. The next code snippet demonstrates how to manipulate a PDF document by deleting a specific page. This method is efficient for PDF document manipulation tasks, specifically for removing pages, saving the modified document, and ensuring proper resource management.
- Opening a PDF File.
- Deleting a Specific Page with page_delete function.
- Saving the Document using save method.
use asposepdf::Document;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open a PDF-document from file
let pdf = Document::open("sample.pdf")?;
// Delete specified page in PDF-document
pdf.page_delete(1)?;
// Save the previously opened PDF-document
pdf.save()?;
Ok(())
}