Crates.io | pdf-create |
lib.rs | pdf-create |
version | 0.1.1 |
source | src |
created_at | 2020-11-23 21:09:28.036522 |
updated_at | 2020-11-23 23:41:51.438627 |
description | low-level, strongly-typed PDF creation library |
homepage | https://xiphoseer.github.io/sdo-tool/implementation#pdf-create |
repository | https://github.com/Xiphoseer/sdo-tool/tree/main/crates/pdf |
max_upload_size | |
id | 315535 |
size | 102,674 |
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.
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.
/Info
valuesAscii85Decode
encoding and PDFDocEncoding
This example creates a single empty A4 page with no text:
use chrono::Local;
use pdf_create::{
common::Point,
common::{PdfString, Rectangle},
high::{Handle, Page, Resources},
};
// Create a new handle
let mut doc = Handle::new();
// Set some metadata
doc.info.author = Some(PdfString::new("Xiphoseer"));
doc.info.creator = Some(PdfString::new("SIGNUM (c) 1986-93 F. Schmerbeck"));
doc.info.producer = Some(PdfString::new("Signum! Document Toolbox"));
doc.info.title = Some(PdfString::new("EMPTY.SDO"));
doc.info.mod_date = Some(Local::now());
doc.info.creation_date = Some(Local::now());
// Create a page
let page = Page {
media_box: Rectangle {
ll: Point { x: 0, y: 0 },
ur: Point { x: 592, y: 842 },
},
resources: Resources::default(),
contents: Vec::new(),
};
// Add the page to the document
doc.pages.push(page);
// Write the PDF to the console
let stdout = std::io::stdout();
let mut stdolock = stdout.lock();
doc.write(&mut stdolock)?;
lopdf
printpdf
,
genpdf
or pdf-canvas
pdf