page_insert

Inserts a new page at the specified position in the PDF-document.

pub fn page_insert(&self, num: i32) -> Result<(), PdfError>

Arguments

  • num - the page number (1-based)

Returns

  • Ok(()) - if the operation succeeds
  • Err(PdfError) - if the operation fails

Example

use asposepdf::Document;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document from file
    let pdf = Document::open("sample.pdf")?;

    // Insert new page at the specified position in PDF-document
    pdf.page_insert(1)?;

    // Save the previously opened PDF-document
    pdf.save()?;

    Ok(())
}