Skip to content
akahmysPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

fepdf

A PDF translator in Rust. It reads any PDF and writes it as ISO 32000-2 (PDF 2.0); it changes what it translated through one vocabulary of operations; and it puts those operations in front of you as a command line, a desktop window and an MCP server.

Reading a file written before PDF 2.0 means choosing: older files are often non-conforming, and parts of the older specifications are ambiguous. fepdf records each choice with the clause it rests on, so a translation can be checked rather than trusted:

$ fepdf inspect info report.pdf

--- [ DECISIONS TAKEN READING (5.3) ] ---
  1 ambiguities, 1 repairs, 0 violations
  [AMBIGUITY] ISO 14.3.3 : /Info /ModDate is "D:20241114200008+09'00'" and the
    metadata stream says "2024-11-08T09:08:18+09:00" -> took the metadata stream
  [REPAIRED] ISO 14.3.3 : /Info carries Title, Subject, Keywords, Creator,
    Producer, deprecated in PDF 2.0 -> moved to the document's metadata stream

Every line names the clause of ISO 32000-2 it rests on, what was found, and what was done about it — enough to disagree with. The record serves the translation; it is not the product.

This is experimental software. It is a personal project, not a product. Read What it cannot do before pointing it at anything you care about, and keep your originals.

Downloads

Pre-built binaries for macOS, Windows, and Linux are available from GitHub Releases.

Platform Download Package Contents
macOS (Apple Silicon) fepdf-macos-arm64.tar.gz fepdf (CLI) & fepdf-gui (GUI)
macOS (Intel) fepdf-macos-x64.tar.gz fepdf (CLI) & fepdf-gui (GUI)
Windows (64-bit) fepdf-windows-x64.zip fepdf.exe (CLI) & fepdf-gui.exe (GUI)
Windows (32-bit) fepdf-windows-x86.zip fepdf.exe (CLI) & fepdf-gui.exe (GUI)
Linux (Static CLI) fepdf-linux-static-x64.tar.gz fepdf (Statically linked standalone CLI)
Linux (Dynamic GUI) fepdf-linux-dynamic-x64.tar.gz fepdf-gui (GUI with GPU rendering support)

Every archive carries a resources/ directory beside the binaries, holding Adobe's CMap collections and CID-to-Unicode tables. Keep it next to the executable. Without it a CJK document loses its character collection: measured on a vertically set Japanese book, the binary alone extracts 4,554 bytes of text where the same binary beside resources/ extracts 212,342. Point FEPDF_RESOURCES at the directory to keep it somewhere else.

Building from source

Needs Rust 1.94 or later.

cargo build --release

Text extraction needs two Adobe resource repositories. They answer opposite questions, and reading one for the other's job is how 7,617 CIDs of Adobe-Japan1 came to be unreadable. external/ carries both as submodules, pinned to the commit the engine was measured against, and that is the only way in:

git submodule update --init

A source archive downloaded as a ZIP carries no submodules and no history to fetch them from; clone the repository instead.

external/arlington is a third submodule, the PDF Association's model of every dictionary in ISO 32000-2. Building does not need it; the tests do, since a save is held against it (crates/fepdf/tests/suite/arlington_test.rs).

That gives you target/release/fepdf (command line) and target/release/fepdf-gui (desktop). The GUI wants a GPU; the CLI does not.

What you can do with it

Translate a file

fepdf publish upgrade in.pdf out.pdf              # write it as PDF 2.0
fepdf publish upgrade in.pdf out.pdf --strip      # …and remove all descriptive metadata

Change what it translated

fepdf publish render in.pdf page.png --page 1     # render a page
fepdf edit merge a.pdf b.pdf -o out.pdf
fepdf edit split in.pdf --pages 1-10 -o out.pdf
fepdf edit rotate in.pdf -o out.pdf --pages 1 --angle 90

Page work has a subcommand each — remove, move, duplicate, insert, crop, resize, split-page, combine, redact, decorate and fill — and any operation in the vocabulary can be applied as JSON:

fepdf edit remove in.pdf -o out.pdf --pages 2-4
fepdf edit apply in.pdf -o out.pdf --op '{"RemovePages": {"Indices": [0]}}'

Encrypted files open with --password. Give any command --help for its own options.

Saving produces a new document, not an edited one. fepdf normalises a file as it reads it, so it cannot write your original back byte for byte, and anything that depends on those exact bytes does not survive. It says so when that costs you something:

[VIOLATION] ISO 7.6.4.2 : the document was opened with user access and its /P
  (-1068) permits no modification and no assembly and no annotation -> this engine
  normalises at load and has no path that writes a faithful copy, so the output is
  modified; /Encrypt cannot survive decryption either, so it declares no permissions
  at all

The output records where it came from, in xmpMM:DerivedFrom and xmpMM:OriginalDocumentID, so a reader can trace it back without having watched. The reasoning is in ADR-0012.

Look at a file without changing it

fepdf inspect structure report.pdf   # revisions, cross-reference form, object storage
fepdf inspect catalog report.pdf     # every catalogue entry, and what the engine makes of it
fepdf inspect encryption report.pdf  # what protects it, and how far the engine conforms
fepdf inspect interactive report.pdf # annotations, form fields, actions, outline
fepdf inspect info report.pdf        # metadata and a font summary
fepdf inspect text report.pdf        # extracted text
fepdf inspect audit report.pdf       # compliance audit against ISO 32000-2 and UA-2
fepdf inspect tree report.pdf        # the logical structure tree
fepdf inspect coverage *.pdf         # how much of what these files contain it reads

structure, catalog, encryption and interactive report the file as written — they read the bytes and decrypt, and nothing else. The rest report the document the engine made of it, which is not the same thing and is not meant to be (ADR-0013).

What it cannot do

Write anything but AES-256 It reads every password-based scheme the standard defines — RC4, AES-128, AES-256 — and writes one: AES-256 at revision 6, with --encrypt-password. Output is always PDF 2.0, and that edition deprecates the rest (ADR-0015).
Sign a file it did not write It signs its own output — publish sign and publish verify-signature — and a signature it made covers the whole file. It cannot add one to someone else's file without rewriting it first, and a signature already in a document does not survive a save. ADR-0014 is why.
Decide whether to trust a certificate verify-signature says whether the signature covers the bytes and is bound to the certificate it carries. It has no trust store, checks no validity window, and reads no revocation list — and says so in its output.
Preserve a file byte for byte There is no faithful-copy path. See above.
Read a certificate-encrypted file in a browser fepdf reads and writes 7.6.5 — --encrypt-to to seal, --recipient-certificate with --recipient-key to open. Chrome and Firefox implement neither, so what this produces they cannot read.
Draw a page in a browser fepdf-wasm opens a document, counts its pages, extracts their text, and hands over the decisions and the structure tree. Its render_page returns an error naming what it did not draw.
Produce a file you can read in a text editor Objects are packed into 7.5.7 object streams by default, which shrinks every sample — intel_sdm.pdf goes from +131% to +1% — and puts almost all of them inside a compressed container. --no-obj-stm writes the loose form (ADR-0016).

All thirty-two of Table 29's catalogue entries have a field. Of the twenty-two the corpora carry, twenty-one have a reader that says what the entry holds — every one but /Type, whose value the clause fixes. The ten that no file carries are declined a reader on purpose, and inspect catalog names them (ADR-0017). It also reports how much of each entry's own table its reader covers, because "modelled" is a statement about the entry and not about everything beneath it: /AcroForm reads 4 of Table 224's 8 (ADR-0020).

inspect coverage puts a number on the whole thing across a corpus — the share of the constructs your files actually contain whose contents the engine reads. Over the ten samples and 515 external files it is 94%, 265 of 279 constructs (re-derived 2026-10-13). It read 88% on 2026-08-22 over nine samples, and the same over 251 files before that: doubling the corpus moved the denominator without moving the ratio. It is a proxy and ADR-0019 says what it is not.

ROADMAP.md has the measured state clause by clause, and ./scripts/dev/status.sh re-derives those numbers so a stale one shows up as a disagreement rather than reading as current.

The crates

Crate What it is
fepdf The public facade and API most callers want (PdfDocument, SaveOptions, Operation)
fepdf-doc The operations: their vocabulary and its one interpreter, structure trees, reading order, and remediation
fepdf-audit The PDF/UA audit against the Matterhorn Protocol, which judges a document and changes nothing
fepdf-model The engine: objects, arena, document graph, xref, reader and writer
fepdf-syntax Lexer and cryptographic primitives (RC4, AES-256, CMS signatures)
fepdf-content Content-stream interpreter and backend rendering contract
fepdf-font Font programs: CFF, TrueType, CMap, subsetting, reconstruction
fepdf-render GPU vector rasteriser on Vello + wgpu
fepdf-cli The fepdf command-line binary
fepdf-gui Desktop application (egui, wgpu, Vello) with visual inspection and redaction
fepdf-mcp Model Context Protocol server over stdio, reaching only the files under --root DIR (default: the working directory)
fepdf-wasm WebAssembly bindings
fepdf-script ECMAScript for the scripts a document carries, translated into operations
fepdf-macros Compile-time procedural macros

Contributing

A few rules are enforced rather than aspired to — no unsafe, no dependency that compiles C, functions under fifty lines, no non-deterministic collections in the core, no wildcard match over a domain enum — and make audit is what checks them.

make audit              # the rules, clippy, cargo-deny, betterleaks
cargo test --workspace  # tests that need samples/, which is not committed, are skipped

Start with AGENTS.md: it says which document answers what, what outranks what, and the habits that matter more than the rules.

Licence

MIT.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages