-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.html
More file actions
997 lines (936 loc) · 56.7 KB
/
Copy pathcli.html
File metadata and controls
997 lines (936 loc) · 56.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CLI Command Builder — pdfnative-cli playground</title>
<meta name="description" content="Interactive command-builder for pdfnative-cli — assemble render, sign, inspect, verify, merge, split, extract, annotate, and govern invocations with a live shell preview. Zero install.">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://pdfnative.dev/playgrounds/cli.html">
<link rel="alternate" hreflang="en" href="https://pdfnative.dev/playgrounds/cli.html">
<link rel="alternate" hreflang="x-default" href="https://pdfnative.dev/playgrounds/cli.html">
<meta property="og:type" content="website">
<meta property="og:site_name" content="pdfnative">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="https://pdfnative.dev/playgrounds/cli.html">
<meta property="og:title" content="CLI Command Builder — pdfnative-cli playground">
<meta property="og:description" content="Interactive command-builder for pdfnative-cli — assemble render, sign, inspect, verify, merge, split, extract, annotate and govern invocations with full flag coverage. Live shell preview, copy-to-clipboard, validation. Zero install.">
<meta property="og:image" content="https://pdfnative.dev/assets/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="CLI Command Builder — pdfnative-cli playground">
<meta name="twitter:description" content="Assemble render, sign, inspect, verify, merge, split, extract, annotate and govern commands with full flag coverage. Live shell preview. Zero install.">
<meta name="twitter:image" content="https://pdfnative.dev/assets/og-image.png">
<link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="stylesheet" href="../style.css">
<link rel="stylesheet" href="../guides/guide.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css" integrity="sha384-wFjoQjtV1y5jVHbt0p35Ui8aV8GVpEZkyF99OXWqP/eNJDU93D3Ugxkoyh6Y2I4A" crossorigin="anonymous">
<style>
.cli-tabs { display: flex; gap: 4px; margin: 24px 0 0; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.cli-tab { padding: 10px 18px; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--c-text-dim); cursor: pointer; font-size: 14px; font-weight: 600; }
.cli-tab:hover { color: var(--c-text); }
.cli-tab[aria-selected="true"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.cli-tab .new-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--c-success); color: #fff; font-size: 10px; font-weight: 700; vertical-align: middle; }
.cli-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-top: 24px; }
.cli-form .full { grid-column: 1 / -1; }
.cli-form label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text); margin-bottom: 4px; }
.cli-form .hint { display: block; font-size: 12px; color: var(--c-text-dim); margin-top: 2px; line-height: 1.4; }
.cli-form input[type="text"],
.cli-form input[type="number"],
.cli-form select,
.cli-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--c-bg); color: var(--c-text); }
.cli-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 70px; resize: vertical; }
.cli-form input[type="checkbox"] { margin-right: 6px; vertical-align: middle; }
.cli-form fieldset { grid-column: 1 / -1; border: 1px solid var(--c-border); border-radius: 8px; padding: 14px 16px 12px; margin: 8px 0 0; }
.cli-form legend { padding: 0 8px; font-size: 13px; font-weight: 700; color: var(--c-text); }
.cli-form fieldset > .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.cli-preview { margin-top: 28px; }
.cli-preview h3 { font-size: 16px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cli-preview pre { background: var(--c-code-bg); color: var(--c-code-text); padding: 16px; border-radius: 8px; font-size: 13px; overflow-x: auto; line-height: 1.5; }
.cli-preview .copy-btn { padding: 4px 10px; font-size: 12px; background: var(--c-primary); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; }
.cli-preview .copy-btn:hover { background: var(--c-accent); }
.cli-validation { margin-top: 14px; padding: 12px 14px; border-radius: 6px; font-size: 13px; line-height: 1.5; display: none; }
.cli-validation.error { display: block; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
[data-theme="dark"] .cli-validation.error { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
.cli-validation.warn { display: block; background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; }
[data-theme="dark"] .cli-validation.warn { background: #422006; border-color: #92400e; color: #fde68a; }
.cli-presets { display: flex; gap: 8px; align-items: center; margin: 18px 0 0; flex-wrap: wrap; }
.cli-presets select { padding: 6px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13px; background: var(--c-bg); color: var(--c-text); }
.cli-panel { display: none; }
.cli-panel.active { display: block; }
@media (max-width: 768px) { .cli-form, .cli-form fieldset > .grid { grid-template-columns: 1fr; } }
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"inLanguage": "en",
"name": "pdfnative-cli Command Builder",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any (browser-based)",
"browserRequirements": "Requires JavaScript and HTML5",
"url": "https://pdfnative.dev/playgrounds/cli.html",
"description": "Interactive command-builder for pdfnative-cli — assemble render, sign, inspect, verify, merge, split, extract, annotate and govern invocations with a live shell preview.",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
"isPartOf": { "@type": "WebSite", "name": "pdfnative", "url": "https://pdfnative.dev" },
"author": { "@type": "Organization", "name": "Nizoka", "url": "https://github.com/Nizoka" }
}
</script>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to main content</a>
<nav class="nav" role="navigation" aria-label="Main navigation">
<div class="nav-inner">
<a class="nav-brand" href="../">
<img src="../assets/logo.svg" alt="" width="28" height="28">
pdfnative
</a>
<button class="nav-hamburger" aria-label="Toggle menu" aria-expanded="false">☰</button>
<ul class="nav-links" role="list">
<li><a href="../#features">Features</a></li>
<li><a href="../#examples">Examples</a></li>
<li><a href="../#demo">Demo</a></li>
<li><a href="../#mcp">MCP</a></li>
<li><a href="../#cli">CLI</a></li>
<li><a href="../#react">React</a></li>
<li><a href="../guides/">Guides</a></li>
<li><a href="./">Playgrounds</a></li>
<li><a href="https://github.com/Nizoka/pdfnative" target="_blank" rel="noopener">GitHub</a></li>
<li><button class="theme-toggle" aria-label="Toggle dark mode">🌙</button></li>
</ul>
</div>
</nav>
<!-- Live version strip (compact) -->
<div class="pn-version-strip" data-mode="compact" aria-label="Live published versions"></div>
<main class="guide-shell" id="main-content" tabindex="-1">
<p class="guide-breadcrumb"><a href="../">Home</a> › <a href="./">Playgrounds</a> › CLI command builder</p>
<nav class="playground-switcher" aria-label="Playground switcher">
<span class="playground-switcher-label">Playgrounds:</span>
<a href="./extreme-scripts.html">Extreme scripts</a>
<a href="./all-scripts.html">All 22 scripts</a>
<a href="./toolkit.html">PDF Toolkit</a>
<a href="./charts.html">Charts</a>
<a href="./authoring-plus.html">Authoring+</a>
<a href="./scale.html">Scale</a>
<a href="./cli.html" aria-current="page">CLI builder</a>
<a href="./mcp.html">MCP explorer</a>
<a href="./react.html">React renderer</a>
<a href="./" style="margin-left:auto;">All →</a>
</nav>
<article class="guide-content">
<h1>pdfnative-cli command builder</h1>
<p>Pick a command, fill the form, copy the resulting <code>npx pdfnative-cli</code> invocation. Covers nine of the seventeen commands — see the <a href="../guides/cli.html">CLI guide</a> for the rest: <code>render</code> (with <code>--outline</code> / <code>--font math</code> / <code>--inspect-layout</code>), <code>sign</code> (RSA + ECDSA-SHA256, native constant-time crypto, <code>--pure-crypto</code> opt-out), <code>inspect</code> (with <code>--annotations</code>), <code>verify</code>, and the v1.2.0 page-tree / governance commands <code>merge</code>, <code>split</code>, <code>extract</code>, <code>annotate</code> and <code>govern</code>. The v1.3.0 additions — <code>fill</code>, <code>encrypt</code>, <code>decrypt</code>, <code>extract-text</code> and <code>doctor</code> — have no tab yet; their full flag reference is in the <a href="../guides/cli.html">CLI guide</a>. The builder runs entirely in your browser — nothing is uploaded.</p>
<div class="cli-presets">
<label for="preset"><strong>Quick preset:</strong></label>
<select id="preset">
<option value="">— blank —</option>
<option value="render-basic">render · basic document</option>
<option value="render-pdfa">render · PDF/A-2b + compress</option>
<option value="render-watermark">render · watermarked draft</option>
<option value="render-encrypted">render · AES-256 encrypted</option>
<option value="render-headers">render · header / footer with placeholders</option>
<option value="render-attachment">render · PDF/A-3 with attachment</option>
<option value="render-table">render · table variant + layout file</option>
<option value="sign-meta">sign · with metadata + cert chain</option>
<option value="inspect-check">inspect · CI assertions</option>
<option value="inspect-annotations">inspect · list annotations + page labels · v1.2</option>
<option value="verify-strict">verify · strict + trust roots</option>
<option value="render-outline-math">render · bookmarks (auto) + math font · v1.2</option>
<option value="merge-basic">merge · combine PDFs · v1.2</option>
<option value="split-ranges">split · by page ranges · v1.2</option>
<option value="extract-pages">extract · selected pages · v1.2</option>
<option value="annotate-notes">annotate · markup from JSON · v1.2</option>
<option value="govern-verify">govern · verify-issue draft · v1.2</option>
</select>
<button id="reset" class="btn btn-secondary" style="padding: 6px 14px; font-size: 13px;">Reset</button>
</div>
<div class="cli-tabs" role="tablist">
<button class="cli-tab" role="tab" aria-selected="true" data-tab="render">render</button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="sign">sign</button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="inspect">inspect</button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="verify">verify</button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="merge">merge<span class="new-badge">v1.2</span></button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="split">split<span class="new-badge">v1.2</span></button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="extract">extract<span class="new-badge">v1.2</span></button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="annotate">annotate<span class="new-badge">v1.2</span></button>
<button class="cli-tab" role="tab" aria-selected="false" data-tab="govern">govern<span class="new-badge">v1.2</span></button>
</div>
<!-- ─────────────── RENDER ─────────────── -->
<section class="cli-panel active" data-panel="render">
<div class="cli-form">
<div>
<label for="r-input">--input</label>
<input id="r-input" type="text" data-cmd="render" data-flag="--input" placeholder="document.json">
<span class="hint">Path to JSON input. Omit to read from stdin.</span>
</div>
<div>
<label for="r-output">--output</label>
<input id="r-output" type="text" data-cmd="render" data-flag="--output" placeholder="report.pdf">
<span class="hint">Output path. Omit to write to stdout.</span>
</div>
<div>
<label for="r-variant">--variant</label>
<select id="r-variant" data-cmd="render" data-flag="--variant">
<option value="">document (default)</option>
<option value="document">document</option>
<option value="table">table</option>
</select>
<span class="hint">Selects the renderer variant.</span>
</div>
<div>
<label for="r-page-size">--page-size</label>
<select id="r-page-size" data-cmd="render" data-flag="--page-size">
<option value="">a4 (default)</option>
<option value="a4">a4</option>
<option value="letter">letter</option>
<option value="legal">legal</option>
<option value="a3">a3</option>
<option value="tabloid">tabloid</option>
<option value="a5">a5</option>
<option value="__custom__">custom WxH…</option>
</select>
<input id="r-page-size-custom" type="text" placeholder="595x842" style="margin-top: 6px; display: none;" data-cmd="render" data-flag="--page-size-custom">
</div>
<div>
<label for="r-margin">--margin</label>
<input id="r-margin" type="text" data-cmd="render" data-flag="--margin" placeholder="50 or 60,50,60,50">
<span class="hint">Single value or top,right,bottom,left in points.</span>
</div>
<div>
<label for="r-tagged">--tagged</label>
<select id="r-tagged" data-cmd="render" data-flag="--tagged">
<option value="">none (default)</option>
<option value="pdfa1b">pdfa1b</option>
<option value="pdfa2b">pdfa2b</option>
<option value="pdfa2u">pdfa2u</option>
<option value="pdfa3b">pdfa3b</option>
</select>
</div>
<div>
<label><input type="checkbox" data-cmd="render" data-flag="--compress"> --compress</label>
<span class="hint">FlateDecode all content streams.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="render" data-flag="--stream"> --stream</label>
<span class="hint">AsyncGenerator streaming output.</span>
</div>
<div class="full">
<label for="r-layout">--layout (file path)</label>
<input id="r-layout" type="text" data-cmd="render" data-flag="--layout" placeholder="layout.json">
<span class="hint">Load any subset of <code>PdfLayoutOptions</code>. CLI flags override the layout file.</span>
</div>
<div class="full">
<label for="r-lang">--lang</label>
<input id="r-lang" type="text" data-cmd="render" data-flag="--lang" placeholder="th,ja,ar">
<span class="hint">Comma-separated language codes. Non-Latin scripts need their font registered — pass the same code to <code>--font</code> (22 bundled scripts).</span>
</div>
<fieldset>
<legend>Iteration helpers</legend>
<div class="grid">
<div>
<label><input type="checkbox" data-cmd="render" data-flag="--watch"> --watch</label>
<span class="hint">Re-render when the <code>--input</code> file changes (only that file is watched). Requires <code>--input</code> + a file <code>--output</code>.</span>
</div>
<div>
<label for="r-template">--template</label>
<input id="r-template" type="text" data-cmd="render" data-flag="--template" placeholder="vars.json">
<span class="hint">Base document JSON: the input (stdin or <code>--input</code>) is deep-merged on top — caller wins, arrays replace. Not variable substitution.</span>
</div>
<div>
<label for="r-font">--font</label>
<select id="r-font" data-cmd="render" data-flag="--font">
<option value="">— none —</option>
<option value="latin">latin (Noto Sans VF)</option>
<option value="emoji">emoji (Noto Emoji)</option>
<option value="math">math (Noto Sans Math) · v1.2</option>
<option value="latin,emoji">latin,emoji</option>
<option value="latin,math">latin,math</option>
</select>
<span class="hint">Bundled font codes — besides these, any of the 22 script codes (<code>ar</code>, <code>th</code>, <code>ja</code>…) works and doubles as the <code>--lang</code> code.</span>
</div>
</div>
</fieldset>
<fieldset>
<legend>Bookmarks, math & layout <span class="new-badge" style="background:var(--c-success);color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;">v1.2</span></legend>
<div class="grid">
<div>
<label for="r-outline">--outline</label>
<input id="r-outline" type="text" data-cmd="render" data-flag="--outline" placeholder="auto or outline.json">
<span class="hint">Add a <code>/Outlines</code> bookmark tree. <code>auto</code> derives it from headings.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="render" data-flag="--inspect-layout"> --inspect-layout</label>
<span class="hint">Emit a <code>LayoutInspection</code> JSON report instead of a PDF.</span>
</div>
<div>
<label for="r-debug-layout">--debug-layout</label>
<input id="r-debug-layout" type="text" data-cmd="render" data-flag="--debug-layout" placeholder="margins,content,cells">
<span class="hint">Overlay layout-debug guides on a normal PDF.</span>
</div>
</div>
</fieldset>
<fieldset>
<legend>Watermark</legend>
<div class="grid">
<div>
<label for="r-wm-text">--watermark-text</label>
<input id="r-wm-text" type="text" data-cmd="render" data-flag="--watermark-text" placeholder="DRAFT">
</div>
<div>
<label for="r-wm-image">--watermark-image</label>
<input id="r-wm-image" type="text" data-cmd="render" data-flag="--watermark-image" placeholder="logo.png">
</div>
<div>
<label for="r-wm-opacity">--watermark-opacity</label>
<input id="r-wm-opacity" type="text" data-cmd="render" data-flag="--watermark-opacity" placeholder="0.15">
</div>
<div>
<label for="r-wm-angle">--watermark-angle</label>
<input id="r-wm-angle" type="text" data-cmd="render" data-flag="--watermark-angle" placeholder="-30">
</div>
<div>
<label for="r-wm-color">--watermark-color</label>
<input id="r-wm-color" type="text" data-cmd="render" data-flag="--watermark-color" placeholder="#cccccc">
</div>
<div>
<label for="r-wm-size">--watermark-font-size</label>
<input id="r-wm-size" type="text" data-cmd="render" data-flag="--watermark-font-size" placeholder="72">
</div>
<div>
<label for="r-wm-pos">--watermark-position</label>
<select id="r-wm-pos" data-cmd="render" data-flag="--watermark-position">
<option value="">background (default)</option>
<option value="background">background</option>
<option value="foreground">foreground</option>
</select>
</div>
</div>
</fieldset>
<fieldset>
<legend>Headers / footers</legend>
<div class="grid">
<div><label for="r-hl">--header-left</label><input id="r-hl" type="text" data-cmd="render" data-flag="--header-left" placeholder="{title}"></div>
<div><label for="r-hc">--header-center</label><input id="r-hc" type="text" data-cmd="render" data-flag="--header-center"></div>
<div><label for="r-hr">--header-right</label><input id="r-hr" type="text" data-cmd="render" data-flag="--header-right" placeholder="{date}"></div>
<div><label for="r-fl">--footer-left</label><input id="r-fl" type="text" data-cmd="render" data-flag="--footer-left"></div>
<div><label for="r-fc">--footer-center</label><input id="r-fc" type="text" data-cmd="render" data-flag="--footer-center" placeholder="Page {page} / {pages}"></div>
<div><label for="r-fr">--footer-right</label><input id="r-fr" type="text" data-cmd="render" data-flag="--footer-right"></div>
</div>
<span class="hint" style="margin-top: 8px; display: block;">Placeholders: <code>{page}</code>, <code>{pages}</code>, <code>{date}</code>, <code>{title}</code>. <code>{pages}</code> is rejected with <code>--stream</code>.</span>
</fieldset>
<fieldset>
<legend>Encryption (mutually exclusive with <code>--tagged pdfa*</code>)</legend>
<div class="grid">
<div>
<label for="r-enc-owner">--encrypt-owner-pass</label>
<input id="r-enc-owner" type="text" data-cmd="render" data-flag="--encrypt-owner-pass" placeholder="$PDFNATIVE_ENCRYPT_OWNER_PASS">
<span class="hint">Required if any <code>--encrypt-*</code> flag is set. Prefer the env var.</span>
</div>
<div>
<label for="r-enc-user">--encrypt-user-pass</label>
<input id="r-enc-user" type="text" data-cmd="render" data-flag="--encrypt-user-pass">
</div>
<div>
<label for="r-enc-algo">--encrypt-algorithm</label>
<select id="r-enc-algo" data-cmd="render" data-flag="--encrypt-algorithm">
<option value="">aes128 (default)</option>
<option value="aes128">aes128</option>
<option value="aes256">aes256</option>
</select>
</div>
<div>
<label for="r-enc-perm">--encrypt-permissions</label>
<input id="r-enc-perm" type="text" data-cmd="render" data-flag="--encrypt-permissions" placeholder="print,copy">
</div>
</div>
<span class="hint" style="margin-top: 8px; display: block;">Since v1.3.0 the CLI also has a unified encryption vocabulary shared by <code>render</code> / <code>merge</code> / <code>split</code> / <code>extract</code> — <code>--encrypt aes-128|aes-256</code>, <code>--owner-password</code>, <code>--user-password</code>, <code>--permissions</code>. See the <a href="../guides/cli.html">CLI guide</a>.</span>
</fieldset>
<fieldset>
<legend>PDF/A-3 attachments</legend>
<div>
<label for="r-attach">--attachment (one per line)</label>
<textarea id="r-attach" data-cmd="render" data-flag="--attachment" placeholder="factur-x.xml:application/xml:Source:Structured invoice data"></textarea>
<span class="hint">Format: <code>path[:mime[:relationship[:description]]]</code>. Repeatable.</span>
</div>
</fieldset>
</div>
</section>
<!-- ─────────────── SIGN ─────────────── -->
<section class="cli-panel" data-panel="sign">
<div class="cli-form">
<div>
<label for="s-input">--input</label>
<input id="s-input" type="text" data-cmd="sign" data-flag="--input" placeholder="report.pdf">
</div>
<div>
<label for="s-output">--output</label>
<input id="s-output" type="text" data-cmd="sign" data-flag="--output" placeholder="signed.pdf">
</div>
<div>
<label for="s-key">--key</label>
<input id="s-key" type="text" data-cmd="sign" data-flag="--key" placeholder="key.pem">
<span class="hint">Or set <code>$PDFNATIVE_SIGN_KEY</code>.</span>
</div>
<div>
<label for="s-cert">--cert</label>
<input id="s-cert" type="text" data-cmd="sign" data-flag="--cert" placeholder="cert.pem">
<span class="hint">Or set <code>$PDFNATIVE_SIGN_CERT</code>.</span>
</div>
<div class="full">
<label for="s-chain">--cert-chain (one per line)</label>
<textarea id="s-chain" data-cmd="sign" data-flag="--cert-chain" placeholder="intermediate.pem"></textarea>
<span class="hint">Repeatable. Or set <code>$PDFNATIVE_SIGN_CHAIN</code>.</span>
</div>
<div>
<label for="s-algo">--algorithm</label>
<select id="s-algo" data-cmd="sign" data-flag="--algorithm">
<option value="">rsa-sha256 (default)</option>
<option value="rsa-sha256">rsa-sha256</option>
<option value="ecdsa-sha256">ecdsa-sha256</option>
</select>
</div>
<div>
<label for="s-time">--signing-time</label>
<input id="s-time" type="text" data-cmd="sign" data-flag="--signing-time" placeholder="2026-04-28T10:00:00Z">
</div>
<div>
<label for="s-reason">--reason</label>
<input id="s-reason" type="text" data-cmd="sign" data-flag="--reason" placeholder="Approved by Finance">
</div>
<div>
<label for="s-name">--name</label>
<input id="s-name" type="text" data-cmd="sign" data-flag="--name" placeholder="Finance Team">
</div>
<div>
<label for="s-loc">--location</label>
<input id="s-loc" type="text" data-cmd="sign" data-flag="--location" placeholder="Paris, FR">
</div>
<div>
<label for="s-contact">--contact</label>
<input id="s-contact" type="text" data-cmd="sign" data-flag="--contact" placeholder="finance@acme.example">
</div>
<div>
<label><input type="checkbox" data-cmd="sign" data-flag="--pure-crypto"> --pure-crypto <span class="new-badge" style="background:var(--c-success);color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;">v1.2</span></label>
<span class="hint">Force the portable pure-JS CMS path. The default delegates to <code>node:crypto</code>, inheriting its side-channel hardening; the pure-JS path is <strong>not</strong> constant-time.</span>
</div>
</div>
</section>
<!-- ─────────────── INSPECT ─────────────── -->
<section class="cli-panel" data-panel="inspect">
<div class="cli-form">
<div>
<label for="i-input">--input</label>
<input id="i-input" type="text" data-cmd="inspect" data-flag="--input" placeholder="signed.pdf">
</div>
<div>
<label for="i-format">--format</label>
<select id="i-format" data-cmd="inspect" data-flag="--format">
<option value="">json (default)</option>
<option value="json">json</option>
<option value="text">text</option>
</select>
</div>
<div>
<label><input type="checkbox" data-cmd="inspect" data-flag="--verbose"> --verbose</label>
<span class="hint">Adds trailerKeys, catalogKeys, objectCount, xmpMetadata.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="inspect" data-flag="--pages"> --pages</label>
<span class="hint">Per-page geometry, annotations, form fields.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="inspect" data-flag="--annotations"> --annotations <span class="new-badge" style="background:var(--c-success);color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;">v1.2</span></label>
<span class="hint">List markup + link annotations per page. Page labels reported automatically.</span>
</div>
<fieldset class="full">
<legend>--check (CI assertions, ANDed)</legend>
<div class="grid">
<div><label><input type="checkbox" data-cmd="inspect" data-flag="--check" data-value="pdfa"> --check pdfa</label></div>
<div><label><input type="checkbox" data-cmd="inspect" data-flag="--check" data-value="signed"> --check signed</label></div>
<div><label><input type="checkbox" data-cmd="inspect" data-flag="--check" data-value="encrypted"> --check encrypted</label></div>
</div>
<span class="hint" style="margin-top: 8px; display: block;">Exit code 0 on all-pass, 1 on any failure. Composable with <code>--format</code>.</span>
</fieldset>
</div>
</section>
<!-- ─────────────── VERIFY ─────────────── -->
<section class="cli-panel" data-panel="verify">
<div class="cli-form">
<div>
<label for="v-input">--input</label>
<input id="v-input" type="text" data-cmd="verify" data-flag="--input" placeholder="signed.pdf">
</div>
<div>
<label for="v-format">--format</label>
<select id="v-format" data-cmd="verify" data-flag="--format">
<option value="">json (default)</option>
<option value="json">json</option>
<option value="text">text</option>
</select>
</div>
<div>
<label><input type="checkbox" data-cmd="verify" data-flag="--strict"> --strict</label>
<span class="hint">Exit 1 on any failure or zero signatures.</span>
</div>
<div class="full">
<label for="v-trust">--trust (one per line)</label>
<textarea id="v-trust" data-cmd="verify" data-flag="--trust" placeholder="ca-root.pem"></textarea>
<span class="hint">Trust-anchor PEMs. Repeatable.</span>
</div>
</div>
<p class="hint" style="margin-top: 14px;">Scope (since v1.0.0): full CMS/PKCS#7 verification (RSA + ECDSA-SHA256), byte-range integrity (SHA-256), certificate chain, trust evaluation against <code>--trust</code> roots, RFC 3161 timestamp validation (<strong>PAdES-T</strong>), and OCSP/CRL revocation checking via <code>--revocation</code> / <code>--revocation-policy</code>. See the <a href="../guides/cli.html">CLI guide</a>.</p>
</section>
<!-- ─────────────── MERGE (v1.2) ─────────────── -->
<section class="cli-panel" data-panel="merge">
<div class="cli-form">
<div class="full">
<label for="m-input">--input (one path per line, 2–50)</label>
<textarea id="m-input" data-cmd="merge" data-flag="--input" placeholder="cover.pdf body.pdf appendix.pdf"></textarea>
<span class="hint">Source PDFs, concatenated in order. Repeatable.</span>
</div>
<div>
<label for="m-output">--output</label>
<input id="m-output" type="text" data-cmd="merge" data-flag="--output" placeholder="combined.pdf">
</div>
<div>
<label for="m-max">--max-output-size</label>
<input id="m-max" type="text" data-cmd="merge" data-flag="--max-output-size" placeholder="268435456">
<span class="hint">Output ceiling in bytes (default 256 MiB).</span>
</div>
<div>
<label><input type="checkbox" data-cmd="merge" data-flag="--drop-annotations"> --drop-annotations</label>
</div>
<div>
<label><input type="checkbox" data-cmd="merge" data-flag="--dry-run"> --dry-run</label>
</div>
</div>
<p class="hint" style="margin-top: 14px;">Encrypted sources are supported since v1.3.0 — decrypt them on ingest with <code>--password</code>, and re-encrypt the merged output with <code>--encrypt</code>. Signatures and <code>/AcroForm</code> are dropped (page edits invalidate <code>/ByteRange</code>); URI <code>/Link</code> annotations are preserved. Every path is validated against traversal.</p>
</section>
<!-- ─────────────── SPLIT (v1.2) ─────────────── -->
<section class="cli-panel" data-panel="split">
<div class="cli-form">
<div>
<label for="sp-input">--input</label>
<input id="sp-input" type="text" data-cmd="split" data-flag="--input" placeholder="report.pdf">
</div>
<div>
<label for="sp-outdir">--output-dir</label>
<input id="sp-outdir" type="text" data-cmd="split" data-flag="--output-dir" placeholder="pages/">
<span class="hint">Required. Parts written as <code><prefix>-<n>.pdf</code>.</span>
</div>
<div>
<label for="sp-prefix">--prefix</label>
<input id="sp-prefix" type="text" data-cmd="split" data-flag="--prefix" placeholder="page">
</div>
<div>
<label for="sp-pages">--pages</label>
<input id="sp-pages" type="text" data-cmd="split" data-flag="--pages" placeholder="1-2,3-4">
<span class="hint">Comma-separated 1-based inclusive ranges. Omit for one output per page.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="split" data-flag="--dry-run"> --dry-run</label>
</div>
</div>
</section>
<!-- ─────────────── EXTRACT (v1.2) ─────────────── -->
<section class="cli-panel" data-panel="extract">
<div class="cli-form">
<div>
<label for="e-input">--input</label>
<input id="e-input" type="text" data-cmd="extract" data-flag="--input" placeholder="report.pdf">
</div>
<div>
<label for="e-output">--output</label>
<input id="e-output" type="text" data-cmd="extract" data-flag="--output" placeholder="cover.pdf">
</div>
<div class="full">
<label for="e-pages">--pages</label>
<input id="e-pages" type="text" data-cmd="extract" data-flag="--pages" placeholder="4,1-2">
<span class="hint">1-based page list/ranges. Order is preserved and repeats are allowed.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="extract" data-flag="--dry-run"> --dry-run</label>
</div>
</div>
</section>
<!-- ─────────────── ANNOTATE (v1.2) ─────────────── -->
<section class="cli-panel" data-panel="annotate">
<div class="cli-form">
<div>
<label for="a-input">--input</label>
<input id="a-input" type="text" data-cmd="annotate" data-flag="--input" placeholder="report.pdf">
</div>
<div>
<label for="a-output">--output</label>
<input id="a-output" type="text" data-cmd="annotate" data-flag="--output" placeholder="annotated.pdf">
</div>
<div class="full">
<label for="a-annotations">--annotations (file path)</label>
<input id="a-annotations" type="text" data-cmd="annotate" data-flag="--annotations" placeholder="notes.json">
<span class="hint">JSON array (or <code>{ "annotations": [...] }</code>): each entry a markup annotation plus a 1-based <code>page</code>.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="annotate" data-flag="--dry-run"> --dry-run</label>
</div>
</div>
<p class="hint" style="margin-top: 14px;">Written with an <strong>incremental save</strong>, so existing signatures stay valid. Types: text, highlight, underline, strikeout, squiggly, square, circle, line, freetext. <strong>Overlay, not redaction.</strong></p>
</section>
<!-- ─────────────── GOVERN (v1.2) ─────────────── -->
<section class="cli-panel" data-panel="govern">
<div class="cli-form">
<div>
<label for="g-sub">subcommand</label>
<select id="g-sub" data-cmd="govern" data-flag="__positional__">
<option value="rules">rules</option>
<option value="policy">policy</option>
<option value="verify-issue">verify-issue</option>
</select>
<span class="hint"><code>rules</code> prints the agent/human protocol; <code>policy</code> the machine-readable JSON; <code>verify-issue</code> gates a draft.</span>
</div>
<div>
<label for="g-draft">draft file (verify-issue)</label>
<input id="g-draft" type="text" data-cmd="govern" data-flag="__arg__" placeholder="draft.md">
<span class="hint">Path to the local issue draft to gate. Exit 1 / <code>E_POLICY</code> on a violation.</span>
</div>
<div>
<label><input type="checkbox" data-cmd="govern" data-flag="--json"> --json</label>
<span class="hint">Machine-readable output (best with <code>policy</code>).</span>
</div>
</div>
<p class="hint" style="margin-top: 14px;">Agents act as <strong>draftsmen</strong>: a human must always review and submit. <code>verify-issue</code> is a pure, fully offline validator — no GitHub or network access.</p>
</section>
<div class="cli-validation" id="validation"></div>
<div class="cli-preview">
<h3>Generated command <button class="copy-btn" id="copy">Copy</button></h3>
<pre><code class="language-bash" id="cmd-output">npx pdfnative-cli render</code></pre>
<p class="hint" style="margin-top: 10px;">Paste this in any shell. Secrets are never sent — the entire builder runs client-side.</p>
</div>
<h2 style="margin-top: 36px;">What this playground does <em>not</em> do</h2>
<p>It does not <strong>execute</strong> the CLI in your browser — signing real PDFs requires real private keys, and we will not pretend to. For an in-browser demo of <code>render</code> output, see the <a href="../#demo">homepage live demo</a>. To exercise the full CLI on your machine: <code>npx pdfnative-cli <your built command></code>.</p>
<h2>Resources</h2>
<ul>
<li><a href="../guides/cli.html">CLI guide</a> — full command reference, security model, recipes</li>
<li><a href="https://github.com/Nizoka/pdfnative-cli">pdfnative-cli on GitHub</a></li>
<li><a href="https://github.com/Nizoka/pdfnative-cli/releases">pdfnative-cli release notes</a></li>
<li><a href="../guides/mcp.html">MCP guide</a> · <a href="./mcp.html">MCP playground</a></li>
</ul>
</article>
</main>
<footer class="footer">
<div class="footer-inner">
<span>MIT License · © 2026 Nizoka</span>
<ul class="footer-links" role="list">
<li><a href="../">Home</a></li>
<li><a href="../guides/">Guides</a></li>
<li><a href="../guides/cli.html">CLI guide</a></li>
<li><a href="./extreme-scripts.html">Extreme scripts playground</a></li>
<li><a href="./scale.html">Scale playground</a></li>
<li><a href="./mcp.html">MCP playground</a></li>
<li><a href="https://github.com/Nizoka/pdfnative-cli" target="_blank" rel="noopener">pdfnative-cli</a></li>
</ul>
</div>
</footer>
<script>
(function () {
'use strict';
// ── State ──────────────────────────────────────────
// For each command, an object { flagName: value | array | bool }
const state = { render: {}, sign: {}, inspect: {}, verify: {}, merge: {}, split: {}, extract: {}, annotate: {}, govern: {} };
let activeCmd = 'render';
// Repeatable flags (one occurrence per item)
const REPEATABLE = new Set(['--cert-chain', '--attachment', '--trust', '--check']);
// ── DOM helpers ───────────────────────────────────
const $ = (id) => document.getElementById(id);
const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
// ── Tabs ──────────────────────────────────────────
$$('.cli-tab').forEach((btn) => {
btn.addEventListener('click', () => {
activeCmd = btn.dataset.tab;
$$('.cli-tab').forEach((b) => b.setAttribute('aria-selected', String(b === btn)));
$$('.cli-panel').forEach((p) => p.classList.toggle('active', p.dataset.panel === activeCmd));
render();
});
});
// ── Custom page-size toggle ───────────────────────
const pageSizeSelect = $('r-page-size');
const pageSizeCustom = $('r-page-size-custom');
pageSizeSelect.addEventListener('change', () => {
pageSizeCustom.style.display = pageSizeSelect.value === '__custom__' ? 'block' : 'none';
if (pageSizeSelect.value !== '__custom__') {
pageSizeCustom.value = '';
delete state.render['--page-size-custom'];
}
render();
});
// ── Generic input bindings ────────────────────────
$$('[data-cmd][data-flag]').forEach((el) => {
const evt = (el.tagName === 'SELECT' || el.type === 'checkbox') ? 'change' : 'input';
el.addEventListener(evt, () => collect(el));
});
function collect(el) {
const cmd = el.dataset.cmd;
const flag = el.dataset.flag;
const bag = state[cmd];
if (el.type === 'checkbox') {
// For repeatable --check use data-value to add/remove from an array
if (flag === '--check') {
const v = el.dataset.value;
let arr = Array.isArray(bag[flag]) ? bag[flag].slice() : [];
if (el.checked) { if (!arr.includes(v)) arr.push(v); }
else { arr = arr.filter((x) => x !== v); }
if (arr.length) bag[flag] = arr; else delete bag[flag];
} else {
if (el.checked) bag[flag] = true; else delete bag[flag];
}
} else if (el.tagName === 'TEXTAREA') {
const lines = el.value.split('\n').map((s) => s.trim()).filter(Boolean);
if (lines.length) bag[flag] = lines; else delete bag[flag];
} else {
const v = el.value.trim();
if (v) bag[flag] = v; else delete bag[flag];
}
render();
}
// ── Validation rules ──────────────────────────────
function validate() {
const errors = [];
const warns = [];
if (activeCmd === 'render') {
const r = state.render;
const tagged = r['--tagged'];
const hasEncrypt = Object.keys(r).some((k) => k.startsWith('--encrypt-'));
const taggedIsPdfA = tagged && /^pdfa/.test(tagged);
if (hasEncrypt && taggedIsPdfA) {
errors.push('Encryption (`--encrypt-*`) is mutually exclusive with `--tagged pdfa*` per ISO 19005-1 §6.3.2.');
}
if (hasEncrypt && !r['--encrypt-owner-pass']) {
warns.push('`--encrypt-*` flag set without `--encrypt-owner-pass`. The CLI will exit 2 unless `PDFNATIVE_ENCRYPT_OWNER_PASS` is exported.');
}
const usesPagesPlaceholder = ['--header-left', '--header-center', '--header-right', '--footer-left', '--footer-center', '--footer-right']
.some((f) => typeof r[f] === 'string' && r[f].includes('{pages}'));
if (r['--stream'] && usesPagesPlaceholder) {
errors.push('`{pages}` placeholder requires multi-pass pagination and is rejected with `--stream`.');
}
if (taggedIsPdfA === false || tagged === '') { /* no-op */ }
if ((tagged === 'pdfa1b') && (r['--watermark-text'] || r['--watermark-image']) && (r['--watermark-opacity'] || true)) {
// Transparency is mutually exclusive with PDF/A-1b. We can't inspect every alpha source, so warn.
if (r['--watermark-opacity']) {
warns.push('PDF/A-1b forbids transparency (ISO 19005-1 §6.4); a watermark with `--watermark-opacity` will be rejected.');
}
}
if (pageSizeSelect.value === '__custom__' && pageSizeCustom.value && !/^\d+x\d+$/i.test(pageSizeCustom.value.trim())) {
errors.push('Custom `--page-size` must be `WxH` in points, e.g. `595x842`.');
}
}
if (activeCmd === 'sign') {
const s = state.sign;
if (!s['--input']) warns.push('No `--input` — `sign` will read the PDF from stdin.');
if (s['--algorithm'] === 'ecdsa-sha256') {
warns.push('`--algorithm ecdsa-sha256` requires a P-256 (secp256r1) private key. Supported since v0.3.0.');
}
if (s['--signing-time'] && !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(s['--signing-time'])) {
errors.push('`--signing-time` must be ISO 8601 (e.g. `2026-04-28T10:00:00Z`).');
}
}
if (activeCmd === 'merge') {
const m = state.merge;
const inputs = Array.isArray(m['--input']) ? m['--input'] : [];
if (inputs.length < 2) warns.push('`merge` needs at least 2 source PDFs (2–50).');
if (inputs.length > 50) errors.push('`merge` accepts at most 50 source PDFs.');
}
if (activeCmd === 'split') {
const sp = state.split;
if (!sp['--output-dir']) warns.push('`split` requires `--output-dir`.');
}
if (activeCmd === 'extract') {
const e = state.extract;
if (!e['--pages']) warns.push('`extract` requires `--pages` (1-based list/ranges).');
}
if (activeCmd === 'annotate') {
const a = state.annotate;
if (!a['--annotations']) warns.push('`annotate` requires `--annotations` (a JSON spec file).');
}
if (activeCmd === 'govern') {
const sub = $('g-sub') ? $('g-sub').value : 'rules';
const draft = $('g-draft') ? $('g-draft').value.trim() : '';
if (sub === 'verify-issue' && !draft) warns.push('`govern verify-issue` needs a draft file path.');
}
return { errors, warns };
}
// ── Command rendering ─────────────────────────────
function shellEscape(v) {
if (v === true) return '';
if (typeof v !== 'string') v = String(v);
if (v === '') return "''";
if (/^[A-Za-z0-9_./:@,=+-]+$/.test(v)) return v; // safe characters
return "'" + v.replace(/'/g, `'\\''`) + "'";
}
function buildCommand() {
const bag = state[activeCmd];
const parts = ['npx', 'pdfnative-cli', activeCmd];
// Special govern: a positional subcommand + optional file arg (read from DOM)
if (activeCmd === 'govern') {
const sub = $('g-sub') ? $('g-sub').value : 'rules';
parts.push(sub || 'rules');
const draft = $('g-draft') ? $('g-draft').value.trim() : '';
if (sub === 'verify-issue' && draft) parts.push(shellEscape(draft));
if (bag['--json'] === true) parts.push('--json');
const singleG = parts.join(' ');
return singleG;
}
// Special render: combine --page-size + --page-size-custom
if (activeCmd === 'render') {
if (pageSizeSelect.value === '__custom__' && pageSizeCustom.value) {
parts.push('--page-size', shellEscape(pageSizeCustom.value.trim()));
} else if (bag['--page-size']) {
parts.push('--page-size', shellEscape(bag['--page-size']));
}
}
Object.keys(bag).forEach((flag) => {
if (flag === '--page-size' || flag === '--page-size-custom') return; // handled above
if (flag === '__positional__' || flag === '__arg__') return; // govern, handled above
const v = bag[flag];
if (v === true) {
parts.push(flag);
} else if (Array.isArray(v)) {
v.forEach((item) => { parts.push(flag, shellEscape(item)); });
} else {
parts.push(flag, shellEscape(v));
}
});
// Wrap onto multiple lines for readability if long
const single = parts.join(' ');
if (single.length <= 80) return single;
let out = parts.slice(0, 3).join(' ');
let line = '';
for (let i = 3; i < parts.length; i++) {
const tok = parts[i];
const isFlag = tok.startsWith('--');
if (isFlag && line.length > 0) { out += ' \\\n ' + line.trim(); line = ''; }
line += tok + ' ';
}
if (line.trim()) out += ' \\\n ' + line.trim();
return out;
}
function render() {
const cmd = buildCommand();
const out = $('cmd-output');
out.textContent = cmd;
if (window.Prism) window.Prism.highlightElement(out);
const { errors, warns } = validate();
const v = $('validation');
if (errors.length) {
v.className = 'cli-validation error';
v.innerHTML = '<strong>Validation errors:</strong><ul style="margin: 6px 0 0 18px;">' + errors.map((e) => '<li>' + e + '</li>').join('') + '</ul>';
} else if (warns.length) {
v.className = 'cli-validation warn';
v.innerHTML = '<strong>Heads up:</strong><ul style="margin: 6px 0 0 18px;">' + warns.map((w) => '<li>' + w + '</li>').join('') + '</ul>';
} else {
v.className = 'cli-validation';
v.innerHTML = '';
}
}
// ── Copy ──────────────────────────────────────────
$('copy').addEventListener('click', async () => {
try {
await navigator.clipboard.writeText($('cmd-output').textContent);
const btn = $('copy'); const old = btn.textContent;
btn.textContent = 'Copied!'; setTimeout(() => { btn.textContent = old; }, 1500);
} catch (e) {
alert('Clipboard write failed: ' + (e && e.message ? e.message : e));
}
});
// ── Reset ─────────────────────────────────────────
$('reset').addEventListener('click', () => {
state.render = {}; state.sign = {}; state.inspect = {}; state.verify = {};
$$('[data-cmd][data-flag]').forEach((el) => {
if (el.type === 'checkbox') el.checked = false;
else if (el.tagName === 'SELECT') el.value = '';
else el.value = '';
});
pageSizeCustom.style.display = 'none';
pageSizeCustom.value = '';
$('preset').value = '';
render();
});
// ── Presets ───────────────────────────────────────
const PRESETS = {
'render-basic': { tab: 'render', fields: { 'r-input': 'document.json', 'r-output': 'report.pdf' } },
'render-pdfa': { tab: 'render', fields: { 'r-input': 'doc.json', 'r-output': 'archive.pdf', 'r-tagged': 'pdfa2b' }, checks: ['--compress'] },
'render-watermark': { tab: 'render', fields: { 'r-input': 'doc.json', 'r-output': 'draft.pdf', 'r-wm-text': 'DRAFT', 'r-wm-opacity': '0.15', 'r-wm-angle': '-30' } },
'render-encrypted': { tab: 'render', fields: { 'r-input': 'contract.json', 'r-output': 'contract.encrypted.pdf', 'r-enc-algo': 'aes256', 'r-enc-perm': 'print' } },
'render-headers': { tab: 'render', fields: { 'r-input': 'report.json', 'r-output': 'report.pdf', 'r-hl': '{title}', 'r-hr': '{date}', 'r-fc': 'Page {page} / {pages}' } },
'render-attachment': { tab: 'render', fields: { 'r-input': 'invoice.json', 'r-output': 'invoice.pdf', 'r-tagged': 'pdfa3b' }, textareas: { 'r-attach': 'factur-x.xml:application/xml:Source:Structured invoice data' } },
'render-table': { tab: 'render', fields: { 'r-input': 'ledger.json', 'r-output': 'ledger.pdf', 'r-variant': 'table', 'r-layout': 'layout.json' } },
'sign-meta': { tab: 'sign', fields: { 's-input': 'report.pdf', 's-output': 'signed.pdf', 's-reason': 'Approved by Finance', 's-name': 'Finance Team', 's-loc': 'Paris, FR', 's-time': '2026-04-28T10:00:00Z' }, textareas: { 's-chain': 'intermediate.pem' } },
'inspect-check': { tab: 'inspect', fields: { 'i-input': 'signed.pdf', 'i-format': 'json' }, checks: ['--verbose'], multiCheck: { '--check': ['pdfa', 'signed'] } },
'inspect-annotations': { tab: 'inspect', fields: { 'i-input': 'annotated.pdf', 'i-format': 'json' }, checks: ['--annotations'] },
'verify-strict': { tab: 'verify', fields: { 'v-input': 'signed.pdf' }, checks: ['--strict'], textareas: { 'v-trust': 'ca-root.pem' } },
'render-outline-math': { tab: 'render', fields: { 'r-input': 'paper.json', 'r-output': 'paper.pdf', 'r-outline': 'auto', 'r-font': 'math' } },
'merge-basic': { tab: 'merge', fields: { 'm-output': 'combined.pdf' }, textareas: { 'm-input': 'cover.pdf\nbody.pdf\nappendix.pdf' } },
'split-ranges': { tab: 'split', fields: { 'sp-input': 'report.pdf', 'sp-outdir': 'out/', 'sp-pages': '1-2,3-4' } },
'extract-pages': { tab: 'extract', fields: { 'e-input': 'report.pdf', 'e-output': 'cover.pdf', 'e-pages': '4,1-2' } },
'annotate-notes': { tab: 'annotate', fields: { 'a-input': 'report.pdf', 'a-output': 'annotated.pdf', 'a-annotations': 'notes.json' } },
'govern-verify': { tab: 'govern', fields: { 'g-sub': 'verify-issue', 'g-draft': 'draft.md' } },
};
$('preset').addEventListener('change', (e) => {
const key = e.target.value;
if (!key) return;
$('reset').click();
const p = PRESETS[key];
// Switch tab
const tabBtn = $$('.cli-tab').find((b) => b.dataset.tab === p.tab);
if (tabBtn) tabBtn.click();
// Apply text/select fields
Object.entries(p.fields || {}).forEach(([id, val]) => {
const el = $(id); if (!el) return;
el.value = val;
el.dispatchEvent(new Event(el.tagName === 'SELECT' ? 'change' : 'input'));
});
// Apply boolean checkboxes (data-flag-only, no data-value)
(p.checks || []).forEach((flag) => {
const cb = $$(`input[type="checkbox"][data-cmd="${p.tab}"][data-flag="${flag}"]:not([data-value])`)[0];
if (cb) { cb.checked = true; cb.dispatchEvent(new Event('change')); }
});
// Apply multi-value checkboxes (--check pdfa, --check signed, …)
Object.entries(p.multiCheck || {}).forEach(([flag, values]) => {
values.forEach((v) => {
const cb = $$(`input[type="checkbox"][data-cmd="${p.tab}"][data-flag="${flag}"][data-value="${v}"]`)[0];
if (cb) { cb.checked = true; cb.dispatchEvent(new Event('change')); }
});
});
// Apply textareas
Object.entries(p.textareas || {}).forEach(([id, val]) => {
const el = $(id); if (!el) return;
el.value = val;
el.dispatchEvent(new Event('input'));
});
});
// ── Theme toggle (parity with main site) ──────────
const themeBtn = document.querySelector('.theme-toggle');
if (themeBtn) {
const stored = localStorage.getItem('theme');
if (stored) document.documentElement.setAttribute('data-theme', stored);
themeBtn.addEventListener('click', () => {
const cur = document.documentElement.getAttribute('data-theme') === 'dark' ? '' : 'dark';
if (cur) document.documentElement.setAttribute('data-theme', cur);
else document.documentElement.removeAttribute('data-theme');
localStorage.setItem('theme', cur);
});
}
// ── Mobile hamburger ──────────────────────────────
const hb = document.querySelector('.nav-hamburger');
if (hb) hb.addEventListener('click', () => {
const nav = document.querySelector('.nav-links');
if (nav) nav.classList.toggle('open');
hb.setAttribute('aria-expanded', String(nav && nav.classList.contains('open')));
});
render();
})();
</script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js" integrity="sha384-BGaNxfftg+9+TtC098wxawPFVEUpKYvaiCgbB0iqAMjK/4jDdmUY+oGxrPNvnXEf" crossorigin="anonymous" defer></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-bash.min.js" integrity="sha384-9WmlN8ABpoFSSHvBGGjhvB3E/D8UkNB9HpLJjBQFC2VSQsM1odiQDv4NbEo+7l15" crossorigin="anonymous" defer></script>
<script src="../assets/versions.js" defer></script>
</body>
</html>