Skip to main content

Module pdf

Module pdf 

Source
Expand description

A tiny, self-contained PDF 1.7 writer for GridCraft’s print and PDF export.

  • The 14 standard fonts (no embedding) with WinAnsiEncoding, plus approximate width tables (text_width) so callers can measure, align and wrap text. Characters outside WinAnsiEncoding (CJK and other scripts) are set in a predefined, non-embedded Adobe-GB1 CID font with the UniGB-UTF16-H CMap instead of being replaced by ?. Symbol uses its own built-in encoding (symbol_code), for Greek letters and mathematical operators.
  • Vector drawing: rectangles, lines (solid or dashed), polygons, circles (Bézier), clipping.
  • RGBA images as RGB image XObjects with a soft mask for alpha (run-length encoded).
  • Coordinates are points with a top-left origin (y grows down); text y is the baseline.

Streams are written uncompressed (images use the trivial RunLengthDecode filter) so the crate needs no dependencies.

Structs§

Info
Document metadata.
Page
A page under construction. Obtain one with PdfDoc::add_page.
PdfDoc
A PDF document under construction.
Point
A point in page coordinates, measured from the top-left corner.
Rect
A page-space rectangle described by its top-left corner and extent.

Enums§

Family
A font family for Font::styled.
Font
The standard 14 fonts minus ZapfDingbats.

Functions§

symbol_code
The Symbol-encoding code for c, or None when Symbol has no such glyph.
symbol_width
The advance width of code code in 1/1000 em, or None for an empty slot.
text_width
Width of text in points when set in font at size points.
win_ansi
Unicode → WinAnsiEncoding (CP1252) byte; unmappable characters become ?.

Type Aliases§

Rgb
RGB colour, 0–255 per channel.