@qrcommunication/gigapdf-lib 0.52.2 → 0.52.4

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,42 @@ 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.52.4] - 2026-06-19
8
+
9
+ ### Added
10
+
11
+ - **True PII redaction — `redactPii(page, rects, opts?)`.** Physically removes
12
+ the text operators in each rect, **overwrites the pixels of any image** that
13
+ intersects the rect (so a scanned / OCR'd page is genuinely sanitised, not
14
+ just covered), strips overlapping annotations + form-field values, and paints
15
+ an opaque black mark (the PII default). Not recoverable by copy-paste, text
16
+ extraction, or pulling the image back out — closing the gap where `redact()`
17
+ left images intact. ABI `gp_redact_pii`; `rects` are `{ x, y, width, height }`
18
+ in PDF user space, `opts: { cover?, coverRgb? }`.
19
+ - **Documentation — new `docs/COOKBOOK.md`** (task-oriented recipes) plus a full
20
+ refresh of the README, SDK, API and usage docs covering the recent additions
21
+ (text decorations, the running header/footer reader, the unified editable
22
+ model and its `modelTo*` exporters, AVIF).
23
+
24
+ ### Changed
25
+
26
+ - **OCR recognition models refreshed** — larger-backbone models and expanded
27
+ training data for better accuracy.
28
+
29
+ ## [0.52.3] - 2026-06-19
30
+
31
+ ### Added
32
+
33
+ - **Bake underline & strikethrough into drawn text.** `addText` /
34
+ `addStandardText` now accept a trailing `opts: { underline?, strikethrough? }`
35
+ (backed by new `add_text_styled` / `gp_add_text_styled`); the rule is painted
36
+ as a filled rectangle that follows the text rotation, its length taken from the
37
+ run's real glyph advances. Existing calls stay byte-identical (flags off).
38
+ - **AVIF (AV1 intra) decode — loop restoration (§7.17 Wiener + SGR) and
39
+ directional intra-edge filtering/upsampling.** Higher-fidelity AVIF decoding;
40
+ the post-deblock / pre-CDEF stripe halo is used for restoration so stripe and
41
+ frame edges are reconstructed correctly.
42
+
7
43
  ## [0.52.2] - 2026-06-19
8
44
 
9
45
  ### Added
package/dist/index.cjs CHANGED
@@ -1077,6 +1077,36 @@ var GigaPdfDoc = class {
1077
1077
  redact(page, x, y, w, h, coverRgb = 0, hasCover = false) {
1078
1078
  return this.ex().gp_redact_region(this.h, page, x, y, w, h, RGB(coverRgb), hasCover ? 1 : 0);
1079
1079
  }
1080
+ /**
1081
+ * True **PII redaction** of one or more rectangles `(x, y, width, height)` in
1082
+ * PDF points (origin bottom-left), in a single call. For every rect this:
1083
+ *
1084
+ * - **deletes** the overlapping text/vector elements from the content stream —
1085
+ * the glyphs and their `/ToUnicode` mapping are gone, so copy/paste and text
1086
+ * extraction reveal nothing in the area;
1087
+ * - **overwrites the pixels** of any underlying image (a scan/photo) with opaque
1088
+ * black — only the intersecting sub-rectangle, so the rest of the page image
1089
+ * survives — and re-encodes the image, erasing the sensitive pixels from the
1090
+ * bytes (not merely covering them);
1091
+ * - strips overlapping annotations and clears their form-field values;
1092
+ * - paints an opaque **black** box over the rect as the visible redaction mark.
1093
+ *
1094
+ * The black cover is the default for PII (unlike {@link redact}). Pass
1095
+ * `opts.coverRgb` to change the mark colour, or `opts.cover = false` to remove
1096
+ * the content/pixels with no visible box. Returns the number of content
1097
+ * elements deleted across all rects.
1098
+ */
1099
+ redactPii(page, rects, opts = {}) {
1100
+ if (rects.length === 0) return 0;
1101
+ const flat = [];
1102
+ for (const r of rects) flat.push(r.x, r.y, r.width, r.height);
1103
+ const cover = opts.cover ?? true;
1104
+ const coverRgb = opts.coverRgb ?? 0;
1105
+ return this.g._withF64(
1106
+ flat,
1107
+ (p, c) => this.ex().gp_redact_pii(this.h, page, p, c, RGB(coverRgb), cover ? 1 : 0)
1108
+ );
1109
+ }
1080
1110
  // pages
1081
1111
  rotatePage(page, degrees) {
1082
1112
  return this.ex().gp_rotate_page(this.h, page, degrees) === 0;
@@ -1226,11 +1256,18 @@ var GigaPdfDoc = class {
1226
1256
  * font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
1227
1257
  * `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
1228
1258
  * family with no embedding, use {@link addStandardText}.
1259
+ *
1260
+ * Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
1261
+ * draws a rule just below the baseline, `{ strikethrough: true }` a rule near
1262
+ * the x-height — both span the run's advance and are filled in the text colour.
1263
+ * Omitting `opts` is fully backward-compatible (no decoration).
1229
1264
  */
1230
- addText(page, x, y, size, text, fontObj, rgb = 0, opacity = 1, rotationDeg = 0) {
1265
+ addText(page, x, y, size, text, fontObj, rgb = 0, opacity = 1, rotationDeg = 0, opts) {
1266
+ const underline = opts?.underline ? 1 : 0;
1267
+ const strikethrough = opts?.strikethrough ? 1 : 0;
1231
1268
  return this.g._withStr(
1232
1269
  text,
1233
- (p, l) => this.ex().gp_add_text(
1270
+ (p, l) => this.ex().gp_add_text_styled(
1234
1271
  this.h,
1235
1272
  page,
1236
1273
  x,
@@ -1241,7 +1278,9 @@ var GigaPdfDoc = class {
1241
1278
  fontObj,
1242
1279
  RGB(rgb),
1243
1280
  opacity,
1244
- rotationDeg
1281
+ rotationDeg,
1282
+ underline,
1283
+ strikethrough
1245
1284
  )
1246
1285
  ) === 0;
1247
1286
  }
@@ -1252,13 +1291,19 @@ var GigaPdfDoc = class {
1252
1291
  * {@link embedFont} (a Google Font fetched by the host, or one pulled out of
1253
1292
  * the document with {@link extractFont}) and use {@link addText}. Returns
1254
1293
  * `false` on an unknown font name or bad page.
1294
+ *
1295
+ * Pass `opts` to bake **text decorations** into the run: `{ underline: true }`
1296
+ * and/or `{ strikethrough: true }` draw filled rules in the text colour.
1297
+ * Omitting `opts` is fully backward-compatible (no decoration).
1255
1298
  */
1256
- addStandardText(page, x, y, size, text, fontName, rgb = 0, opacity = 1, rotationDeg = 0) {
1299
+ addStandardText(page, x, y, size, text, fontName, rgb = 0, opacity = 1, rotationDeg = 0, opts) {
1300
+ const underline = opts?.underline ? 1 : 0;
1301
+ const strikethrough = opts?.strikethrough ? 1 : 0;
1257
1302
  return this.g._withStr(
1258
1303
  text,
1259
1304
  (tp, tl) => this.g._withStr(
1260
1305
  fontName,
1261
- (fp, fl) => this.ex().gp_add_text_standard(
1306
+ (fp, fl) => this.ex().gp_add_text_standard_styled(
1262
1307
  this.h,
1263
1308
  page,
1264
1309
  x,
@@ -1270,7 +1315,9 @@ var GigaPdfDoc = class {
1270
1315
  fl,
1271
1316
  RGB(rgb),
1272
1317
  opacity,
1273
- rotationDeg
1318
+ rotationDeg,
1319
+ underline,
1320
+ strikethrough
1274
1321
  )
1275
1322
  )
1276
1323
  ) === 0;