code wiki / _hdl_build / nx_pdf.nx
nx_pdf.nx
buildroot/runtime/_hdl_build/nx_pdf.nx
about
nx_pdf.nx -- sovereign PDF -> HTML preview (v1 = TEXT-LAYER preview). Composes the proven extractor
nx_pdf_text (objects -> FlateDecode -> per-font /ToUnicode CMap -> UTF-8; rule 15 DRY, fork-exec'd) and
adds the viewer half: a TEXT-QUALITY LINE FILTER (real PDFs leak non-text streams + glyph soup from
subset fonts without usable ToUnicode -- a line is kept only if it looks like language: a >=3-letter word,
>=40% ASCII-alpha of non-space bytes, no control bytes) then wraps the survivors as the standard 0-JS
preview page. HONEST v1: text layer only -- figures/graphics/exact typography are NOT painted, and the
page footer says so. Same `html <in> <out.html> [dlurl]` iface as nx_docx/nx_md/nx_csv, so the
nx_doc_view registry routes .pdf with zero special-casing. license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const K_MAGIC_6000: i64 = 6000 |
| 12 | const K_MAGIC_33554432: i64 = 33554432 |
functions
| 14 | func pf_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8) { n=n+1 } return n } called by 1: pf_puts |
| 15 | func pf_puts(s: *u8) -> i64 { sys_write(1, s, pf_slen(s)); return 0 } |
| 20 | func pf_num(v: i64) -> i64 { nxi_out(v); return 0 } |
| 21 | func pf_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { dst[off+i]=s[i]; i=i+1 } return off+i } |
| 23 | func pf_exists(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 } |
| 26 | func pf_extract(inp: *u8, txtout: *u8) -> i64 |
| 46 | func pf_is_text(src: *u8, s: i64, e: i64) -> i64 called by 1: pf_to_html |
| 70 | func pf_esc(dst: *u8, off: i64, src: *u8, s: i64, e: i64) -> i64 |
| 84 | func pf_to_html(txt: *u8, tlen: i64, out: *u8, dlurl: *u8) -> i64 |
| 114 | func main(argc: i64, argv: *i64) -> i64 |