pdf-create
This is yet another PDF creation library, developed as part of the
Signum!-Document-Toolbox. In
some respect, it's a prototype for missing parts of the pdf
crate.
Rationale
The main goal of this crate is the ability to use custom Type3 fonts to
create a document. The main design philosophy is the idea of storing all
data as rustic types and serializing them through a trait similar to
the std::fmt
API.
As a PDF is fundamentally a list of objects that are linked using
their IDs and serializing some struct requires the referenced IDs
to be known, this crate has a high
-level and a low
-level component
that represent the document before and after assigning global IDs.
Features
- Arbitrary content & glyph streams
- Custom
/Info
values - Type3 fonts
- Outlines
- Page Labels
- Implementations of
Ascii85Decode
encoding andPDFDocEncoding
Basic Usage
This example creates a single empty A4 page with no text:
use Local;
use ;
// Create a new handle
let mut doc = new;
// Set some metadata
doc.info.author = Some;
doc.info.creator = Some;
doc.info.producer = Some;
doc.info.title = Some;
doc.info.mod_date = Some;
doc.info.creation_date = Some;
// Create a page
let page = Page ;
// Add the page to the document
doc.pages.push;
// Write the PDF to the console
let stdout = stdout;
let mut stdolock = stdout.lock;
doc.write?;
Alternatives
- If you are looking for a crate that can generate valid PDF files
with arbitrary content, you should probably use
lopdf
- If you are looking for a crate to save a combination of graphics
and text as a PDF, you should probably use
printpdf
,genpdf
orpdf-canvas
- If you are looking for a crate that can load and render a PDF, you should
probably use
pdf