blob: 91e1a0ecda6221e9571701ba9b0101fb19cc46e1 (
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
|
use lopdf::{Document, Object};
fn main() {
let mut doc = Document::load("./f1040.pdf").unwrap();
for (_, mut obj) in &mut doc.objects {
// println!("{:?}", obj);
match &mut obj {
Object::Dictionary(ref mut d) => {
for (k, v) in d.iter_mut() {
let key = std::str::from_utf8(k).unwrap();
if key == "DA" {
// println!("{:?}", d);
let properties = v.as_str_mut().unwrap();
let new_properties = std::str::from_utf8(properties)
.unwrap()
.replace("HelveticaLTStd-Bold", "CourierNewPSMT");
*properties = new_properties.into_bytes();
dbg!(std::str::from_utf8(properties).unwrap());
// dbg!(properties);
}
}
},
_ => (),
}
}
doc.save("./new.pdf").unwrap();
}
|