@pdfluent/sdk-wasm 1.2.0 → 1.3.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/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
[Source on GitHub](https://github.com/pdfluent/pdfluent-sdk) · [Documentation](https://pdfluent.com/docs) · [Report an issue](https://github.com/pdfluent/pdfluent-sdk/issues)
|
|
4
4
|
|
|
5
5
|
WebAssembly distribution of the PDFluent PDF engine. Read, edit, annotate,
|
|
6
|
-
redact, sign, and validate PDFs (including XFA) entirely in the browser
|
|
6
|
+
redact, sign, and validate PDFs (including XFA) entirely in the browser -
|
|
7
7
|
zero bytes go to a server.
|
|
8
8
|
|
|
9
9
|
Published as `@pdfluent/sdk-wasm` on npm. (The crate directory is named
|
|
10
|
-
`xfa-wasm` for historical XFA roots
|
|
10
|
+
`xfa-wasm` for historical XFA roots - the published npm package covers the
|
|
11
11
|
full SDK surface needed for an in-browser PDF editor. Previously known as
|
|
12
12
|
`@pdfluent/xfa-wasm`; renamed to `@pdfluent/sdk-wasm`.)
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ full SDK surface needed for an in-browser PDF editor. Previously known as
|
|
|
22
22
|
- **Text watermark**: diagonal text watermark with configurable opacity
|
|
23
23
|
- **Redaction**: by region (rectangle) or by search query (permanent removal: the content is gone, not covered)
|
|
24
24
|
- **Stream compression**: re-deflate content streams for smaller file size
|
|
25
|
-
- **`PdfDocMut`**: stateful editing handle
|
|
25
|
+
- **`PdfDocMut`**: stateful editing handle - open once, mutate in place,
|
|
26
26
|
save once. One parse and one serialise for a whole editing session instead
|
|
27
27
|
of one per operation, with identical output bytes.
|
|
28
28
|
|
|
@@ -216,7 +216,7 @@ wasm-pack build crates/xfa-wasm --target web -- --no-default-features
|
|
|
216
216
|
| `redactSearch(query)` | Find all literal matches of `query` and redact each |
|
|
217
217
|
| `compress()` | Re-deflate content streams; returns optimised bytes |
|
|
218
218
|
|
|
219
|
-
### PdfDocMut
|
|
219
|
+
### PdfDocMut - **recommended for editor workflows**
|
|
220
220
|
|
|
221
221
|
`PdfDocMut` is a stateful editing handle. Open once, mutate in place,
|
|
222
222
|
save once. The `PdfDoc` class above is great for inspection and
|
|
@@ -229,14 +229,14 @@ serialise per step.
|
|
|
229
229
|
|--------|-------------|
|
|
230
230
|
| `PdfDocMut.open(bytes)` | Open for editing |
|
|
231
231
|
| `pageCount()` | Live page count after any mutations so far |
|
|
232
|
-
| `save()` | Serialise current state to `Uint8Array`. Non-consuming
|
|
232
|
+
| `save()` | Serialise current state to `Uint8Array`. Non-consuming - keep editing after |
|
|
233
233
|
| `free()` | Release the WASM-side memory deterministically |
|
|
234
234
|
| `deletePages(pages)` | In place |
|
|
235
235
|
| `rotatePage(pageIndex, degrees)` | In place |
|
|
236
236
|
| `reorderPages(newOrder)` | In place |
|
|
237
237
|
| `extractPages(pages)` | Returns bytes for a NEW subdocument; current editor unchanged |
|
|
238
|
-
| `setFormField(path, value)` | In place
|
|
239
|
-
| `setFormFields(jsonObject)` | In place, bulk
|
|
238
|
+
| `setFormField(path, value)` | In place - text, checkbox, radio, and choice; updates `/V`, `/AS`, and `/AP` |
|
|
239
|
+
| `setFormFields(jsonObject)` | In place, bulk - same full chain for each entry |
|
|
240
240
|
| `addHighlight(pageIndex, x, y, w, h, colorHex?)` | In place (feature: annotate) |
|
|
241
241
|
| `addStickyNote(pageIndex, x, y, contents)` | In place (feature: annotate) |
|
|
242
242
|
| `addFreeText(pageIndex, x, y, w, h, contents)` | In place (feature: annotate) |
|
|
@@ -254,7 +254,7 @@ await init();
|
|
|
254
254
|
const bytes = new Uint8Array(await (await fetch('/document.pdf')).arrayBuffer());
|
|
255
255
|
const editor = PdfDocMut.open(bytes);
|
|
256
256
|
|
|
257
|
-
// All edits operate on the same internal lopdf::Document
|
|
257
|
+
// All edits operate on the same internal lopdf::Document - no re-parse.
|
|
258
258
|
editor.reorderPages(new Uint32Array([1, 0, 2]));
|
|
259
259
|
editor.addTextWatermark('CONCEPT', 0.3);
|
|
260
260
|
editor.addHighlight(0, 100, 700, 200, 20, '#ffeb3b');
|
package/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -133,8 +133,27 @@ Two vendored files, both Adobe's own CMap resources, both BSD-3-Clause:
|
|
|
133
133
|
form, read by the PDF/A fixups for
|
|
134
134
|
EUC-encoded CID text
|
|
135
135
|
Copyright 1990-2019 Adobe
|
|
136
|
+
crates/pdf-manip/resources/predefined-cmaps/pack.z
|
|
137
|
+
the 61 predefined CMaps of the PDF
|
|
138
|
+
specification as one compressed
|
|
139
|
+
pack, built by
|
|
140
|
+
scripts/pdfa/build_cmap_pack.py
|
|
141
|
+
from github.com/adobe-type-tools/
|
|
142
|
+
cmap-resources, commit f5cf3bca
|
|
143
|
+
(BSD-3-Clause); read by the PDF/A
|
|
144
|
+
conversion so it needs no
|
|
145
|
+
poppler-data on the host
|
|
146
|
+
Copyright 1990-2023 Adobe
|
|
147
|
+
crates/pdf-manip/resources/predefined-cmaps/PROVENANCE.sha256
|
|
148
|
+
ours: the SHA-256 of each source
|
|
149
|
+
file and of the pack built from
|
|
150
|
+
them
|
|
151
|
+
crates/pdf-manip/resources/predefined-cmaps/LICENSE-Adobe-CMap.txt
|
|
152
|
+
the full BSD-3-Clause text and
|
|
153
|
+
Adobe's notice for the pack above
|
|
136
154
|
|
|
137
155
|
Upstream licence texts in the tree:
|
|
156
|
+
crates/pdf-manip/resources/predefined-cmaps/LICENSE-Adobe-CMap.txt (BSD-3-Clause, full text)
|
|
138
157
|
crates/pdf-font/assets/LICENSE.txt (BSD-3-Clause, full text)
|
|
139
158
|
crates/pdf-manip/resources/cmap/GB-EUC-H (the notice is the file's own
|
|
140
159
|
header, as Adobe ships it)
|
|
@@ -880,3 +899,27 @@ SOFTWARE
|
|
|
880
899
|
================================================================================
|
|
881
900
|
END OF THIRD PARTY LICENSES
|
|
882
901
|
================================================================================
|
|
902
|
+
|
|
903
|
+
================================================================================
|
|
904
|
+
qrcodegen 1.8.0 — QR Code generator library (MIT)
|
|
905
|
+
https://www.nayuki.io/page/qr-code-generator-library
|
|
906
|
+
================================================================================
|
|
907
|
+
|
|
908
|
+
Copyright (c) Project Nayuki. (MIT License)
|
|
909
|
+
https://www.nayuki.io/page/qr-code-generator-library
|
|
910
|
+
|
|
911
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
912
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
913
|
+
the Software without restriction, including without limitation the rights to
|
|
914
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
915
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
916
|
+
subject to the following conditions:
|
|
917
|
+
- The above copyright notice and this permission notice shall be included in
|
|
918
|
+
all copies or substantial portions of the Software.
|
|
919
|
+
- The Software is provided "as is", without warranty of any kind, express or
|
|
920
|
+
implied, including but not limited to the warranties of merchantability,
|
|
921
|
+
fitness for a particular purpose and noninfringement. In no event shall the
|
|
922
|
+
authors or copyright holders be liable for any claim, damages or other
|
|
923
|
+
liability, whether in an action of contract, tort or otherwise, arising from,
|
|
924
|
+
out of or in connection with the Software or the use or other dealings in the
|
|
925
|
+
Software.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@pdfluent/sdk-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "PDFluent browser SDK — find and replace PDF text programmatically while preserving fonts and layout, plus edit, annotate, redact, sign and validate PDFs (including XFA), entirely client-side via WASM.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.3.0",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE-OFFER",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/xfa_wasm.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ export enum ChromaSampling {
|
|
|
122
122
|
*
|
|
123
123
|
* # Errors
|
|
124
124
|
*
|
|
125
|
-
* All fallible methods throw a `PdfluentError`
|
|
125
|
+
* All fallible methods throw a `PdfluentError` - a standard `Error` subclass with
|
|
126
126
|
* these properties:
|
|
127
127
|
* - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
|
|
128
128
|
* (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
|
|
@@ -372,7 +372,7 @@ export class PdfDoc {
|
|
|
372
372
|
* Render a page directly to an HTML canvas element (wasm32 only).
|
|
373
373
|
*
|
|
374
374
|
* Calls `canvas.getContext("2d")`, sets the canvas dimensions to the
|
|
375
|
-
* rendered pixel size, and calls `putImageData`
|
|
375
|
+
* rendered pixel size, and calls `putImageData` - no round-trip through
|
|
376
376
|
* a JS Uint8Array. XFA documents are auto-flattened before rendering.
|
|
377
377
|
*
|
|
378
378
|
* ```js
|
|
@@ -489,7 +489,7 @@ export class PdfDocMut {
|
|
|
489
489
|
addFreeText(page_index: number, x: number, y: number, w: number, h: number, contents: string): void;
|
|
490
490
|
/**
|
|
491
491
|
* Add a highlight annotation over the given page rectangle.
|
|
492
|
-
* `color_hex` like `"#ffeb3b"`
|
|
492
|
+
* `color_hex` like `"#ffeb3b"` - defaults to yellow when `None`.
|
|
493
493
|
*/
|
|
494
494
|
addHighlight(page_index: number, x: number, y: number, w: number, h: number, color_hex?: string | null): void;
|
|
495
495
|
/**
|
|
@@ -591,14 +591,14 @@ export class PdfDocMut {
|
|
|
591
591
|
*/
|
|
592
592
|
replaceImage(page_index: number, handle_json: string, data: Uint8Array): string;
|
|
593
593
|
/**
|
|
594
|
-
* G3
|
|
594
|
+
* G3 - Replace a text span on a page.
|
|
595
595
|
*
|
|
596
596
|
* The editor passes the **exact** text it extracted from
|
|
597
597
|
* `getTextPositions()` as `original_text`, and the desired
|
|
598
598
|
* replacement as `replacement_text`. The replacement is
|
|
599
599
|
* re-encoded into the same font used by the matched span
|
|
600
600
|
* (subset-font fallback applies when the original font cannot
|
|
601
|
-
* encode the replacement
|
|
601
|
+
* encode the replacement - see
|
|
602
602
|
* `pdf-manip::text_replace::replace_text`).
|
|
603
603
|
*
|
|
604
604
|
* `page_num` is **1-based** to match the rest of the
|
|
@@ -619,11 +619,11 @@ export class PdfDocMut {
|
|
|
619
619
|
*
|
|
620
620
|
* Typed unsupported codes (all set `replaced=false`):
|
|
621
621
|
*
|
|
622
|
-
* - `"NO_MATCH"`
|
|
623
|
-
* - `"ENCODING_UNSUPPORTED"`
|
|
622
|
+
* - `"NO_MATCH"` - `original_text` not found on the page.
|
|
623
|
+
* - `"ENCODING_UNSUPPORTED"` - replacement contains characters
|
|
624
624
|
* the matched font cannot encode and no fallback font is
|
|
625
625
|
* available.
|
|
626
|
-
* - `"REPLACE_FAILED"`
|
|
626
|
+
* - `"REPLACE_FAILED"` - anything else (lopdf I/O,
|
|
627
627
|
* serialisation, FontMap construction, …). `reason` carries
|
|
628
628
|
* the lower-level error message.
|
|
629
629
|
*
|
|
@@ -648,7 +648,7 @@ export class PdfDocMut {
|
|
|
648
648
|
/**
|
|
649
649
|
* Set a single AcroForm field value (text, checkbox, radio, or choice).
|
|
650
650
|
*
|
|
651
|
-
* Delegates to [`pdf_forms::apply_field_value`]
|
|
651
|
+
* Delegates to [`pdf_forms::apply_field_value`] - the single SDK
|
|
652
652
|
* writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
|
|
653
653
|
* per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
|
|
654
654
|
* fully-qualified names through `/Kids`, and rejects read-only fields.
|
|
@@ -767,7 +767,7 @@ export class TextEditor {
|
|
|
767
767
|
*
|
|
768
768
|
* # Errors
|
|
769
769
|
*
|
|
770
|
-
* All fallible methods throw a `PdfluentError`
|
|
770
|
+
* All fallible methods throw a `PdfluentError` - a standard `Error` subclass with
|
|
771
771
|
* these properties:
|
|
772
772
|
* - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
|
|
773
773
|
* (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
|
package/xfa_wasm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./xfa_wasm.d.ts" */
|
|
2
|
-
import { __pdfluent_error_ctor } from './snippets/xfa-wasm-
|
|
2
|
+
import { __pdfluent_error_ctor } from './snippets/xfa-wasm-d23d7ce846a87fdd/inline0.js';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -45,7 +45,7 @@ export const ChromaSampling = Object.freeze({
|
|
|
45
45
|
*
|
|
46
46
|
* # Errors
|
|
47
47
|
*
|
|
48
|
-
* All fallible methods throw a `PdfluentError`
|
|
48
|
+
* All fallible methods throw a `PdfluentError` - a standard `Error` subclass with
|
|
49
49
|
* these properties:
|
|
50
50
|
* - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
|
|
51
51
|
* (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
|
|
@@ -823,7 +823,7 @@ export class PdfDoc {
|
|
|
823
823
|
* Render a page directly to an HTML canvas element (wasm32 only).
|
|
824
824
|
*
|
|
825
825
|
* Calls `canvas.getContext("2d")`, sets the canvas dimensions to the
|
|
826
|
-
* rendered pixel size, and calls `putImageData`
|
|
826
|
+
* rendered pixel size, and calls `putImageData` - no round-trip through
|
|
827
827
|
* a JS Uint8Array. XFA documents are auto-flattened before rendering.
|
|
828
828
|
*
|
|
829
829
|
* ```js
|
|
@@ -1266,7 +1266,7 @@ export class PdfDocMut {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
/**
|
|
1268
1268
|
* Add a highlight annotation over the given page rectangle.
|
|
1269
|
-
* `color_hex` like `"#ffeb3b"`
|
|
1269
|
+
* `color_hex` like `"#ffeb3b"` - defaults to yellow when `None`.
|
|
1270
1270
|
* @param {number} page_index
|
|
1271
1271
|
* @param {number} x
|
|
1272
1272
|
* @param {number} y
|
|
@@ -1693,14 +1693,14 @@ export class PdfDocMut {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
1695
1695
|
/**
|
|
1696
|
-
* G3
|
|
1696
|
+
* G3 - Replace a text span on a page.
|
|
1697
1697
|
*
|
|
1698
1698
|
* The editor passes the **exact** text it extracted from
|
|
1699
1699
|
* `getTextPositions()` as `original_text`, and the desired
|
|
1700
1700
|
* replacement as `replacement_text`. The replacement is
|
|
1701
1701
|
* re-encoded into the same font used by the matched span
|
|
1702
1702
|
* (subset-font fallback applies when the original font cannot
|
|
1703
|
-
* encode the replacement
|
|
1703
|
+
* encode the replacement - see
|
|
1704
1704
|
* `pdf-manip::text_replace::replace_text`).
|
|
1705
1705
|
*
|
|
1706
1706
|
* `page_num` is **1-based** to match the rest of the
|
|
@@ -1721,11 +1721,11 @@ export class PdfDocMut {
|
|
|
1721
1721
|
*
|
|
1722
1722
|
* Typed unsupported codes (all set `replaced=false`):
|
|
1723
1723
|
*
|
|
1724
|
-
* - `"NO_MATCH"`
|
|
1725
|
-
* - `"ENCODING_UNSUPPORTED"`
|
|
1724
|
+
* - `"NO_MATCH"` - `original_text` not found on the page.
|
|
1725
|
+
* - `"ENCODING_UNSUPPORTED"` - replacement contains characters
|
|
1726
1726
|
* the matched font cannot encode and no fallback font is
|
|
1727
1727
|
* available.
|
|
1728
|
-
* - `"REPLACE_FAILED"`
|
|
1728
|
+
* - `"REPLACE_FAILED"` - anything else (lopdf I/O,
|
|
1729
1729
|
* serialisation, FontMap construction, …). `reason` carries
|
|
1730
1730
|
* the lower-level error message.
|
|
1731
1731
|
*
|
|
@@ -1813,7 +1813,7 @@ export class PdfDocMut {
|
|
|
1813
1813
|
/**
|
|
1814
1814
|
* Set a single AcroForm field value (text, checkbox, radio, or choice).
|
|
1815
1815
|
*
|
|
1816
|
-
* Delegates to [`pdf_forms::apply_field_value`]
|
|
1816
|
+
* Delegates to [`pdf_forms::apply_field_value`] - the single SDK
|
|
1817
1817
|
* writeback chain. It keeps `/V` (ASCII literal else UTF-16BE+BOM),
|
|
1818
1818
|
* per-widget `/AS`, and regenerated `/AP` streams consistent, resolves
|
|
1819
1819
|
* fully-qualified names through `/Kids`, and rejects read-only fields.
|
|
@@ -2191,7 +2191,7 @@ if (Symbol.dispose) TextEditor.prototype[Symbol.dispose] = TextEditor.prototype.
|
|
|
2191
2191
|
*
|
|
2192
2192
|
* # Errors
|
|
2193
2193
|
*
|
|
2194
|
-
* All fallible methods throw a `PdfluentError`
|
|
2194
|
+
* All fallible methods throw a `PdfluentError` - a standard `Error` subclass with
|
|
2195
2195
|
* these properties:
|
|
2196
2196
|
* - `code`: stable C8 catalogue identifier in `E-<CATEGORY>-<SPECIFIC>` format
|
|
2197
2197
|
* (e.g. `"E-PARSE-INVALID-PDF"`). Use this for programmatic dispatch.
|
|
@@ -2588,7 +2588,7 @@ export function signPdf(bytes, pkcs12, password, options) {
|
|
|
2588
2588
|
function __wbg_get_imports() {
|
|
2589
2589
|
const import0 = {
|
|
2590
2590
|
__proto__: null,
|
|
2591
|
-
|
|
2591
|
+
__wbg___pdfluent_error_ctor_ed1ceb6e41324c5c: function() {
|
|
2592
2592
|
const ret = __pdfluent_error_ctor();
|
|
2593
2593
|
return addHeapObject(ret);
|
|
2594
2594
|
},
|
package/xfa_wasm_bg.wasm
CHANGED
|
Binary file
|
|
File without changes
|