oxidize-pdf 2.6.0

A pure Rust PDF generation and manipulation library with zero external dependencies
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
/// Count the number of /Type /Page entries in PDF bytes (excluding /Type /Pages).
pub fn count_pages(bytes: &[u8]) -> usize {
    let content = String::from_utf8_lossy(bytes);
    content
        .lines()
        .filter(|line| {
            let trimmed = line.trim();
            (trimmed.contains("/Type /Page") || trimmed.contains("/Type/Page"))
                && !trimmed.contains("/Pages")
        })
        .count()
}