Struct pdf_canvas::Pdf
source · [−]pub struct Pdf { /* private fields */ }
Expand description
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.
Implementations
sourceimpl Pdf
impl Pdf
sourcepub fn create(filename: &str) -> Result<Pdf>
pub fn create(filename: &str) -> Result<Pdf>
Create a new PDF document as a new file with given filename.
Set metadata: the name of the person who created the document.
sourcepub fn set_subject(&mut self, subject: &str)
pub fn set_subject(&mut self, subject: &str)
Set metadata: the subject of the document.
sourcepub fn set_keywords(&mut self, keywords: &str)
pub fn set_keywords(&mut self, keywords: &str)
Set metadata: keywords associated with the document.
sourcepub fn set_creator(&mut self, creator: &str)
pub 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.
sourcepub fn set_producer(&mut self, producer: &str)
pub 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.
sourcepub fn render_page<F>(
&mut self,
width: f32,
height: f32,
render_contents: F
) -> Result<()> where
F: FnOnce(&mut Canvas<'_>) -> Result<()>,
pub 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.
Auto Trait Implementations
impl RefUnwindSafe for Pdf
impl Send for Pdf
impl Sync for Pdf
impl Unpin for Pdf
impl UnwindSafe for Pdf
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more