Crate pdf_writer[−][src]
Expand description
A step-by-step PDF writer.
The entry point into the API is the main PdfWriter
. The document is written
into one big internal buffer, but otherwise the API is largely non-allocating.
Minimal example
The following example creates a PDF with a single, empty A4 page.
use pdf_writer::{PdfWriter, Rect, Ref}; // Start writing with the PDF version 1.7 header. let mut writer = PdfWriter::new(1, 7); // The document catalog and a page tree with one A4 page that uses no resources. writer.catalog(Ref::new(1)).pages(Ref::new(2)); writer.pages(Ref::new(2)).kids(vec![Ref::new(3)]); writer.page(Ref::new(3)) .parent(Ref::new(2)) .media_box(Rect::new(0.0, 0.0, 595.0, 842.0)) .resources(); // Finish with cross-reference table and trailer and write to file. std::fs::write("target/empty.pdf", writer.finish(Ref::new(1)))?;
For a more comprehensive overview, check out the hello world example in the repository, which creates a document with text in it.
Modules
writers | Writers for specific PDF structures. |
Structs
Any | Writer for an arbitrary object. |
Array | Writer for an array. |
Content | Builder for a content stream. |
Dict | Writer for a dictionary. |
FontFlags | Bitflags describing various characteristics of fonts. |
IndirectGuard | A guard that finishes an indirect object when released. |
Name | A name object. |
PdfWriter | The root writer. |
Rect | A rectangle, specified by two opposite corners. |
Ref | An indirect reference. |
Str | A string object (any byte sequence). |
Stream | Writer for a stream dictionary. |
StreamGuard | A guard that finishes a stream when released. |
SystemInfo | Specifics about a character collection. |
TypedArray | Writer for an array with fixed primitive value type. |
TypedDict | Writer for a dictionary with fixed primitive value type. |
UnicodeCmap | Builder for a |
Enums
CidFontType | The subtype of a CID font. |
ColorSpace | A color space. |
Filter | A compression filter. |
LineCapStyle | How to terminate lines. |
Traits
Guard | Finishes an entity when released. |
Object | A PDF object. |