aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..91e1a0e
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,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();
+}