pdfox 🦊
A pure-Rust PDF library. Create, parse, and render PDF documents with zero C dependencies and zero unsafe blocks.
Features
| Feature | Description |
|---|---|
| PDF creation | Pages, text, shapes, images, hyperlinks |
| PDF parsing | Object tree traversal, text extraction |
| 14 built-in fonts | Helvetica, Times, Courier families with per-glyph widths |
| Tables | Headers, alternating rows, column spans, borders |
| Text flow | Multi-page reflowing with headings, bullets, code blocks |
| AcroForm | Text, checkbox, radio, dropdown, button fields |
| Outlines | Nested bookmarks with color and style |
| Watermarks | Diagonal text stamps with opacity |
| Headers/Footers | {page} / {total} macros, automatic per-page |
| Encryption | RC4-40 / RC4-128 with permission flags |
| Digital signatures | adbe.pkcs7.detached placeholder + inject workflow |
| Images | JPEG (DCTDecode) and raw RGB embedding |
| Compression | FlateDecode (zlib) on all content streams |
Quick Start
[]
= "0.1"
use *;
use Color;
Full Example
use *;
use Color;
Running the Demo
# Opens pdfox_demo.pdf — a 7-page showcase of all features
Running Tests
# 55 tests covering every module
Architecture
Document ← top-level builder (pages, metadata, outline, form, sig)
└── PageBuilder ← per-page content (fonts, text, shapes, images, tables)
├── ContentStream ← raw PDF operator emitter
├── Table ← grid layout renderer
└── PdfImage ← JPEG / RGB image XObjects
TextFlow ← multi-page reflow engine
AcroForm ← interactive form fields
Outline ← bookmark navigation tree
Watermark ← diagonal/straight text stamps
HeaderFooter ← page header/footer with macros
Encryption ← RC4-40/128 + permission flags
SignatureField ← adbe.pkcs7.detached placeholder
PdfWriter ← low-level byte emitter + xref table
ParsedDocument ← PDF parser + text extractor
Modules
| Module | Purpose |
|---|---|
color |
RGB, Grayscale, CMYK color types |
content |
PDF content stream operators |
document |
Top-level document builder |
encrypt |
RC4 encryption + permission flags |
error |
Unified PdfError type |
flow |
Multi-page text flow engine |
font |
14 built-in Type1 fonts with glyph widths |
form |
AcroForm interactive fields |
image |
JPEG and raw RGB image embedding |
object |
Core PDF object model |
outline |
Document bookmarks/outline tree |
page |
Page builder and font registration |
parser |
PDF parser and text extractor |
signature |
Digital signature placeholder |
table |
Table layout and rendering |
watermark |
Watermarks and header/footer |
writer |
Low-level byte writer and xref |
License
MIT — see LICENSE