@qrcommunication/gigapdf-lib 0.52.3 → 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,28 @@ 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
+
7
29
  ## [0.52.3] - 2026-06-19
8
30
 
9
31
  ### 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;