@qrcommunication/gigapdf-lib 0.65.0 → 0.67.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.67.0] - 2026-06-23
8
+
9
+ ### Added
10
+
11
+ - **Structured-editing ModelOps + permissions API exposed in the SDK.** New
12
+ `applyModelOps` variants: paragraph formatting (`setParagraphStyle` — align/indent/
13
+ spacing/line-height), lists (`setListLevel`/`setListMarker`/`setListOrdered`),
14
+ absolute block placement (`setBlockFrame`/`setBlockRotation`), and table styling
15
+ (`setCellShading`/`setRowHeight`/`setColWidth`/`setTableBorder`). Table structural
16
+ edits (`insertTableRow`/`deleteTableRow`/`insertTableColumn`/`deleteTableColumn`/
17
+ `setCellSpan` + sheet row/column ops) and `GigaPdfDoc` permission helpers
18
+ (`permissionsToP`/`decodePermissions`/`getPermissions` + `saveEncrypted({ flags })`)
19
+ are now callable from JS.
20
+
21
+ ### Changed
22
+
23
+ - 8 PDF permission flags are functional: `/P` is computed from named flags per
24
+ ISO 32000-1 Table 22 (previously a cosmetic integer).
25
+
26
+ ## [0.66.0] - 2026-06-23
27
+
28
+ ### Added
29
+
30
+ - **HTML/CSS rendering — LibreOffice-level fidelity.** `htmlRender` gains real **CSS
31
+ grid** (`fr`/`minmax`/`repeat`/`span`/`auto-rows`) and **complete flexbox**
32
+ (basis/grow/shrink/wrap/justify/align), **multi-column** (`column-count`/`columns`/
33
+ `column-gap`), **pragmatic RTL/bidi** (`direction`/`dir`, RTL block/inline/run
34
+ layout), table fidelity (colspan/rowspan, LibreOffice-level), text styling
35
+ (super/sub, underline, strike), `@media`, font shorthand and further CSS-2 coverage.
36
+ - **Document reconstruction (`structuredText`) — waves R1–R10.** Typed + populated
37
+ `pageBlocks` bodies, merged-cell spans, strikethrough, hyperlinks, paragraph
38
+ spacing, super/subscript, document outline + figure captions, list nesting +
39
+ continuation lines, multi-column reading order, multiple tables per page
40
+ (connected-component split), borderless right/decimal-aligned columns, true
41
+ decimal-tab alignment.
42
+ - **PDF permissions — 8 functional flags.** `getPermissions` + correct `/P` encoding
43
+ of the 8 standard permission bits (print, modify, copy, annotate, fill-forms,
44
+ extract, assemble, high-res print).
45
+ - **Model structural edits.** Table & sheet structural-edit ModelOps.
46
+
47
+ ### OCR (native `gigapdf-ocr-rten` crate — host-side, not bundled in the npm package)
48
+
49
+ - Pivoted the OCR engine to **PaddleOCR PP-OCR on RTen** (pure-Rust ONNX, no C++/
50
+ Tesseract): 13 printed languages incl. our own **Hebrew** model, with automatic
51
+ per-line **script selection**.
52
+ - **Handwriting** recognizer (`latin_hw`) — our own CRNN trained on real handwriting
53
+ (IAM/RIMES/NorHand/…; standard `nn.LSTM` → dynamic-width ONNX), **opt-in** via
54
+ `recognize_page_handwriting` / `recognize_page_with(img, "latin_hw")`.
55
+ - Full OCR documentation refresh (architecture, training data, SDK, cookbook).
56
+
7
57
  ## [0.65.0] - 2026-06-22
8
58
 
9
59
  ### Added
package/dist/index.cjs CHANGED
@@ -27,6 +27,16 @@ module.exports = __toCommonJS(index_exports);
27
27
  var import_node_fs = require("./node-fs.js");
28
28
  var enc = new TextEncoder();
29
29
  var dec = new TextDecoder();
30
+ var ALL_PERMISSIONS = {
31
+ print: true,
32
+ modify: true,
33
+ copy: true,
34
+ annotate: true,
35
+ fillForms: true,
36
+ accessibility: true,
37
+ assemble: true,
38
+ printHighRes: true
39
+ };
30
40
  var GigaPdfEngine = class _GigaPdfEngine {
31
41
  constructor(ex) {
32
42
  this.ex = ex;
@@ -243,6 +253,43 @@ var GigaPdfEngine = class _GigaPdfEngine {
243
253
  );
244
254
  return JSON.parse(dec.decode(json));
245
255
  }
256
+ /**
257
+ * Decode the eight access-permission flags from a `/P` permission bitmask
258
+ * (ISO 32000-1 Table 22) into named booleans (`true` = the action is
259
+ * granted). Reserved bits are ignored.
260
+ */
261
+ decodePermissions(p) {
262
+ const json = dec.decode(this._buffer((o) => this.ex.gp_permissions_from_p(p, o)));
263
+ return JSON.parse(json);
264
+ }
265
+ /**
266
+ * Read a PDF's access permissions **without decrypting it** (no password
267
+ * needed). Returns the eight named flags decoded from the `/Encrypt`
268
+ * dictionary's `/P`; an unencrypted document grants everything.
269
+ */
270
+ getPermissions(pdf) {
271
+ const { encrypted, permissions } = this.encryptionInfo(pdf);
272
+ return encrypted ? this.decodePermissions(permissions) : { ...ALL_PERMISSIONS };
273
+ }
274
+ /**
275
+ * Pack eight access-permission flags into a signed 32-bit `/P` value
276
+ * (ISO 32000-1 Table 22). Omitted flags default to **granted**, so an empty
277
+ * object means "all allowed". Feed the result to {@link GigaPdfDoc.saveEncrypted}
278
+ * via `opts.permissions`, or pass `opts.flags` directly.
279
+ */
280
+ permissionsToP(flags = {}) {
281
+ const f = { ...ALL_PERMISSIONS, ...flags };
282
+ return this.ex.gp_permissions_to_p(
283
+ f.print ? 1 : 0,
284
+ f.modify ? 1 : 0,
285
+ f.copy ? 1 : 0,
286
+ f.annotate ? 1 : 0,
287
+ f.fillForms ? 1 : 0,
288
+ f.accessibility ? 1 : 0,
289
+ f.assemble ? 1 : 0,
290
+ f.printHighRes ? 1 : 0
291
+ );
292
+ }
246
293
  /**
247
294
  * Width of `text` set in standard Helvetica at `size` points (AFM metrics) —
248
295
  * place watermark/header text without embedding a font.
@@ -1525,7 +1572,7 @@ var GigaPdfDoc = class {
1525
1572
  saveEncrypted(password, fileId, opts = {}) {
1526
1573
  const algo = opts.algorithm ?? "aes256";
1527
1574
  const algoCode = algo === "rc4" ? 0 : algo === "aes128" ? 1 : 2;
1528
- const permissions = opts.permissions ?? -44;
1575
+ const permissions = opts.flags !== void 0 ? this.g.permissionsToP(opts.flags) : opts.permissions ?? this.g.permissionsToP();
1529
1576
  let key = opts.keySeed ?? new Uint8Array(0);
1530
1577
  if (algoCode === 2 && key.length < 32) {
1531
1578
  const c = globalThis.crypto;