@lpdfio/lpdf 0.30.0 → 0.32.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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/_shared.d.ts +42 -3
- package/dist/_shared.js +52 -3
- package/dist/attrs.d.ts +580 -89
- package/dist/browser.js +125 -61
- package/dist/canvas.d.ts +10 -9
- package/dist/constants.d.ts +27 -0
- package/dist/constants.js +25 -1
- package/dist/engine.d.ts +23 -41
- package/dist/engine.js +114 -43
- package/dist/index.d.ts +3 -4
- package/dist/index.js +4 -1
- package/dist/kit.d.ts +97 -32
- package/dist/kit.js +7 -1
- package/dist/layout.d.ts +20 -19
- package/dist/markdown.d.ts +5 -4
- package/dist/wasm/lpdf-web.js +64 -50
- package/dist/wasm/lpdf.js +64 -50
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/wasm/lpdf-web.js
CHANGED
|
@@ -12,10 +12,17 @@ export class LpdfEngine {
|
|
|
12
12
|
wasm.__wbg_lpdfengine_free(ptr, 0);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Register the bytes of a file a document carries, for the `<file>` of its `<attachments>` whose `ref`, or with
|
|
16
|
+
* no ref whose name, is `name`. The PDF carries them as they are.
|
|
17
|
+
* @param {string} name
|
|
18
|
+
* @param {Uint8Array} bytes
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
wasm.
|
|
20
|
+
load_file(name, bytes) {
|
|
21
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22
|
+
const len0 = WASM_VECTOR_LEN;
|
|
23
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
24
|
+
const len1 = WASM_VECTOR_LEN;
|
|
25
|
+
wasm.lpdfengine_load_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Register raw font bytes (TTF/OTF) for a custom font name.
|
|
@@ -60,6 +67,19 @@ export class LpdfEngine {
|
|
|
60
67
|
const len1 = WASM_VECTOR_LEN;
|
|
61
68
|
wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
62
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
|
+
}
|
|
63
83
|
/**
|
|
64
84
|
* @param {string} license_key
|
|
65
85
|
*/
|
|
@@ -98,22 +118,38 @@ export class LpdfEngine {
|
|
|
98
118
|
* `json_data` is an optional JSON string used to resolve `data-*`
|
|
99
119
|
* attributes in the template. Pass `None` (or `null` / `undefined` from
|
|
100
120
|
* JavaScript) to render the template with its inline fallback content.
|
|
121
|
+
*
|
|
122
|
+
* The rest is for a document that asks for encryption in its `<output>`, which sets the cipher and
|
|
123
|
+
* the permissions: the passwords, which the template never holds, and `entropy`, at least 32 random
|
|
124
|
+
* bytes from the host's secure generator for AES-256. A document that asks for encryption needs an
|
|
125
|
+
* owner password, or `skip_encryption` to render it unencrypted, as a preview does; passwords for a
|
|
126
|
+
* document that doesn't ask for it are an error, and so are passwords with `skip_encryption`.
|
|
101
127
|
* @param {string} xml
|
|
102
|
-
* @param {string | null}
|
|
128
|
+
* @param {string | null | undefined} json_data
|
|
129
|
+
* @param {string | null | undefined} user_password
|
|
130
|
+
* @param {string | null | undefined} owner_password
|
|
131
|
+
* @param {boolean} skip_encryption
|
|
132
|
+
* @param {Uint8Array} entropy
|
|
103
133
|
* @returns {Uint8Array}
|
|
104
134
|
*/
|
|
105
|
-
render_pdf(xml, json_data) {
|
|
135
|
+
render_pdf(xml, json_data, user_password, owner_password, skip_encryption, entropy) {
|
|
106
136
|
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
107
137
|
const len0 = WASM_VECTOR_LEN;
|
|
108
138
|
var ptr1 = isLikeNone(json_data) ? 0 : passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
109
139
|
var len1 = WASM_VECTOR_LEN;
|
|
110
|
-
|
|
140
|
+
var ptr2 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
|
+
var len2 = WASM_VECTOR_LEN;
|
|
142
|
+
var ptr3 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
143
|
+
var len3 = WASM_VECTOR_LEN;
|
|
144
|
+
const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
145
|
+
const len4 = WASM_VECTOR_LEN;
|
|
146
|
+
const ret = wasm.lpdfengine_render_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, skip_encryption, ptr4, len4);
|
|
111
147
|
if (ret[3]) {
|
|
112
148
|
throw takeFromExternrefTable0(ret[2]);
|
|
113
149
|
}
|
|
114
|
-
var
|
|
150
|
+
var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
115
151
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
116
|
-
return
|
|
152
|
+
return v6;
|
|
117
153
|
}
|
|
118
154
|
/**
|
|
119
155
|
* @param {string} json
|
|
@@ -140,23 +176,37 @@ export class LpdfEngine {
|
|
|
140
176
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
|
141
177
|
* intermediate XML serialisation step. PHP, Python, and .NET adapters also
|
|
142
178
|
* use this entry point.
|
|
179
|
+
*
|
|
180
|
+
* The passwords, `skip_encryption` and `entropy` are those of `render_pdf`, for a document whose
|
|
181
|
+
* `output` asks for encryption.
|
|
143
182
|
* @param {string} json
|
|
183
|
+
* @param {string | null | undefined} user_password
|
|
184
|
+
* @param {string | null | undefined} owner_password
|
|
185
|
+
* @param {boolean} skip_encryption
|
|
186
|
+
* @param {Uint8Array} entropy
|
|
144
187
|
* @returns {Uint8Array}
|
|
145
188
|
*/
|
|
146
|
-
render_tree_pdf(json) {
|
|
189
|
+
render_tree_pdf(json, user_password, owner_password, skip_encryption, entropy) {
|
|
147
190
|
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
191
|
const len0 = WASM_VECTOR_LEN;
|
|
149
|
-
|
|
192
|
+
var ptr1 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
var len1 = WASM_VECTOR_LEN;
|
|
194
|
+
var ptr2 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
var len2 = WASM_VECTOR_LEN;
|
|
196
|
+
const ptr3 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
197
|
+
const len3 = WASM_VECTOR_LEN;
|
|
198
|
+
const ret = wasm.lpdfengine_render_tree_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, skip_encryption, ptr3, len3);
|
|
150
199
|
if (ret[3]) {
|
|
151
200
|
throw takeFromExternrefTable0(ret[2]);
|
|
152
201
|
}
|
|
153
|
-
var
|
|
202
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
154
203
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
155
|
-
return
|
|
204
|
+
return v5;
|
|
156
205
|
}
|
|
157
206
|
/**
|
|
158
|
-
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`
|
|
159
|
-
* When provided, written as `/CreationDate` in the PDF info dictionary
|
|
207
|
+
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`, `"2024-06-01T12:00:00.000Z"` or
|
|
208
|
+
* `"2024-06-01T12:00:00+01:00"`). When provided, written as `/CreationDate` in the PDF info dictionary, with
|
|
209
|
+
* the precision and the time zone it was given in; a value that is not a date makes the render an error.
|
|
160
210
|
* Omitting this keeps builds reproducible (no embedded timestamp).
|
|
161
211
|
* @param {string} iso
|
|
162
212
|
*/
|
|
@@ -165,42 +215,6 @@ export class LpdfEngine {
|
|
|
165
215
|
const len0 = WASM_VECTOR_LEN;
|
|
166
216
|
wasm.lpdfengine_set_created_on(this.__wbg_ptr, ptr0, len0);
|
|
167
217
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Configure encryption applied to every subsequent `render_pdf` call.
|
|
170
|
-
*
|
|
171
|
-
* `permissions_json` is a JSON object with boolean fields matching the
|
|
172
|
-
* `Permissions` struct (`print`, `modify`, `copy`, `annotate`, `fill_forms`,
|
|
173
|
-
* `accessibility`, `assemble`, `print_hq`). Omitted fields default to `true`.
|
|
174
|
-
*
|
|
175
|
-
* `algorithm` is `"aes-256"` or `"rc4-128"`. AES-256 needs `entropy`: at least 32
|
|
176
|
-
* random bytes from the host's secure generator, from which the core cuts the file
|
|
177
|
-
* key, salts and IVs. RC4-128 ignores it. Fails when the algorithm is unknown or
|
|
178
|
-
* AES-256 gets too little entropy.
|
|
179
|
-
*
|
|
180
|
-
* To apply permissions without an open password, pass an empty `user_password`
|
|
181
|
-
* and a non-empty `owner_password`.
|
|
182
|
-
* @param {string} user_password
|
|
183
|
-
* @param {string} owner_password
|
|
184
|
-
* @param {string} permissions_json
|
|
185
|
-
* @param {string} algorithm
|
|
186
|
-
* @param {Uint8Array} entropy
|
|
187
|
-
*/
|
|
188
|
-
set_encryption(user_password, owner_password, permissions_json, algorithm, entropy) {
|
|
189
|
-
const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
-
const len0 = WASM_VECTOR_LEN;
|
|
191
|
-
const ptr1 = passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
-
const len1 = WASM_VECTOR_LEN;
|
|
193
|
-
const ptr2 = passStringToWasm0(permissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
194
|
-
const len2 = WASM_VECTOR_LEN;
|
|
195
|
-
const ptr3 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
196
|
-
const len3 = WASM_VECTOR_LEN;
|
|
197
|
-
const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
198
|
-
const len4 = WASM_VECTOR_LEN;
|
|
199
|
-
const ret = wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
200
|
-
if (ret[1]) {
|
|
201
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
218
|
/**
|
|
205
219
|
* Inject glyph advance-width tables for custom fonts.
|
|
206
220
|
*
|
package/dist/wasm/lpdf.js
CHANGED
|
@@ -12,10 +12,17 @@ class LpdfEngine {
|
|
|
12
12
|
wasm.__wbg_lpdfengine_free(ptr, 0);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Register the bytes of a file a document carries, for the `<file>` of its `<attachments>` whose `ref`, or with
|
|
16
|
+
* no ref whose name, is `name`. The PDF carries them as they are.
|
|
17
|
+
* @param {string} name
|
|
18
|
+
* @param {Uint8Array} bytes
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
wasm.
|
|
20
|
+
load_file(name, bytes) {
|
|
21
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22
|
+
const len0 = WASM_VECTOR_LEN;
|
|
23
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
24
|
+
const len1 = WASM_VECTOR_LEN;
|
|
25
|
+
wasm.lpdfengine_load_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Register raw font bytes (TTF/OTF) for a custom font name.
|
|
@@ -60,6 +67,19 @@ class LpdfEngine {
|
|
|
60
67
|
const len1 = WASM_VECTOR_LEN;
|
|
61
68
|
wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
62
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
|
+
}
|
|
63
83
|
/**
|
|
64
84
|
* @param {string} license_key
|
|
65
85
|
*/
|
|
@@ -98,22 +118,38 @@ class LpdfEngine {
|
|
|
98
118
|
* `json_data` is an optional JSON string used to resolve `data-*`
|
|
99
119
|
* attributes in the template. Pass `None` (or `null` / `undefined` from
|
|
100
120
|
* JavaScript) to render the template with its inline fallback content.
|
|
121
|
+
*
|
|
122
|
+
* The rest is for a document that asks for encryption in its `<output>`, which sets the cipher and
|
|
123
|
+
* the permissions: the passwords, which the template never holds, and `entropy`, at least 32 random
|
|
124
|
+
* bytes from the host's secure generator for AES-256. A document that asks for encryption needs an
|
|
125
|
+
* owner password, or `skip_encryption` to render it unencrypted, as a preview does; passwords for a
|
|
126
|
+
* document that doesn't ask for it are an error, and so are passwords with `skip_encryption`.
|
|
101
127
|
* @param {string} xml
|
|
102
|
-
* @param {string | null}
|
|
128
|
+
* @param {string | null | undefined} json_data
|
|
129
|
+
* @param {string | null | undefined} user_password
|
|
130
|
+
* @param {string | null | undefined} owner_password
|
|
131
|
+
* @param {boolean} skip_encryption
|
|
132
|
+
* @param {Uint8Array} entropy
|
|
103
133
|
* @returns {Uint8Array}
|
|
104
134
|
*/
|
|
105
|
-
render_pdf(xml, json_data) {
|
|
135
|
+
render_pdf(xml, json_data, user_password, owner_password, skip_encryption, entropy) {
|
|
106
136
|
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
107
137
|
const len0 = WASM_VECTOR_LEN;
|
|
108
138
|
var ptr1 = isLikeNone(json_data) ? 0 : passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
109
139
|
var len1 = WASM_VECTOR_LEN;
|
|
110
|
-
|
|
140
|
+
var ptr2 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
|
+
var len2 = WASM_VECTOR_LEN;
|
|
142
|
+
var ptr3 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
143
|
+
var len3 = WASM_VECTOR_LEN;
|
|
144
|
+
const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
145
|
+
const len4 = WASM_VECTOR_LEN;
|
|
146
|
+
const ret = wasm.lpdfengine_render_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, skip_encryption, ptr4, len4);
|
|
111
147
|
if (ret[3]) {
|
|
112
148
|
throw takeFromExternrefTable0(ret[2]);
|
|
113
149
|
}
|
|
114
|
-
var
|
|
150
|
+
var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
115
151
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
116
|
-
return
|
|
152
|
+
return v6;
|
|
117
153
|
}
|
|
118
154
|
/**
|
|
119
155
|
* @param {string} json
|
|
@@ -140,23 +176,37 @@ class LpdfEngine {
|
|
|
140
176
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
|
141
177
|
* intermediate XML serialisation step. PHP, Python, and .NET adapters also
|
|
142
178
|
* use this entry point.
|
|
179
|
+
*
|
|
180
|
+
* The passwords, `skip_encryption` and `entropy` are those of `render_pdf`, for a document whose
|
|
181
|
+
* `output` asks for encryption.
|
|
143
182
|
* @param {string} json
|
|
183
|
+
* @param {string | null | undefined} user_password
|
|
184
|
+
* @param {string | null | undefined} owner_password
|
|
185
|
+
* @param {boolean} skip_encryption
|
|
186
|
+
* @param {Uint8Array} entropy
|
|
144
187
|
* @returns {Uint8Array}
|
|
145
188
|
*/
|
|
146
|
-
render_tree_pdf(json) {
|
|
189
|
+
render_tree_pdf(json, user_password, owner_password, skip_encryption, entropy) {
|
|
147
190
|
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
191
|
const len0 = WASM_VECTOR_LEN;
|
|
149
|
-
|
|
192
|
+
var ptr1 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
var len1 = WASM_VECTOR_LEN;
|
|
194
|
+
var ptr2 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
var len2 = WASM_VECTOR_LEN;
|
|
196
|
+
const ptr3 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
197
|
+
const len3 = WASM_VECTOR_LEN;
|
|
198
|
+
const ret = wasm.lpdfengine_render_tree_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, skip_encryption, ptr3, len3);
|
|
150
199
|
if (ret[3]) {
|
|
151
200
|
throw takeFromExternrefTable0(ret[2]);
|
|
152
201
|
}
|
|
153
|
-
var
|
|
202
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
154
203
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
155
|
-
return
|
|
204
|
+
return v5;
|
|
156
205
|
}
|
|
157
206
|
/**
|
|
158
|
-
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`
|
|
159
|
-
* When provided, written as `/CreationDate` in the PDF info dictionary
|
|
207
|
+
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`, `"2024-06-01T12:00:00.000Z"` or
|
|
208
|
+
* `"2024-06-01T12:00:00+01:00"`). When provided, written as `/CreationDate` in the PDF info dictionary, with
|
|
209
|
+
* the precision and the time zone it was given in; a value that is not a date makes the render an error.
|
|
160
210
|
* Omitting this keeps builds reproducible (no embedded timestamp).
|
|
161
211
|
* @param {string} iso
|
|
162
212
|
*/
|
|
@@ -165,42 +215,6 @@ class LpdfEngine {
|
|
|
165
215
|
const len0 = WASM_VECTOR_LEN;
|
|
166
216
|
wasm.lpdfengine_set_created_on(this.__wbg_ptr, ptr0, len0);
|
|
167
217
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Configure encryption applied to every subsequent `render_pdf` call.
|
|
170
|
-
*
|
|
171
|
-
* `permissions_json` is a JSON object with boolean fields matching the
|
|
172
|
-
* `Permissions` struct (`print`, `modify`, `copy`, `annotate`, `fill_forms`,
|
|
173
|
-
* `accessibility`, `assemble`, `print_hq`). Omitted fields default to `true`.
|
|
174
|
-
*
|
|
175
|
-
* `algorithm` is `"aes-256"` or `"rc4-128"`. AES-256 needs `entropy`: at least 32
|
|
176
|
-
* random bytes from the host's secure generator, from which the core cuts the file
|
|
177
|
-
* key, salts and IVs. RC4-128 ignores it. Fails when the algorithm is unknown or
|
|
178
|
-
* AES-256 gets too little entropy.
|
|
179
|
-
*
|
|
180
|
-
* To apply permissions without an open password, pass an empty `user_password`
|
|
181
|
-
* and a non-empty `owner_password`.
|
|
182
|
-
* @param {string} user_password
|
|
183
|
-
* @param {string} owner_password
|
|
184
|
-
* @param {string} permissions_json
|
|
185
|
-
* @param {string} algorithm
|
|
186
|
-
* @param {Uint8Array} entropy
|
|
187
|
-
*/
|
|
188
|
-
set_encryption(user_password, owner_password, permissions_json, algorithm, entropy) {
|
|
189
|
-
const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
-
const len0 = WASM_VECTOR_LEN;
|
|
191
|
-
const ptr1 = passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
-
const len1 = WASM_VECTOR_LEN;
|
|
193
|
-
const ptr2 = passStringToWasm0(permissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
194
|
-
const len2 = WASM_VECTOR_LEN;
|
|
195
|
-
const ptr3 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
196
|
-
const len3 = WASM_VECTOR_LEN;
|
|
197
|
-
const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
198
|
-
const len4 = WASM_VECTOR_LEN;
|
|
199
|
-
const ret = wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
200
|
-
if (ret[1]) {
|
|
201
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
218
|
/**
|
|
205
219
|
* Inject glyph advance-width tables for custom fonts.
|
|
206
220
|
*
|
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.32.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",
|