pdfcrate
Warning: This project is under active development. The API is unstable and subject to breaking changes. Do not use in production environments.
A Rust library for creating and manipulating PDF documents with a focus on ease of use and comprehensive text layout support.
Features
- Layout-based document creation - Cursor-based layout with automatic text flow, margins, and bounding boxes
- Rich text formatting - Bold, italic, colors, alignment (left/center/right/justify)
- Font support - 14 standard PDF fonts + TrueType/OpenType embedding with text shaping
- Font fallback - Automatic fallback for mixed-language text (CJK, emoji, etc.)
- Tables - Full-featured tables with borders, cell styles, column spans, and overflow handling
- Images - PNG and JPEG embedding with fit/fill modes
- SVG rendering - Embed SVG graphics directly
- Links and outlines - Hyperlinks, internal links, and document bookmarks
- Forms - Interactive form fields (text, checkbox, radio, dropdown)
- WASM support - Works in WebAssembly environments (tested with Cloudflare Workers)
- Python bindings - Use pdfcrate from Python via PyO3
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use *;
Examples
Custom Fonts
use *;
generate?;
Font Fallback for CJK
use *;
generate?;
Tables
use *;
generate?;
Images
use *;
generate?;
Python
pdfcrate provides Python bindings via PyO3 and maturin.
# Install in development mode
# Run the showcase
=
Feature Flags
All features are pure Rust and WASM-compatible.
| Feature | Default | Description |
|---|---|---|
std |
Yes | Standard library support (file I/O) |
png |
Yes | PNG image support (JPEG is always supported) |
fonts |
Yes | TrueType/OpenType font embedding |
text-shaping |
Yes | Complex text shaping via rustybuzz |
svg |
Yes | SVG rendering support |
barcode |
Yes | QR code and barcode generation |
python |
No | Python bindings (PyO3) |
To use minimal features:
[]
= { = "0.1", = false }
Minimum Supported Rust Version (MSRV)
Rust 1.87 or later.
License
This project is licensed under the MIT License - see the LICENSE file for details.