Rust

The engine itself: extract a document, then render it.

Cargo.toml
[dependencies]
khpdf = {{ git = "https://github.com/MoriartyPuth/khpdf" }}
Rust
use khpdf::{extract_pdf, render_markdown, ExtractOptions};

fn main() -> khpdf::Result<()> {
    let options = ExtractOptions::default();
    let doc = extract_pdf("report.pdf", &options)?;
    println!("{}", render_markdown(&doc, &options));
    Ok(())
}

Main API

Item
extract_pdf(path, &options)Read a PDF file into a Document.
extract_pdf_bytes(&bytes, &options)The same from bytes in memory (used by the browser demo).
render_markdown(&doc, &options)Markdown text.
render_text(&doc, &options)Plain text, tables tab-separated.
render_json(&doc, pretty)JSON, as described in The output.
cli::run(args)Run the command line with your own arguments; returns the exit code.

ExtractOptions

FieldDefault
pagesempty (all)1-based page numbers to read.
page_markersfalseMark page starts in rendered output.
normalize_khmertrueReorder visually stored Khmer into Unicode order.
decode_legacy_fontstrueDecode Limon legacy fonts.

Khmer helpers

khpdf::khmer exposes the text tools on their own: normalize_khmer_text (canonical cluster order), decode_limon (Limon text to Unicode) and is_khmer_char.

Rust
assert_eq!(khpdf::khmer::decode_limon("Exµr"), "ខ្មែរ");