@qrcommunication/gigapdf-lib 0.59.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,56 @@ All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and the
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.61.0] - 2026-06-22
8
+
9
+ ### Fixed
10
+
11
+ - **Form layouts no longer mis-detected as giant tables.** The layout
12
+ reconstruction (`recon/tables`, surfaced by `pageBlocks`/`toModel`) clustered
13
+ every ruling line into grid edges and claimed every text line inside the grid
14
+ bounding box, so a form's field-separator rules synthesised a giant table that
15
+ swallowed the title and intro prose into cells. A geometric sanity gate now
16
+ rejects a table candidate when `n_cols > 14`, `n_rows × n_cols > 160`, or the
17
+ cell fill ratio `< 0.28` — the text flows back to the heading/paragraph
18
+ pipeline. Real data tables (regular grid, well-filled) are preserved; dense
19
+ ruled forms (16–47 columns, 7–24% fill) become standalone headings/paragraphs
20
+ in reading order. No change to genuine `table` blocks.
21
+
22
+ ## [0.60.0] - 2026-06-22
23
+
24
+ ### Added
25
+
26
+ - **`pageBlocks(page)`** — per-page layout blocks (paragraphs, headings, tables,
27
+ lists, columns) in reading order, each run carrying its `source_index` for
28
+ lossless editing. Surfaces the existing `recon/` reconstruction pipeline
29
+ (until now whole-document only, via `toModel()`) one page at a time, for
30
+ continuous / lazily-virtualised editors. Routes through form XObject text so
31
+ cerfa / invoice template text is reconstructed into blocks too.
32
+ - **Base-14 standard fonts in the rasterizer** — `renderPage` now draws the
33
+ standard 14 fonts (Helvetica / Arial / Times / Courier / Symbol /
34
+ ZapfDingbats) via a bundled metric-compatible face, **in memory only**
35
+ (nothing is written to the PDF). Authoritative Symbol + ZapfDingbats
36
+ `code → Unicode` tables (e.g. ZapfDingbats `0x34` → U+2714 ✔, not the digit).
37
+
38
+ ### Changed
39
+
40
+ - **Form-field appearances reference the field's `/DA` standard font** (e.g.
41
+ `/Helv`) instead of injecting a bundled font resource into the PDF. Filling a
42
+ text field adds **no** font to the document; Adobe draws the standard font
43
+ natively. A `/DA` font missing from `/DR` is registered as a bare base-14
44
+ `/Type1` dict (no `FontFile`), exactly what a clean AcroForm carries.
45
+
46
+ ### Fixed
47
+
48
+ - Embedded **Type1 / CFF subsets with a base-14 BaseFont** (e.g. `Times-Bold`)
49
+ now render — they were drawn as `.notdef` (invisible) because the base-14
50
+ substitution was applied even when the font embeds its own program. The
51
+ substitute is now used only when no program is embedded.
52
+ - Glyph advances honour the PDF **`/Widths`** (`/W` + `/DW`, or `/Widths` +
53
+ `/FirstChar`) authoritatively per ISO 32000-1 §9.2.4; the embedded-font
54
+ advance is the fallback. Fixes collapsed / overlapping words on subset fonts
55
+ whose charstring advances are degenerate.
56
+
7
57
  ## [0.59.0] - 2026-06-21
8
58
 
9
59
  ### Added — Universal font decoding (text extraction matches Adobe, zero OCR)
package/dist/index.cjs CHANGED
@@ -36,7 +36,21 @@ var OCR_MODEL_FILES = {
36
36
  tamil: "ocr_taml.gpocr",
37
37
  cjk: "ocr_cjk.gpocr",
38
38
  japanese: "ocr_jpn.gpocr",
39
- korean: "ocr_kor.gpocr"
39
+ korean: "ocr_kor.gpocr",
40
+ thai: "ocr_thai.gpocr",
41
+ telugu: "ocr_telu.gpocr",
42
+ kannada: "ocr_kann.gpocr",
43
+ malayalam: "ocr_mlym.gpocr",
44
+ gujarati: "ocr_gujr.gpocr",
45
+ gurmukhi: "ocr_guru.gpocr",
46
+ oriya: "ocr_orya.gpocr",
47
+ sinhala: "ocr_sinh.gpocr",
48
+ georgian: "ocr_geor.gpocr",
49
+ armenian: "ocr_armn.gpocr",
50
+ khmer: "ocr_khmr.gpocr",
51
+ lao: "ocr_laoo.gpocr",
52
+ myanmar: "ocr_mymr.gpocr",
53
+ amharic: "ocr_ethi.gpocr"
40
54
  };
41
55
  var ALL_OCR_SCRIPTS = [
42
56
  "alpha",
@@ -46,7 +60,21 @@ var ALL_OCR_SCRIPTS = [
46
60
  "tamil",
47
61
  "cjk",
48
62
  "japanese",
49
- "korean"
63
+ "korean",
64
+ "thai",
65
+ "telugu",
66
+ "kannada",
67
+ "malayalam",
68
+ "gujarati",
69
+ "gurmukhi",
70
+ "oriya",
71
+ "sinhala",
72
+ "georgian",
73
+ "armenian",
74
+ "khmer",
75
+ "lao",
76
+ "myanmar",
77
+ "amharic"
50
78
  ];
51
79
  var GigaPdfEngine = class _GigaPdfEngine {
52
80
  constructor(ex) {
@@ -944,6 +972,23 @@ var GigaPdfDoc = class {
944
972
  structuredText(page) {
945
973
  return this.g._json((o) => this.ex().gp_structured_text_json(this.h, page, o));
946
974
  }
975
+ /**
976
+ * The **layout blocks** of a single page — the structural reconstruction
977
+ * (paragraphs, headings, lists, tables, shapes, images) of the page's flat
978
+ * glyph/path geometry, in reading order (column-major), each {@link GigaBlock}
979
+ * keeping a top-down `frame` and every text run its `source_index` back to the
980
+ * editable content-stream operator.
981
+ *
982
+ * The **per-page** counterpart of {@link GigaPdfDoc.toModel} (which
983
+ * reconstructs the whole document at once): a continuous / lazily-virtualized
984
+ * editor calls this one page at a time. Identifies 1- and 2-column layouts,
985
+ * merges lines into justified/left/centred/right paragraphs, promotes large
986
+ * isolated lines to headings, and recovers ruled tables. An out-of-range page
987
+ * yields `[]`.
988
+ */
989
+ pageBlocks(page) {
990
+ return this.g._json((o) => this.ex().gp_page_blocks_json(this.h, page, o));
991
+ }
947
992
  search(query, caseInsensitive = true) {
948
993
  return this.g._withStr(
949
994
  query,