Rustybara
Prepress-focused PDF manipulation toolkit for graphic designers and print operators.
Rustybara is the convergence of three standalone prepress CLI tools into a unified Rust library and interactive toolset, built on the same primitives those tools proved in production:
| Origin Tool | Primitive |
|---|---|
pdf-mark-removal |
Content stream filtering, CTM math |
resize_to_bleed_or_trim_pdf |
Page box geometry (MediaBox, TrimBox, BleedBox) |
pdf-2-image |
PDF rasterization and image encoding |
It ships as a library crate (rustybara), a CLI/TUI binary (rbara), and a
GPU-accelerated PDF page viewer (rbv).
Workspace
| Crate | Description | License |
|---|---|---|
rustybara |
Core PDF manipulation library | LGPLv3 |
rustybara-icc |
ICC color management — 22 bundled profiles | LGPLv3 |
rustybara-wasm |
WebAssembly bindings — browser, Node.js, edge | LGPLv3 |
rbara |
Terminal UI (Ratatui TUI) | GPLv3 |
rbara-gui |
Native desktop GUI | GPLv3 |
rbv |
GPU-accelerated PDF page viewer (wgpu + winit) | GPLv3 |
Features
| Feature | rustybara | rustybara-icc | rustybara-wasm |
|---|---|---|---|
| Page trim & resize | ✓ | — | ✓ |
| CMYK remap | ✓ | — | ✓ |
| Split / stitch pages | ✓ | — | — |
| Extract page ranges | ✓ | — | — |
| Flatten spot colors | ✓ | — | — |
| Rasterization (pdfium) | ✓ | — | — |
| ICC color transforms | — | ✓ | — |
| WebAssembly / browser | — | — | ✓ |
| Node.js / edge runtime | — | — | ✓ |
- Pipeline API — Chain operations fluently:
open → trim → resize → remap → save. - Batch processing — Process entire directories of PDFs from CLI or TUI.
- Interactive TUI — App-style terminal interface for designers who prefer guided workflows over raw CLI flags. Configurable output directory.
- Prepress vocabulary — Every API surface speaks in boxes, bleeds, and DPI — not generic PDF primitives.
Installation
Pre-built installers for rbara (the CLI/TUI binary) are published with each
release. Each installer bundles its own pdfium runtime — no system pdfium
needed.
Windows
Download rbara-setup-<version>-x64.exe from the
Releases page and run it.
This is a per-user Inno Setup installer (no admin required) that installs to
%LOCALAPPDATA%\Programs\rbara\, registers an opt-in PATH entry, and adds
an Add/Remove Programs entry. SmartScreen may warn the first time — the
binary is currently unsigned.
macOS
# Apple silicon
&&
# Intel
&&
The bundle is unsigned; install.sh strips the com.apple.quarantine
attribute automatically. To uninstall: ./uninstall.sh.
Linux (glibc x86_64)
&&
Tested on Ubuntu 22.04+, Debian 12+, Fedora 38+, RHEL 9+, Arch, openSUSE
Tumbleweed. Musl distros (Alpine) need a source build. To uninstall:
./uninstall.sh.
Docker
# CLI usage — bind-mount your working directory
The image is ~175 MB (debian:bookworm-slim base) and runs as a non-root user.
Building from source
See the Contributing section. The maintainer-side installer
scripts live in installer/ (one subdir per platform, each
with its own README).
Quick Start
As a library
Add to your Cargo.toml:
[]
= "0.1"
use PdfPipeline;
Rasterize a page
use ;
CLI
# Trim print marks
# Resize to 9pt bleed
# Export pages as 300 DPI PNGs
# Remap a CMYK color (rich black → 60/40/20/100)
TUI
Launch rbara with no arguments to enter the interactive terminal interface:
Arrow keys navigate, Enter selects, Esc goes back. Single-letter shortcuts are
shown in the footer bar. Press ? for the full keyboard reference.
rustybara-wasm
WebAssembly bindings for rustybara. Run PDF manipulation in any JavaScript or TypeScript environment — browser, Node.js, Deno, or Cloudflare Workers — with no native dependencies.
Exposes the pure-Rust pipeline subset:
trim()— strip content outside TrimBoxresize(bleed_pts)— expand page boxes by a bleed marginremap_color(from, to, tolerance)— substitute CMYK values in content streamsto_pdf_bytes()— serialize result as bytes for download or further processing
Rasterization (pdfium) and ICC color transforms (lcms2) require the native crate and are not available in the wasm build.
Browser quickstart
import init from './pkg/rustybara_wasm.js'
await
const bytes =
let handle =
handle = handle.
handle = handle.
const result = handle.
Build
npm
npm distribution coming soon. Pre-built artifacts are available via the rustybara playground on the marketing site.
Architecture
Module Map
rustybara/src/
lib.rs — Public re-exports
pipeline.rs — PdfPipeline: high-level chaining API
error.rs — Unified error type
geometry/
rect.rs — Rect (position + dimensions, PDF coordinate system)
matrix.rs — Matrix (2D affine CTM transformations)
pages/
boxes.rs — PageBoxes: TrimBox, MediaBox, BleedBox, CropBox reader
split.rs — Page extraction and splitting utilities
stream/
filter.rs — ContentFilter: CTM-walking content stream filter
color_ops.rs — ColorRemap: CMYK→CMYK value substitution in content streams
raster/
render.rs — PageRenderer trait, CpuRenderer (pdfium-render)
config.rs — RenderConfig (DPI, annotation toggles)
encode/
save.rs — OutputFormat enum, image encoding (JPG/PNG/WebP/TIFF)
color/ — (feature-gated: "color")
icc.rs — Re-exports from rustybara-icc crate
transform.rs — Re-exports from rustybara-icc crate
rustybara-icc/src/ (separate crate, optionally used via "color" feature)
lib.rs — ICC color management engine
color_space.rs — ColorSpaceKind enum (CMYK, RGB, Gray, Lab)
error.rs — IccError type for color operations
intent.rs — RenderingIntent enum for ICC transforms
pixel_format.rs — PixelFormat enum (RGB8, CMYK8, etc.)
transform.rs — ColorTransform: pixel-level ICC profile transforms
pdf.rs — PdfColorConverter: document-level color space conversion
profiles/ — Bundled ICC profiles (FOGRA39, GRACoL2006, etc.)
Public API
rustybara is a high-level, prepress-scoped crate. The public API speaks in
prepress vocabulary:
// Prepress operations
open?
.trim? // Remove content outside TrimBox
.resize? // Expand page boxes by bleed margin
.remap_color? // Substitute CMYK values
.save_pdf?; // Write the result
// Rasterization
pipeline.render_page?; // → DynamicImage
pipeline.save_page_image?; // → file
// Page inspection
let boxes = read?;
boxes.trim_or_media // TrimBox if present, else MediaBox
boxes.bleed_rect // Expand trim by bleed amount
// Color space conversion (requires "color" feature)
Renderer Trait
Rendering is behind a trait for future GPU backend support:
; // pdfium-render — ships today
// pub struct GpuRenderer; // vello/wgpu — future work
Dependencies
| Crate | Role |
|---|---|
lopdf 0.40 |
PDF object graph manipulation |
pdfium-render 0.9 |
PDF rasterization via PDFium |
image 0.25 |
Bitmap encoding (JPEG, PNG, WebP, TIFF) |
rayon 1.11 |
Parallel page rendering |
rustybara-icc 0.1 |
ICC color management (optional, color feature) |
lcms2 6.1 |
Little CMS color engine (via rustybara-icc, color feature) |
Runtime Requirement — PDFium
The render_page and save_page_image functions require the PDFium shared library
at runtime. Place the appropriate binary alongside your executable:
| Platform | File |
|---|---|
| Windows | pdfium.dll |
| macOS | libpdfium.dylib |
| Linux | libpdfium.so |
Pre-built binaries: pdfium-binaries
Note: End-users of the
rbarabinary do not need to do this manually — the pre-built installers bundle the matching pdfium for each platform. This requirement applies only when consumingrustybaraas a library in your own Rust project.
Operations that do not rasterize (trim, resize, save_pdf, page_count,
PageBoxes::read) work without PDFium.
rbara — CLI & TUI Binary
rbara is the interactive front-end for rustybara. It provides both a
flag-based CLI for scripting and a TUI for guided workflows.
Keyboard Reference (TUI)
| Key | Action |
|---|---|
t |
Trim print marks |
r |
Resize to bleed |
x |
Export to image |
m |
Remap colors |
c |
Convert color space |
s |
Flatten spot colors |
b |
Add trim box |
p |
Split pages |
g |
Stitch pages |
e |
Extract pages |
/ |
Output path |
o |
Toggle overwrite mode |
f |
Add files |
a / n / i |
Scope all / none / invert |
v |
View active file in rbv |
Enter |
Run active action |
: |
Open command bar |
? |
Keyboard reference overlay |
UX Model
The TUI follows an app-style keyboard model — arrow keys, Enter, Esc — designed for designers who have never used a terminal before. Vim-style bindings may be layered on as aliases in a future version.
File-first workflow: launch → select file or directory → commands become
available. Directories auto-glob *.pdf files.
rbv — PDF Page Viewer
rbv is a GPU-accelerated window for PDF page preview, built on wgpu + winit.
It is spawned by rbara-gui on demand for single-file previews.
rbv <file_path>
Navigate pages with H/←/K/↑ (prev) and L/→/J/↓ (next). Jump to a
page with Ng (e.g. 5g). Close with Esc.
Requires a GPU or software fallback adapter at runtime. Gracefully errors on headless environments.
Known Limitations
| Limitation | Notes |
|---|---|
| sRGB rasterization only | CMYK→sRGB via PDFium. ICC color transforms available via color feature for stream-level operations. |
| JPEG quality not configurable | Fixed encoder quality. --quality flag planned. |
| Spot color approximation | PDFium renders spot inks as CMYK approximations. |
| No Form XObject ColorSpace pruning | Inherited limitation from content stream filtering. |
rbv requires display server |
No headless preview. Graceful error on missing GPU. |
Roadmap
- ICC color management (
colormodule vialcms2) — v0.1.2 - CMYK→CMYK color remapping in content streams — v0.1.2
- Cross-platform installers (Windows / macOS / Linux / Docker) with bundled pdfium — v0.1.3
- GitHub Actions release pipeline (one tag → all installers + GHCR image) — v0.1.3
-
rbvGPU-accelerated page viewer (wgpu + winit) — v0.1.4 -
rbara-guinative desktop GUI (Tauri v2) — v0.1.4 - Split Pages — divide spreads into individual panels at a configurable width — v0.1.5
- Stitch Pages — combine panels back into spreads at a configurable spread width — v0.1.5
- Extract Pages — extract arbitrary page ranges into a new PDF — v0.1.5
- Flatten Spot Colors — flatten spot color inks to CMYK process — v0.1.5
- Command bar (
:mode) with chord shortcuts and live preview — v0.1.5 - RGB→CMYK conversion (vector graphics + embedded images)
- Spot color detection service
- PDF/X validation and preflight reports
- Configurable JPEG quality (
--qualityflag)
Contributing
- MSRV is Rust 1.85 (edition 2024). Do not raise this floor without discussion.
- Targets:
x86_64,aarch64,wasm32-unknown-unknown(via rustybara-wasm) - The TrimBox is always the source-of-truth reference box. It is never modified by any operation.
- Public API additions require documentation and at least one integration test.
- The app-style keyboard model is the UX baseline for
rbara. Modal bindings are opt-in aliases only.
Cutting a release
Releases are fully automated by .github/workflows/release.yml.
To cut a new version:
- Bump
versioninrbara/Cargo.toml(andrustybara/Cargo.tomlif the lib changed). - Commit and push.
- Tag and push the tag:
- The workflow will build the Windows installer, the Linux tarball, both
macOS tarballs (Apple silicon + Intel), and the Docker image, then create
a GitHub Release with all artifacts and a
SHA256SUMS.txtattached.
The pdfium chromium build is pinned via PDFIUM_CHROMIUM env var in the
workflow (currently 7776). Bump it there to refresh pdfium across all
artifacts in lockstep.
Playground
Try rustybara-wasm live in the browser at rustybara.com/playground. Upload a PDF or use a sample file — trim, resize, and remap CMYK values entirely client-side via WebAssembly. No account, no upload, no server.
License
rustybara(library): LGPL-3.0-onlyrbaraandrbv(binaries): GPL-3.0-only
The LGPL license on the library allows downstream tools to link against
rustybara without copyleft obligations on their own code, while the
binaries remain fully copyleft.
Copyright (c) 2026 Addy Alvarado