Struct pdf::Pdf
[−]
[src]
pub struct Pdf { // some fields omitted }
The top-level object for writing a PDF.
A PDF file is created with the create
or new
methods.
Some metadata can be stored with set_foo
methods, and pages
are appended with the render_page
method.
Don't forget to call finish
when done, to write the document
trailer, without it the written file won't be a proper PDF.
Methods
impl Pdf
[src]
fn create(filename: &str) -> Result<Pdf>
Create a new PDF document as a new file with given filename.
fn new(output: File) -> Result<Pdf>
Create a new PDF document, writing to output
.
fn set_title(&mut self, title: &str)
Set metadata: the document's title.
Set metadata: the name of the person who created the document.
fn set_subject(&mut self, subject: &str)
Set metadata: the subject of the document.
fn set_keywords(&mut self, keywords: &str)
Set metadata: keywords associated with the document.
fn set_creator(&mut self, creator: &str)
Set metadata: If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted.
fn set_producer(&mut self, producer: &str)
Set metadata: If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF.
fn render_page<F>(&mut self, width: f32, height: f32, render_contents: F) -> Result<()> where F: FnOnce(&mut Canvas) -> Result<()>
Create a new page in the PDF document.
The page will be width
x height
points large, and the
actual content of the page will be created by the function
render_contents
by applying drawing methods on the Canvas.
fn finish(self) -> Result<()>
Write out the document trailer. The trailer consists of the pages object, the root object, the xref list, the trailer object and the startxref position.