page_count

Returns the number of pages in the PDF-document.

pub fn page_count(&self) -> Result<i32, PdfError>

Arguments

Returns

  • Ok(i32) - 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")?;

    // Return page count in PDF-document
    let count = pdf.page_count()?;

    // Print the page count
    println!("Count: {}", count);

    Ok(())
}