lopdf
A Rust library for PDF document manipulation.
Example Code
- Create new PDF document
extern crate lopdf;
use ;
use ;
let mut doc = new;
doc.version = "1.5".to_string;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
doc.add_object;
let mut dict = new;
dict.set;
dict.set;
dict.set;
doc.add_object;
doc.compress;
doc.save.unwrap;
- Read PDF document
let mut doc = load.unwrap;
FAQ
-
Why keeping everything in memory as high-level objects until finallay serializing the entire document?
Normally a PDF document won't be very large, ranging form tens of KB to hundreds of MB. Memory size is not a bottle neck for today's computer. By keep the whole document in memory, stream length can be pre-calculated, no need to use a reference object for the Length entry, the resulting PDF file is smaller for distribution and faster for PDF consumers to process.
Producing is a one-time effort, while consuming is many more.