forked from SimonSapin/rust-pdf
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I feel the current code is difficult to extend for adding new features.
Suggest to use lopdf to do PDF object serialization.
Here is some example code:
extern crate lopdf;
use lopdf::{Document, Object, Dictionary, Stream, StringFormat};
use Object::{Null, Integer, Name, String, Reference};
let mut doc = Document::new();
doc.version = "1.5".to_string();
doc.add_object(Null);
doc.add_object(true);
doc.add_object(3);
doc.add_object(0.5);
doc.add_object(String("text".as_bytes().to_vec(), StringFormat::Literal));
doc.add_object(Name("name".to_string()));
doc.add_object(Reference((1,0)));
doc.add_object(vec![Integer(1), Integer(2), Integer(3)]);
doc.add_object(Stream::new(Dictionary::new(), vec![0x41, 0x42, 0x43]));
let mut dict = Dictionary::new();
dict.set("A", Null);
dict.set("B", false);
dict.set("C", Name("name".to_string()));
doc.add_object(dict);
doc.save("test.pdf").unwrap();Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels