kura-pdf-wasm 1.2.0 → 1.2.1

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
@@ -36,7 +36,7 @@ npx kura-wasm --level 2b -r -d out/ inbox/
36
36
  npx kura-wasm --help
37
37
  ```
38
38
 
39
- Exit status: 0 on success, 1 when check mode found findings, 2 when the input was rejected, 64 on a usage error.
39
+ The output path is optional: left out, the result is written next to the input as `<input>.<level>.pdf`. Exit status: 0 on success, 1 when check mode found findings, 2 when the input was rejected, 64 on a usage error.
40
40
 
41
41
  ## API
42
42
 
package/bin/kura.js CHANGED
@@ -10,9 +10,9 @@ const EXIT_FINDINGS = 1;
10
10
  const EXIT_REJECTED = 2;
11
11
  const EXIT_USAGE = 64;
12
12
 
13
- const USAGE = `usage: kura --level {1b,1a,2b,2u,2a,3b,3u,3a,4,4f,4e,x1a,x3,x4,x6,e1,vt1,vt3} [--ua] [--lang <tag>] (check only: x4p,x5g,x5n,x5pg,x6n,x6p,vt2) [--output-condition <name>] [--output-condition-info <text>] [--registry <url>] [--vt-records <ranges>] [--allow-visual-risk] [--password <pw>] <input.pdf> <output.pdf>
13
+ const USAGE = `usage: kura --level {1b,1a,2b,2u,2a,3b,3u,3a,4,4f,4e,x1a,x3,x4,x6,e1,vt1,vt3} [--ua] [--lang <tag>] (check only: x4p,x5g,x5n,x5pg,x6n,x6p,vt2) [--output-condition <name>] [--output-condition-info <text>] [--registry <url>] [--vt-records <ranges>] [--allow-visual-risk] [--password <pw>] <input.pdf> [output.pdf]
14
14
  kura --check --level <level> [options] <input.pdf>
15
- kura --einvoice <invoice.xml> [--level 3b|3u|3a] <input.pdf> <output.pdf>
15
+ kura --einvoice <invoice.xml> [--level 3b|3u|3a] <input.pdf> [output.pdf]
16
16
  kura --level <level> --batch [-r] [-d <dir>] [-s <suffix>] [-w] <folder>
17
17
 
18
18
  exit status: 0 ok, 1 check found findings, 2 input rejected, 64 usage error`;
@@ -50,8 +50,15 @@ function usage() {
50
50
  return EXIT_USAGE;
51
51
  }
52
52
 
53
- function report(file, r, opts, level) {
53
+ function defaultOutput(input, level, ua) {
54
+ const m = input.match(/\.(pdf|jpe?g)$/i);
55
+ const base = m ? input.slice(0, -m[0].length) : input;
56
+ return `${base}.${level}${ua ? '-ua' : ''}.pdf`;
57
+ }
58
+
59
+ function report(file, r, opts, level, output) {
54
60
  const out = { file, ok: r.ok };
61
+ if (output) out.output = output;
55
62
  if (r.level) out.level = r.level;
56
63
  else if (level) out.level = level;
57
64
  if (r.engine) out.engine = r.engine;
@@ -92,7 +99,7 @@ async function runOne(input, output, level, opts, embedSource) {
92
99
  console.error(`cannot write ${output}`);
93
100
  return EXIT_REJECTED;
94
101
  }
95
- console.log(report(input, { ok: true, ...r }, opts, level));
102
+ console.log(report(input, { ok: true, ...r }, opts, level, output));
96
103
  return EXIT_OK;
97
104
  } catch (e) {
98
105
  if (!(e instanceof KuraError)) throw e;
@@ -201,8 +208,10 @@ async function main(argv) {
201
208
  if (batch.active) {
202
209
  if (output !== null) return usage();
203
210
  if (!opts.check && !batch.outDir && !batch.suffix && !batch.overwrite) batch.suffix = '_pdfa';
204
- } else if (opts.check ? output !== null : output === null) {
205
- return usage();
211
+ } else if (opts.check) {
212
+ if (output !== null) return usage();
213
+ } else if (output === null) {
214
+ output = defaultOutput(input, level, !!opts.ua);
206
215
  }
207
216
 
208
217
  if (!batch.active) return runOne(input, output, level, opts, embedSource);
package/engine/kura.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kura-pdf-wasm",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Kura, the open source PDF standards and preflight engine by BentoPDF, compiled to WebAssembly: runs on any platform and in browsers, no native binaries.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",