Skip to main content

Crate rightkit_pdf

Crate rightkit_pdf 

Source
Expand description

RightKit PDF engine: the pure, Tauri-free half of the PDF edit pipeline, extracted from ViewRight’s crates/pdf (the most mature donor), plus ScrapeRight text extraction and Legion page merge as opt-in features.

Every function takes bytes, paths, or in-memory lopdf::Documents and returns typed values. Path authorization (the host’s file broker) stays in the app; commit provides the atomic disk write (through rightkit-fs) once the host has authorized a target.

moduleresponsibility
modelwire types: commands, islands, locators, typed PdfEditError
inspectpage graph walk: text islands with quads, fonts, source locators
fontbundled + system font catalog, subsetting, ToUnicode
composesparse-write composition of edit commands onto fresh bytes
savecandidate verification, single-use save tokens, commit resolution
commit(feature edit) lock, recheck and rightkit-fs replace of a token
merge(feature merge) merge PDFs, select/reorder pages
organize(feature merge) delete, reorder, rotate, insert pages; keeps outline and labels
extract(feature extract) text extraction, whole-document and per page
scanscanned-page detection (no text layer, page-sized image)
raster(feature raster) render scanned pages to gray/RGBA/PNG for OCR
redact(feature redact) remove content under marks, fail closed
forms(feature forms) AcroForm fields, set values, appearances
optimize(feature optimize) unused objects, measured image downsampling
writebuild a new PDF: JPEG pages, ICC profiles, page sizes (write_to needs edit)

Modules§

commit
Atomic on-disk commit for a staged save token.
compose
PDF editor sparse composition (Dispatch C, lane C1).
font
PDF editor font system (Dispatch B, lane B2): catalog discovery, embedding/subsetting permission checks, glyph subsetting, & Type0/CID/ToUnicode assembly — docs/PDF-EDITOR-NOW.md §7.
inspect
Authoritative PDF source graph extraction (Dispatch B, lane B1).
merge
Page-level assembly: merge several PDFs into one and select/reorder pages.
model
Shared PDF-editor wire/model types (Dispatch A, lane A1).
organize
Page organisation beyond merge: delete, reorder, rotate and insert pages, keeping the outline and the page labels (feature merge).
save
PDF editor save protocol (Dispatch C, lane C2): prepare_pdf_save’s structural recheck, save-token lifecycle, and commit_pdf_save’s atomic write — docs/PDF-EDITOR-NOW.md §10.
scan
Scanned-page detection and the shared page content walker (also used by raster).
write
Document writer: a NEW PDF, one full-page JPEG per page, optional embedded ICC profile.