blob: cb96c0ec4cec11a755ae9b921d7a4b73eb067da7 (
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
41
|
extern crate lopdf;
use std::path::Path;
use std::str;
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 = str::from_utf8(&k).unwrap();
if key == "A" {
for (k, v) in v.as_dict().unwrap() {
let key = str::from_utf8(&k).unwrap();
if key == "URI" {
match v {
Object::String(s, _) => {
println!("{}", str::from_utf8(s).unwrap());
()
},
_ => (),
}
}
}
}
}
()
},
_ => (),
}
}
}
|