@lpdfio/lpdf 0.31.0 → 0.33.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 +2 -0
- package/dist/L.d.ts +8 -2
- package/dist/L.js +7 -2
- package/dist/_shared.d.ts +23 -3
- package/dist/_shared.js +19 -3
- package/dist/attrs.d.ts +600 -13
- package/dist/browser.js +282 -33
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +7 -1
- package/dist/engine.d.ts +58 -13
- package/dist/engine.js +185 -102
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/kit-to-xml.js +5 -4
- package/dist/kit.d.ts +87 -5
- package/dist/kit.js +11 -2
- package/dist/render-error.d.ts +11 -0
- package/dist/render-error.js +19 -0
- package/dist/render-job.d.ts +67 -0
- package/dist/render-job.js +74 -0
- package/dist/render-queue.d.ts +52 -0
- package/dist/render-queue.js +116 -0
- package/dist/render-worker.d.ts +1 -0
- package/dist/render-worker.js +16 -0
- package/dist/stamp.d.ts +51 -0
- package/dist/stamp.js +30 -0
- package/dist/wasm/lpdf-web.js +73 -2
- package/dist/wasm/lpdf.js +73 -2
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +2 -2
package/dist/wasm/lpdf.js
CHANGED
|
@@ -67,6 +67,19 @@ class LpdfEngine {
|
|
|
67
67
|
const len1 = WASM_VECTOR_LEN;
|
|
68
68
|
wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Register the bytes of an ICC colour profile, for the `<profile>` of a document's `<assets>` whose `ref`, or with
|
|
72
|
+
* no ref whose name, is `name`: the press profile a PDF/X document names in `<output profile>`.
|
|
73
|
+
* @param {string} name
|
|
74
|
+
* @param {Uint8Array} bytes
|
|
75
|
+
*/
|
|
76
|
+
load_profile(name, bytes) {
|
|
77
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
80
|
+
const len1 = WASM_VECTOR_LEN;
|
|
81
|
+
wasm.lpdfengine_load_profile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
82
|
+
}
|
|
70
83
|
/**
|
|
71
84
|
* @param {string} license_key
|
|
72
85
|
*/
|
|
@@ -222,6 +235,20 @@ class LpdfEngine {
|
|
|
222
235
|
const len0 = WASM_VECTOR_LEN;
|
|
223
236
|
wasm.lpdfengine_set_font_metrics(this.__wbg_ptr, ptr0, len0);
|
|
224
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Set the memory a render may allocate, in megabytes: 1024 when it isn't set. A render that needs more stops
|
|
240
|
+
* with an error that names the cap. What the engine holds before the render, such as its loaded fonts, doesn't
|
|
241
|
+
* count.
|
|
242
|
+
*
|
|
243
|
+
* Returns an error when `mb` is 0 or above 4096, the most 32-bit WebAssembly addresses.
|
|
244
|
+
* @param {number} mb
|
|
245
|
+
*/
|
|
246
|
+
set_max_memory_mb(mb) {
|
|
247
|
+
const ret = wasm.lpdfengine_set_max_memory_mb(this.__wbg_ptr, mb);
|
|
248
|
+
if (ret[1]) {
|
|
249
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
225
252
|
/**
|
|
226
253
|
* Set the current Unix timestamp (seconds) for license expiry checking.
|
|
227
254
|
* Must be called before `render_pdf` when using a time-limited token.
|
|
@@ -231,6 +258,32 @@ class LpdfEngine {
|
|
|
231
258
|
set_now(unix) {
|
|
232
259
|
wasm.lpdfengine_set_now(this.__wbg_ptr, unix);
|
|
233
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Draw PNG stamps over the pages of an existing PDF, and return the file with them added as an incremental
|
|
263
|
+
* update: the input, byte for byte, then the images and the pages they change. The original bytes stay as they
|
|
264
|
+
* were, so an owner password and its permissions stay, and so does a digital signature's revision.
|
|
265
|
+
*
|
|
266
|
+
* `stamps` is a JSON list of stamps, each with an `image`, the name of a PNG loaded with `load_image`, a `page`
|
|
267
|
+
* scope, a box (`x`, `y`, `anchor`, `width`, `height`, placed as a layer element is) and how the image sits in it
|
|
268
|
+
* (`align`, `justify`, `scale`, `max-grow`). Without a valid license key, each stamped page gets the attribution
|
|
269
|
+
* line of a render in its top-right corner.
|
|
270
|
+
* @param {Uint8Array} pdf
|
|
271
|
+
* @param {string} stamps
|
|
272
|
+
* @returns {Uint8Array}
|
|
273
|
+
*/
|
|
274
|
+
stamp(pdf, stamps) {
|
|
275
|
+
const ptr0 = passArray8ToWasm0(pdf, wasm.__wbindgen_malloc);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
const ptr1 = passStringToWasm0(stamps, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
const len1 = WASM_VECTOR_LEN;
|
|
279
|
+
const ret = wasm.lpdfengine_stamp(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
280
|
+
if (ret[3]) {
|
|
281
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
282
|
+
}
|
|
283
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
284
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
285
|
+
return v3;
|
|
286
|
+
}
|
|
234
287
|
}
|
|
235
288
|
if (Symbol.dispose) LpdfEngine.prototype[Symbol.dispose] = LpdfEngine.prototype.free;
|
|
236
289
|
exports.LpdfEngine = LpdfEngine;
|
|
@@ -281,7 +334,7 @@ exports.check_license = check_license;
|
|
|
281
334
|
* in multiple target languages.
|
|
282
335
|
*
|
|
283
336
|
* `options_json` accepts the same shape as `codegen_wasm`:
|
|
284
|
-
* - `target`: `"js"`, `"dotnet"`, `"php"`, or `"
|
|
337
|
+
* - `target`: `"js"`, `"dotnet"`, `"php"`, `"python"` or `"java"` (required)
|
|
285
338
|
* - `indent`: `2` or `4` (optional, default `4`)
|
|
286
339
|
* @param {string} xml
|
|
287
340
|
* @param {string} options_json
|
|
@@ -315,7 +368,7 @@ exports.codegen_fragment_wasm = codegen_fragment_wasm;
|
|
|
315
368
|
* Generate SDK source code from an Lpdf XML string.
|
|
316
369
|
*
|
|
317
370
|
* `options_json` is a JSON object with:
|
|
318
|
-
* - `target`: `"js"` (required)
|
|
371
|
+
* - `target`: `"js"`, `"dotnet"`, `"php"`, `"python"` or `"java"` (required)
|
|
319
372
|
* - `indent`: `2` or `4` (optional, default `4`)
|
|
320
373
|
*
|
|
321
374
|
* Returns the generated source code as a string.
|
|
@@ -516,6 +569,9 @@ function __wbg_get_imports() {
|
|
|
516
569
|
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
517
570
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
518
571
|
},
|
|
572
|
+
__wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
|
|
573
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
574
|
+
}, arguments); },
|
|
519
575
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
520
576
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
521
577
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
@@ -541,6 +597,12 @@ const LpdfEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
541
597
|
? { register: () => {}, unregister: () => {} }
|
|
542
598
|
: new FinalizationRegistry(ptr => wasm.__wbg_lpdfengine_free(ptr >>> 0, 1));
|
|
543
599
|
|
|
600
|
+
function addToExternrefTable0(obj) {
|
|
601
|
+
const idx = wasm.__externref_table_alloc();
|
|
602
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
603
|
+
return idx;
|
|
604
|
+
}
|
|
605
|
+
|
|
544
606
|
function getArrayU8FromWasm0(ptr, len) {
|
|
545
607
|
ptr = ptr >>> 0;
|
|
546
608
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -559,6 +621,15 @@ function getUint8ArrayMemory0() {
|
|
|
559
621
|
return cachedUint8ArrayMemory0;
|
|
560
622
|
}
|
|
561
623
|
|
|
624
|
+
function handleError(f, args) {
|
|
625
|
+
try {
|
|
626
|
+
return f.apply(this, args);
|
|
627
|
+
} catch (e) {
|
|
628
|
+
const idx = addToExternrefTable0(e);
|
|
629
|
+
wasm.__wbindgen_exn_store(idx);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
562
633
|
function isLikeNone(x) {
|
|
563
634
|
return x === undefined || x === null;
|
|
564
635
|
}
|
package/dist/wasm/lpdf_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lpdfio/lpdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Node.js SDK for Lpdf — PDF as Code on every platform. You describe a document as code or XML. Lpdf renders a compact, pixel-perfect PDF — identical across platforms.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build": "tsc && node build-browser.mjs && node -e \"require('node:fs').cpSync('./wasm', './dist/wasm', {recursive:true})\"",
|
|
20
20
|
"build:node": "tsc",
|
|
21
21
|
"build:browser": "node build-browser.mjs",
|
|
22
|
-
"test": "node --test test/render.test.mjs test/package-entry.test.mjs"
|
|
22
|
+
"test": "node --test test/render.test.mjs test/package-entry.test.mjs test/timeout.test.mjs test/memory.test.mjs test/stamp.test.mjs"
|
|
23
23
|
},
|
|
24
24
|
"author": "lpdf.io",
|
|
25
25
|
"homepage": "https://lpdf.io",
|