Expand description
karet-pdf — headless, pure-Rust PDF rasterization for karet.
It wraps the hayro PDF interpreter/renderer (pure Rust, no C-sys
dependencies) to turn PDF bytes into RenderedPages of straight
(un-premultiplied) 8-bit RGBA pixels. A renderer such as karet-fileview can
then hand those pixels to the Kitty graphics protocol (or a halfblock
fallback). The crate is headless — no ratatui, no terminal — so a PDF can be
turned into pixels anywhere.
Parsing happens once in Document::load; pages are rasterized on demand via
Document::render_page, so a large document is not fully rendered up front.
let doc = karet_pdf::Document::load(bytes)?;
for i in 0..doc.page_count() {
let page = doc.render_page(i, 2.0)?; // 2× the native 72-DPI size
assert_eq!(
page.rgba().len(),
page.width() as usize * page.height() as usize * 4
);
}Structs§
- Document
- A parsed PDF document. Load once, then rasterize pages on demand.
- Outline
Item - One entry in a PDF’s navigation outline (a bookmark / table-of-contents node).
- Rendered
Page - A single rasterized PDF page: straight 8-bit RGBA pixels plus dimensions.
Enums§
- PdfError
- An error loading or rasterizing a PDF document.