@qrcommunication/gigapdf-lib 0.52.3 → 0.52.5

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,39 @@ 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.5] - 2026-06-19
8
+
9
+ ### Added
10
+
11
+ - **Arrow line annotations — `addLineAnnotation(page, x1, y1, x2, y2, rgb, lineWidth, endArrow?)`.**
12
+ The new `endArrow` flag draws an open arrowhead at the `(x2,y2)` end and records
13
+ `/LE [/None /OpenArrow]` on the `/Line` annotation, so the arrowhead survives in
14
+ any conforming reader (Adobe Reader, Preview, Chrome) — and stays editable, not
15
+ baked. The `/Rect` is padded around the arrowhead so it is never clipped. Ideal
16
+ for callouts that point at content. Backward compatible: `endArrow` defaults to `false`.
17
+
18
+ ## [0.52.4] - 2026-06-19
19
+
20
+ ### Added
21
+
22
+ - **True PII redaction — `redactPii(page, rects, opts?)`.** Physically removes
23
+ the text operators in each rect, **overwrites the pixels of any image** that
24
+ intersects the rect (so a scanned / OCR'd page is genuinely sanitised, not
25
+ just covered), strips overlapping annotations + form-field values, and paints
26
+ an opaque black mark (the PII default). Not recoverable by copy-paste, text
27
+ extraction, or pulling the image back out — closing the gap where `redact()`
28
+ left images intact. ABI `gp_redact_pii`; `rects` are `{ x, y, width, height }`
29
+ in PDF user space, `opts: { cover?, coverRgb? }`.
30
+ - **Documentation — new `docs/COOKBOOK.md`** (task-oriented recipes) plus a full
31
+ refresh of the README, SDK, API and usage docs covering the recent additions
32
+ (text decorations, the running header/footer reader, the unified editable
33
+ model and its `modelTo*` exporters, AVIF).
34
+
35
+ ### Changed
36
+
37
+ - **OCR recognition models refreshed** — larger-backbone models and expanded
38
+ training data for better accuracy.
39
+
7
40
  ## [0.52.3] - 2026-06-19
8
41
 
9
42
  ### 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;
@@ -1511,8 +1541,14 @@ var GigaPdfDoc = class {
1511
1541
  addHighlight(page, x0, y0, x1, y1, rgb = 16776960) {
1512
1542
  return this.ex().gp_add_highlight(this.h, page, x0, y0, x1, y1, RGB(rgb)) === 0;
1513
1543
  }
1514
- addLineAnnotation(page, x1, y1, x2, y2, rgb = 0, lineWidth = 1) {
1515
- return this.ex().gp_add_line(this.h, page, x1, y1, x2, y2, RGB(rgb), lineWidth) === 0;
1544
+ /**
1545
+ * Add a `/Line` annotation from `(x1,y1)` to `(x2,y2)`. When `endArrow` is
1546
+ * `true`, an open arrowhead (`/LE [/None /OpenArrow]`) is drawn at the
1547
+ * `(x2,y2)` end — a real, editable annotation in conforming readers, ideal
1548
+ * for callouts that point at content.
1549
+ */
1550
+ addLineAnnotation(page, x1, y1, x2, y2, rgb = 0, lineWidth = 1, endArrow = false) {
1551
+ return this.ex().gp_add_line(this.h, page, x1, y1, x2, y2, RGB(rgb), lineWidth, endArrow ? 1 : 0) === 0;
1516
1552
  }
1517
1553
  addFreeText(page, x0, y0, x1, y1, text, fontSize = 12, rgb = 0) {
1518
1554
  return this.g._withStr(