blob: f1ac51708dcdaa36a8f1bb1db699d493751f3027 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
extern crate lopdf;
use std::path::Path;
use lopdf::{Document, Object};
pub fn get_urls_from_pdf<P: AsRef<Path>>(path: P) {
let doc = Document::load(path).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());
()
},
_ => (),
}
}
}
}
}
()
},
_ => (),
}
}
}
|