From 612842e55541d112ae4dbf56d49a6026319d1165 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 30 Oct 2019 22:16:22 +0100 Subject: Inspect an example PDF file using the 'lopdf' crate Walk the different objects in the PDF to discover how hyperlinks are stored and how I can access them. --- src/main.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index e7a11a9..95a6d1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,29 @@ +extern crate lopdf; + +use lopdf::{Document, Object}; + fn main() { - println!("Hello, world!"); + let doc = Document::load("example.pdf").unwrap(); + // dbg!("{:?}", doc); + + for (id, obj) in doc.objects { + // dbg!(obj.as_dict().unwrap()); + + match obj { + // Object::String(bs, format) => { + // dbg!(bs, format); + // () + // }, + Object::Dictionary(d) => { + // dbg!(d); + + for (k, v) in d.iter() { + dbg!(::std::str::from_utf8(&k).unwrap(), v); + } + + () + }, + _ => (), + } + } } -- cgit v1.2.3