diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..fbe8b8a --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,38 @@ +extern crate lopdf; + +use lopdf::{Document, Object}; + +pub fn get_urls_from_pdf() { + let doc = Document::load("example.pdf").unwrap(); + + for (_, obj) in doc.objects { + match obj { + Object::Dictionary(d) => { + for (k, v) in d.iter() { + let key = ::std::str::from_utf8(&k).unwrap(); + + if key == "A" { + for (k, v) in v.as_dict().unwrap() { + let key = ::std::str::from_utf8(&k).unwrap(); + + if key == "URI" { + + match v { + Object::String(s, _) => { + println!("{}", ::std::str::from_utf8(s).unwrap()); + + () + }, + _ => (), + } + } + } + } + } + + () + }, + _ => (), + } + } +} |