@qrcommunication/gigapdf-lib 0.71.1 → 0.104.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/dist/index.cjs CHANGED
@@ -22,12 +22,17 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  GigaPdfDoc: () => GigaPdfDoc,
24
24
  GigaPdfEngine: () => GigaPdfEngine,
25
+ PAGE_BOX_KINDS: () => PAGE_BOX_KINDS,
26
+ PAGE_TRANSITION_STYLES: () => PAGE_TRANSITION_STYLES,
25
27
  defaultCrlGet: () => defaultCrlGet,
26
28
  defaultOcspPost: () => defaultOcspPost,
27
29
  defaultTsaPost: () => defaultTsaPost
28
30
  });
29
31
  module.exports = __toCommonJS(index_exports);
30
32
  var import_node_fs = require("./node-fs.js");
33
+ function pdfVersionCode(v) {
34
+ return v === "2.0" ? 1 : 0;
35
+ }
31
36
  var enc = new TextEncoder();
32
37
  var dec = new TextDecoder();
33
38
  var ALL_PERMISSIONS = {
@@ -244,6 +249,23 @@ var GigaPdfEngine = class _GigaPdfEngine {
244
249
  this._free(pwPtr, b.length);
245
250
  return handle === 0 ? null : new GigaPdfDoc(this, handle);
246
251
  }
252
+ /**
253
+ * Open a **public-key (certificate) encrypted** PDF (`/Filter /Adobe.PubSec`,
254
+ * ISO 32000-1 §7.6.5) with a recipient's DER `certificate` + PKCS#1 RSA
255
+ * `privateKey`. `null` if this key is not a recipient. Counterpart of
256
+ * {@link GigaPdfDoc.encryptForRecipients}.
257
+ */
258
+ openWithPrivateKey(pdf, certificate, privateKey) {
259
+ const cP = this._toWasm(certificate);
260
+ const kP = this._toWasm(privateKey);
261
+ const handle = this._withBytes(
262
+ pdf,
263
+ (p, l) => this.ex.gp_open_with_private_key(p, l, cP, certificate.length, kP, privateKey.length)
264
+ );
265
+ this._free(cP, certificate.length);
266
+ this._free(kP, privateKey.length);
267
+ return handle === 0 ? null : new GigaPdfDoc(this, handle);
268
+ }
247
269
  /**
248
270
  * Inspect a PDF's encryption **without decrypting it** (no password needed):
249
271
  * whether it has an `/Encrypt` dictionary, plus its `/P` permission bitmask
@@ -372,19 +394,34 @@ var GigaPdfEngine = class _GigaPdfEngine {
372
394
  );
373
395
  }
374
396
  /**
375
- * Merge several PDFs into one by appending their pages in order. Returns an
376
- * empty document for an empty list, or the single input unchanged for a list
377
- * of one. Each subsequent PDF is appended onto the first via
397
+ * Merge several PDFs into one by appending their pages in order. Each input is
398
+ * either raw bytes (every page) or a {@link MergePart} `{ pdf, pages? }` that
399
+ * selects 1-based page numbers (ISO 32000-1 §7.7.3) — so the two forms can be
400
+ * mixed (e.g. `[whole, { pdf: b, pages: [1, 3] }]`). Returns an empty document
401
+ * for an empty list, or — when the only input is a whole PDF (no `pages`) —
402
+ * that input unchanged. Each subsequent part is appended onto the first via
378
403
  * {@link GigaPdfDoc.appendPages}; the merged bytes are returned and the working
379
404
  * document is closed.
380
405
  */
381
- mergePdfs(pdfs) {
382
- if (pdfs.length === 0) return new Uint8Array(0);
383
- if (pdfs.length === 1) return pdfs[0];
384
- const base = this.open(pdfs[0]);
406
+ mergePdfs(parts) {
407
+ if (parts.length === 0) return new Uint8Array(0);
408
+ const part = (p) => p instanceof Uint8Array ? { pdf: p } : p;
409
+ const first = part(parts[0]);
410
+ if (parts.length === 1 && first.pages === void 0) return first.pdf;
411
+ let seed = first.pdf;
412
+ if (first.pages !== void 0) {
413
+ const head = this.open(first.pdf);
414
+ try {
415
+ seed = head.extractPages(first.pages);
416
+ } finally {
417
+ head.close();
418
+ }
419
+ }
420
+ const base = this.open(seed);
385
421
  try {
386
- for (let i = 1; i < pdfs.length; i++) {
387
- base.appendPages(pdfs[i]);
422
+ for (let i = 1; i < parts.length; i++) {
423
+ const p = part(parts[i]);
424
+ base.appendPages(p.pdf, p.pages);
388
425
  }
389
426
  return base.save();
390
427
  } finally {
@@ -955,7 +992,48 @@ function frameBlobs(blobs) {
955
992
  }
956
993
  return out;
957
994
  }
995
+ var AF_RELATIONSHIP_CODE = {
996
+ source: 0,
997
+ data: 1,
998
+ alternative: 2,
999
+ supplement: 3,
1000
+ unspecified: 4
1001
+ };
1002
+ var PAGE_BOX_KINDS = ["media", "crop", "bleed", "trim", "art"];
1003
+ var PAGE_LABEL_STYLE_TOKEN = {
1004
+ decimal: "D",
1005
+ romanLower: "r",
1006
+ romanUpper: "R",
1007
+ alphaLower: "a",
1008
+ alphaUpper: "A",
1009
+ none: "-"
1010
+ };
1011
+ var PAGE_TRANSITION_STYLES = [
1012
+ "split",
1013
+ "blinds",
1014
+ "box",
1015
+ "wipe",
1016
+ "dissolve",
1017
+ "glitter",
1018
+ "fly",
1019
+ "push",
1020
+ "cover",
1021
+ "uncover",
1022
+ "fade",
1023
+ "replace"
1024
+ ];
958
1025
  var RGB = (rgb) => rgb & 16777215;
1026
+ function cryptoRandom(n) {
1027
+ const c = globalThis.crypto;
1028
+ if (!c?.getRandomValues) {
1029
+ throw new Error(
1030
+ "this operation needs Web Crypto (globalThis.crypto.getRandomValues) or an explicit seed"
1031
+ );
1032
+ }
1033
+ const out = new Uint8Array(n);
1034
+ c.getRandomValues(out);
1035
+ return out;
1036
+ }
959
1037
  function styleArgs(s = {}) {
960
1038
  const hasBorder = s.border === null ? 0 : 1;
961
1039
  const borderRgb = s.border == null ? 0 : s.border;
@@ -993,6 +1071,47 @@ var GigaPdfDoc = class {
993
1071
  saveCompressed() {
994
1072
  return this.g._buffer((o) => this.ex().gp_save_compressed(this.h, o));
995
1073
  }
1074
+ /**
1075
+ * Serialize with PDF 1.5+ **object streams** + a **cross-reference stream**
1076
+ * (ISO 32000-1 §7.5.7 / §7.5.8) — the most compact output. `objectStreams`
1077
+ * (default `true`) packs non-stream objects into compressed `/ObjStm`s (needs
1078
+ * the xref stream); `xrefStreams` (default `true`) writes a `/XRef` stream.
1079
+ * `version` selects the `%PDF-x.y` header banner (default `"1.7"`).
1080
+ * Uncompressed streams are Flate-compressed first, like {@link saveCompressed}.
1081
+ * Linearization (Fast Web View) is not performed.
1082
+ */
1083
+ saveOptimized(opts = {}) {
1084
+ const obj = opts.objectStreams ?? true;
1085
+ const xref = opts.xrefStreams ?? true;
1086
+ const ver = pdfVersionCode(opts.version);
1087
+ return this.g._buffer(
1088
+ (o) => this.ex().gp_save_optimized(this.h, obj ? 1 : 0, xref ? 1 : 0, ver, o)
1089
+ );
1090
+ }
1091
+ /**
1092
+ * Serialize as a **linearized** ("Fast Web View") PDF (ISO 32000-1 Annex F).
1093
+ *
1094
+ * The first page and only the objects needed to render it — together with a
1095
+ * `/Linearized` parameter dictionary and a primary hint stream — are written at
1096
+ * the **front** of the file, so a web viewer can display page 1 before the rest
1097
+ * of the document has downloaded (progressive rendering / byte-range serving).
1098
+ * The remaining pages follow, then a main cross-reference table; the first-page
1099
+ * cross-reference section chains to it via `/Prev`. Streams are Flate-compressed
1100
+ * first (like {@link saveCompressed}) and embedded fonts are subset.
1101
+ *
1102
+ * Falls back to the plain {@link save} output if the document cannot be
1103
+ * linearized (no catalog / page tree / zero pages). `version` selects the
1104
+ * `%PDF-x.y` header banner (default `"1.7"`).
1105
+ */
1106
+ toLinearized(version = "1.7") {
1107
+ return this.g._buffer(
1108
+ (o) => this.ex().gp_to_linearized(this.h, pdfVersionCode(version), o)
1109
+ );
1110
+ }
1111
+ /** Alias of {@link toLinearized} — serialize as a linearized (Fast Web View) PDF. */
1112
+ saveLinearized(version = "1.7") {
1113
+ return this.toLinearized(version);
1114
+ }
996
1115
  // text intelligence
997
1116
  textRuns(page) {
998
1117
  return this.g._json((o) => this.ex().gp_text_runs_json(this.h, page, o));
@@ -1182,7 +1301,7 @@ var GigaPdfDoc = class {
1182
1301
  * stream, painted last); otherwise it is sent behind everything (moved to the
1183
1302
  * start, painted first). The moved range is re-wrapped in `q … Q` so it neither
1184
1303
  * inherits nor leaks graphics state. Works for text, image and shape elements.
1185
- * The element's index changes after the move — re-read {@link pageElements}.
1304
+ * The element's index changes after the move — re-read {@link GigaPdfDoc.elements}.
1186
1305
  * Returns `false` if the page/index doesn't exist.
1187
1306
  */
1188
1307
  reorderElement(page, index, toFront) {
@@ -1239,6 +1358,212 @@ var GigaPdfDoc = class {
1239
1358
  opacity
1240
1359
  ) === 0;
1241
1360
  }
1361
+ /**
1362
+ * Paint a **linear** or **radial** gradient over `rect` on `page` (ISO 32000-1
1363
+ * §8.7.4 shading + §8.7.3 pattern). `coords` is `[x0,y0,x1,y1]` for `"linear"`
1364
+ * or `[x0,y0,r0,x1,y1,r1]` for `"radial"`; `stops` is ≥ 2 colour stops
1365
+ * (`offset` 0…1, `rgb` packed `0xRRGGBB`). `extend` (default `[true,true]`)
1366
+ * sets `/Extend`; `opacity` (default `1`) is the fill alpha.
1367
+ *
1368
+ * @example
1369
+ * doc.addGradient(1, {
1370
+ * kind: "linear", coords: [50, 50, 250, 50],
1371
+ * stops: [{ offset: 0, rgb: 0xff0000 }, { offset: 1, rgb: 0x0000ff }],
1372
+ * rect: { x: 50, y: 40, w: 200, h: 60 },
1373
+ * });
1374
+ */
1375
+ addGradient(page, spec) {
1376
+ const kind = spec.kind === "radial" ? 1 : 0;
1377
+ const offsets = spec.stops.map((s) => s.offset);
1378
+ const colors = spec.stops.map((s) => RGB(s.rgb));
1379
+ const [es, ee] = spec.extend ?? [true, true];
1380
+ const opacity = spec.opacity ?? 1;
1381
+ const r = spec.rect;
1382
+ return this.g._withF64(
1383
+ spec.coords,
1384
+ (cp, cc) => this.g._withF64(
1385
+ offsets,
1386
+ (op, _oc) => this.g._withU32(
1387
+ colors,
1388
+ (clp, _clc) => this.ex().gp_add_gradient(
1389
+ this.h,
1390
+ page,
1391
+ kind,
1392
+ cp,
1393
+ cc,
1394
+ op,
1395
+ clp,
1396
+ offsets.length,
1397
+ r.x,
1398
+ r.y,
1399
+ r.w,
1400
+ r.h,
1401
+ es ? 1 : 0,
1402
+ ee ? 1 : 0,
1403
+ opacity
1404
+ )
1405
+ )
1406
+ )
1407
+ ) === 0;
1408
+ }
1409
+ /**
1410
+ * Encode a {@link Color} into the ABI's `(kind, comps, name, profile)` buffers
1411
+ * and invoke `fn` with the resulting pointers. Internal.
1412
+ */
1413
+ _color(color, fn) {
1414
+ let kind;
1415
+ let comps;
1416
+ let name = "";
1417
+ let profile = null;
1418
+ switch (color.space) {
1419
+ case "cmyk":
1420
+ kind = 1;
1421
+ comps = [color.c, color.m, color.y, color.k];
1422
+ break;
1423
+ case "gray":
1424
+ kind = 2;
1425
+ comps = [color.gray];
1426
+ break;
1427
+ case "separation":
1428
+ kind = 3;
1429
+ comps = [color.tint, ...color.cmyk];
1430
+ name = color.name;
1431
+ break;
1432
+ case "icc":
1433
+ kind = 4;
1434
+ comps = color.components;
1435
+ profile = color.profile;
1436
+ break;
1437
+ default: {
1438
+ const c = RGB(color.rgb);
1439
+ kind = 0;
1440
+ comps = [(c >> 16 & 255) / 255, (c >> 8 & 255) / 255, (c & 255) / 255];
1441
+ }
1442
+ }
1443
+ return this.g._withF64(
1444
+ comps,
1445
+ (cp, cc) => this.g._withOptStr(
1446
+ name,
1447
+ (np, nl) => profile ? this.g._withBytes(profile, (pp, pl) => fn(kind, cp, cc, np, nl, pp, pl)) : fn(kind, cp, cc, np, nl, 0, 0)
1448
+ )
1449
+ );
1450
+ }
1451
+ /**
1452
+ * Fill a rectangle with `color` in **any** colour space — the press-ready
1453
+ * counterpart of {@link addRectangle} (CMYK, spot `Separation`, gray, ICC).
1454
+ *
1455
+ * @example
1456
+ * doc.addFilledRectangle(1, { x: 40, y: 700, w: 200, h: 40 },
1457
+ * { space: "cmyk", c: 0.1, m: 0.8, y: 0.9, k: 0 });
1458
+ */
1459
+ addFilledRectangle(page, rect, color, opacity = 1) {
1460
+ return this._color(
1461
+ color,
1462
+ (kind, cp, cc, np, nl, pp, pl) => this.ex().gp_add_filled_rectangle(
1463
+ this.h,
1464
+ page,
1465
+ rect.x,
1466
+ rect.y,
1467
+ rect.w,
1468
+ rect.h,
1469
+ kind,
1470
+ cp,
1471
+ cc,
1472
+ np,
1473
+ nl,
1474
+ pp,
1475
+ pl,
1476
+ opacity
1477
+ )
1478
+ ) === 0;
1479
+ }
1480
+ /**
1481
+ * Fill a polygon through flat `[x0,y0,x1,y1,…]` `points` (≥ 3 vertices) with
1482
+ * `color` in any colour space. The path is closed automatically.
1483
+ */
1484
+ addFilledPolygon(page, points, color, opacity = 1) {
1485
+ return this.g._withF64(
1486
+ points,
1487
+ (ptsPtr, ptsCount) => this._color(
1488
+ color,
1489
+ (kind, cp, cc, np, nl, pp, pl) => this.ex().gp_add_filled_polygon(
1490
+ this.h,
1491
+ page,
1492
+ ptsPtr,
1493
+ ptsCount,
1494
+ kind,
1495
+ cp,
1496
+ cc,
1497
+ np,
1498
+ nl,
1499
+ pp,
1500
+ pl,
1501
+ opacity
1502
+ )
1503
+ )
1504
+ ) === 0;
1505
+ }
1506
+ /**
1507
+ * Draw a base-14 text run in **any** colour space — the press-ready
1508
+ * counterpart of {@link addTextStandard}. `font` is a base-14 family
1509
+ * (`Helvetica`, `Times-Roman`, `Courier`, …).
1510
+ */
1511
+ addTextColor(page, x, y, size, text, font, color, opts = {}) {
1512
+ const { opacity = 1, rotation = 0, underline = false, strikethrough = false } = opts;
1513
+ return this.g._withStr(
1514
+ text,
1515
+ (tp, tl) => this.g._withStr(
1516
+ font,
1517
+ (fp, fl) => this._color(
1518
+ color,
1519
+ (kind, cp, cc, np, nl, pp, pl) => this.ex().gp_add_text_color(
1520
+ this.h,
1521
+ page,
1522
+ x,
1523
+ y,
1524
+ size,
1525
+ tp,
1526
+ tl,
1527
+ fp,
1528
+ fl,
1529
+ kind,
1530
+ cp,
1531
+ cc,
1532
+ np,
1533
+ nl,
1534
+ pp,
1535
+ pl,
1536
+ opacity,
1537
+ rotation,
1538
+ underline ? 1 : 0,
1539
+ strikethrough ? 1 : 0
1540
+ )
1541
+ )
1542
+ )
1543
+ ) === 0;
1544
+ }
1545
+ /**
1546
+ * Turn **overprint** on/off for content drawn **after** this call (`/op` fill,
1547
+ * `/OP` stroke, `/OPM` mode — `0` independent colorants, `1` non-erasing).
1548
+ * Essential for prepress black-overprint / trapping.
1549
+ */
1550
+ setOverprint(page, fill, stroke, mode = 1) {
1551
+ return this.ex().gp_set_overprint(this.h, page, fill ? 1 : 0, stroke ? 1 : 0, mode) === 0;
1552
+ }
1553
+ /**
1554
+ * Add a document-level **OutputIntent** embedding the ICC `profile` (its `/N`
1555
+ * is read from the profile), with `condition` as the output-condition
1556
+ * identifier (e.g. `"Coated FOGRA39"`). Decoupled from the PDF/A path.
1557
+ */
1558
+ addOutputIntent(profile, condition) {
1559
+ return this.g._withBytes(
1560
+ profile,
1561
+ (pp, pl) => this.g._withStr(
1562
+ condition,
1563
+ (cp, cl) => this.ex().gp_add_output_intent(this.h, pp, pl, cp, cl)
1564
+ )
1565
+ ) === 0;
1566
+ }
1242
1567
  /**
1243
1568
  * Draw a polyline/polygon through flat `[x0,y0,x1,y1,…]` points. `close` joins
1244
1569
  * the last vertex back to the first. `0xRRGGBB` colours, or `null` to omit.
@@ -1295,6 +1620,27 @@ var GigaPdfDoc = class {
1295
1620
  (p, l) => this.ex().gp_add_image(this.h, page, p, l, x, y, w, h, opacity)
1296
1621
  ) === 0;
1297
1622
  }
1623
+ /**
1624
+ * Replace the pixels of an **existing image XObject in place** — swap a logo or
1625
+ * photo while every reference to it stays intact (ISO 32000-1 §8.9). `index` is
1626
+ * the **unified element index** of an image on `page`, exactly the `index`
1627
+ * reported by {@link imageElements} (and accepted by {@link removeElement} /
1628
+ * {@link transformElement}); `data` is a fresh PNG or JPEG.
1629
+ *
1630
+ * Unlike a delete-then-re-add, the image keeps its object number, **every `/Do`
1631
+ * placement, and its position / scale / rotation / clip matrix** — only the
1632
+ * stream bytes and the image dictionary (`/Width`, `/Height`, `/ColorSpace`,
1633
+ * `/BitsPerComponent`, `/Filter`) are rewritten. The new raster is re-encoded
1634
+ * through the same path as {@link addImage} (PNG alpha → a fresh `/SMask`; JPEG
1635
+ * → `/DCTDecode` passthrough). It need not match the old pixel size — it is
1636
+ * drawn into the same box (transform the element first to re-fit it).
1637
+ *
1638
+ * Returns `false` if `page`/`index` doesn't resolve to a top-level image, or the
1639
+ * bytes aren't a decodable PNG/JPEG.
1640
+ */
1641
+ replaceImage(page, index, data) {
1642
+ return this.g._withBytes(data, (p, l) => this.ex().gp_replace_image(this.h, page, index, p, l)) === 0;
1643
+ }
1298
1644
  /**
1299
1645
  * Stamp an **image watermark** across pages from raw image bytes. Accepts the
1300
1646
  * same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
@@ -1391,8 +1737,25 @@ var GigaPdfDoc = class {
1391
1737
  movePage(from, to) {
1392
1738
  return this.ex().gp_move_page(this.h, from, to) === 0;
1393
1739
  }
1394
- appendPages(otherPdf) {
1395
- return this.g._withBytes(otherPdf, (p, l) => this.ex().gp_append_pages(this.h, p, l)) === 0;
1740
+ /**
1741
+ * Append pages of another PDF onto this document. With no `pages`, every page
1742
+ * is appended (powers *merge*). With `pages` — 1-based page numbers, in the
1743
+ * order given — only that selection is brought in (ISO 32000-1 §7.7.3), each
1744
+ * page keeping its content, resources, annotations and box geometry. Numbers
1745
+ * out of range are skipped; an empty/all-out-of-range selection returns
1746
+ * `false`.
1747
+ */
1748
+ appendPages(otherPdf, pages) {
1749
+ if (pages === void 0) {
1750
+ return this.g._withBytes(otherPdf, (p, l) => this.ex().gp_append_pages(this.h, p, l)) === 0;
1751
+ }
1752
+ return this.g._withBytes(
1753
+ otherPdf,
1754
+ (bp, bl) => this.g._withU32(
1755
+ pages,
1756
+ (pp, pc) => this.ex().gp_append_pages_subset(this.h, bp, bl, pp, pc)
1757
+ )
1758
+ ) === 0;
1396
1759
  }
1397
1760
  /**
1398
1761
  * Add an invisible (text render mode 3) standard-Helvetica text layer to
@@ -1435,10 +1798,71 @@ var GigaPdfDoc = class {
1435
1798
  (p, c) => this.g._buffer((o) => this.ex().gp_extract_pages(this.h, p, c, o))
1436
1799
  );
1437
1800
  }
1438
- /** Resize a page's MediaBox to `width`×`height` points. */
1801
+ /**
1802
+ * Resize a page's `/MediaBox` to `width`×`height` points — **box geometry
1803
+ * only**. The drawn content keeps its own coordinates (it is *not* rescaled to
1804
+ * the new box, so it may clip or float). To scale the page content along with
1805
+ * the box (keeping annotations aligned) use {@link scalePageContent} or
1806
+ * {@link scalePageTo}; for large-format authoring see {@link setUserUnit}.
1807
+ */
1439
1808
  resizePage(page, width, height) {
1440
1809
  return this.ex().gp_resize_page(this.h, page, width, height) === 0;
1441
1810
  }
1811
+ /**
1812
+ * Scale a page's **content** uniformly by `factor` about the page origin (ISO
1813
+ * 32000-1 §8.3.4) — a true zoom of the whole page, not just the box. Three
1814
+ * things move together: (1) the content stream is wrapped in
1815
+ * `q <factor 0 0 factor 0 0> cm … Q`; (2) `/MediaBox` and `/CropBox` (resolved
1816
+ * through inheritance) plus any locally declared `/BleedBox`/`/TrimBox`/
1817
+ * `/ArtBox` are scaled about the origin; (3) every annotation `/Rect` is scaled,
1818
+ * so widget/stamp appearances — mapped from their `/BBox` into the `/Rect` per
1819
+ * §12.5.5 — rescale to stay aligned automatically. `factor` must be finite and
1820
+ * positive. `false` on engine error (bad page number / non-positive factor).
1821
+ */
1822
+ scalePageContent(page, factor) {
1823
+ return this.ex().gp_scale_page_content(this.h, page, factor) === 0;
1824
+ }
1825
+ /**
1826
+ * Anisotropic {@link scalePageContent}: scale a page's content by `sx`
1827
+ * horizontally and `sy` vertically about the origin, scaling the boxes and
1828
+ * annotation `/Rect`s by the same factors. Both must be finite and positive.
1829
+ * `false` on engine error.
1830
+ */
1831
+ scalePageContentXY(page, sx, sy) {
1832
+ return this.ex().gp_scale_page_content_xy(this.h, page, sx, sy) === 0;
1833
+ }
1834
+ /**
1835
+ * Scale a page's content to **fit within** `width`×`height` points (shrink- or
1836
+ * grow-to-fit), preserving aspect ratio — equivalent to {@link scalePageContent}
1837
+ * with `min(width / currentWidth, height / currentHeight)` over the page's
1838
+ * displayed size (`/MediaBox` with `/Rotate` applied). Returns the uniform
1839
+ * factor applied, or `null` on engine error (bad page number, non-positive
1840
+ * target, or zero-area page).
1841
+ */
1842
+ scalePageTo(page, width, height) {
1843
+ const factor = this.ex().gp_scale_page_to(this.h, page, width, height);
1844
+ return factor < 0 ? null : factor;
1845
+ }
1846
+ /**
1847
+ * Set a page's `/UserUnit` (ISO 32000-1 §14.11.2) for **large-format
1848
+ * authoring**: one default user-space unit becomes `unit`⁄72 inch, so the same
1849
+ * coordinates render larger (e.g. `2.0` doubles the physical size, lifting the
1850
+ * ~200-inch coordinate ceiling). `1.0` is the default and removes the key. This
1851
+ * is distinct from {@link scalePageContent}: it rescales the coordinate system
1852
+ * (a viewer-level zoom of the medium), not the content or boxes. `unit` must be
1853
+ * finite and positive. `false` on engine error.
1854
+ */
1855
+ setUserUnit(page, unit) {
1856
+ return this.ex().gp_set_user_unit(this.h, page, unit) === 0;
1857
+ }
1858
+ /**
1859
+ * A page's `/UserUnit` (ISO 32000-1 §14.11.2), defaulting to `1.0` when absent.
1860
+ * Returns `null` on engine error (bad page number).
1861
+ */
1862
+ pageUserUnit(page) {
1863
+ const unit = this.ex().gp_page_user_unit(this.h, page);
1864
+ return unit < 0 ? null : unit;
1865
+ }
1442
1866
  /** Insert a blank page after the 1-based `after` page (0 = front); returns its id. */
1443
1867
  addPage(width, height, after = 0) {
1444
1868
  return this.ex().gp_add_page(this.h, width, height, after);
@@ -1447,6 +1871,56 @@ var GigaPdfDoc = class {
1447
1871
  copyPage(page) {
1448
1872
  return this.ex().gp_copy_page(this.h, page);
1449
1873
  }
1874
+ /**
1875
+ * N-up imposition (ISO 32000-1 §8.10): draw the **content** of the 1-based
1876
+ * `source` page, scaled and translated, onto the 1-based `target` page — the
1877
+ * basis for 2-up/4-up, booklets, contact sheets and page-on-page stamping. The
1878
+ * source page becomes a Form XObject (its content + `/Resources`, so its fonts
1879
+ * and images come along) and is drawn with `q <cm> /Fmn Do Q` appended to the
1880
+ * target. `(x, y)` is where the visible page's lower-left corner lands and
1881
+ * `(scaleX, scaleY)` scale the page **as displayed** (its `/MediaBox` origin
1882
+ * and `/Rotate` are absorbed into the matrix). Wrapped in `q`/`Q`, so it never
1883
+ * disturbs existing target content and is **composable** — call it repeatedly
1884
+ * (different sources and/or cells) to build an N-up sheet. `source` and
1885
+ * `target` may be the same page. `false` on engine error (bad page number).
1886
+ */
1887
+ placePage(target, source, x, y, scaleX, scaleY) {
1888
+ return this.ex().gp_place_page(this.h, target, source, x, y, scaleX, scaleY) === 0;
1889
+ }
1890
+ /**
1891
+ * Place `source` onto `target` (both 1-based) using an explicit content-stream
1892
+ * matrix `[a, b, c, d, e, f]` — the low-level primitive behind
1893
+ * {@link placePage} for full control of the affine (shear, arbitrary rotation,
1894
+ * reflection). The matrix maps the source page's form space (its user space,
1895
+ * including the `/MediaBox` origin) to the target; unlike {@link placePage} no
1896
+ * origin/rotation normalisation is applied, so identity draws the source 1:1
1897
+ * at the target origin. `false` on engine error.
1898
+ */
1899
+ placePageMatrix(target, source, matrix) {
1900
+ const [a, b, c, d, e, f] = matrix;
1901
+ return this.ex().gp_place_page_matrix(this.h, target, source, a, b, c, d, e, f) === 0;
1902
+ }
1903
+ /**
1904
+ * Impose **all** existing pages `cols × rows` per sheet onto freshly added
1905
+ * sheets (2-up, 4-up, booklet thumbnails, contact sheets). Pages go
1906
+ * left-to-right, top-to-bottom; each is scaled uniformly to fit its cell
1907
+ * (aspect preserved) and centred. The new sheets are appended after the last
1908
+ * original page and the **originals are removed**, leaving only the imposed
1909
+ * sheets. Returns the number of sheets produced (negative on error: `cols`/
1910
+ * `rows` 0, or an empty document). `sheetWidth`/`sheetHeight` default to A4
1911
+ * portrait; `margin`/`gutter` to 14 pt.
1912
+ */
1913
+ nUp(cols, rows, opts = {}) {
1914
+ return this.ex().gp_n_up(
1915
+ this.h,
1916
+ cols,
1917
+ rows,
1918
+ opts.sheetWidth ?? 595.28,
1919
+ opts.sheetHeight ?? 841.89,
1920
+ opts.margin ?? 14,
1921
+ opts.gutter ?? 14
1922
+ );
1923
+ }
1450
1924
  /** A page's size (points) and `/Rotate` (0/90/180/270). */
1451
1925
  pageInfo(page) {
1452
1926
  return this.g._json((o) => this.ex().gp_page_info_json(this.h, page, o));
@@ -1466,6 +1940,118 @@ var GigaPdfDoc = class {
1466
1940
  setPageMargins(page, m) {
1467
1941
  return this.ex().gp_set_page_margins(this.h, page, m.top, m.right, m.bottom, m.left) === 0;
1468
1942
  }
1943
+ /**
1944
+ * All five page boundary boxes (`media`/`crop`/`bleed`/`trim`/`art`) for the
1945
+ * 1-based `page`, each as `[x0, y0, x1, y1]` in points, with ISO 32000-1
1946
+ * inheritance and defaults applied. See {@link PageBoxes} for the exact
1947
+ * default chain and the `declared` flags.
1948
+ */
1949
+ getPageBoxes(page) {
1950
+ return this.g._json((o) => this.ex().gp_page_boxes_json(this.h, page, o));
1951
+ }
1952
+ /**
1953
+ * Set one of a page's boundary boxes. `kind` is one of {@link PAGE_BOX_KINDS}
1954
+ * and `box` is given as `{ x, y, w, h }` (origin + size, points); it is written
1955
+ * as `[x, y, x+w, y+h]`, normalised so reversed sizes are accepted. Sibling
1956
+ * boxes are preserved. Returns `true` on success, `false` for an unknown kind,
1957
+ * a degenerate box (zero/negative area), or a bad page number.
1958
+ *
1959
+ * Setting `"trim"`/`"bleed"` is the prerequisite for PDF/X and commercial-print
1960
+ * (imposition, bleed, finished-size) pipelines.
1961
+ */
1962
+ setPageBox(page, kind, box) {
1963
+ const k = PAGE_BOX_KINDS.indexOf(kind);
1964
+ if (k < 0) return false;
1965
+ return this.ex().gp_set_page_box(this.h, page, k, box.x, box.y, box.x + box.w, box.y + box.h) === 0;
1966
+ }
1967
+ /**
1968
+ * The document's page-label ranges (`/PageLabels`, ISO 32000-1 §12.4.2), sorted
1969
+ * by `startPage` (1-based). Empty when the document declares no page labels.
1970
+ */
1971
+ getPageLabels() {
1972
+ return this.g._json((o) => this.ex().gp_page_labels_json(this.h, o));
1973
+ }
1974
+ /**
1975
+ * Replace the document's page labels. Pass an **empty** array to remove all
1976
+ * labels. Ranges are sorted by `startPage` and collapsed to one entry per page
1977
+ * (last wins). Returns `true` on success.
1978
+ *
1979
+ * @example
1980
+ * // Front matter in lowercase roman, body in decimal, appendix "A-1, A-2…".
1981
+ * doc.setPageLabels([
1982
+ * { startPage: 1, style: "romanLower", prefix: "", startNumber: 1 },
1983
+ * { startPage: 5, style: "decimal", prefix: "", startNumber: 1 },
1984
+ * { startPage: 20, style: "decimal", prefix: "A-", startNumber: 1 },
1985
+ * ]);
1986
+ */
1987
+ setPageLabels(ranges) {
1988
+ const text = ranges.map(
1989
+ (r) => `${r.startPage} ${PAGE_LABEL_STYLE_TOKEN[r.style] ?? "-"} ${r.startNumber ?? 1} ${r.prefix ?? ""}`
1990
+ ).join("\n");
1991
+ return this.g._withOptStr(text, (p, l) => this.ex().gp_set_page_labels(this.h, p, l)) === 0;
1992
+ }
1993
+ /**
1994
+ * The viewer-visible label string for the 1-based `page` (e.g. `"iv"`, `"A-3"`),
1995
+ * resolving the applicable `/PageLabels` range; the decimal page number when no
1996
+ * range applies (including a document with no page labels).
1997
+ */
1998
+ pageLabel(page) {
1999
+ return this.g._str((o) => this.ex().gp_page_label(this.h, page, o));
2000
+ }
2001
+ /**
2002
+ * Author a presentation transition + auto-advance on `page` (1-based),
2003
+ * ISO 32000-1 §12.4.4. Writes the page's `/Trans` dictionary from
2004
+ * {@link PageTransition.style} plus only the optional sub-keys that apply to
2005
+ * that style (`dimension`/`motion` for `split`, `direction`/`scale`/
2006
+ * `flyAreaOpaque` for `fly`, …) — inapplicable fields are dropped.
2007
+ * {@link PageTransition.displayDuration} becomes the page's `/Dur`
2008
+ * (auto-advance); omitting it removes any existing `/Dur`. Re-calling replaces
2009
+ * the prior transition in full (idempotent). Returns `true` on success,
2010
+ * `false` for an unknown style, a negative/non-finite `duration`/`scale`/
2011
+ * `displayDuration`, or a bad page number.
2012
+ *
2013
+ * @example
2014
+ * // Kiosk slideshow: every page wipes in over 0.5 s, auto-advancing after 5 s.
2015
+ * for (let p = 1; p <= doc.pageCount(); p++) {
2016
+ * doc.setPageTransition(p, { style: "wipe", duration: 0.5, displayDuration: 5 });
2017
+ * }
2018
+ */
2019
+ setPageTransition(page, trans) {
2020
+ const style = PAGE_TRANSITION_STYLES.indexOf(trans.style);
2021
+ if (style < 0) return false;
2022
+ const dimension = trans.dimension === "horizontal" ? 0 : trans.dimension === "vertical" ? 1 : -1;
2023
+ const motion = trans.motion === "inward" ? 0 : trans.motion === "outward" ? 1 : -1;
2024
+ const direction = trans.direction === void 0 ? -2 : trans.direction === "none" ? -1 : trans.direction;
2025
+ const flyB = trans.flyAreaOpaque === void 0 ? -1 : trans.flyAreaOpaque ? 1 : 0;
2026
+ return this.ex().gp_set_page_transition(
2027
+ this.h,
2028
+ page,
2029
+ style,
2030
+ trans.duration ?? Number.NaN,
2031
+ dimension,
2032
+ motion,
2033
+ direction,
2034
+ trans.scale ?? Number.NaN,
2035
+ flyB,
2036
+ trans.displayDuration ?? Number.NaN
2037
+ ) === 0;
2038
+ }
2039
+ /**
2040
+ * The presentation transition declared on `page` (1-based), or `null` when the
2041
+ * page has no `/Trans` (ISO 32000-1 §12.4.4). Optional fields that do not apply
2042
+ * to the recovered style are omitted from the result.
2043
+ */
2044
+ getPageTransition(page) {
2045
+ return this.g._jsonOrNull((o) => this.ex().gp_page_transition_json(this.h, page, o));
2046
+ }
2047
+ /**
2048
+ * Remove any presentation transition from `page` (1-based) — drops the page's
2049
+ * `/Trans` dictionary and its `/Dur` auto-advance entry. A no-op if neither is
2050
+ * present. Returns `true` on success.
2051
+ */
2052
+ clearPageTransition(page) {
2053
+ return this.ex().gp_clear_page_transition(this.h, page) === 0;
2054
+ }
1469
2055
  /**
1470
2056
  * Bake a running header onto every in-range page (idempotent: re-baking
1471
2057
  * replaces the prior header). Returns `true` on success.
@@ -1507,22 +2093,26 @@ var GigaPdfDoc = class {
1507
2093
  /**
1508
2094
  * Rasterize a page to a PNG **without the page content stream's text** — glyphs
1509
2095
  * are suppressed while gradients, shadings, images, vectors and patterns are
1510
- * preserved. Annotation/widget appearances are still painted in full. Use this
1511
- * to paint a text-free raster background the editor can overlay real, editable
1512
- * text on top of.
2096
+ * preserved. Form-field **widget** appearances are omitted (the editor re-shows
2097
+ * their values as an editable overlay, so baking them in would double every
2098
+ * field); other annotation appearances (stamps, highlights, ink) are still
2099
+ * painted. Use this to paint a text-free raster background the editor can
2100
+ * overlay real, editable text on top of.
1513
2101
  */
1514
2102
  renderPageNoText(page, scale = 1) {
1515
2103
  return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
1516
2104
  }
1517
2105
  /**
1518
2106
  * Rasterize a page to a PNG while **omitting** the given top-level element
1519
- * `indices` (from {@link pageElements}). Each excluded element paints nothing
2107
+ * `indices` (from {@link GigaPdfDoc.elements}). Each excluded element paints nothing
1520
2108
  * — fills, strokes, shadings, images and text alike — while everything else
1521
2109
  * (including the non-text content of non-excluded elements) renders normally.
1522
2110
  * Use it to paint a background without specific elements and overlay live,
1523
2111
  * editable versions on top. Generalises {@link renderPageNoText} (which
1524
- * suppresses *all* text). An empty `indices` renders the full page; unknown
1525
- * indices are ignored.
2112
+ * suppresses *all* text). Like {@link renderPageNoText}, form-field **widget**
2113
+ * appearances are omitted (the editor re-shows them as an editable overlay);
2114
+ * other annotation appearances are painted. An empty `indices` renders the full
2115
+ * page; unknown indices are ignored.
1526
2116
  */
1527
2117
  renderPageExcluding(page, indices, scale = 1) {
1528
2118
  return this.g._buffer(
@@ -1703,8 +2293,73 @@ var GigaPdfDoc = class {
1703
2293
  toRtf() {
1704
2294
  return this.g._buffer((o) => this.ex().gp_to_rtf(this.h, o));
1705
2295
  }
1706
- toPdfA() {
1707
- return this.g._buffer((o) => this.ex().gp_to_pdfa(this.h, o));
2296
+ /**
2297
+ * Re-serialize the document as **PDF/A** (archival).
2298
+ *
2299
+ * `level` selects the conformance flavour (default `"pdfa-2b"`):
2300
+ * - `"pdfa-1b"` — ISO 19005-1, based on PDF 1.4.
2301
+ * - `"pdfa-1a"` — ISO 19005-1 **Tagged PDF** (level A): 1b + a logical
2302
+ * structure tree, marked content and `/Lang`. Built from the structure the
2303
+ * engine reconstructs (paragraphs, headings, tables, lists).
2304
+ * - `"pdfa-2b"` — ISO 19005-2 (default).
2305
+ * - `"pdfa-2u"` — like 2b but requires every glyph Unicode-mapped (a
2306
+ * `/ToUnicode` CMap on each font); only validator-clean when the source
2307
+ * fonts already carry one — otherwise prefer `"pdfa-2b"`.
2308
+ * - `"pdfa-2a"` — ISO 19005-2 **Tagged PDF** (level A): 2u + a logical
2309
+ * structure tree and marked content (`/StructTreeRoot`, `/MarkInfo`).
2310
+ * - `"pdfa-3b"` — ISO 19005-3; permits embedded file attachments.
2311
+ *
2312
+ * Full conformance also requires every font embedded — this method does not
2313
+ * embed missing fonts (see the Rust `to_pdfa_level` docs). For the level-A
2314
+ * (`1a`/`2a`) flavours the tagging is rendering-neutral: it only inserts
2315
+ * balanced marked-content operators and a structure tree, never changing the
2316
+ * page appearance.
2317
+ */
2318
+ toPdfA(level = "pdfa-2b") {
2319
+ return this.g._withStr(
2320
+ level,
2321
+ (p, l) => this.g._buffer((o) => this.ex().gp_to_pdfa(this.h, p, l, o))
2322
+ );
2323
+ }
2324
+ /**
2325
+ * Author a **tagged (accessible) PDF** — a `/StructTreeRoot` logical-structure
2326
+ * tree (`P`/`H1`–`H6`/`Table`/`L`/`Figure` …) with marked content, `/MarkInfo`,
2327
+ * `/Lang`, `/RoleMap` and `/Alt` on figures — **without** forcing PDF/A. Pass
2328
+ * `{ pdfUa: true }` to also stamp the PDF/UA-1 identifier (ISO 14289). If the
2329
+ * document has no reconstructable structure the plain PDF is returned.
2330
+ * ISO 32000-1 §14.7/§14.8.
2331
+ */
2332
+ toTagged(opts = {}) {
2333
+ return this.g._buffer((o) => this.ex().gp_to_tagged(this.h, opts.pdfUa ? 1 : 0, o));
2334
+ }
2335
+ /**
2336
+ * The number of taggable **figures** the engine reconstructs across the whole
2337
+ * document — the valid range `0..figureCount()` for {@link setFigureAlt}'s
2338
+ * `index`. Each figure is an image the geometric reconstruction surfaces; the
2339
+ * Tagged-PDF / PDF-A-level-A export emits one `/Figure` structure element per
2340
+ * figure, in this same order.
2341
+ */
2342
+ figureCount() {
2343
+ return this.ex().gp_figure_count(this.h);
2344
+ }
2345
+ /**
2346
+ * Attach **author-supplied alternate text** (`/Alt`) to a figure so assistive
2347
+ * technology can describe the image (WCAG / PDF/UA, ISO 32000-1 §14.9.3).
2348
+ *
2349
+ * `index` is the **document-global figure index** — figures are numbered
2350
+ * `0, 1, 2, …` in page order, then in page-content order within each page (the
2351
+ * Nth image of the whole document is figure `N`; {@link figureCount} bounds the
2352
+ * range). The text lands on the matching `/Figure` structure element's `/Alt`
2353
+ * when an accessible export is produced — {@link toTagged} or {@link toPdfA}
2354
+ * with `"pdfa-1a"`/`"pdfa-2a"`. Figures with no author-supplied text keep a
2355
+ * generic non-empty placeholder, so the output stays structurally valid even
2356
+ * for unlabeled figures.
2357
+ *
2358
+ * Returns `true` on success; `false` if `alt` is empty (a `/Alt` must be
2359
+ * non-empty) or the call otherwise fails.
2360
+ */
2361
+ setFigureAlt(index, alt) {
2362
+ return this.g._withStr(alt, (p, l) => this.ex().gp_set_figure_alt(this.h, index, p, l)) === 0;
1708
2363
  }
1709
2364
  // security
1710
2365
  /**
@@ -1759,6 +2414,117 @@ var GigaPdfDoc = class {
1759
2414
  )
1760
2415
  );
1761
2416
  }
2417
+ /**
2418
+ * Re-encrypt an already-opened (decrypted) document with **new** passwords,
2419
+ * discarding the prior encryption (ISO 32000-1 §7.6). Opening with the old
2420
+ * password is what authorises the change. Mirrors {@link saveEncrypted} plus
2421
+ * `encryptMetadata` (when `false`, the metadata stream is left in the clear).
2422
+ */
2423
+ changePasswords(newPassword, fileId, opts = {}) {
2424
+ const algo = opts.algorithm ?? "aes256";
2425
+ const algoCode = algo === "rc4" ? 0 : algo === "aes128" ? 1 : 2;
2426
+ const permissions = opts.flags !== void 0 ? this.g.permissionsToP(opts.flags) : opts.permissions ?? this.g.permissionsToP();
2427
+ let key = opts.keySeed ?? new Uint8Array(0);
2428
+ if (algoCode === 2 && key.length < 32) {
2429
+ key = cryptoRandom(32);
2430
+ }
2431
+ const encMeta = opts.encryptMetadata ?? true;
2432
+ return this.g._withStr(
2433
+ newPassword,
2434
+ (pwP, pwL) => this.g._withOptStr(
2435
+ opts.ownerPassword,
2436
+ (oP, oL) => this.g._withStr(
2437
+ fileId,
2438
+ (idP, idL) => this.g._withBytes(
2439
+ key,
2440
+ (kP, kL) => this.g._buffer(
2441
+ (o) => this.ex().gp_change_passwords(
2442
+ this.h,
2443
+ pwP,
2444
+ pwL,
2445
+ oP,
2446
+ oL,
2447
+ idP,
2448
+ idL,
2449
+ kP,
2450
+ kL,
2451
+ algoCode,
2452
+ permissions,
2453
+ encMeta ? 1 : 0,
2454
+ o
2455
+ )
2456
+ )
2457
+ )
2458
+ )
2459
+ )
2460
+ );
2461
+ }
2462
+ /**
2463
+ * Strip encryption from an already-opened (decrypted) document, returning a
2464
+ * **plaintext** PDF. The document must have been opened with a valid password.
2465
+ */
2466
+ removeEncryption() {
2467
+ return this.g._buffer((o) => this.ex().gp_remove_encryption(this.h, o));
2468
+ }
2469
+ /**
2470
+ * Encrypt the document to one or more **X.509 recipients** (public-key /
2471
+ * certificate security, ISO 32000-1 §7.6.5, `/Filter /Adobe.PubSec`): only a
2472
+ * holder of a recipient private key can open it — no shared password.
2473
+ * `certificates` are DER X.509 certs. `seed`/`rngSeed` default to Web Crypto
2474
+ * randomness. Open the result with {@link GigaPdfEngine.openWithPrivateKey}.
2475
+ */
2476
+ encryptForRecipients(certificates, opts = {}) {
2477
+ if (certificates.length === 0) {
2478
+ throw new Error("encryptForRecipients needs at least one recipient certificate");
2479
+ }
2480
+ const total = certificates.reduce((n, c) => n + c.length, 0);
2481
+ const blob = new Uint8Array(total);
2482
+ const lens = [];
2483
+ let off = 0;
2484
+ for (const c of certificates) {
2485
+ blob.set(c, off);
2486
+ off += c.length;
2487
+ lens.push(c.length);
2488
+ }
2489
+ const permissions = opts.flags !== void 0 ? this.g.permissionsToP(opts.flags) : opts.permissions ?? this.g.permissionsToP();
2490
+ const aes256 = opts.aes256 ?? true;
2491
+ const encMeta = opts.encryptMetadata ?? true;
2492
+ const seed = opts.seed ?? cryptoRandom(20);
2493
+ const rng = opts.rngSeed ?? cryptoRandom(32);
2494
+ const out = this.g._withBytes(
2495
+ blob,
2496
+ (cP, cL) => this.g._withU32(
2497
+ lens,
2498
+ (lP, lC) => this.g._withBytes(
2499
+ seed,
2500
+ (sP, sL) => this.g._withBytes(
2501
+ rng,
2502
+ (rP, rL) => this.g._buffer(
2503
+ (o) => this.ex().gp_encrypt_for_recipients(
2504
+ this.h,
2505
+ cP,
2506
+ cL,
2507
+ lP,
2508
+ lC,
2509
+ permissions,
2510
+ aes256 ? 1 : 0,
2511
+ encMeta ? 1 : 0,
2512
+ sP,
2513
+ sL,
2514
+ rP,
2515
+ rL,
2516
+ o
2517
+ )
2518
+ )
2519
+ )
2520
+ )
2521
+ )
2522
+ );
2523
+ if (out.length === 0) {
2524
+ throw new Error("encryptForRecipients failed (invalid recipient certificate?)");
2525
+ }
2526
+ return out;
2527
+ }
1762
2528
  /** Self-signed digital signature. `random` ≥ 256 bytes from crypto.getRandomValues. */
1763
2529
  sign(fields, random, keyBits = 2048) {
1764
2530
  const rPtr = this.g._toWasm(random);
@@ -1769,6 +2535,43 @@ var GigaPdfDoc = class {
1769
2535
  this.g._free(rPtr, random.length);
1770
2536
  return out;
1771
2537
  }
2538
+ /**
2539
+ * **Certify** the document (DocMDP) — like {@link sign} but also declares which
2540
+ * later changes are allowed: `docmdpLevel` is `1` (no changes), `2` (form-fill
2541
+ * + sign) or `3` (also annotate). `fields` is the same tab-separated string as
2542
+ * {@link sign} (`name⇥reason⇥date⇥notBefore⇥notAfter`).
2543
+ */
2544
+ certify(fields, random, docmdpLevel, keyBits = 2048) {
2545
+ const rPtr = this.g._toWasm(random);
2546
+ const out = this.g._withStr(
2547
+ fields,
2548
+ (fP, fL) => this.g._buffer(
2549
+ (o) => this.ex().gp_sign_certify(this.h, fP, fL, rPtr, random.length, keyBits, docmdpLevel, o)
2550
+ )
2551
+ );
2552
+ this.g._free(rPtr, random.length);
2553
+ return out;
2554
+ }
2555
+ /**
2556
+ * List every signature on the document (each `/Sig` field's `/V`) with its
2557
+ * metadata and `/ByteRange`. For cryptographic validity call
2558
+ * {@link verifySignatures}.
2559
+ */
2560
+ signatures() {
2561
+ return this.g._json((o) => this.ex().gp_signatures_json(this.h, o));
2562
+ }
2563
+ /**
2564
+ * Cryptographically verify every signature against `pdf` — the **original
2565
+ * bytes** this document was opened from. Each report carries `byteRangeOk`,
2566
+ * `digestOk` (content integrity), `signatureOk` (the RSA signature),
2567
+ * `coversWholeDocument`, the signer CN, and the algorithm.
2568
+ */
2569
+ verifySignatures(pdf) {
2570
+ return this.g._withBytes(
2571
+ pdf,
2572
+ (p, l) => this.g._json((o) => this.ex().gp_verify_signatures(this.h, p, l, o))
2573
+ );
2574
+ }
1772
2575
  /**
1773
2576
  * Sign with a PKCS#12 (`.p12`/`.pfx`) identity — a CA-issued / eIDAS
1774
2577
  * certificate and its RSA key, imported natively (no external crypto). `opts`
@@ -2036,13 +2839,49 @@ var GigaPdfDoc = class {
2036
2839
  (p, l) => this.g._str((o) => this.ex().gp_get_metadata(this.h, p, l, o))
2037
2840
  );
2038
2841
  }
2039
- /** Set an Info-dictionary entry (e.g. "Title", "Author"). */
2842
+ /**
2843
+ * Set a **single** Info-dictionary entry (e.g. `"Title"`, `"Author"`). This
2844
+ * touches only `/Info`; use {@link setInfo} to update the typed fields and keep
2845
+ * the XMP `/Metadata` packet in sync.
2846
+ */
2040
2847
  setMetadata(key, value) {
2041
2848
  return this.g._withStr(
2042
2849
  key,
2043
2850
  (kP, kL) => this.g._withStr(value, (vP, vL) => this.ex().gp_set_metadata(this.h, kP, kL, vP, vL))
2044
2851
  ) === 0;
2045
2852
  }
2853
+ /**
2854
+ * The document's XMP metadata packet (catalog `/Metadata`, ISO 32000-1 §14.3.2)
2855
+ * as raw bytes, or `null` when the document carries no XMP.
2856
+ */
2857
+ getXmp() {
2858
+ const bytes = this.g._buffer((o) => this.ex().gp_get_xmp(this.h, o));
2859
+ return bytes.length === 0 ? null : bytes;
2860
+ }
2861
+ /**
2862
+ * Replace (or create) the document's XMP metadata stream (catalog `/Metadata`,
2863
+ * stored uncompressed). Accepts a UTF-8 string or raw bytes. Returns `true` on
2864
+ * success.
2865
+ */
2866
+ setXmp(xmp) {
2867
+ const bytes = typeof xmp === "string" ? new TextEncoder().encode(xmp) : xmp;
2868
+ return this.g._withBytes(bytes, (p, l) => this.ex().gp_set_xmp(this.h, p, l)) === 0;
2869
+ }
2870
+ /**
2871
+ * Set the standard document-information fields, writing **both** the `/Info`
2872
+ * dictionary and a synced XMP `/Metadata` packet so the two never drift. This is
2873
+ * a **partial** update — only the fields you provide are changed; omit a field
2874
+ * to leave it untouched. Returns `true` on success.
2875
+ *
2876
+ * @example
2877
+ * doc.setInfo({ title: "Annual Report", author: "Ada Lovelace", keywords: "finance, 2026" });
2878
+ */
2879
+ setInfo(fields) {
2880
+ return this.g._withStr(
2881
+ JSON.stringify(fields),
2882
+ (p, l) => this.ex().gp_set_info_json(this.h, p, l)
2883
+ ) === 0;
2884
+ }
2046
2885
  // annotations (Acrobat-style markup)
2047
2886
  annotations(page) {
2048
2887
  return this.g._json((o) => this.ex().gp_annotations_json(this.h, page, o));
@@ -2157,6 +2996,73 @@ var GigaPdfDoc = class {
2157
2996
  (p, l) => this.ex().gp_add_stamp(this.h, page, x0, y0, x1, y1, p, l, RGB(rgb))
2158
2997
  ) === 0;
2159
2998
  }
2999
+ /**
3000
+ * Add a `/Circle` (ellipse) annotation inscribed in `[x0,y0,x1,y1]`. `stroke`
3001
+ * (border) and `fill` (interior) are packed `0xRRGGBB` numbers, or `null` to
3002
+ * omit. Returns `true` on success.
3003
+ */
3004
+ addCircleAnnotation(page, x0, y0, x1, y1, stroke = 0, fill = null, lineWidth = 1) {
3005
+ return this.ex().gp_add_circle_annot(
3006
+ this.h,
3007
+ page,
3008
+ x0,
3009
+ y0,
3010
+ x1,
3011
+ y1,
3012
+ RGB(stroke ?? 0),
3013
+ stroke === null ? 0 : 1,
3014
+ RGB(fill ?? 0),
3015
+ fill === null ? 0 : 1,
3016
+ lineWidth
3017
+ ) === 0;
3018
+ }
3019
+ /**
3020
+ * Add a `/Polygon` annotation — a closed shape through `points` (a flat
3021
+ * `[x0, y0, x1, y1, …]` array, PDF user space), with optional `stroke`/`fill`
3022
+ * (`0xRRGGBB` or `null`). Returns `true` on success.
3023
+ */
3024
+ addPolygonAnnotation(page, points, stroke = 0, fill = null, lineWidth = 1) {
3025
+ return this.g._withF64(
3026
+ points,
3027
+ (p, c) => this.ex().gp_add_polygon_annot(
3028
+ this.h,
3029
+ page,
3030
+ p,
3031
+ c,
3032
+ RGB(stroke ?? 0),
3033
+ stroke === null ? 0 : 1,
3034
+ RGB(fill ?? 0),
3035
+ fill === null ? 0 : 1,
3036
+ lineWidth
3037
+ )
3038
+ ) === 0;
3039
+ }
3040
+ /**
3041
+ * Add a `/PolyLine` annotation — an open path through `points` (a flat
3042
+ * `[x0, y0, x1, y1, …]` array). `rgb` is packed `0xRRGGBB`.
3043
+ */
3044
+ addPolylineAnnotation(page, points, rgb = 0, lineWidth = 1) {
3045
+ return this.g._withF64(
3046
+ points,
3047
+ (p, c) => this.ex().gp_add_polyline_annot(this.h, page, p, c, RGB(rgb), lineWidth)
3048
+ ) === 0;
3049
+ }
3050
+ /**
3051
+ * Add a `/Caret` annotation — a small upward wedge in `[x0,y0,x1,y1]` marking
3052
+ * an insertion point. `rgb` is packed `0xRRGGBB`.
3053
+ */
3054
+ addCaretAnnotation(page, x0, y0, x1, y1, rgb = 0) {
3055
+ return this.ex().gp_add_caret_annot(this.h, page, x0, y0, x1, y1, RGB(rgb)) === 0;
3056
+ }
3057
+ /**
3058
+ * Regenerate the appearance stream (`/AP /N`) of the 0-based `index`
3059
+ * annotation on `page` from its stored geometry, after editing its colour,
3060
+ * border or geometry. Returns `true` on success, `false` for a bad index or a
3061
+ * subtype whose appearance can't be reconstructed (FreeText/Stamp/Text/Link).
3062
+ */
3063
+ regenerateAppearance(page, index) {
3064
+ return this.ex().gp_regenerate_appearance(this.h, page, index) === 0;
3065
+ }
2160
3066
  flattenAnnotations(page) {
2161
3067
  return this.ex().gp_flatten_annotations(this.h, page);
2162
3068
  }
@@ -2225,6 +3131,150 @@ var GigaPdfDoc = class {
2225
3131
  data: this.g._fromBase64(dataBase64)
2226
3132
  }));
2227
3133
  }
3134
+ /**
3135
+ * Embed `bytes` as a document-level file attachment named `name`
3136
+ * (`/Names /EmbeddedFiles`, ISO 32000-1 §7.11.4). Re-using a `name` **replaces**
3137
+ * that attachment; the bytes are stored FlateDecode-compressed. Returns `true`
3138
+ * on success (`false` e.g. for an empty name).
3139
+ */
3140
+ addAttachment(name, bytes, opts = {}) {
3141
+ return this.g._withStr(
3142
+ name,
3143
+ (np, nl) => this.g._withBytes(
3144
+ bytes,
3145
+ (bp, bl) => this.g._withOptStr(
3146
+ opts.mime ?? "",
3147
+ (mp, ml) => this.g._withOptStr(
3148
+ opts.description ?? "",
3149
+ (dp, dl) => this.ex().gp_add_attachment(this.h, np, nl, bp, bl, mp, ml, dp, dl)
3150
+ )
3151
+ )
3152
+ )
3153
+ ) === 0;
3154
+ }
3155
+ /**
3156
+ * Embed `bytes` as an **associated file** (`/AF`, PDF/A-3) named `name` with the
3157
+ * given {@link AfRelationship} — the mechanism Factur-X / ZUGFeRD / Order-X use
3158
+ * to carry their invoice XML (`"alternative"`). The file is also a normal
3159
+ * attachment, is linked from the catalog `/AF` array, and its filespec carries
3160
+ * `/AFRelationship`. Returns `true` on success.
3161
+ */
3162
+ addAssociatedFile(name, bytes, relationship, opts = {}) {
3163
+ const rel = AF_RELATIONSHIP_CODE[relationship] ?? AF_RELATIONSHIP_CODE.unspecified;
3164
+ return this.g._withStr(
3165
+ name,
3166
+ (np, nl) => this.g._withBytes(
3167
+ bytes,
3168
+ (bp, bl) => this.g._withOptStr(
3169
+ opts.mime ?? "",
3170
+ (mp, ml) => this.g._withOptStr(
3171
+ opts.description ?? "",
3172
+ (dp, dl) => this.ex().gp_add_associated_file(this.h, np, nl, bp, bl, mp, ml, dp, dl, rel)
3173
+ )
3174
+ )
3175
+ )
3176
+ ) === 0;
3177
+ }
3178
+ /**
3179
+ * Remove the attachment named `name` (from `/Names /EmbeddedFiles` and, if
3180
+ * present, the catalog `/AF` array). Returns `true` if one was removed, `false`
3181
+ * if no attachment had that name.
3182
+ */
3183
+ removeAttachment(name) {
3184
+ return this.g._withStr(name, (p, l) => this.ex().gp_remove_attachment(this.h, p, l)) === 1;
3185
+ }
3186
+ /**
3187
+ * Mark this document as an embedded-file **portfolio** and configure how its
3188
+ * attachments are presented, by writing the catalog `/Collection`
3189
+ * (ISO 32000-1 §7.11.6, §12.3.5). The files must already be embedded (add them
3190
+ * first with {@link addAttachment} / {@link addAssociatedFile}); this only adds
3191
+ * the presentation layer: the initial {@link CollectionConfig.view view}, the
3192
+ * {@link CollectionConfig.schema schema} columns, the
3193
+ * {@link CollectionConfig.sort sort} order, the
3194
+ * {@link CollectionConfig.defaultFile default file}, and per-file
3195
+ * {@link CollectionConfig.items column values} (each written as a `/CI` on the
3196
+ * matching file's filespec). An empty/omitted schema still produces a valid
3197
+ * `/Collection`. Calling again **replaces** the previous configuration. Returns
3198
+ * `true` on success (`false` on a malformed config or write error).
3199
+ */
3200
+ setCollection(config) {
3201
+ return this.g._withStr(
3202
+ JSON.stringify(config),
3203
+ (p, l) => this.ex().gp_set_collection_json(this.h, p, l)
3204
+ ) === 0;
3205
+ }
3206
+ /**
3207
+ * Read this document's portfolio configuration back from the catalog
3208
+ * `/Collection` — the reader counterpart of {@link setCollection}. Returns
3209
+ * `null` when the document is not a portfolio. The recovered
3210
+ * {@link CollectionConfig} carries the `view`, the `schema` columns (sorted by
3211
+ * order), the `sort`, the `defaultFile`, and each embedded file's `/CI` column
3212
+ * `values`.
3213
+ */
3214
+ collection() {
3215
+ return this.g._json((o) => this.ex().gp_collection_json(this.h, o));
3216
+ }
3217
+ /**
3218
+ * Install a **document-level JavaScript** under the catalog `/Names /JavaScript`
3219
+ * name tree (ISO 32000-1 §7.7.3.4 + §12.6.4.16): a named JavaScript action
3220
+ * (`<< /S /JavaScript /JS … >>`) keyed by `name`. On open, a conforming viewer
3221
+ * runs every document-level script in **name (lexical) order** — this is where
3222
+ * form-calculation / validation helper libraries live (e.g. `AFNumber_Format`).
3223
+ * Re-using a `name` **replaces** that script; long sources are stored as a
3224
+ * FlateDecode stream, and sibling `/Names` subtrees (`/EmbeddedFiles`,
3225
+ * `/Dests`, …) are preserved. Returns `true` on success (`false` e.g. for an
3226
+ * empty name).
3227
+ */
3228
+ addDocumentJavascript(name, script) {
3229
+ return this.g._withStr(
3230
+ name,
3231
+ (np, nl) => this.g._withStr(
3232
+ script,
3233
+ (sp, sl) => this.ex().gp_add_document_javascript(this.h, np, nl, sp, sl)
3234
+ )
3235
+ ) === 0;
3236
+ }
3237
+ /**
3238
+ * Every document-level JavaScript as `{ name, script }` pairs, in name
3239
+ * (lexical) order — the read side of {@link addDocumentJavascript} (decodes
3240
+ * both a literal `/JS` string and a `/JS` stream).
3241
+ */
3242
+ documentJavascripts() {
3243
+ return this.g._json((o) => this.ex().gp_document_javascripts_json(this.h, o));
3244
+ }
3245
+ /**
3246
+ * Remove the document-level JavaScript named `name` from `/Names /JavaScript`.
3247
+ * Returns `true` if one was removed, `false` if none had that name.
3248
+ */
3249
+ removeDocumentJavascript(name) {
3250
+ return this.g._withStr(name, (p, l) => this.ex().gp_remove_document_javascript(this.h, p, l)) === 1;
3251
+ }
3252
+ /**
3253
+ * Add a page-anchored **FileAttachment** annotation over `rect` on the 1-based
3254
+ * `page`, pointing at the already-embedded attachment `name` (add it first with
3255
+ * {@link addAttachment}). `icon` is the visual marker (default `"PushPin"`).
3256
+ * Returns `true` on success (`false` if no such attachment exists).
3257
+ */
3258
+ addFileAttachmentAnnot(page, rect, name, icon = "PushPin") {
3259
+ return this.g._withStr(
3260
+ name,
3261
+ (np, nl) => this.g._withOptStr(
3262
+ icon,
3263
+ (ip, il) => this.ex().gp_add_file_attachment_annot(
3264
+ this.h,
3265
+ page,
3266
+ rect.x,
3267
+ rect.y,
3268
+ rect.x + rect.w,
3269
+ rect.y + rect.h,
3270
+ np,
3271
+ nl,
3272
+ ip,
3273
+ il
3274
+ )
3275
+ )
3276
+ ) === 0;
3277
+ }
2228
3278
  /**
2229
3279
  * Add an internal hyperlink over a rectangle that jumps to the named
2230
3280
  * destination `name` (define it with {@link addNamedDest}). Unlike
@@ -2254,6 +3304,24 @@ var GigaPdfDoc = class {
2254
3304
  removeLayer(id) {
2255
3305
  return this.ex().gp_remove_layer(this.h, id) === 0;
2256
3306
  }
3307
+ /**
3308
+ * Begin an optional-content marked-content sequence on `page` for the layer
3309
+ * `ocg` (its id, from {@link addLayer}). Registers the OCG under the page's
3310
+ * `/Resources /Properties` and appends `/OC /OCn BDC` to the content stream;
3311
+ * every drawing call after it ({@link addText}, {@link addRectangle},
3312
+ * {@link addImage}, …) is gated on that layer's visibility until the matching
3313
+ * {@link endOptionalContent} appends `EMC`. Calls nest. Returns the `OCn`
3314
+ * property name (empty string on error).
3315
+ */
3316
+ beginOptionalContent(page, ocg) {
3317
+ return this.g._str(
3318
+ (o) => this.ex().gp_begin_optional_content(this.h, page, ocg, o)
3319
+ );
3320
+ }
3321
+ /** End the innermost optional-content sequence on `page` (`EMC`). */
3322
+ endOptionalContent(page) {
3323
+ return this.ex().gp_end_optional_content(this.h, page) === 0;
3324
+ }
2257
3325
  // outline (bookmarks)
2258
3326
  outline() {
2259
3327
  return this.g._json((o) => this.ex().gp_outline_json(this.h, o));
@@ -2263,6 +3331,79 @@ var GigaPdfDoc = class {
2263
3331
  const text = entries.map((e) => `${e.level} ${e.page ?? 0} ${e.title}`).join("\n");
2264
3332
  return this.g._withStr(text, (p, l) => this.ex().gp_set_outline(this.h, p, l)) === 0;
2265
3333
  }
3334
+ /**
3335
+ * Add a `/Link` annotation over `rect` (`{ x, y, w, h }`) carrying any
3336
+ * {@link Action} — the full action & destination model (GoTo with every fit
3337
+ * mode, GoToR, URI, Named navigation, Launch, JavaScript, SubmitForm,
3338
+ * ResetForm). Returns `true` on success (`false` for a malformed action).
3339
+ *
3340
+ * @example
3341
+ * doc.addLink(1, { x: 72, y: 700, w: 120, h: 16 },
3342
+ * { type: "goto", dest: { fit: "xyz", page: 4, top: 720, zoom: 1.5 } });
3343
+ */
3344
+ addLink(page, rect, action) {
3345
+ return this.g._withStr(
3346
+ JSON.stringify(action),
3347
+ (p, l) => this.ex().gp_add_link(this.h, page, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, p, l)
3348
+ ) === 0;
3349
+ }
3350
+ /**
3351
+ * Set the document `/OpenAction` — the {@link Action} performed when the file
3352
+ * is opened. Returns `true` on success.
3353
+ */
3354
+ setOpenAction(action) {
3355
+ return this.g._withStr(
3356
+ JSON.stringify(action),
3357
+ (p, l) => this.ex().gp_set_open_action(this.h, p, l)
3358
+ ) === 0;
3359
+ }
3360
+ /**
3361
+ * Remove the `linkIndex`-th `/Link` annotation on `page` (links counted in
3362
+ * order, ignoring non-link annotations). Returns `true` if one was removed.
3363
+ */
3364
+ removeLink(page, linkIndex) {
3365
+ return this.ex().gp_remove_link(this.h, page, linkIndex) === 1;
3366
+ }
3367
+ /**
3368
+ * Replace the outline with {@link Bookmark}s that may carry actions (a `goto`
3369
+ * action becomes a `/Dest`, any other action an `/A`). An empty array clears
3370
+ * the outline. Returns `true` on success.
3371
+ */
3372
+ setBookmarks(bookmarks) {
3373
+ const text = bookmarks.map((b) => `${b.level} ${b.title} ${b.action ? JSON.stringify(b.action) : ""}`).join("\n");
3374
+ return this.g._withOptStr(text, (p, l) => this.ex().gp_set_bookmarks(this.h, p, l)) === 0;
3375
+ }
3376
+ // catalog reading / UX hints (ViewerPreferences, PageLayout, PageMode)
3377
+ /**
3378
+ * Write the catalog `/ViewerPreferences` (ISO 32000-1 §12.2). Each omitted
3379
+ * field is left unchanged; a boolean sets the key. After applying, an empty
3380
+ * dictionary is removed. Returns `false` on an invalid `direction`.
3381
+ */
3382
+ setViewerPreferences(prefs) {
3383
+ const tri = (v) => v === void 0 ? -1 : v ? 1 : 0;
3384
+ return this.g._withStr(
3385
+ prefs.direction ?? "",
3386
+ (dP, dL) => this.ex().gp_set_viewer_preferences(
3387
+ this.h,
3388
+ tri(prefs.hideToolbar),
3389
+ tri(prefs.hideMenubar),
3390
+ tri(prefs.hideWindowUI),
3391
+ tri(prefs.fitWindow),
3392
+ tri(prefs.centerWindow),
3393
+ tri(prefs.displayDocTitle),
3394
+ dP,
3395
+ dL
3396
+ )
3397
+ ) === 0;
3398
+ }
3399
+ /** Set the catalog `/PageLayout`. `null` removes the key. Returns `false` on an unknown name. */
3400
+ setPageLayout(layout) {
3401
+ return this.g._withStr(layout ?? "", (p, l) => this.ex().gp_set_page_layout(this.h, p, l)) === 0;
3402
+ }
3403
+ /** Set the catalog `/PageMode`. `null` removes the key. Returns `false` on an unknown name. */
3404
+ setPageMode(mode) {
3405
+ return this.g._withStr(mode ?? "", (p, l) => this.ex().gp_set_page_mode(this.h, p, l)) === 0;
3406
+ }
2266
3407
  // interactive forms (AcroForm)
2267
3408
  fields() {
2268
3409
  return this.g._json((o) => this.ex().gp_fields_json(this.h, o));
@@ -2424,11 +3565,80 @@ var GigaPdfDoc = class {
2424
3565
  )
2425
3566
  ) === 0;
2426
3567
  }
3568
+ /**
3569
+ * Create a **visible signature field** (`/FT /Sig`) over `rect` — an empty
3570
+ * widget the signing pipeline can later target — and flag the AcroForm
3571
+ * `/SigFlags`. Returns `true` on success.
3572
+ */
3573
+ addSignatureField(page, name, rect, opts = {}) {
3574
+ const st = styleArgs(opts.style);
3575
+ return this.g._withStr(
3576
+ name,
3577
+ (nP, nL) => this.ex().gp_add_signature_field(
3578
+ this.h,
3579
+ page,
3580
+ nP,
3581
+ nL,
3582
+ rect[0],
3583
+ rect[1],
3584
+ rect[2],
3585
+ rect[3],
3586
+ ...st
3587
+ )
3588
+ ) === 0;
3589
+ }
3590
+ /**
3591
+ * Attach field-level JavaScript to a field's `/AA` for the given `trigger`
3592
+ * (`"keystroke"` filters input, `"format"` formats display, `"validate"`
3593
+ * checks on change, `"calculate"` recomputes — ordered by
3594
+ * {@link setCalculationOrder}). Returns `true` if set, `false` if no field has
3595
+ * that name.
3596
+ */
3597
+ setFieldScript(name, trigger, js) {
3598
+ return this.g._withStr(
3599
+ name,
3600
+ (nP, nL) => this.g._withStr(
3601
+ trigger,
3602
+ (tP, tL) => this.g._withStr(
3603
+ js,
3604
+ (jP, jL) => this.ex().gp_set_field_script(this.h, nP, nL, tP, tL, jP, jL)
3605
+ )
3606
+ )
3607
+ ) === 1;
3608
+ }
3609
+ /**
3610
+ * Set the AcroForm calculation order (`/CO`) — the sequence in which fields
3611
+ * with a `calculate` script recompute. Unknown names are skipped.
3612
+ */
3613
+ setCalculationOrder(names) {
3614
+ return this.g._withOptStr(
3615
+ names.join("\n"),
3616
+ (p, l) => this.ex().gp_set_calculation_order(this.h, p, l)
3617
+ ) === 0;
3618
+ }
3619
+ /**
3620
+ * Delete a form field by name (removed from `/Fields`, `/CO` and every page's
3621
+ * annotations). Returns `true` if a field was removed.
3622
+ */
3623
+ removeField(name) {
3624
+ return this.g._withStr(name, (p, l) => this.ex().gp_remove_field(this.h, p, l)) === 1;
3625
+ }
3626
+ /**
3627
+ * Rebuild a field's appearance from its current value/style — call after
3628
+ * changing a field's value programmatically. Returns `true` if regenerated
3629
+ * (`false` for an unknown name or a kind that can't be regenerated alone, e.g.
3630
+ * a radio parent with kids).
3631
+ */
3632
+ regenerateFieldAppearance(name) {
3633
+ return this.g._withStr(name, (p, l) => this.ex().gp_regenerate_field_appearance(this.h, p, l)) === 1;
3634
+ }
2427
3635
  };
2428
3636
  // Annotate the CommonJS export names for ESM import in node:
2429
3637
  0 && (module.exports = {
2430
3638
  GigaPdfDoc,
2431
3639
  GigaPdfEngine,
3640
+ PAGE_BOX_KINDS,
3641
+ PAGE_TRANSITION_STYLES,
2432
3642
  defaultCrlGet,
2433
3643
  defaultOcspPost,
2434
3644
  defaultTsaPost