Rust
The engine itself: extract a document, then render it.
[dependencies]
khpdf = {{ git = "https://github.com/MoriartyPuth/khpdf" }}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
| Field | Default | |
|---|---|---|
pages | empty (all) | 1-based page numbers to read. |
page_markers | false | Mark page starts in rendered output. |
normalize_khmer | true | Reorder visually stored Khmer into Unicode order. |
decode_legacy_fonts | true | Decode 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.
assert_eq!(khpdf::khmer::decode_limon("Exµr"), "ខ្មែរ");