@qrcommunication/gigapdf-lib 0.72.0 → 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/CHANGELOG.md +593 -0
- package/dist/index.cjs +1221 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1050 -9
- package/dist/index.d.ts +1050 -9
- package/dist/index.js +1219 -15
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,13 @@ type Exports = {
|
|
|
18
18
|
gp_free(ptr: number, len: number): void;
|
|
19
19
|
[k: string]: any;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* PDF file-version banner for the compact ({@link GigaPdfDoc.saveOptimized}) and
|
|
23
|
+
* linearized ({@link GigaPdfDoc.toLinearized}) writers. Object streams,
|
|
24
|
+
* cross-reference streams and linearization are valid in both, so the choice only
|
|
25
|
+
* changes the `%PDF-x.y` header line. Defaults to `"1.7"`.
|
|
26
|
+
*/
|
|
27
|
+
type PdfVersion = "1.7" | "2.0";
|
|
21
28
|
/**
|
|
22
29
|
* The eight PDF access permissions carried by an `/Encrypt` dictionary's `/P`
|
|
23
30
|
* entry (ISO 32000-1 §7.6.3.2, Table 22). Each flag is `true` when the action
|
|
@@ -42,6 +49,15 @@ type PdfPermissions = {
|
|
|
42
49
|
/** Print to a high-resolution device (requires {@link print}). */
|
|
43
50
|
printHighRes: boolean;
|
|
44
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* One source in a {@link GigaPdfEngine.mergePdfs} call. `pdf` is the source
|
|
54
|
+
* bytes; the optional `pages` selects 1-based page numbers (in the given order)
|
|
55
|
+
* to bring in — omit it to append every page.
|
|
56
|
+
*/
|
|
57
|
+
type MergePart = {
|
|
58
|
+
pdf: Uint8Array;
|
|
59
|
+
pages?: number[];
|
|
60
|
+
};
|
|
45
61
|
/** Loaded engine module. Create documents with {@link open} / {@link openEncrypted}. */
|
|
46
62
|
declare class GigaPdfEngine {
|
|
47
63
|
private readonly ex;
|
|
@@ -97,6 +113,13 @@ declare class GigaPdfEngine {
|
|
|
97
113
|
open(pdf: Uint8Array): GigaPdfDoc;
|
|
98
114
|
/** Open an encrypted PDF with a password. Returns null if the password is wrong. */
|
|
99
115
|
openEncrypted(pdf: Uint8Array, password: string): GigaPdfDoc | null;
|
|
116
|
+
/**
|
|
117
|
+
* Open a **public-key (certificate) encrypted** PDF (`/Filter /Adobe.PubSec`,
|
|
118
|
+
* ISO 32000-1 §7.6.5) with a recipient's DER `certificate` + PKCS#1 RSA
|
|
119
|
+
* `privateKey`. `null` if this key is not a recipient. Counterpart of
|
|
120
|
+
* {@link GigaPdfDoc.encryptForRecipients}.
|
|
121
|
+
*/
|
|
122
|
+
openWithPrivateKey(pdf: Uint8Array, certificate: Uint8Array, privateKey: Uint8Array): GigaPdfDoc | null;
|
|
100
123
|
/**
|
|
101
124
|
* Inspect a PDF's encryption **without decrypting it** (no password needed):
|
|
102
125
|
* whether it has an `/Encrypt` dictionary, plus its `/P` permission bitmask
|
|
@@ -173,13 +196,16 @@ declare class GigaPdfEngine {
|
|
|
173
196
|
*/
|
|
174
197
|
imageToPdf(image: Uint8Array): Uint8Array;
|
|
175
198
|
/**
|
|
176
|
-
* Merge several PDFs into one by appending their pages in order.
|
|
177
|
-
*
|
|
178
|
-
*
|
|
199
|
+
* Merge several PDFs into one by appending their pages in order. Each input is
|
|
200
|
+
* either raw bytes (every page) or a {@link MergePart} `{ pdf, pages? }` that
|
|
201
|
+
* selects 1-based page numbers (ISO 32000-1 §7.7.3) — so the two forms can be
|
|
202
|
+
* mixed (e.g. `[whole, { pdf: b, pages: [1, 3] }]`). Returns an empty document
|
|
203
|
+
* for an empty list, or — when the only input is a whole PDF (no `pages`) —
|
|
204
|
+
* that input unchanged. Each subsequent part is appended onto the first via
|
|
179
205
|
* {@link GigaPdfDoc.appendPages}; the merged bytes are returned and the working
|
|
180
206
|
* document is closed.
|
|
181
207
|
*/
|
|
182
|
-
mergePdfs(
|
|
208
|
+
mergePdfs(parts: (Uint8Array | MergePart)[]): Uint8Array;
|
|
183
209
|
/**
|
|
184
210
|
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
185
211
|
* sheet per page — with the engine's native spreadsheet writer (no
|
|
@@ -1319,6 +1345,42 @@ interface LinkInfo {
|
|
|
1319
1345
|
}
|
|
1320
1346
|
type FieldKind = "text" | "checkbox" | "radio" | "pushbutton" | "combo" | "list" | "signature" | "unknown";
|
|
1321
1347
|
/** An AcroForm field with its flags and (for choices) options. */
|
|
1348
|
+
/** One signature on the document (a `/Sig` field's `/V`), from {@link GigaPdfDoc.signatures}. */
|
|
1349
|
+
interface SignatureInfo {
|
|
1350
|
+
/** The signature field's `/T` name. */
|
|
1351
|
+
fieldName: string;
|
|
1352
|
+
/** The signer name (`/Name`), or `null`. */
|
|
1353
|
+
signerName: string | null;
|
|
1354
|
+
/** The stated reason (`/Reason`), or `null`. */
|
|
1355
|
+
reason: string | null;
|
|
1356
|
+
/** The stated location (`/Location`), or `null`. */
|
|
1357
|
+
location: string | null;
|
|
1358
|
+
/** The signing date string (`/M`, e.g. `D:20260624…`), or `null`. */
|
|
1359
|
+
date: string | null;
|
|
1360
|
+
/** The `/SubFilter` (e.g. `adbe.pkcs7.detached`), or `null`. */
|
|
1361
|
+
subFilter: string | null;
|
|
1362
|
+
/** The `/ByteRange` `[a, b, c, d]` the signature covers. */
|
|
1363
|
+
byteRange: [number, number, number, number];
|
|
1364
|
+
}
|
|
1365
|
+
/** The cryptographic verdict for one signature, from {@link GigaPdfDoc.verifySignatures}. */
|
|
1366
|
+
interface SignatureReport {
|
|
1367
|
+
/** The signature field's `/T` name. */
|
|
1368
|
+
fieldName: string;
|
|
1369
|
+
/** The `/ByteRange` is well-formed and within the file bounds. */
|
|
1370
|
+
byteRangeOk: boolean;
|
|
1371
|
+
/** The CMS `messageDigest` equals SHA-256 of the covered bytes (integrity). */
|
|
1372
|
+
digestOk: boolean;
|
|
1373
|
+
/** The SignerInfo signature validates under the signer certificate's key. */
|
|
1374
|
+
signatureOk: boolean;
|
|
1375
|
+
/** The signature covers the **whole** current file (nothing appended after it). */
|
|
1376
|
+
coversWholeDocument: boolean;
|
|
1377
|
+
/** The signer certificate's Common Name, or `null`. */
|
|
1378
|
+
signerCommonName: string | null;
|
|
1379
|
+
/** Number of certificates embedded in the CMS. */
|
|
1380
|
+
certCount: number;
|
|
1381
|
+
/** The recognised signature algorithm (`RSA+SHA-256`) or an unsupported note. */
|
|
1382
|
+
algorithm: string;
|
|
1383
|
+
}
|
|
1322
1384
|
interface FieldInfo {
|
|
1323
1385
|
name: string;
|
|
1324
1386
|
type: string;
|
|
@@ -1361,6 +1423,85 @@ interface FieldInfo {
|
|
|
1361
1423
|
value: string;
|
|
1362
1424
|
options: string[];
|
|
1363
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* A view destination (ISO 32000-1 §12.3.2). `page` is 1-based; optional
|
|
1428
|
+
* coordinates are in the target page's user space (omit to leave unchanged).
|
|
1429
|
+
*/
|
|
1430
|
+
type Destination = {
|
|
1431
|
+
fit: "xyz";
|
|
1432
|
+
page: number;
|
|
1433
|
+
left?: number;
|
|
1434
|
+
top?: number;
|
|
1435
|
+
zoom?: number;
|
|
1436
|
+
} | {
|
|
1437
|
+
fit: "fit";
|
|
1438
|
+
page: number;
|
|
1439
|
+
} | {
|
|
1440
|
+
fit: "fitH";
|
|
1441
|
+
page: number;
|
|
1442
|
+
top?: number;
|
|
1443
|
+
} | {
|
|
1444
|
+
fit: "fitV";
|
|
1445
|
+
page: number;
|
|
1446
|
+
left?: number;
|
|
1447
|
+
} | {
|
|
1448
|
+
fit: "fitR";
|
|
1449
|
+
page: number;
|
|
1450
|
+
rect: [number, number, number, number];
|
|
1451
|
+
} | {
|
|
1452
|
+
fit: "fitB";
|
|
1453
|
+
page: number;
|
|
1454
|
+
} | {
|
|
1455
|
+
fit: "fitBH";
|
|
1456
|
+
page: number;
|
|
1457
|
+
top?: number;
|
|
1458
|
+
} | {
|
|
1459
|
+
fit: "fitBV";
|
|
1460
|
+
page: number;
|
|
1461
|
+
left?: number;
|
|
1462
|
+
} | {
|
|
1463
|
+
fit: "named";
|
|
1464
|
+
name: string;
|
|
1465
|
+
};
|
|
1466
|
+
/**
|
|
1467
|
+
* A PDF action (ISO 32000-1 §12.6) usable on a link, the document open-action,
|
|
1468
|
+
* or an outline bookmark — passed to {@link GigaPdfDoc.addLink} /
|
|
1469
|
+
* {@link GigaPdfDoc.setOpenAction} / {@link GigaPdfDoc.setBookmarks}.
|
|
1470
|
+
*/
|
|
1471
|
+
type Action = {
|
|
1472
|
+
type: "goto";
|
|
1473
|
+
dest: Destination;
|
|
1474
|
+
} | {
|
|
1475
|
+
type: "gotoR";
|
|
1476
|
+
file: string;
|
|
1477
|
+
dest: Destination;
|
|
1478
|
+
} | {
|
|
1479
|
+
type: "uri";
|
|
1480
|
+
uri: string;
|
|
1481
|
+
} | {
|
|
1482
|
+
type: "named";
|
|
1483
|
+
action: "nextPage" | "prevPage" | "firstPage" | "lastPage";
|
|
1484
|
+
} | {
|
|
1485
|
+
type: "launch";
|
|
1486
|
+
file: string;
|
|
1487
|
+
} | {
|
|
1488
|
+
type: "javascript";
|
|
1489
|
+
js: string;
|
|
1490
|
+
} | {
|
|
1491
|
+
type: "submitForm";
|
|
1492
|
+
url: string;
|
|
1493
|
+
} | {
|
|
1494
|
+
type: "resetForm";
|
|
1495
|
+
};
|
|
1496
|
+
/** One outline bookmark for {@link GigaPdfDoc.setBookmarks}. */
|
|
1497
|
+
interface Bookmark {
|
|
1498
|
+
/** The bookmark label. */
|
|
1499
|
+
title: string;
|
|
1500
|
+
/** Nesting depth (0 = top); deeper consecutive items become children. */
|
|
1501
|
+
level: number;
|
|
1502
|
+
/** What clicking the bookmark does (a `goto` becomes `/Dest`, else `/A`). */
|
|
1503
|
+
action?: Action;
|
|
1504
|
+
}
|
|
1364
1505
|
/** One outline (bookmark) entry; `level` is the nesting depth (0 = top). */
|
|
1365
1506
|
interface OutlineEntry {
|
|
1366
1507
|
level: number;
|
|
@@ -1381,11 +1522,55 @@ interface OutlineEntry {
|
|
|
1381
1522
|
/** `/XYZ` magnification. */
|
|
1382
1523
|
zoom?: number;
|
|
1383
1524
|
}
|
|
1525
|
+
/**
|
|
1526
|
+
* How a reader arranges pages on screen — the catalog `/PageLayout` name
|
|
1527
|
+
* (ISO 32000-1 §7.7.2). Passed to {@link GigaPdfDoc.setPageLayout}.
|
|
1528
|
+
*/
|
|
1529
|
+
type PageLayout = 'SinglePage' | 'OneColumn' | 'TwoColumnLeft' | 'TwoColumnRight' | 'TwoPageLeft' | 'TwoPageRight';
|
|
1530
|
+
/**
|
|
1531
|
+
* Which panel (if any) a reader shows on open — the catalog `/PageMode` name
|
|
1532
|
+
* (ISO 32000-1 §7.7.2). Passed to {@link GigaPdfDoc.setPageMode}.
|
|
1533
|
+
*/
|
|
1534
|
+
type PageMode = 'UseNone' | 'UseOutlines' | 'UseThumbs' | 'FullScreen' | 'UseOC' | 'UseAttachments';
|
|
1535
|
+
/**
|
|
1536
|
+
* Authoring options for the catalog `/ViewerPreferences` dictionary
|
|
1537
|
+
* (ISO 32000-1 §12.2) — UX hints a reader honours when it opens the document.
|
|
1538
|
+
*
|
|
1539
|
+
* Every field is optional: an omitted (or `undefined`) field leaves whatever
|
|
1540
|
+
* the document already had untouched; a boolean sets the corresponding key.
|
|
1541
|
+
* Passed to {@link GigaPdfDoc.setViewerPreferences}.
|
|
1542
|
+
*/
|
|
1543
|
+
interface ViewerPreferences {
|
|
1544
|
+
/** `/HideToolbar` — hide the reader's tool bars. */
|
|
1545
|
+
hideToolbar?: boolean;
|
|
1546
|
+
/** `/HideMenubar` — hide the reader's menu bar. */
|
|
1547
|
+
hideMenubar?: boolean;
|
|
1548
|
+
/** `/HideWindowUI` — hide scroll bars / navigation controls, page only. */
|
|
1549
|
+
hideWindowUI?: boolean;
|
|
1550
|
+
/** `/FitWindow` — resize the window to fit the first page. */
|
|
1551
|
+
fitWindow?: boolean;
|
|
1552
|
+
/** `/CenterWindow` — centre the document window on screen. */
|
|
1553
|
+
centerWindow?: boolean;
|
|
1554
|
+
/** `/DisplayDocTitle` — show the doc title (not the file name) in the title bar. */
|
|
1555
|
+
displayDocTitle?: boolean;
|
|
1556
|
+
/** `/Direction` — predominant reading order: `"L2R"` or `"R2L"`. */
|
|
1557
|
+
direction?: 'L2R' | 'R2L';
|
|
1558
|
+
}
|
|
1384
1559
|
/** A named destination from {@link GigaPdfDoc.namedDests}: a name → page anchor. */
|
|
1385
1560
|
interface NamedDest {
|
|
1386
1561
|
name: string;
|
|
1387
1562
|
page: number;
|
|
1388
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* One document-level JavaScript read back by {@link GigaPdfDoc.documentJavascripts}:
|
|
1566
|
+
* the `/Names /JavaScript` name-tree key and the script source.
|
|
1567
|
+
*/
|
|
1568
|
+
interface DocumentJavascript {
|
|
1569
|
+
/** The name-tree key the script is registered under. */
|
|
1570
|
+
name: string;
|
|
1571
|
+
/** The JavaScript source. */
|
|
1572
|
+
script: string;
|
|
1573
|
+
}
|
|
1389
1574
|
/**
|
|
1390
1575
|
* One embedded file attachment read back by {@link GigaPdfDoc.attachments}.
|
|
1391
1576
|
* `data` is the decoded file bytes; `mime`/`description`/dates are `null` when
|
|
@@ -1407,6 +1592,107 @@ interface Attachment {
|
|
|
1407
1592
|
/** The decoded (filters applied) file bytes. */
|
|
1408
1593
|
data: Uint8Array;
|
|
1409
1594
|
}
|
|
1595
|
+
/**
|
|
1596
|
+
* The relationship an **associated file** (`/AF`) bears to the document (ISO
|
|
1597
|
+
* 32000-2 / PDF/A-3). Hybrid e-invoices (Factur-X, ZUGFeRD, Order-X) embed their
|
|
1598
|
+
* XML payload as `"alternative"`.
|
|
1599
|
+
*/
|
|
1600
|
+
type AfRelationship = "source" | "data" | "alternative" | "supplement" | "unspecified";
|
|
1601
|
+
/** Options for embedding a file attachment (see {@link GigaPdfDoc.addAttachment}). */
|
|
1602
|
+
interface AttachmentOptions {
|
|
1603
|
+
/** The embedded stream `/Subtype` MIME type (e.g. `"application/pdf"`). */
|
|
1604
|
+
mime?: string;
|
|
1605
|
+
/** A human-readable description (`/Desc`). */
|
|
1606
|
+
description?: string;
|
|
1607
|
+
}
|
|
1608
|
+
/** The visual marker of a {@link GigaPdfDoc.addFileAttachmentAnnot} annotation. */
|
|
1609
|
+
type FileAttachmentIcon = "PushPin" | "Paperclip" | "Graph" | "Tag";
|
|
1610
|
+
/**
|
|
1611
|
+
* The initial navigator a PDF **portfolio** shows for its embedded files
|
|
1612
|
+
* (`/Collection /View`, ISO 32000-1 §7.11.6): `"details"` (a multi-column list),
|
|
1613
|
+
* `"tile"` (a grid of file tiles), or `"hidden"` (the navigator starts
|
|
1614
|
+
* collapsed). See {@link GigaPdfDoc.setCollection}.
|
|
1615
|
+
*/
|
|
1616
|
+
type CollectionView = "details" | "tile" | "hidden";
|
|
1617
|
+
/**
|
|
1618
|
+
* The data type of a portfolio schema column (`/CollectionField /Subtype`). The
|
|
1619
|
+
* first three are **user-defined** values supplied per file via
|
|
1620
|
+
* {@link CollectionItem.values}; the rest are **synthetic** columns the viewer
|
|
1621
|
+
* derives from each file (its name, description, size, dates) and need no value.
|
|
1622
|
+
*/
|
|
1623
|
+
type CollectionFieldSubtype = "text" | "date" | "number" | "filename" | "description" | "size" | "creationDate" | "modDate";
|
|
1624
|
+
/** One column of a portfolio schema (a `/CollectionField`). */
|
|
1625
|
+
interface CollectionField {
|
|
1626
|
+
/** The schema key; per-file {@link CollectionItem.values} reference it. */
|
|
1627
|
+
key: string;
|
|
1628
|
+
/** The displayed column header (`/N`). Defaults to `key` when omitted. */
|
|
1629
|
+
name?: string;
|
|
1630
|
+
/** The column data type (`/Subtype`). Defaults to `"text"`. */
|
|
1631
|
+
subtype?: CollectionFieldSubtype;
|
|
1632
|
+
/** The relative ordering (`/O`); columns are shown in ascending order. */
|
|
1633
|
+
order?: number;
|
|
1634
|
+
/** `/V` — whether the column is initially visible (default `true`). */
|
|
1635
|
+
visible?: boolean;
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Per-file portfolio metadata — the `/CI` (collection item) values for one
|
|
1639
|
+
* embedded file, keyed by schema field {@link CollectionField.key}. Values are
|
|
1640
|
+
* strings (numeric columns parse the string as a number; date columns expect a
|
|
1641
|
+
* PDF date string `"D:YYYYMMDD…"`). Only user-defined columns
|
|
1642
|
+
* (`text`/`date`/`number`) carry a value.
|
|
1643
|
+
*/
|
|
1644
|
+
interface CollectionItem {
|
|
1645
|
+
/** The embedded-file name (a key from {@link GigaPdfDoc.attachments}). */
|
|
1646
|
+
file: string;
|
|
1647
|
+
/** Schema-field `key` → value. */
|
|
1648
|
+
values: Record<string, string | number>;
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Configuration for a PDF **portfolio** / embedded-file collection — what
|
|
1652
|
+
* {@link GigaPdfDoc.setCollection} writes into the catalog `/Collection`
|
|
1653
|
+
* (ISO 32000-1 §7.11.6, §12.3.5). Marks the document as a portfolio and
|
|
1654
|
+
* configures its presentation.
|
|
1655
|
+
*/
|
|
1656
|
+
interface CollectionConfig {
|
|
1657
|
+
/** `/View` — the initial navigator. Defaults to `"details"`. */
|
|
1658
|
+
view?: CollectionView;
|
|
1659
|
+
/** `/Schema` — the columns, in declaration order. May be empty/omitted. */
|
|
1660
|
+
schema?: CollectionField[];
|
|
1661
|
+
/** `/Sort` — the column to sort on and direction. Omit/`null` to leave unset. */
|
|
1662
|
+
sort?: {
|
|
1663
|
+
field: string;
|
|
1664
|
+
ascending?: boolean;
|
|
1665
|
+
} | null;
|
|
1666
|
+
/** `/D` — the embedded-file name initially selected. Omit/`null` to leave unset. */
|
|
1667
|
+
defaultFile?: string | null;
|
|
1668
|
+
/** Per-file `/CI` metadata populating the schema columns. */
|
|
1669
|
+
items?: CollectionItem[];
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* The standard document-information fields (ISO 32000-1 §14.3.3), shared by the
|
|
1673
|
+
* `/Info` dictionary and the XMP `/Metadata` packet. Passed to
|
|
1674
|
+
* {@link GigaPdfDoc.setInfo}, which writes both and keeps them in sync. Every
|
|
1675
|
+
* field is optional; on `setInfo` an omitted field is left unchanged (a partial
|
|
1676
|
+
* update). Dates are PDF date strings (`"D:YYYYMMDDHHmmSS+HH'mm'"`).
|
|
1677
|
+
*/
|
|
1678
|
+
interface InfoFields {
|
|
1679
|
+
/** `/Title` → `dc:title`. */
|
|
1680
|
+
title?: string;
|
|
1681
|
+
/** `/Author` → `dc:creator`. */
|
|
1682
|
+
author?: string;
|
|
1683
|
+
/** `/Subject` → `dc:description`. */
|
|
1684
|
+
subject?: string;
|
|
1685
|
+
/** `/Keywords` → `pdf:Keywords`. */
|
|
1686
|
+
keywords?: string;
|
|
1687
|
+
/** `/Creator` (authoring app) → `xmp:CreatorTool`. */
|
|
1688
|
+
creator?: string;
|
|
1689
|
+
/** `/Producer` (PDF producer) → `pdf:Producer`. */
|
|
1690
|
+
producer?: string;
|
|
1691
|
+
/** `/CreationDate` (PDF date string) → `xmp:CreateDate`. */
|
|
1692
|
+
creationDate?: string;
|
|
1693
|
+
/** `/ModDate` (PDF date string) → `xmp:ModifyDate`. */
|
|
1694
|
+
modDate?: string;
|
|
1695
|
+
}
|
|
1410
1696
|
/** One sheet read back from an `.xlsx` by {@link GigaPdfEngine.xlsxToGrids}. */
|
|
1411
1697
|
interface XlsxSheet {
|
|
1412
1698
|
name: string;
|
|
@@ -1441,6 +1727,108 @@ interface PageMargins {
|
|
|
1441
1727
|
bottom: number;
|
|
1442
1728
|
left: number;
|
|
1443
1729
|
}
|
|
1730
|
+
/**
|
|
1731
|
+
* The five page boundary boxes (ISO 32000-1 §14.11.2), in display/source order.
|
|
1732
|
+
* Used as the `kind` selector for {@link GigaPdfDoc.setPageBox} and as the keys of
|
|
1733
|
+
* {@link PageBoxes.declared}.
|
|
1734
|
+
*/
|
|
1735
|
+
declare const PAGE_BOX_KINDS: readonly ["media", "crop", "bleed", "trim", "art"];
|
|
1736
|
+
/** One of the five page boundary boxes — see {@link PAGE_BOX_KINDS}. */
|
|
1737
|
+
type PageBoxKind = (typeof PAGE_BOX_KINDS)[number];
|
|
1738
|
+
/**
|
|
1739
|
+
* A page's five boundary boxes (see {@link GigaPdfDoc.getPageBoxes}). Each box is
|
|
1740
|
+
* the **effective** rectangle `[x0, y0, x1, y1]` in user-space points, with ISO
|
|
1741
|
+
* 32000-1 inheritance and the per-box default chain already applied — so `crop`
|
|
1742
|
+
* equals `media` when no `/CropBox` is declared, and `bleed`/`trim`/`art` each
|
|
1743
|
+
* fall back to `crop`. Values are reported verbatim (not clamped to their
|
|
1744
|
+
* intersection with the media box), so the source file round-trips faithfully.
|
|
1745
|
+
*/
|
|
1746
|
+
interface PageBoxes {
|
|
1747
|
+
/** `/MediaBox` (inherited if absent; defaults to US Letter `[0, 0, 612, 792]`). */
|
|
1748
|
+
media: [number, number, number, number];
|
|
1749
|
+
/** `/CropBox` (inherited if absent; defaults to the media box). */
|
|
1750
|
+
crop: [number, number, number, number];
|
|
1751
|
+
/** `/BleedBox` (defaults to the crop box). */
|
|
1752
|
+
bleed: [number, number, number, number];
|
|
1753
|
+
/** `/TrimBox` (defaults to the crop box). */
|
|
1754
|
+
trim: [number, number, number, number];
|
|
1755
|
+
/** `/ArtBox` (defaults to the crop box). */
|
|
1756
|
+
art: [number, number, number, number];
|
|
1757
|
+
/**
|
|
1758
|
+
* Which boxes are **explicitly declared** on the page dictionary (vs inherited
|
|
1759
|
+
* from an ancestor `/Pages` node or defaulted by the rules above) — lets a host
|
|
1760
|
+
* tell a real `/TrimBox` from one defaulted to the crop box.
|
|
1761
|
+
*/
|
|
1762
|
+
declared: Record<PageBoxKind, boolean>;
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* The numbering style of a page-label range (ISO 32000-1 §12.4.2):
|
|
1766
|
+
* `decimal` (1,2,3…), `romanLower` (i,ii,iii…), `romanUpper` (I,II,III…),
|
|
1767
|
+
* `alphaLower` (a…z,aa…), `alphaUpper` (A…Z,AA…), or `none` (the prefix alone,
|
|
1768
|
+
* with no numeric portion).
|
|
1769
|
+
*/
|
|
1770
|
+
type PageLabelStyle = "decimal" | "romanLower" | "romanUpper" | "alphaLower" | "alphaUpper" | "none";
|
|
1771
|
+
/**
|
|
1772
|
+
* One page-label range (ISO 32000-1 §12.4.2). From {@link startPage} onward (until
|
|
1773
|
+
* the next range, or the end of the document), pages are labelled {@link prefix}
|
|
1774
|
+
* followed by the {@link style}-formatted number counting up from
|
|
1775
|
+
* {@link startNumber}.
|
|
1776
|
+
*/
|
|
1777
|
+
interface PageLabelRange {
|
|
1778
|
+
/** 1-based page number where this labelling range begins. */
|
|
1779
|
+
startPage: number;
|
|
1780
|
+
/** The numbering style of the numeric portion. */
|
|
1781
|
+
style: PageLabelStyle;
|
|
1782
|
+
/** A label prefix prepended to every page in the range (may be empty). */
|
|
1783
|
+
prefix: string;
|
|
1784
|
+
/** The value the range's first page is numbered with (≥ 1; default 1). */
|
|
1785
|
+
startNumber: number;
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* The visual style of a page transition (ISO 32000-1 §12.4.4, the `/S` entry).
|
|
1789
|
+
* Index order matches the engine's enum and selects which optional fields of
|
|
1790
|
+
* {@link PageTransition} apply.
|
|
1791
|
+
*/
|
|
1792
|
+
declare const PAGE_TRANSITION_STYLES: readonly ["split", "blinds", "box", "wipe", "dissolve", "glitter", "fly", "push", "cover", "uncover", "fade", "replace"];
|
|
1793
|
+
/** A page transition style — see {@link PAGE_TRANSITION_STYLES}. */
|
|
1794
|
+
type PageTransitionStyle = (typeof PAGE_TRANSITION_STYLES)[number];
|
|
1795
|
+
/** Orientation of a `split`/`blinds` transition (the `/Dm` entry). */
|
|
1796
|
+
type PageTransitionDimension = "horizontal" | "vertical";
|
|
1797
|
+
/** Motion direction of a `split`/`box` transition (the `/M` entry). */
|
|
1798
|
+
type PageTransitionMotion = "inward" | "outward";
|
|
1799
|
+
/**
|
|
1800
|
+
* The sweep direction of a directional transition (the `/Di` entry). A number
|
|
1801
|
+
* of degrees — only the discrete angles `0`, `90`, `180`, `270`, `315` are
|
|
1802
|
+
* valid — or `"none"` (the `/Di /None` name, used by `fly` to mean "fly toward
|
|
1803
|
+
* the viewer").
|
|
1804
|
+
*/
|
|
1805
|
+
type PageTransitionDirection = 0 | 90 | 180 | 270 | 315 | "none";
|
|
1806
|
+
/**
|
|
1807
|
+
* A presentation transition + auto-advance for a page (ISO 32000-1 §12.4.4),
|
|
1808
|
+
* passed to {@link GigaPdfDoc.setPageTransition}. {@link style} picks the
|
|
1809
|
+
* effect; the remaining fields are optional and only the ones that apply to the
|
|
1810
|
+
* chosen style are written (`dimension`/`motion` for `split`, `direction`/
|
|
1811
|
+
* `scale`/`flyAreaOpaque` for `fly`, …). {@link displayDuration} is the page's
|
|
1812
|
+
* `/Dur` auto-advance time and is independent of the transition itself.
|
|
1813
|
+
*/
|
|
1814
|
+
interface PageTransition {
|
|
1815
|
+
/** The transition style (`/S`). */
|
|
1816
|
+
style: PageTransitionStyle;
|
|
1817
|
+
/** `/D` — the transition effect duration in **seconds** (viewer default: 1). */
|
|
1818
|
+
duration?: number;
|
|
1819
|
+
/** `/Dm` — orientation; `split`/`blinds` only. */
|
|
1820
|
+
dimension?: PageTransitionDimension;
|
|
1821
|
+
/** `/M` — motion direction; `split`/`box` only. */
|
|
1822
|
+
motion?: PageTransitionMotion;
|
|
1823
|
+
/** `/Di` — sweep direction; `wipe`/`glitter`/`fly`/`cover`/`uncover`/`push`. */
|
|
1824
|
+
direction?: PageTransitionDirection;
|
|
1825
|
+
/** `/SS` — starting/ending scale for `fly` (PDF 1.5; default 1.0). */
|
|
1826
|
+
scale?: number;
|
|
1827
|
+
/** `/B` — whether the `fly` area is rectangular + opaque (PDF 1.5; default false). */
|
|
1828
|
+
flyAreaOpaque?: boolean;
|
|
1829
|
+
/** `/Dur` — the page's display time in **seconds** before auto-advancing. */
|
|
1830
|
+
displayDuration?: number;
|
|
1831
|
+
}
|
|
1444
1832
|
/** Horizontal alignment of header/footer text within the printable width. */
|
|
1445
1833
|
type HeaderFooterAlign = "left" | "center" | "right";
|
|
1446
1834
|
/**
|
|
@@ -1465,6 +1853,57 @@ interface HeaderFooterSpec {
|
|
|
1465
1853
|
/** Band height from the page edge, in points (default `36`). */
|
|
1466
1854
|
bandHeight?: number;
|
|
1467
1855
|
}
|
|
1856
|
+
/** One colour stop of a {@link GradientSpec}. */
|
|
1857
|
+
interface GradientStop {
|
|
1858
|
+
/** Position along the gradient axis, `0`…`1`. */
|
|
1859
|
+
offset: number;
|
|
1860
|
+
/** Colour, packed `0xRRGGBB`. */
|
|
1861
|
+
rgb: number;
|
|
1862
|
+
}
|
|
1863
|
+
/** A gradient fill for {@link GigaPdfDoc.addGradient}. */
|
|
1864
|
+
interface GradientSpec {
|
|
1865
|
+
/** Axial (`"linear"`) or radial geometry. */
|
|
1866
|
+
kind: "linear" | "radial";
|
|
1867
|
+
/** `[x0,y0,x1,y1]` for `"linear"`, `[x0,y0,r0,x1,y1,r1]` for `"radial"`. */
|
|
1868
|
+
coords: number[];
|
|
1869
|
+
/** At least two colour stops. */
|
|
1870
|
+
stops: GradientStop[];
|
|
1871
|
+
/** The rectangle `{ x, y, w, h }` filled with the gradient. */
|
|
1872
|
+
rect: Box;
|
|
1873
|
+
/** Extend before the first / after the last stop (`/Extend`; default `[true, true]`). */
|
|
1874
|
+
extend?: [boolean, boolean];
|
|
1875
|
+
/** Fill opacity `0`…`1` (default `1`). */
|
|
1876
|
+
opacity?: number;
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* A fill colour in any authored colour space (ISO 32000-1 §8.6), for
|
|
1880
|
+
* {@link GigaPdfDoc.addFilledRectangle}/{@link GigaPdfDoc.addFilledPolygon}/
|
|
1881
|
+
* {@link GigaPdfDoc.addTextColor}. `cmyk`/`gray` are press-ready; `separation`
|
|
1882
|
+
* is a spot ink (with its `DeviceCMYK` tint approximation); `icc` embeds a
|
|
1883
|
+
* profile. CMYK/gray/tint components are `0`…`1`; `rgb` is packed `0xRRGGBB`.
|
|
1884
|
+
*/
|
|
1885
|
+
type Color = {
|
|
1886
|
+
space: "rgb";
|
|
1887
|
+
rgb: number;
|
|
1888
|
+
} | {
|
|
1889
|
+
space: "cmyk";
|
|
1890
|
+
c: number;
|
|
1891
|
+
m: number;
|
|
1892
|
+
y: number;
|
|
1893
|
+
k: number;
|
|
1894
|
+
} | {
|
|
1895
|
+
space: "gray";
|
|
1896
|
+
gray: number;
|
|
1897
|
+
} | {
|
|
1898
|
+
space: "separation";
|
|
1899
|
+
name: string;
|
|
1900
|
+
tint: number;
|
|
1901
|
+
cmyk: [number, number, number, number];
|
|
1902
|
+
} | {
|
|
1903
|
+
space: "icc";
|
|
1904
|
+
components: number[];
|
|
1905
|
+
profile: Uint8Array;
|
|
1906
|
+
};
|
|
1468
1907
|
/** Visual styling for a newly-created form field. */
|
|
1469
1908
|
interface FieldStyle {
|
|
1470
1909
|
/** Text size in points; `0` (default) auto-sizes to the field box. */
|
|
@@ -1495,6 +1934,38 @@ declare class GigaPdfDoc {
|
|
|
1495
1934
|
pageCount(): number;
|
|
1496
1935
|
save(): Uint8Array;
|
|
1497
1936
|
saveCompressed(): Uint8Array;
|
|
1937
|
+
/**
|
|
1938
|
+
* Serialize with PDF 1.5+ **object streams** + a **cross-reference stream**
|
|
1939
|
+
* (ISO 32000-1 §7.5.7 / §7.5.8) — the most compact output. `objectStreams`
|
|
1940
|
+
* (default `true`) packs non-stream objects into compressed `/ObjStm`s (needs
|
|
1941
|
+
* the xref stream); `xrefStreams` (default `true`) writes a `/XRef` stream.
|
|
1942
|
+
* `version` selects the `%PDF-x.y` header banner (default `"1.7"`).
|
|
1943
|
+
* Uncompressed streams are Flate-compressed first, like {@link saveCompressed}.
|
|
1944
|
+
* Linearization (Fast Web View) is not performed.
|
|
1945
|
+
*/
|
|
1946
|
+
saveOptimized(opts?: {
|
|
1947
|
+
objectStreams?: boolean;
|
|
1948
|
+
xrefStreams?: boolean;
|
|
1949
|
+
version?: PdfVersion;
|
|
1950
|
+
}): Uint8Array;
|
|
1951
|
+
/**
|
|
1952
|
+
* Serialize as a **linearized** ("Fast Web View") PDF (ISO 32000-1 Annex F).
|
|
1953
|
+
*
|
|
1954
|
+
* The first page and only the objects needed to render it — together with a
|
|
1955
|
+
* `/Linearized` parameter dictionary and a primary hint stream — are written at
|
|
1956
|
+
* the **front** of the file, so a web viewer can display page 1 before the rest
|
|
1957
|
+
* of the document has downloaded (progressive rendering / byte-range serving).
|
|
1958
|
+
* The remaining pages follow, then a main cross-reference table; the first-page
|
|
1959
|
+
* cross-reference section chains to it via `/Prev`. Streams are Flate-compressed
|
|
1960
|
+
* first (like {@link saveCompressed}) and embedded fonts are subset.
|
|
1961
|
+
*
|
|
1962
|
+
* Falls back to the plain {@link save} output if the document cannot be
|
|
1963
|
+
* linearized (no catalog / page tree / zero pages). `version` selects the
|
|
1964
|
+
* `%PDF-x.y` header banner (default `"1.7"`).
|
|
1965
|
+
*/
|
|
1966
|
+
toLinearized(version?: PdfVersion): Uint8Array;
|
|
1967
|
+
/** Alias of {@link toLinearized} — serialize as a linearized (Fast Web View) PDF. */
|
|
1968
|
+
saveLinearized(version?: PdfVersion): Uint8Array;
|
|
1498
1969
|
textRuns(page: number): TextRunInfo[];
|
|
1499
1970
|
elements(page: number): Element[];
|
|
1500
1971
|
/**
|
|
@@ -1663,6 +2134,63 @@ declare class GigaPdfDoc {
|
|
|
1663
2134
|
* `0xRRGGBB` colour for `stroke`/`fill`, or `null` to omit that paint.
|
|
1664
2135
|
*/
|
|
1665
2136
|
addEllipse(page: number, cx: number, cy: number, rx: number, ry: number, stroke?: number | null, fill?: number | null, lineWidth?: number, opacity?: number): boolean;
|
|
2137
|
+
/**
|
|
2138
|
+
* Paint a **linear** or **radial** gradient over `rect` on `page` (ISO 32000-1
|
|
2139
|
+
* §8.7.4 shading + §8.7.3 pattern). `coords` is `[x0,y0,x1,y1]` for `"linear"`
|
|
2140
|
+
* or `[x0,y0,r0,x1,y1,r1]` for `"radial"`; `stops` is ≥ 2 colour stops
|
|
2141
|
+
* (`offset` 0…1, `rgb` packed `0xRRGGBB`). `extend` (default `[true,true]`)
|
|
2142
|
+
* sets `/Extend`; `opacity` (default `1`) is the fill alpha.
|
|
2143
|
+
*
|
|
2144
|
+
* @example
|
|
2145
|
+
* doc.addGradient(1, {
|
|
2146
|
+
* kind: "linear", coords: [50, 50, 250, 50],
|
|
2147
|
+
* stops: [{ offset: 0, rgb: 0xff0000 }, { offset: 1, rgb: 0x0000ff }],
|
|
2148
|
+
* rect: { x: 50, y: 40, w: 200, h: 60 },
|
|
2149
|
+
* });
|
|
2150
|
+
*/
|
|
2151
|
+
addGradient(page: number, spec: GradientSpec): boolean;
|
|
2152
|
+
/**
|
|
2153
|
+
* Encode a {@link Color} into the ABI's `(kind, comps, name, profile)` buffers
|
|
2154
|
+
* and invoke `fn` with the resulting pointers. Internal.
|
|
2155
|
+
*/
|
|
2156
|
+
private _color;
|
|
2157
|
+
/**
|
|
2158
|
+
* Fill a rectangle with `color` in **any** colour space — the press-ready
|
|
2159
|
+
* counterpart of {@link addRectangle} (CMYK, spot `Separation`, gray, ICC).
|
|
2160
|
+
*
|
|
2161
|
+
* @example
|
|
2162
|
+
* doc.addFilledRectangle(1, { x: 40, y: 700, w: 200, h: 40 },
|
|
2163
|
+
* { space: "cmyk", c: 0.1, m: 0.8, y: 0.9, k: 0 });
|
|
2164
|
+
*/
|
|
2165
|
+
addFilledRectangle(page: number, rect: Box, color: Color, opacity?: number): boolean;
|
|
2166
|
+
/**
|
|
2167
|
+
* Fill a polygon through flat `[x0,y0,x1,y1,…]` `points` (≥ 3 vertices) with
|
|
2168
|
+
* `color` in any colour space. The path is closed automatically.
|
|
2169
|
+
*/
|
|
2170
|
+
addFilledPolygon(page: number, points: number[], color: Color, opacity?: number): boolean;
|
|
2171
|
+
/**
|
|
2172
|
+
* Draw a base-14 text run in **any** colour space — the press-ready
|
|
2173
|
+
* counterpart of {@link addTextStandard}. `font` is a base-14 family
|
|
2174
|
+
* (`Helvetica`, `Times-Roman`, `Courier`, …).
|
|
2175
|
+
*/
|
|
2176
|
+
addTextColor(page: number, x: number, y: number, size: number, text: string, font: string, color: Color, opts?: {
|
|
2177
|
+
opacity?: number;
|
|
2178
|
+
rotation?: number;
|
|
2179
|
+
underline?: boolean;
|
|
2180
|
+
strikethrough?: boolean;
|
|
2181
|
+
}): boolean;
|
|
2182
|
+
/**
|
|
2183
|
+
* Turn **overprint** on/off for content drawn **after** this call (`/op` fill,
|
|
2184
|
+
* `/OP` stroke, `/OPM` mode — `0` independent colorants, `1` non-erasing).
|
|
2185
|
+
* Essential for prepress black-overprint / trapping.
|
|
2186
|
+
*/
|
|
2187
|
+
setOverprint(page: number, fill: boolean, stroke: boolean, mode?: number): boolean;
|
|
2188
|
+
/**
|
|
2189
|
+
* Add a document-level **OutputIntent** embedding the ICC `profile` (its `/N`
|
|
2190
|
+
* is read from the profile), with `condition` as the output-condition
|
|
2191
|
+
* identifier (e.g. `"Coated FOGRA39"`). Decoupled from the PDF/A path.
|
|
2192
|
+
*/
|
|
2193
|
+
addOutputIntent(profile: Uint8Array, condition: string): boolean;
|
|
1666
2194
|
/**
|
|
1667
2195
|
* Draw a polyline/polygon through flat `[x0,y0,x1,y1,…]` points. `close` joins
|
|
1668
2196
|
* the last vertex back to the first. `0xRRGGBB` colours, or `null` to omit.
|
|
@@ -1679,6 +2207,25 @@ declare class GigaPdfDoc {
|
|
|
1679
2207
|
* user space. PNG alpha is honoured; `opacity` (0..1) sets an overall alpha.
|
|
1680
2208
|
*/
|
|
1681
2209
|
addImage(page: number, data: Uint8Array, x: number, y: number, w: number, h: number, opacity?: number): boolean;
|
|
2210
|
+
/**
|
|
2211
|
+
* Replace the pixels of an **existing image XObject in place** — swap a logo or
|
|
2212
|
+
* photo while every reference to it stays intact (ISO 32000-1 §8.9). `index` is
|
|
2213
|
+
* the **unified element index** of an image on `page`, exactly the `index`
|
|
2214
|
+
* reported by {@link imageElements} (and accepted by {@link removeElement} /
|
|
2215
|
+
* {@link transformElement}); `data` is a fresh PNG or JPEG.
|
|
2216
|
+
*
|
|
2217
|
+
* Unlike a delete-then-re-add, the image keeps its object number, **every `/Do`
|
|
2218
|
+
* placement, and its position / scale / rotation / clip matrix** — only the
|
|
2219
|
+
* stream bytes and the image dictionary (`/Width`, `/Height`, `/ColorSpace`,
|
|
2220
|
+
* `/BitsPerComponent`, `/Filter`) are rewritten. The new raster is re-encoded
|
|
2221
|
+
* through the same path as {@link addImage} (PNG alpha → a fresh `/SMask`; JPEG
|
|
2222
|
+
* → `/DCTDecode` passthrough). It need not match the old pixel size — it is
|
|
2223
|
+
* drawn into the same box (transform the element first to re-fit it).
|
|
2224
|
+
*
|
|
2225
|
+
* Returns `false` if `page`/`index` doesn't resolve to a top-level image, or the
|
|
2226
|
+
* bytes aren't a decodable PNG/JPEG.
|
|
2227
|
+
*/
|
|
2228
|
+
replaceImage(page: number, index: number, data: Uint8Array): boolean;
|
|
1682
2229
|
/**
|
|
1683
2230
|
* Stamp an **image watermark** across pages from raw image bytes. Accepts the
|
|
1684
2231
|
* same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
|
|
@@ -1743,7 +2290,15 @@ declare class GigaPdfDoc {
|
|
|
1743
2290
|
rotatePage(page: number, degrees: number): boolean;
|
|
1744
2291
|
deletePage(page: number): boolean;
|
|
1745
2292
|
movePage(from: number, to: number): boolean;
|
|
1746
|
-
|
|
2293
|
+
/**
|
|
2294
|
+
* Append pages of another PDF onto this document. With no `pages`, every page
|
|
2295
|
+
* is appended (powers *merge*). With `pages` — 1-based page numbers, in the
|
|
2296
|
+
* order given — only that selection is brought in (ISO 32000-1 §7.7.3), each
|
|
2297
|
+
* page keeping its content, resources, annotations and box geometry. Numbers
|
|
2298
|
+
* out of range are skipped; an empty/all-out-of-range selection returns
|
|
2299
|
+
* `false`.
|
|
2300
|
+
*/
|
|
2301
|
+
appendPages(otherPdf: Uint8Array, pages?: number[]): boolean;
|
|
1747
2302
|
/**
|
|
1748
2303
|
* Add an invisible (text render mode 3) standard-Helvetica text layer to
|
|
1749
2304
|
* `page` in a SINGLE content append — for OCR. Each run is `{x, y, size,
|
|
@@ -1760,12 +2315,101 @@ declare class GigaPdfDoc {
|
|
|
1760
2315
|
}[]): number;
|
|
1761
2316
|
/** Extract the given 1-based page numbers into a NEW standalone PDF. */
|
|
1762
2317
|
extractPages(pages: number[]): Uint8Array;
|
|
1763
|
-
/**
|
|
2318
|
+
/**
|
|
2319
|
+
* Resize a page's `/MediaBox` to `width`×`height` points — **box geometry
|
|
2320
|
+
* only**. The drawn content keeps its own coordinates (it is *not* rescaled to
|
|
2321
|
+
* the new box, so it may clip or float). To scale the page content along with
|
|
2322
|
+
* the box (keeping annotations aligned) use {@link scalePageContent} or
|
|
2323
|
+
* {@link scalePageTo}; for large-format authoring see {@link setUserUnit}.
|
|
2324
|
+
*/
|
|
1764
2325
|
resizePage(page: number, width: number, height: number): boolean;
|
|
2326
|
+
/**
|
|
2327
|
+
* Scale a page's **content** uniformly by `factor` about the page origin (ISO
|
|
2328
|
+
* 32000-1 §8.3.4) — a true zoom of the whole page, not just the box. Three
|
|
2329
|
+
* things move together: (1) the content stream is wrapped in
|
|
2330
|
+
* `q <factor 0 0 factor 0 0> cm … Q`; (2) `/MediaBox` and `/CropBox` (resolved
|
|
2331
|
+
* through inheritance) plus any locally declared `/BleedBox`/`/TrimBox`/
|
|
2332
|
+
* `/ArtBox` are scaled about the origin; (3) every annotation `/Rect` is scaled,
|
|
2333
|
+
* so widget/stamp appearances — mapped from their `/BBox` into the `/Rect` per
|
|
2334
|
+
* §12.5.5 — rescale to stay aligned automatically. `factor` must be finite and
|
|
2335
|
+
* positive. `false` on engine error (bad page number / non-positive factor).
|
|
2336
|
+
*/
|
|
2337
|
+
scalePageContent(page: number, factor: number): boolean;
|
|
2338
|
+
/**
|
|
2339
|
+
* Anisotropic {@link scalePageContent}: scale a page's content by `sx`
|
|
2340
|
+
* horizontally and `sy` vertically about the origin, scaling the boxes and
|
|
2341
|
+
* annotation `/Rect`s by the same factors. Both must be finite and positive.
|
|
2342
|
+
* `false` on engine error.
|
|
2343
|
+
*/
|
|
2344
|
+
scalePageContentXY(page: number, sx: number, sy: number): boolean;
|
|
2345
|
+
/**
|
|
2346
|
+
* Scale a page's content to **fit within** `width`×`height` points (shrink- or
|
|
2347
|
+
* grow-to-fit), preserving aspect ratio — equivalent to {@link scalePageContent}
|
|
2348
|
+
* with `min(width / currentWidth, height / currentHeight)` over the page's
|
|
2349
|
+
* displayed size (`/MediaBox` with `/Rotate` applied). Returns the uniform
|
|
2350
|
+
* factor applied, or `null` on engine error (bad page number, non-positive
|
|
2351
|
+
* target, or zero-area page).
|
|
2352
|
+
*/
|
|
2353
|
+
scalePageTo(page: number, width: number, height: number): number | null;
|
|
2354
|
+
/**
|
|
2355
|
+
* Set a page's `/UserUnit` (ISO 32000-1 §14.11.2) for **large-format
|
|
2356
|
+
* authoring**: one default user-space unit becomes `unit`⁄72 inch, so the same
|
|
2357
|
+
* coordinates render larger (e.g. `2.0` doubles the physical size, lifting the
|
|
2358
|
+
* ~200-inch coordinate ceiling). `1.0` is the default and removes the key. This
|
|
2359
|
+
* is distinct from {@link scalePageContent}: it rescales the coordinate system
|
|
2360
|
+
* (a viewer-level zoom of the medium), not the content or boxes. `unit` must be
|
|
2361
|
+
* finite and positive. `false` on engine error.
|
|
2362
|
+
*/
|
|
2363
|
+
setUserUnit(page: number, unit: number): boolean;
|
|
2364
|
+
/**
|
|
2365
|
+
* A page's `/UserUnit` (ISO 32000-1 §14.11.2), defaulting to `1.0` when absent.
|
|
2366
|
+
* Returns `null` on engine error (bad page number).
|
|
2367
|
+
*/
|
|
2368
|
+
pageUserUnit(page: number): number | null;
|
|
1765
2369
|
/** Insert a blank page after the 1-based `after` page (0 = front); returns its id. */
|
|
1766
2370
|
addPage(width: number, height: number, after?: number): number;
|
|
1767
2371
|
/** Duplicate a page, inserting the copy right after it; returns the new page's id. */
|
|
1768
2372
|
copyPage(page: number): number;
|
|
2373
|
+
/**
|
|
2374
|
+
* N-up imposition (ISO 32000-1 §8.10): draw the **content** of the 1-based
|
|
2375
|
+
* `source` page, scaled and translated, onto the 1-based `target` page — the
|
|
2376
|
+
* basis for 2-up/4-up, booklets, contact sheets and page-on-page stamping. The
|
|
2377
|
+
* source page becomes a Form XObject (its content + `/Resources`, so its fonts
|
|
2378
|
+
* and images come along) and is drawn with `q <cm> /Fmn Do Q` appended to the
|
|
2379
|
+
* target. `(x, y)` is where the visible page's lower-left corner lands and
|
|
2380
|
+
* `(scaleX, scaleY)` scale the page **as displayed** (its `/MediaBox` origin
|
|
2381
|
+
* and `/Rotate` are absorbed into the matrix). Wrapped in `q`/`Q`, so it never
|
|
2382
|
+
* disturbs existing target content and is **composable** — call it repeatedly
|
|
2383
|
+
* (different sources and/or cells) to build an N-up sheet. `source` and
|
|
2384
|
+
* `target` may be the same page. `false` on engine error (bad page number).
|
|
2385
|
+
*/
|
|
2386
|
+
placePage(target: number, source: number, x: number, y: number, scaleX: number, scaleY: number): boolean;
|
|
2387
|
+
/**
|
|
2388
|
+
* Place `source` onto `target` (both 1-based) using an explicit content-stream
|
|
2389
|
+
* matrix `[a, b, c, d, e, f]` — the low-level primitive behind
|
|
2390
|
+
* {@link placePage} for full control of the affine (shear, arbitrary rotation,
|
|
2391
|
+
* reflection). The matrix maps the source page's form space (its user space,
|
|
2392
|
+
* including the `/MediaBox` origin) to the target; unlike {@link placePage} no
|
|
2393
|
+
* origin/rotation normalisation is applied, so identity draws the source 1:1
|
|
2394
|
+
* at the target origin. `false` on engine error.
|
|
2395
|
+
*/
|
|
2396
|
+
placePageMatrix(target: number, source: number, matrix: [number, number, number, number, number, number]): boolean;
|
|
2397
|
+
/**
|
|
2398
|
+
* Impose **all** existing pages `cols × rows` per sheet onto freshly added
|
|
2399
|
+
* sheets (2-up, 4-up, booklet thumbnails, contact sheets). Pages go
|
|
2400
|
+
* left-to-right, top-to-bottom; each is scaled uniformly to fit its cell
|
|
2401
|
+
* (aspect preserved) and centred. The new sheets are appended after the last
|
|
2402
|
+
* original page and the **originals are removed**, leaving only the imposed
|
|
2403
|
+
* sheets. Returns the number of sheets produced (negative on error: `cols`/
|
|
2404
|
+
* `rows` 0, or an empty document). `sheetWidth`/`sheetHeight` default to A4
|
|
2405
|
+
* portrait; `margin`/`gutter` to 14 pt.
|
|
2406
|
+
*/
|
|
2407
|
+
nUp(cols: number, rows: number, opts?: {
|
|
2408
|
+
sheetWidth?: number;
|
|
2409
|
+
sheetHeight?: number;
|
|
2410
|
+
margin?: number;
|
|
2411
|
+
gutter?: number;
|
|
2412
|
+
}): number;
|
|
1769
2413
|
/** A page's size (points) and `/Rotate` (0/90/180/270). */
|
|
1770
2414
|
pageInfo(page: number): PageInfo;
|
|
1771
2415
|
/**
|
|
@@ -1778,6 +2422,80 @@ declare class GigaPdfDoc {
|
|
|
1778
2422
|
* — a real, visible margin change. Returns `true` on success.
|
|
1779
2423
|
*/
|
|
1780
2424
|
setPageMargins(page: number, m: PageMargins): boolean;
|
|
2425
|
+
/**
|
|
2426
|
+
* All five page boundary boxes (`media`/`crop`/`bleed`/`trim`/`art`) for the
|
|
2427
|
+
* 1-based `page`, each as `[x0, y0, x1, y1]` in points, with ISO 32000-1
|
|
2428
|
+
* inheritance and defaults applied. See {@link PageBoxes} for the exact
|
|
2429
|
+
* default chain and the `declared` flags.
|
|
2430
|
+
*/
|
|
2431
|
+
getPageBoxes(page: number): PageBoxes;
|
|
2432
|
+
/**
|
|
2433
|
+
* Set one of a page's boundary boxes. `kind` is one of {@link PAGE_BOX_KINDS}
|
|
2434
|
+
* and `box` is given as `{ x, y, w, h }` (origin + size, points); it is written
|
|
2435
|
+
* as `[x, y, x+w, y+h]`, normalised so reversed sizes are accepted. Sibling
|
|
2436
|
+
* boxes are preserved. Returns `true` on success, `false` for an unknown kind,
|
|
2437
|
+
* a degenerate box (zero/negative area), or a bad page number.
|
|
2438
|
+
*
|
|
2439
|
+
* Setting `"trim"`/`"bleed"` is the prerequisite for PDF/X and commercial-print
|
|
2440
|
+
* (imposition, bleed, finished-size) pipelines.
|
|
2441
|
+
*/
|
|
2442
|
+
setPageBox(page: number, kind: PageBoxKind, box: Box): boolean;
|
|
2443
|
+
/**
|
|
2444
|
+
* The document's page-label ranges (`/PageLabels`, ISO 32000-1 §12.4.2), sorted
|
|
2445
|
+
* by `startPage` (1-based). Empty when the document declares no page labels.
|
|
2446
|
+
*/
|
|
2447
|
+
getPageLabels(): PageLabelRange[];
|
|
2448
|
+
/**
|
|
2449
|
+
* Replace the document's page labels. Pass an **empty** array to remove all
|
|
2450
|
+
* labels. Ranges are sorted by `startPage` and collapsed to one entry per page
|
|
2451
|
+
* (last wins). Returns `true` on success.
|
|
2452
|
+
*
|
|
2453
|
+
* @example
|
|
2454
|
+
* // Front matter in lowercase roman, body in decimal, appendix "A-1, A-2…".
|
|
2455
|
+
* doc.setPageLabels([
|
|
2456
|
+
* { startPage: 1, style: "romanLower", prefix: "", startNumber: 1 },
|
|
2457
|
+
* { startPage: 5, style: "decimal", prefix: "", startNumber: 1 },
|
|
2458
|
+
* { startPage: 20, style: "decimal", prefix: "A-", startNumber: 1 },
|
|
2459
|
+
* ]);
|
|
2460
|
+
*/
|
|
2461
|
+
setPageLabels(ranges: PageLabelRange[]): boolean;
|
|
2462
|
+
/**
|
|
2463
|
+
* The viewer-visible label string for the 1-based `page` (e.g. `"iv"`, `"A-3"`),
|
|
2464
|
+
* resolving the applicable `/PageLabels` range; the decimal page number when no
|
|
2465
|
+
* range applies (including a document with no page labels).
|
|
2466
|
+
*/
|
|
2467
|
+
pageLabel(page: number): string;
|
|
2468
|
+
/**
|
|
2469
|
+
* Author a presentation transition + auto-advance on `page` (1-based),
|
|
2470
|
+
* ISO 32000-1 §12.4.4. Writes the page's `/Trans` dictionary from
|
|
2471
|
+
* {@link PageTransition.style} plus only the optional sub-keys that apply to
|
|
2472
|
+
* that style (`dimension`/`motion` for `split`, `direction`/`scale`/
|
|
2473
|
+
* `flyAreaOpaque` for `fly`, …) — inapplicable fields are dropped.
|
|
2474
|
+
* {@link PageTransition.displayDuration} becomes the page's `/Dur`
|
|
2475
|
+
* (auto-advance); omitting it removes any existing `/Dur`. Re-calling replaces
|
|
2476
|
+
* the prior transition in full (idempotent). Returns `true` on success,
|
|
2477
|
+
* `false` for an unknown style, a negative/non-finite `duration`/`scale`/
|
|
2478
|
+
* `displayDuration`, or a bad page number.
|
|
2479
|
+
*
|
|
2480
|
+
* @example
|
|
2481
|
+
* // Kiosk slideshow: every page wipes in over 0.5 s, auto-advancing after 5 s.
|
|
2482
|
+
* for (let p = 1; p <= doc.pageCount(); p++) {
|
|
2483
|
+
* doc.setPageTransition(p, { style: "wipe", duration: 0.5, displayDuration: 5 });
|
|
2484
|
+
* }
|
|
2485
|
+
*/
|
|
2486
|
+
setPageTransition(page: number, trans: PageTransition): boolean;
|
|
2487
|
+
/**
|
|
2488
|
+
* The presentation transition declared on `page` (1-based), or `null` when the
|
|
2489
|
+
* page has no `/Trans` (ISO 32000-1 §12.4.4). Optional fields that do not apply
|
|
2490
|
+
* to the recovered style are omitted from the result.
|
|
2491
|
+
*/
|
|
2492
|
+
getPageTransition(page: number): PageTransition | null;
|
|
2493
|
+
/**
|
|
2494
|
+
* Remove any presentation transition from `page` (1-based) — drops the page's
|
|
2495
|
+
* `/Trans` dictionary and its `/Dur` auto-advance entry. A no-op if neither is
|
|
2496
|
+
* present. Returns `true` on success.
|
|
2497
|
+
*/
|
|
2498
|
+
clearPageTransition(page: number): boolean;
|
|
1781
2499
|
/**
|
|
1782
2500
|
* Bake a running header onto every in-range page (idempotent: re-baking
|
|
1783
2501
|
* replaces the prior header). Returns `true` on success.
|
|
@@ -1913,7 +2631,65 @@ declare class GigaPdfDoc {
|
|
|
1913
2631
|
toXlsx(): Uint8Array;
|
|
1914
2632
|
toOds(): Uint8Array;
|
|
1915
2633
|
toRtf(): Uint8Array;
|
|
1916
|
-
|
|
2634
|
+
/**
|
|
2635
|
+
* Re-serialize the document as **PDF/A** (archival).
|
|
2636
|
+
*
|
|
2637
|
+
* `level` selects the conformance flavour (default `"pdfa-2b"`):
|
|
2638
|
+
* - `"pdfa-1b"` — ISO 19005-1, based on PDF 1.4.
|
|
2639
|
+
* - `"pdfa-1a"` — ISO 19005-1 **Tagged PDF** (level A): 1b + a logical
|
|
2640
|
+
* structure tree, marked content and `/Lang`. Built from the structure the
|
|
2641
|
+
* engine reconstructs (paragraphs, headings, tables, lists).
|
|
2642
|
+
* - `"pdfa-2b"` — ISO 19005-2 (default).
|
|
2643
|
+
* - `"pdfa-2u"` — like 2b but requires every glyph Unicode-mapped (a
|
|
2644
|
+
* `/ToUnicode` CMap on each font); only validator-clean when the source
|
|
2645
|
+
* fonts already carry one — otherwise prefer `"pdfa-2b"`.
|
|
2646
|
+
* - `"pdfa-2a"` — ISO 19005-2 **Tagged PDF** (level A): 2u + a logical
|
|
2647
|
+
* structure tree and marked content (`/StructTreeRoot`, `/MarkInfo`).
|
|
2648
|
+
* - `"pdfa-3b"` — ISO 19005-3; permits embedded file attachments.
|
|
2649
|
+
*
|
|
2650
|
+
* Full conformance also requires every font embedded — this method does not
|
|
2651
|
+
* embed missing fonts (see the Rust `to_pdfa_level` docs). For the level-A
|
|
2652
|
+
* (`1a`/`2a`) flavours the tagging is rendering-neutral: it only inserts
|
|
2653
|
+
* balanced marked-content operators and a structure tree, never changing the
|
|
2654
|
+
* page appearance.
|
|
2655
|
+
*/
|
|
2656
|
+
toPdfA(level?: "pdfa-1b" | "pdfa-1a" | "pdfa-2b" | "pdfa-2u" | "pdfa-2a" | "pdfa-3b"): Uint8Array;
|
|
2657
|
+
/**
|
|
2658
|
+
* Author a **tagged (accessible) PDF** — a `/StructTreeRoot` logical-structure
|
|
2659
|
+
* tree (`P`/`H1`–`H6`/`Table`/`L`/`Figure` …) with marked content, `/MarkInfo`,
|
|
2660
|
+
* `/Lang`, `/RoleMap` and `/Alt` on figures — **without** forcing PDF/A. Pass
|
|
2661
|
+
* `{ pdfUa: true }` to also stamp the PDF/UA-1 identifier (ISO 14289). If the
|
|
2662
|
+
* document has no reconstructable structure the plain PDF is returned.
|
|
2663
|
+
* ISO 32000-1 §14.7/§14.8.
|
|
2664
|
+
*/
|
|
2665
|
+
toTagged(opts?: {
|
|
2666
|
+
pdfUa?: boolean;
|
|
2667
|
+
}): Uint8Array;
|
|
2668
|
+
/**
|
|
2669
|
+
* The number of taggable **figures** the engine reconstructs across the whole
|
|
2670
|
+
* document — the valid range `0..figureCount()` for {@link setFigureAlt}'s
|
|
2671
|
+
* `index`. Each figure is an image the geometric reconstruction surfaces; the
|
|
2672
|
+
* Tagged-PDF / PDF-A-level-A export emits one `/Figure` structure element per
|
|
2673
|
+
* figure, in this same order.
|
|
2674
|
+
*/
|
|
2675
|
+
figureCount(): number;
|
|
2676
|
+
/**
|
|
2677
|
+
* Attach **author-supplied alternate text** (`/Alt`) to a figure so assistive
|
|
2678
|
+
* technology can describe the image (WCAG / PDF/UA, ISO 32000-1 §14.9.3).
|
|
2679
|
+
*
|
|
2680
|
+
* `index` is the **document-global figure index** — figures are numbered
|
|
2681
|
+
* `0, 1, 2, …` in page order, then in page-content order within each page (the
|
|
2682
|
+
* Nth image of the whole document is figure `N`; {@link figureCount} bounds the
|
|
2683
|
+
* range). The text lands on the matching `/Figure` structure element's `/Alt`
|
|
2684
|
+
* when an accessible export is produced — {@link toTagged} or {@link toPdfA}
|
|
2685
|
+
* with `"pdfa-1a"`/`"pdfa-2a"`. Figures with no author-supplied text keep a
|
|
2686
|
+
* generic non-empty placeholder, so the output stays structurally valid even
|
|
2687
|
+
* for unlabeled figures.
|
|
2688
|
+
*
|
|
2689
|
+
* Returns `true` on success; `false` if `alt` is empty (a `/Alt` must be
|
|
2690
|
+
* non-empty) or the call otherwise fails.
|
|
2691
|
+
*/
|
|
2692
|
+
setFigureAlt(index: number, alt: string): boolean;
|
|
1917
2693
|
/**
|
|
1918
2694
|
* Serialize the document encrypted with the PDF Standard Security Handler.
|
|
1919
2695
|
* Defaults to **AES-256 (R6)**. `fileId` is the document `/ID` (any stable
|
|
@@ -1936,8 +2712,62 @@ declare class GigaPdfDoc {
|
|
|
1936
2712
|
permissions?: number;
|
|
1937
2713
|
keySeed?: Uint8Array;
|
|
1938
2714
|
}): Uint8Array;
|
|
2715
|
+
/**
|
|
2716
|
+
* Re-encrypt an already-opened (decrypted) document with **new** passwords,
|
|
2717
|
+
* discarding the prior encryption (ISO 32000-1 §7.6). Opening with the old
|
|
2718
|
+
* password is what authorises the change. Mirrors {@link saveEncrypted} plus
|
|
2719
|
+
* `encryptMetadata` (when `false`, the metadata stream is left in the clear).
|
|
2720
|
+
*/
|
|
2721
|
+
changePasswords(newPassword: string, fileId: string, opts?: {
|
|
2722
|
+
ownerPassword?: string;
|
|
2723
|
+
algorithm?: "rc4" | "aes128" | "aes256";
|
|
2724
|
+
flags?: Partial<PdfPermissions>;
|
|
2725
|
+
permissions?: number;
|
|
2726
|
+
keySeed?: Uint8Array;
|
|
2727
|
+
encryptMetadata?: boolean;
|
|
2728
|
+
}): Uint8Array;
|
|
2729
|
+
/**
|
|
2730
|
+
* Strip encryption from an already-opened (decrypted) document, returning a
|
|
2731
|
+
* **plaintext** PDF. The document must have been opened with a valid password.
|
|
2732
|
+
*/
|
|
2733
|
+
removeEncryption(): Uint8Array;
|
|
2734
|
+
/**
|
|
2735
|
+
* Encrypt the document to one or more **X.509 recipients** (public-key /
|
|
2736
|
+
* certificate security, ISO 32000-1 §7.6.5, `/Filter /Adobe.PubSec`): only a
|
|
2737
|
+
* holder of a recipient private key can open it — no shared password.
|
|
2738
|
+
* `certificates` are DER X.509 certs. `seed`/`rngSeed` default to Web Crypto
|
|
2739
|
+
* randomness. Open the result with {@link GigaPdfEngine.openWithPrivateKey}.
|
|
2740
|
+
*/
|
|
2741
|
+
encryptForRecipients(certificates: Uint8Array[], opts?: {
|
|
2742
|
+
flags?: Partial<PdfPermissions>;
|
|
2743
|
+
permissions?: number;
|
|
2744
|
+
aes256?: boolean;
|
|
2745
|
+
encryptMetadata?: boolean;
|
|
2746
|
+
seed?: Uint8Array;
|
|
2747
|
+
rngSeed?: Uint8Array;
|
|
2748
|
+
}): Uint8Array;
|
|
1939
2749
|
/** Self-signed digital signature. `random` ≥ 256 bytes from crypto.getRandomValues. */
|
|
1940
2750
|
sign(fields: string, random: Uint8Array, keyBits?: number): Uint8Array;
|
|
2751
|
+
/**
|
|
2752
|
+
* **Certify** the document (DocMDP) — like {@link sign} but also declares which
|
|
2753
|
+
* later changes are allowed: `docmdpLevel` is `1` (no changes), `2` (form-fill
|
|
2754
|
+
* + sign) or `3` (also annotate). `fields` is the same tab-separated string as
|
|
2755
|
+
* {@link sign} (`name⇥reason⇥date⇥notBefore⇥notAfter`).
|
|
2756
|
+
*/
|
|
2757
|
+
certify(fields: string, random: Uint8Array, docmdpLevel: 1 | 2 | 3, keyBits?: number): Uint8Array;
|
|
2758
|
+
/**
|
|
2759
|
+
* List every signature on the document (each `/Sig` field's `/V`) with its
|
|
2760
|
+
* metadata and `/ByteRange`. For cryptographic validity call
|
|
2761
|
+
* {@link verifySignatures}.
|
|
2762
|
+
*/
|
|
2763
|
+
signatures(): SignatureInfo[];
|
|
2764
|
+
/**
|
|
2765
|
+
* Cryptographically verify every signature against `pdf` — the **original
|
|
2766
|
+
* bytes** this document was opened from. Each report carries `byteRangeOk`,
|
|
2767
|
+
* `digestOk` (content integrity), `signatureOk` (the RSA signature),
|
|
2768
|
+
* `coversWholeDocument`, the signer CN, and the algorithm.
|
|
2769
|
+
*/
|
|
2770
|
+
verifySignatures(pdf: Uint8Array): SignatureReport[];
|
|
1941
2771
|
/**
|
|
1942
2772
|
* Sign with a PKCS#12 (`.p12`/`.pfx`) identity — a CA-issued / eIDAS
|
|
1943
2773
|
* certificate and its RSA key, imported natively (no external crypto). `opts`
|
|
@@ -1989,8 +2819,33 @@ declare class GigaPdfDoc {
|
|
|
1989
2819
|
* included. */
|
|
1990
2820
|
private appendDocumentTimestamp;
|
|
1991
2821
|
getMetadata(key: string): string;
|
|
1992
|
-
/**
|
|
2822
|
+
/**
|
|
2823
|
+
* Set a **single** Info-dictionary entry (e.g. `"Title"`, `"Author"`). This
|
|
2824
|
+
* touches only `/Info`; use {@link setInfo} to update the typed fields and keep
|
|
2825
|
+
* the XMP `/Metadata` packet in sync.
|
|
2826
|
+
*/
|
|
1993
2827
|
setMetadata(key: string, value: string): boolean;
|
|
2828
|
+
/**
|
|
2829
|
+
* The document's XMP metadata packet (catalog `/Metadata`, ISO 32000-1 §14.3.2)
|
|
2830
|
+
* as raw bytes, or `null` when the document carries no XMP.
|
|
2831
|
+
*/
|
|
2832
|
+
getXmp(): Uint8Array | null;
|
|
2833
|
+
/**
|
|
2834
|
+
* Replace (or create) the document's XMP metadata stream (catalog `/Metadata`,
|
|
2835
|
+
* stored uncompressed). Accepts a UTF-8 string or raw bytes. Returns `true` on
|
|
2836
|
+
* success.
|
|
2837
|
+
*/
|
|
2838
|
+
setXmp(xmp: Uint8Array | string): boolean;
|
|
2839
|
+
/**
|
|
2840
|
+
* Set the standard document-information fields, writing **both** the `/Info`
|
|
2841
|
+
* dictionary and a synced XMP `/Metadata` packet so the two never drift. This is
|
|
2842
|
+
* a **partial** update — only the fields you provide are changed; omit a field
|
|
2843
|
+
* to leave it untouched. Returns `true` on success.
|
|
2844
|
+
*
|
|
2845
|
+
* @example
|
|
2846
|
+
* doc.setInfo({ title: "Annual Report", author: "Ada Lovelace", keywords: "finance, 2026" });
|
|
2847
|
+
*/
|
|
2848
|
+
setInfo(fields: InfoFields): boolean;
|
|
1994
2849
|
annotations(page: number): AnnotationInfo[];
|
|
1995
2850
|
removeAnnotation(page: number, index: number): boolean;
|
|
1996
2851
|
addSquare(page: number, x0: number, y0: number, x1: number, y1: number, stroke?: number | null, fill?: number | null, lineWidth?: number): boolean;
|
|
@@ -2032,6 +2887,35 @@ declare class GigaPdfDoc {
|
|
|
2032
2887
|
/** Freehand ink annotation from one polyline (`points` = flat [x0,y0,x1,y1,…]). */
|
|
2033
2888
|
addInk(page: number, points: number[], rgb?: number, lineWidth?: number): boolean;
|
|
2034
2889
|
addStamp(page: number, x0: number, y0: number, x1: number, y1: number, label: string, rgb?: number): boolean;
|
|
2890
|
+
/**
|
|
2891
|
+
* Add a `/Circle` (ellipse) annotation inscribed in `[x0,y0,x1,y1]`. `stroke`
|
|
2892
|
+
* (border) and `fill` (interior) are packed `0xRRGGBB` numbers, or `null` to
|
|
2893
|
+
* omit. Returns `true` on success.
|
|
2894
|
+
*/
|
|
2895
|
+
addCircleAnnotation(page: number, x0: number, y0: number, x1: number, y1: number, stroke?: number | null, fill?: number | null, lineWidth?: number): boolean;
|
|
2896
|
+
/**
|
|
2897
|
+
* Add a `/Polygon` annotation — a closed shape through `points` (a flat
|
|
2898
|
+
* `[x0, y0, x1, y1, …]` array, PDF user space), with optional `stroke`/`fill`
|
|
2899
|
+
* (`0xRRGGBB` or `null`). Returns `true` on success.
|
|
2900
|
+
*/
|
|
2901
|
+
addPolygonAnnotation(page: number, points: number[], stroke?: number | null, fill?: number | null, lineWidth?: number): boolean;
|
|
2902
|
+
/**
|
|
2903
|
+
* Add a `/PolyLine` annotation — an open path through `points` (a flat
|
|
2904
|
+
* `[x0, y0, x1, y1, …]` array). `rgb` is packed `0xRRGGBB`.
|
|
2905
|
+
*/
|
|
2906
|
+
addPolylineAnnotation(page: number, points: number[], rgb?: number, lineWidth?: number): boolean;
|
|
2907
|
+
/**
|
|
2908
|
+
* Add a `/Caret` annotation — a small upward wedge in `[x0,y0,x1,y1]` marking
|
|
2909
|
+
* an insertion point. `rgb` is packed `0xRRGGBB`.
|
|
2910
|
+
*/
|
|
2911
|
+
addCaretAnnotation(page: number, x0: number, y0: number, x1: number, y1: number, rgb?: number): boolean;
|
|
2912
|
+
/**
|
|
2913
|
+
* Regenerate the appearance stream (`/AP /N`) of the 0-based `index`
|
|
2914
|
+
* annotation on `page` from its stored geometry, after editing its colour,
|
|
2915
|
+
* border or geometry. Returns `true` on success, `false` for a bad index or a
|
|
2916
|
+
* subtype whose appearance can't be reconstructed (FreeText/Stamp/Text/Link).
|
|
2917
|
+
*/
|
|
2918
|
+
regenerateAppearance(page: number, index: number): boolean;
|
|
2035
2919
|
flattenAnnotations(page: number): number;
|
|
2036
2920
|
/**
|
|
2037
2921
|
* Flatten the interactive form: bake every field widget across all pages into
|
|
@@ -2075,6 +2959,81 @@ declare class GigaPdfDoc {
|
|
|
2075
2959
|
* files (the native replacement for a reader's `getAttachments()`).
|
|
2076
2960
|
*/
|
|
2077
2961
|
attachments(): Attachment[];
|
|
2962
|
+
/**
|
|
2963
|
+
* Embed `bytes` as a document-level file attachment named `name`
|
|
2964
|
+
* (`/Names /EmbeddedFiles`, ISO 32000-1 §7.11.4). Re-using a `name` **replaces**
|
|
2965
|
+
* that attachment; the bytes are stored FlateDecode-compressed. Returns `true`
|
|
2966
|
+
* on success (`false` e.g. for an empty name).
|
|
2967
|
+
*/
|
|
2968
|
+
addAttachment(name: string, bytes: Uint8Array, opts?: AttachmentOptions): boolean;
|
|
2969
|
+
/**
|
|
2970
|
+
* Embed `bytes` as an **associated file** (`/AF`, PDF/A-3) named `name` with the
|
|
2971
|
+
* given {@link AfRelationship} — the mechanism Factur-X / ZUGFeRD / Order-X use
|
|
2972
|
+
* to carry their invoice XML (`"alternative"`). The file is also a normal
|
|
2973
|
+
* attachment, is linked from the catalog `/AF` array, and its filespec carries
|
|
2974
|
+
* `/AFRelationship`. Returns `true` on success.
|
|
2975
|
+
*/
|
|
2976
|
+
addAssociatedFile(name: string, bytes: Uint8Array, relationship: AfRelationship, opts?: AttachmentOptions): boolean;
|
|
2977
|
+
/**
|
|
2978
|
+
* Remove the attachment named `name` (from `/Names /EmbeddedFiles` and, if
|
|
2979
|
+
* present, the catalog `/AF` array). Returns `true` if one was removed, `false`
|
|
2980
|
+
* if no attachment had that name.
|
|
2981
|
+
*/
|
|
2982
|
+
removeAttachment(name: string): boolean;
|
|
2983
|
+
/**
|
|
2984
|
+
* Mark this document as an embedded-file **portfolio** and configure how its
|
|
2985
|
+
* attachments are presented, by writing the catalog `/Collection`
|
|
2986
|
+
* (ISO 32000-1 §7.11.6, §12.3.5). The files must already be embedded (add them
|
|
2987
|
+
* first with {@link addAttachment} / {@link addAssociatedFile}); this only adds
|
|
2988
|
+
* the presentation layer: the initial {@link CollectionConfig.view view}, the
|
|
2989
|
+
* {@link CollectionConfig.schema schema} columns, the
|
|
2990
|
+
* {@link CollectionConfig.sort sort} order, the
|
|
2991
|
+
* {@link CollectionConfig.defaultFile default file}, and per-file
|
|
2992
|
+
* {@link CollectionConfig.items column values} (each written as a `/CI` on the
|
|
2993
|
+
* matching file's filespec). An empty/omitted schema still produces a valid
|
|
2994
|
+
* `/Collection`. Calling again **replaces** the previous configuration. Returns
|
|
2995
|
+
* `true` on success (`false` on a malformed config or write error).
|
|
2996
|
+
*/
|
|
2997
|
+
setCollection(config: CollectionConfig): boolean;
|
|
2998
|
+
/**
|
|
2999
|
+
* Read this document's portfolio configuration back from the catalog
|
|
3000
|
+
* `/Collection` — the reader counterpart of {@link setCollection}. Returns
|
|
3001
|
+
* `null` when the document is not a portfolio. The recovered
|
|
3002
|
+
* {@link CollectionConfig} carries the `view`, the `schema` columns (sorted by
|
|
3003
|
+
* order), the `sort`, the `defaultFile`, and each embedded file's `/CI` column
|
|
3004
|
+
* `values`.
|
|
3005
|
+
*/
|
|
3006
|
+
collection(): CollectionConfig | null;
|
|
3007
|
+
/**
|
|
3008
|
+
* Install a **document-level JavaScript** under the catalog `/Names /JavaScript`
|
|
3009
|
+
* name tree (ISO 32000-1 §7.7.3.4 + §12.6.4.16): a named JavaScript action
|
|
3010
|
+
* (`<< /S /JavaScript /JS … >>`) keyed by `name`. On open, a conforming viewer
|
|
3011
|
+
* runs every document-level script in **name (lexical) order** — this is where
|
|
3012
|
+
* form-calculation / validation helper libraries live (e.g. `AFNumber_Format`).
|
|
3013
|
+
* Re-using a `name` **replaces** that script; long sources are stored as a
|
|
3014
|
+
* FlateDecode stream, and sibling `/Names` subtrees (`/EmbeddedFiles`,
|
|
3015
|
+
* `/Dests`, …) are preserved. Returns `true` on success (`false` e.g. for an
|
|
3016
|
+
* empty name).
|
|
3017
|
+
*/
|
|
3018
|
+
addDocumentJavascript(name: string, script: string): boolean;
|
|
3019
|
+
/**
|
|
3020
|
+
* Every document-level JavaScript as `{ name, script }` pairs, in name
|
|
3021
|
+
* (lexical) order — the read side of {@link addDocumentJavascript} (decodes
|
|
3022
|
+
* both a literal `/JS` string and a `/JS` stream).
|
|
3023
|
+
*/
|
|
3024
|
+
documentJavascripts(): DocumentJavascript[];
|
|
3025
|
+
/**
|
|
3026
|
+
* Remove the document-level JavaScript named `name` from `/Names /JavaScript`.
|
|
3027
|
+
* Returns `true` if one was removed, `false` if none had that name.
|
|
3028
|
+
*/
|
|
3029
|
+
removeDocumentJavascript(name: string): boolean;
|
|
3030
|
+
/**
|
|
3031
|
+
* Add a page-anchored **FileAttachment** annotation over `rect` on the 1-based
|
|
3032
|
+
* `page`, pointing at the already-embedded attachment `name` (add it first with
|
|
3033
|
+
* {@link addAttachment}). `icon` is the visual marker (default `"PushPin"`).
|
|
3034
|
+
* Returns `true` on success (`false` if no such attachment exists).
|
|
3035
|
+
*/
|
|
3036
|
+
addFileAttachmentAnnot(page: number, rect: Box, name: string, icon?: FileAttachmentIcon): boolean;
|
|
2078
3037
|
/**
|
|
2079
3038
|
* Add an internal hyperlink over a rectangle that jumps to the named
|
|
2080
3039
|
* destination `name` (define it with {@link addNamedDest}). Unlike
|
|
@@ -2088,9 +3047,58 @@ declare class GigaPdfDoc {
|
|
|
2088
3047
|
setLayerVisibility(id: number, visible: boolean): boolean;
|
|
2089
3048
|
setLayerLocked(id: number, locked: boolean): boolean;
|
|
2090
3049
|
removeLayer(id: number): boolean;
|
|
3050
|
+
/**
|
|
3051
|
+
* Begin an optional-content marked-content sequence on `page` for the layer
|
|
3052
|
+
* `ocg` (its id, from {@link addLayer}). Registers the OCG under the page's
|
|
3053
|
+
* `/Resources /Properties` and appends `/OC /OCn BDC` to the content stream;
|
|
3054
|
+
* every drawing call after it ({@link addText}, {@link addRectangle},
|
|
3055
|
+
* {@link addImage}, …) is gated on that layer's visibility until the matching
|
|
3056
|
+
* {@link endOptionalContent} appends `EMC`. Calls nest. Returns the `OCn`
|
|
3057
|
+
* property name (empty string on error).
|
|
3058
|
+
*/
|
|
3059
|
+
beginOptionalContent(page: number, ocg: number): string;
|
|
3060
|
+
/** End the innermost optional-content sequence on `page` (`EMC`). */
|
|
3061
|
+
endOptionalContent(page: number): boolean;
|
|
2091
3062
|
outline(): OutlineEntry[];
|
|
2092
3063
|
/** Replace the outline. Each entry: `{level, page?, title}` (page 0/undefined = no dest). */
|
|
2093
3064
|
setOutline(entries: OutlineEntry[]): boolean;
|
|
3065
|
+
/**
|
|
3066
|
+
* Add a `/Link` annotation over `rect` (`{ x, y, w, h }`) carrying any
|
|
3067
|
+
* {@link Action} — the full action & destination model (GoTo with every fit
|
|
3068
|
+
* mode, GoToR, URI, Named navigation, Launch, JavaScript, SubmitForm,
|
|
3069
|
+
* ResetForm). Returns `true` on success (`false` for a malformed action).
|
|
3070
|
+
*
|
|
3071
|
+
* @example
|
|
3072
|
+
* doc.addLink(1, { x: 72, y: 700, w: 120, h: 16 },
|
|
3073
|
+
* { type: "goto", dest: { fit: "xyz", page: 4, top: 720, zoom: 1.5 } });
|
|
3074
|
+
*/
|
|
3075
|
+
addLink(page: number, rect: Box, action: Action): boolean;
|
|
3076
|
+
/**
|
|
3077
|
+
* Set the document `/OpenAction` — the {@link Action} performed when the file
|
|
3078
|
+
* is opened. Returns `true` on success.
|
|
3079
|
+
*/
|
|
3080
|
+
setOpenAction(action: Action): boolean;
|
|
3081
|
+
/**
|
|
3082
|
+
* Remove the `linkIndex`-th `/Link` annotation on `page` (links counted in
|
|
3083
|
+
* order, ignoring non-link annotations). Returns `true` if one was removed.
|
|
3084
|
+
*/
|
|
3085
|
+
removeLink(page: number, linkIndex: number): boolean;
|
|
3086
|
+
/**
|
|
3087
|
+
* Replace the outline with {@link Bookmark}s that may carry actions (a `goto`
|
|
3088
|
+
* action becomes a `/Dest`, any other action an `/A`). An empty array clears
|
|
3089
|
+
* the outline. Returns `true` on success.
|
|
3090
|
+
*/
|
|
3091
|
+
setBookmarks(bookmarks: Bookmark[]): boolean;
|
|
3092
|
+
/**
|
|
3093
|
+
* Write the catalog `/ViewerPreferences` (ISO 32000-1 §12.2). Each omitted
|
|
3094
|
+
* field is left unchanged; a boolean sets the key. After applying, an empty
|
|
3095
|
+
* dictionary is removed. Returns `false` on an invalid `direction`.
|
|
3096
|
+
*/
|
|
3097
|
+
setViewerPreferences(prefs: ViewerPreferences): boolean;
|
|
3098
|
+
/** Set the catalog `/PageLayout`. `null` removes the key. Returns `false` on an unknown name. */
|
|
3099
|
+
setPageLayout(layout: PageLayout | null): boolean;
|
|
3100
|
+
/** Set the catalog `/PageMode`. `null` removes the key. Returns `false` on an unknown name. */
|
|
3101
|
+
setPageMode(mode: PageMode | null): boolean;
|
|
2094
3102
|
fields(): FieldInfo[];
|
|
2095
3103
|
setTextField(name: string, value: string): boolean;
|
|
2096
3104
|
setCheckbox(name: string, checked: boolean): boolean;
|
|
@@ -2133,6 +3141,39 @@ declare class GigaPdfDoc {
|
|
|
2133
3141
|
multi?: boolean;
|
|
2134
3142
|
style?: FieldStyle;
|
|
2135
3143
|
}): boolean;
|
|
3144
|
+
/**
|
|
3145
|
+
* Create a **visible signature field** (`/FT /Sig`) over `rect` — an empty
|
|
3146
|
+
* widget the signing pipeline can later target — and flag the AcroForm
|
|
3147
|
+
* `/SigFlags`. Returns `true` on success.
|
|
3148
|
+
*/
|
|
3149
|
+
addSignatureField(page: number, name: string, rect: [number, number, number, number], opts?: {
|
|
3150
|
+
style?: FieldStyle;
|
|
3151
|
+
}): boolean;
|
|
3152
|
+
/**
|
|
3153
|
+
* Attach field-level JavaScript to a field's `/AA` for the given `trigger`
|
|
3154
|
+
* (`"keystroke"` filters input, `"format"` formats display, `"validate"`
|
|
3155
|
+
* checks on change, `"calculate"` recomputes — ordered by
|
|
3156
|
+
* {@link setCalculationOrder}). Returns `true` if set, `false` if no field has
|
|
3157
|
+
* that name.
|
|
3158
|
+
*/
|
|
3159
|
+
setFieldScript(name: string, trigger: "keystroke" | "format" | "validate" | "calculate", js: string): boolean;
|
|
3160
|
+
/**
|
|
3161
|
+
* Set the AcroForm calculation order (`/CO`) — the sequence in which fields
|
|
3162
|
+
* with a `calculate` script recompute. Unknown names are skipped.
|
|
3163
|
+
*/
|
|
3164
|
+
setCalculationOrder(names: string[]): boolean;
|
|
3165
|
+
/**
|
|
3166
|
+
* Delete a form field by name (removed from `/Fields`, `/CO` and every page's
|
|
3167
|
+
* annotations). Returns `true` if a field was removed.
|
|
3168
|
+
*/
|
|
3169
|
+
removeField(name: string): boolean;
|
|
3170
|
+
/**
|
|
3171
|
+
* Rebuild a field's appearance from its current value/style — call after
|
|
3172
|
+
* changing a field's value programmatically. Returns `true` if regenerated
|
|
3173
|
+
* (`false` for an unknown name or a kind that can't be regenerated alone, e.g.
|
|
3174
|
+
* a radio parent with kids).
|
|
3175
|
+
*/
|
|
3176
|
+
regenerateFieldAppearance(name: string): boolean;
|
|
2136
3177
|
}
|
|
2137
3178
|
|
|
2138
|
-
export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type DocumentLanguage, type Element, type EmbeddedFont, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type LayerInfo, type LinkInfo, type ModelOp, type NamedDest, type OutlineEntry, type PageInfo, type PageMargins, type PathSegment, type PdfPermissions, type RadioOption, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|
|
3179
|
+
export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type ViewerPreferences, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|