Skip to content

PdfDocument::bookmarks::iter skips the root bookmark #120

@xVanTuring

Description

@xVanTuring

The doc says it starting from the top-level root bookmark. I assume that means including the root(first) bookmark.

Code

use pdfium_render::prelude::*;

pub fn main() -> Result<(), PdfiumError> {
    let bindings = Pdfium::bind_to_library(Pdfium::pdfium_platform_library_name_at_path("./"))
        .or_else(|_| Pdfium::bind_to_system_library())?;

    let pdfidum = Pdfium::new(bindings);
    let document: PdfDocument<'_> = pdfidum.load_pdf_from_file(
        "F:/archive/pdf/NET-Microservices-Architecture-for-Containerized-NET-Applications.pdf",
        None,
    )?;

    let bookmarks = document.bookmarks();
    println!("root: {}", bookmarks.root().unwrap().title().unwrap());
    println!("Iter:");
    for (idx, bookmark) in bookmarks.iter().enumerate() {
        println!("{idx}: {}", bookmark.title().unwrap());
    }
    Ok(())
}

Output

root: Introduction to Containers and Docker
Iter: ## skipped the root bookmark
0: Choosing Between .NET and .NET Framework for Docker Containers
1: Architecting container and microservice-based applications
2: Development process for Docker-based applications
3: Designing and Developing Multi-Container and Microservice-Based .NET Applications
4: Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
5: Implement resilient applications
6: Make secure .NET Microservices and Web Applications
7: .NET Microservices Architecture key takeaways

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions