Skip to main content

pdf2_render/
lib.rs

1//! A rasteriser for the `pdf2` crate: paths, clips, transforms, dashes and the
2//! beginnings of a content-stream interpreter.
3//!
4//! The walker reuses `pdf2`'s tokenizer and document model — there is no second
5//! PDF parser here. What it can draw today:
6//!
7//! - path construction (`m`, `l`, `c`, `v`, `y`, `h`, `re`) in user space, with
8//!   the CTM applied at flattening time;
9//! - fills with the non-zero (`f`, `F`, `B`) and even-odd (`f*`, `B*`) rules;
10//! - strokes with butt, round and square caps, round joins, and dash patterns
11//!   (`d`) with a phase;
12//! - clipping (`W`, `W*`) as a per-pixel mask that nested `q`/`Q` restores;
13//! - colour operators `g`/`G`, `rg`/`RG` and the naive `k`/`K` conversion.
14//!
15//! Not yet drawn, and reported per page in [`Report::unsupported`] instead of
16//! failing: text and images. Rendering is deliberately without anti-aliasing
17//! for now: coverage is decided at pixel centres, which keeps the golden images
18//! exact and the scanline code small.
19
20mod canvas;
21mod font;
22mod function;
23mod geom;
24mod image;
25mod path;
26mod png;
27mod raster;
28mod shading;
29mod type1;
30mod walk;
31
32pub use canvas::{Canvas, ClipMask, Color};
33pub use font::{Font, Glyph};
34pub use geom::{Matrix, Point};
35pub use image::Image;
36pub use path::{Cap, Dash, Join, Path, Segment, Subpath};
37pub use pdf2::{Error, Rect, Result};
38pub use png::encode_png;
39pub use raster::{clip_mask, fill_polygons};
40pub use walk::{render_page, render_page_number, RenderOptions, RenderedPage, Report};