code wiki / _hdl_build / _pdf_reflow_lib.nx
_pdf_reflow_lib.nx
buildroot/runtime/_hdl_build/_pdf_reflow_lib.nx
about
_pdf_reflow_lib.nx -- SOVEREIGN PDF -> reflowable-mobile-HTML pipeline (shared library).
Imported by nx_pdf_reflow.nx (the KAT gate) and nx_media_server.nx (the live /reflow route), so the
extraction logic lives once (DRY). Pure functions: caller provides the html/txt/dec buffers.
pr_pdf_to_reflow(pdf,n,html,txt,dec,txt_out) -> html_len: iterates EVERY "stream".."endstream", decodes
FlateDecode (zlib +2) or raw, runs an operator-aware content-stream text extractor (BT/ET, Tj/TJ, '/",
Td/TD/T*, (..)+<hex> strings, TJ word-gaps, line breaks; i+op in an *i64 state cell + pr_lit/pr_hex helpers
to keep per-function locals low -- a fat function miscompiles under nx_cc), and emits reflowable mobile HTML.
txt_out[0] receives the extracted-text char count (the reflow-vs-pageimage signal). license_tier: ORIGINAL
dependencies 3 imports · 3 importers
imports: nx_syscalls.nx_inflate_lib_authored.nxnx_charset.nx
imported by: nx_media_server.nxnx_pdf_reflow.nxnx_pdf_reflow_charset_gate.nx
structs
| none |
consts
| none |
functions
| 14 | func pr_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 15 | func pr_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 } called by 1: pr_pdf_to_reflow |
| 17 | func pr_sub(buf: *u8, n: i64, from: i64, needle: *u8, nl: i64) -> i64 |
| 22 | func pr_has(hay: *u8, hn: i64, needle: *u8) -> i64 |
| 29 | func pr_back_flate(pdf: *u8, pos: i64, win: i64) -> i64 |
| 35 | func pr_alpha(ch: i64) -> i64 { if ch>=65 { if ch<=90 { return 1 } } if ch>=97 { if ch<=122 { return 1 } } return 0 } called by 1: pr_extract |
| 38 | func pr_lit(c: *u8, n: i64, out: *u8, st: *i64) -> i64 called by 1: pr_extract |
| 63 | func pr_hex(c: *u8, n: i64, out: *u8, st: *i64) -> i64 called by 1: pr_extract |
| 87 | func pr_extract(c: *u8, n: i64, out: *u8, op0: i64) -> i64 |
| 134 | func pr_pdf_to_reflow(pdf: *u8, n: i64, html: *u8, txt: *u8, dec: *u8, txt_out: *i64) -> i64 called by 3: ms_handle_openmainmain calls 6: pr_subpr_back_flateinflatepr_extractnx_charset_repair_utf8pr_cat |