n8n-nodes-htmlcsstopdf 2.2.0 → 3.0.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.
|
@@ -14,8 +14,8 @@ class Htmlcsstopdf {
|
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'HTML to PDF',
|
|
16
16
|
},
|
|
17
|
-
inputs: [
|
|
18
|
-
outputs: [
|
|
17
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
19
|
credentials: [
|
|
20
20
|
{
|
|
21
21
|
name: 'htmlcsstopdfApi',
|
|
@@ -24,11 +24,45 @@ class Htmlcsstopdf {
|
|
|
24
24
|
],
|
|
25
25
|
usableAsTool: true,
|
|
26
26
|
properties: [
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Resource',
|
|
29
|
+
name: 'resource',
|
|
30
|
+
type: 'options',
|
|
31
|
+
noDataExpression: true,
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
name: 'PDF Creation',
|
|
35
|
+
value: 'pdfCreation',
|
|
36
|
+
description: 'Create PDF documents from various sources',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'PDF Manipulation',
|
|
40
|
+
value: 'pdfManipulation',
|
|
41
|
+
description: 'Merge, split, or compress PDF documents',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'PDF Security',
|
|
45
|
+
value: 'pdfSecurity',
|
|
46
|
+
description: 'Lock and unlock password-protected PDFs',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'PDF Extraction & Parsing',
|
|
50
|
+
value: 'pdfParsing',
|
|
51
|
+
description: 'Parse PDFs into structured JSON data',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
default: 'pdfCreation',
|
|
55
|
+
},
|
|
27
56
|
{
|
|
28
57
|
displayName: 'Operation',
|
|
29
58
|
name: 'operation',
|
|
30
59
|
type: 'options',
|
|
31
60
|
noDataExpression: true,
|
|
61
|
+
displayOptions: {
|
|
62
|
+
show: {
|
|
63
|
+
resource: ['pdfCreation'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
32
66
|
options: [
|
|
33
67
|
{
|
|
34
68
|
name: 'HTML to PDF',
|
|
@@ -45,6 +79,84 @@ class Htmlcsstopdf {
|
|
|
45
79
|
],
|
|
46
80
|
default: 'htmlToPdf',
|
|
47
81
|
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Operation',
|
|
84
|
+
name: 'operation',
|
|
85
|
+
type: 'options',
|
|
86
|
+
noDataExpression: true,
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
resource: ['pdfManipulation'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
options: [
|
|
93
|
+
{
|
|
94
|
+
name: 'Merge PDFs',
|
|
95
|
+
value: 'mergePdfs',
|
|
96
|
+
description: 'Merge multiple PDF files into one',
|
|
97
|
+
action: 'Merge multiple PDFS into one',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Split PDF',
|
|
101
|
+
value: 'splitPdf',
|
|
102
|
+
description: 'Split or extract pages from a PDF',
|
|
103
|
+
action: 'Split PDF',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'Compress PDF',
|
|
107
|
+
value: 'compressPdf',
|
|
108
|
+
description: 'Compress a PDF to reduce file size',
|
|
109
|
+
action: 'Compress PDF',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
default: 'mergePdfs',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
displayName: 'Operation',
|
|
116
|
+
name: 'operation',
|
|
117
|
+
type: 'options',
|
|
118
|
+
noDataExpression: true,
|
|
119
|
+
displayOptions: {
|
|
120
|
+
show: {
|
|
121
|
+
resource: ['pdfSecurity'],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
options: [
|
|
125
|
+
{
|
|
126
|
+
name: 'Lock PDF',
|
|
127
|
+
value: 'lockPdf',
|
|
128
|
+
description: 'Add password protection to a PDF',
|
|
129
|
+
action: 'Lock PDF with password',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'Unlock PDF',
|
|
133
|
+
value: 'unlockPdf',
|
|
134
|
+
description: 'Remove password protection from a PDF',
|
|
135
|
+
action: 'Unlock password protected PDF',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
default: 'lockPdf',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
displayName: 'Operation',
|
|
142
|
+
name: 'operation',
|
|
143
|
+
type: 'options',
|
|
144
|
+
noDataExpression: true,
|
|
145
|
+
displayOptions: {
|
|
146
|
+
show: {
|
|
147
|
+
resource: ['pdfParsing'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
options: [
|
|
151
|
+
{
|
|
152
|
+
name: 'Parse PDF',
|
|
153
|
+
value: 'parsePdf',
|
|
154
|
+
description: 'Extract structured data from PDF',
|
|
155
|
+
action: 'Parse PDF to JSON',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
default: 'parsePdf',
|
|
159
|
+
},
|
|
48
160
|
{
|
|
49
161
|
displayName: 'HTML Content',
|
|
50
162
|
name: 'html_content',
|
|
@@ -169,61 +281,661 @@ class Htmlcsstopdf {
|
|
|
169
281
|
},
|
|
170
282
|
},
|
|
171
283
|
},
|
|
284
|
+
{
|
|
285
|
+
displayName: 'Dynamic Params',
|
|
286
|
+
name: 'dynamic_params',
|
|
287
|
+
type: 'fixedCollection',
|
|
288
|
+
typeOptions: {
|
|
289
|
+
multipleValues: true,
|
|
290
|
+
},
|
|
291
|
+
default: {},
|
|
292
|
+
description: 'Dynamic parameters for templating (key/value pairs)',
|
|
293
|
+
displayOptions: {
|
|
294
|
+
show: {
|
|
295
|
+
operation: ['htmlToPdf'],
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
options: [
|
|
299
|
+
{
|
|
300
|
+
name: 'params',
|
|
301
|
+
displayName: 'Params',
|
|
302
|
+
values: [
|
|
303
|
+
{
|
|
304
|
+
displayName: 'Key',
|
|
305
|
+
name: 'key',
|
|
306
|
+
type: 'string',
|
|
307
|
+
default: '',
|
|
308
|
+
description: 'Placeholder key, for example {cert}',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
displayName: 'Value',
|
|
312
|
+
name: 'value',
|
|
313
|
+
type: 'string',
|
|
314
|
+
default: '',
|
|
315
|
+
description: 'Replacement value, for example name',
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
displayName: 'PDF URLs',
|
|
323
|
+
name: 'pdf_urls',
|
|
324
|
+
type: 'string',
|
|
325
|
+
default: '',
|
|
326
|
+
description: 'Comma-separated list of PDF URLs to merge (minimum 2, maximum 15)',
|
|
327
|
+
displayOptions: {
|
|
328
|
+
show: {
|
|
329
|
+
operation: ['mergePdfs'],
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
displayName: 'Output Type',
|
|
335
|
+
name: 'merge_output',
|
|
336
|
+
type: 'options',
|
|
337
|
+
options: [
|
|
338
|
+
{ name: 'URL', value: 'url' },
|
|
339
|
+
{ name: 'File', value: 'file' },
|
|
340
|
+
{ name: 'Base64', value: 'base64' },
|
|
341
|
+
],
|
|
342
|
+
default: 'url',
|
|
343
|
+
description: 'Format of the merged PDF output',
|
|
344
|
+
displayOptions: {
|
|
345
|
+
show: {
|
|
346
|
+
operation: ['mergePdfs'],
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
displayName: 'PDF URL',
|
|
352
|
+
name: 'split_url',
|
|
353
|
+
type: 'string',
|
|
354
|
+
default: '',
|
|
355
|
+
description: 'URL of the PDF to split',
|
|
356
|
+
displayOptions: {
|
|
357
|
+
show: {
|
|
358
|
+
operation: ['splitPdf'],
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
displayName: 'Split Mode',
|
|
364
|
+
name: 'split_mode',
|
|
365
|
+
type: 'options',
|
|
366
|
+
options: [
|
|
367
|
+
{ name: 'Extract Pages', value: 'pages' },
|
|
368
|
+
{ name: 'Split Each Page', value: 'each' },
|
|
369
|
+
{ name: 'Split Into Chunks', value: 'chunks' },
|
|
370
|
+
],
|
|
371
|
+
default: 'pages',
|
|
372
|
+
description: 'How to split the PDF',
|
|
373
|
+
displayOptions: {
|
|
374
|
+
show: {
|
|
375
|
+
operation: ['splitPdf'],
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
displayName: 'Page Range',
|
|
381
|
+
name: 'pages',
|
|
382
|
+
type: 'string',
|
|
383
|
+
default: '1-5',
|
|
384
|
+
description: 'Page range (e.g., "1-5", "1,3,5", "10-")',
|
|
385
|
+
displayOptions: {
|
|
386
|
+
show: {
|
|
387
|
+
operation: ['splitPdf'],
|
|
388
|
+
split_mode: ['pages'],
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
displayName: 'Number of Chunks',
|
|
394
|
+
name: 'chunks',
|
|
395
|
+
type: 'number',
|
|
396
|
+
default: 2,
|
|
397
|
+
description: 'Number of chunks to split the PDF into',
|
|
398
|
+
displayOptions: {
|
|
399
|
+
show: {
|
|
400
|
+
operation: ['splitPdf'],
|
|
401
|
+
split_mode: ['chunks'],
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
displayName: 'Output Type',
|
|
407
|
+
name: 'split_output',
|
|
408
|
+
type: 'options',
|
|
409
|
+
options: [
|
|
410
|
+
{ name: 'URL', value: 'url' },
|
|
411
|
+
{ name: 'File', value: 'file' },
|
|
412
|
+
{ name: 'Base64', value: 'base64' },
|
|
413
|
+
],
|
|
414
|
+
default: 'url',
|
|
415
|
+
description: 'Format of the split PDF output',
|
|
416
|
+
displayOptions: {
|
|
417
|
+
show: {
|
|
418
|
+
operation: ['splitPdf'],
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
displayName: 'PDF URL',
|
|
424
|
+
name: 'compress_url',
|
|
425
|
+
type: 'string',
|
|
426
|
+
default: '',
|
|
427
|
+
description: 'URL of the PDF to compress (max 10MB)',
|
|
428
|
+
displayOptions: {
|
|
429
|
+
show: {
|
|
430
|
+
operation: ['compressPdf'],
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
displayName: 'Compression Level',
|
|
436
|
+
name: 'compression',
|
|
437
|
+
type: 'options',
|
|
438
|
+
options: [
|
|
439
|
+
{ name: 'Low', value: 'low' },
|
|
440
|
+
{ name: 'Medium', value: 'medium' },
|
|
441
|
+
{ name: 'High', value: 'high' },
|
|
442
|
+
{ name: 'Max', value: 'max' },
|
|
443
|
+
],
|
|
444
|
+
default: 'high',
|
|
445
|
+
description: 'Compression strength (higher is more aggressive)',
|
|
446
|
+
displayOptions: {
|
|
447
|
+
show: {
|
|
448
|
+
operation: ['compressPdf'],
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
displayName: 'Output Type',
|
|
454
|
+
name: 'compress_output',
|
|
455
|
+
type: 'options',
|
|
456
|
+
options: [
|
|
457
|
+
{ name: 'URL', value: 'url' },
|
|
458
|
+
{ name: 'File', value: 'file' },
|
|
459
|
+
{ name: 'Base64', value: 'base64' },
|
|
460
|
+
],
|
|
461
|
+
default: 'file',
|
|
462
|
+
description: 'Format of the compressed PDF output',
|
|
463
|
+
displayOptions: {
|
|
464
|
+
show: {
|
|
465
|
+
operation: ['compressPdf'],
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
displayName: 'Output Filename',
|
|
471
|
+
name: 'compress_output_name',
|
|
472
|
+
type: 'string',
|
|
473
|
+
default: 'compressed.pdf',
|
|
474
|
+
description: 'Custom name for the output file',
|
|
475
|
+
displayOptions: {
|
|
476
|
+
show: {
|
|
477
|
+
operation: ['compressPdf'],
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
displayName: 'PDF URL',
|
|
483
|
+
name: 'lock_url',
|
|
484
|
+
type: 'string',
|
|
485
|
+
default: '',
|
|
486
|
+
description: 'URL of the PDF to lock (max 10MB)',
|
|
487
|
+
displayOptions: {
|
|
488
|
+
show: {
|
|
489
|
+
operation: ['lockPdf'],
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
displayName: 'Password',
|
|
495
|
+
name: 'lock_password',
|
|
496
|
+
type: 'string',
|
|
497
|
+
typeOptions: {
|
|
498
|
+
password: true,
|
|
499
|
+
},
|
|
500
|
+
default: '',
|
|
501
|
+
description: 'Password to set on the PDF',
|
|
502
|
+
displayOptions: {
|
|
503
|
+
show: {
|
|
504
|
+
operation: ['lockPdf'],
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
displayName: 'Input Password',
|
|
510
|
+
name: 'lock_input_password',
|
|
511
|
+
type: 'string',
|
|
512
|
+
typeOptions: {
|
|
513
|
+
password: true,
|
|
514
|
+
},
|
|
515
|
+
default: '',
|
|
516
|
+
description: 'Optional password if the input PDF is already encrypted',
|
|
517
|
+
displayOptions: {
|
|
518
|
+
show: {
|
|
519
|
+
operation: ['lockPdf'],
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
displayName: 'Output Type',
|
|
525
|
+
name: 'lock_output',
|
|
526
|
+
type: 'options',
|
|
527
|
+
options: [
|
|
528
|
+
{ name: 'URL', value: 'url' },
|
|
529
|
+
{ name: 'File', value: 'file' },
|
|
530
|
+
{ name: 'Base64', value: 'base64' },
|
|
531
|
+
],
|
|
532
|
+
default: 'file',
|
|
533
|
+
description: 'Format of the locked PDF output',
|
|
534
|
+
displayOptions: {
|
|
535
|
+
show: {
|
|
536
|
+
operation: ['lockPdf'],
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
displayName: 'Output Filename',
|
|
542
|
+
name: 'lock_output_name',
|
|
543
|
+
type: 'string',
|
|
544
|
+
default: 'locked.pdf',
|
|
545
|
+
description: 'Custom name for the output file',
|
|
546
|
+
displayOptions: {
|
|
547
|
+
show: {
|
|
548
|
+
operation: ['lockPdf'],
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
displayName: 'PDF URL',
|
|
554
|
+
name: 'unlock_url',
|
|
555
|
+
type: 'string',
|
|
556
|
+
default: '',
|
|
557
|
+
description: 'URL of the password-protected PDF to unlock (max 10MB)',
|
|
558
|
+
displayOptions: {
|
|
559
|
+
show: {
|
|
560
|
+
operation: ['unlockPdf'],
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
displayName: 'Password',
|
|
566
|
+
name: 'unlock_password',
|
|
567
|
+
type: 'string',
|
|
568
|
+
typeOptions: {
|
|
569
|
+
password: true,
|
|
570
|
+
},
|
|
571
|
+
default: '',
|
|
572
|
+
description: 'Password to unlock the PDF',
|
|
573
|
+
displayOptions: {
|
|
574
|
+
show: {
|
|
575
|
+
operation: ['unlockPdf'],
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
displayName: 'Output Type',
|
|
581
|
+
name: 'unlock_output',
|
|
582
|
+
type: 'options',
|
|
583
|
+
options: [
|
|
584
|
+
{ name: 'URL', value: 'url' },
|
|
585
|
+
{ name: 'File', value: 'file' },
|
|
586
|
+
{ name: 'Base64', value: 'base64' },
|
|
587
|
+
],
|
|
588
|
+
default: 'file',
|
|
589
|
+
description: 'Format of the unlocked PDF output',
|
|
590
|
+
displayOptions: {
|
|
591
|
+
show: {
|
|
592
|
+
operation: ['unlockPdf'],
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
displayName: 'Output Filename',
|
|
598
|
+
name: 'unlock_output_name',
|
|
599
|
+
type: 'string',
|
|
600
|
+
default: 'unlocked.pdf',
|
|
601
|
+
description: 'Custom name for the output file',
|
|
602
|
+
displayOptions: {
|
|
603
|
+
show: {
|
|
604
|
+
operation: ['unlockPdf'],
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
displayName: 'PDF URL',
|
|
610
|
+
name: 'parse_url',
|
|
611
|
+
type: 'string',
|
|
612
|
+
default: '',
|
|
613
|
+
description: 'URL of the PDF to parse',
|
|
614
|
+
displayOptions: {
|
|
615
|
+
show: {
|
|
616
|
+
operation: ['parsePdf'],
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
displayName: 'Parse Mode',
|
|
622
|
+
name: 'parse_mode',
|
|
623
|
+
type: 'options',
|
|
624
|
+
options: [
|
|
625
|
+
{ name: 'Text Only', value: 'text', description: 'Extract text only' },
|
|
626
|
+
{ name: 'Layout', value: 'layout', description: 'Text + text blocks with bounding boxes' },
|
|
627
|
+
{ name: 'Tables', value: 'tables', description: 'Text + table blocks' },
|
|
628
|
+
{ name: 'Full', value: 'full', description: 'Text + blocks + tables + images' },
|
|
629
|
+
],
|
|
630
|
+
default: 'full',
|
|
631
|
+
description: 'What to extract from the PDF',
|
|
632
|
+
displayOptions: {
|
|
633
|
+
show: {
|
|
634
|
+
operation: ['parsePdf'],
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
displayName: 'Pages',
|
|
640
|
+
name: 'parse_pages',
|
|
641
|
+
type: 'string',
|
|
642
|
+
default: 'all',
|
|
643
|
+
description: 'Page selection: "all" or a range like "1-3" or single page like "2"',
|
|
644
|
+
displayOptions: {
|
|
645
|
+
show: {
|
|
646
|
+
operation: ['parsePdf'],
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
},
|
|
172
650
|
],
|
|
173
651
|
};
|
|
174
652
|
}
|
|
175
653
|
async execute() {
|
|
654
|
+
var _a;
|
|
176
655
|
const items = this.getInputData();
|
|
177
656
|
const returnData = [];
|
|
178
657
|
for (let i = 0; i < items.length; i++) {
|
|
179
658
|
try {
|
|
659
|
+
const resource = this.getNodeParameter('resource', i);
|
|
180
660
|
const operation = this.getNodeParameter('operation', i);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
661
|
+
if (resource === 'pdfCreation') {
|
|
662
|
+
const outputFormat = this.getNodeParameter('output_format', i);
|
|
663
|
+
const outputFilename = this.getNodeParameter('output_filename', i);
|
|
664
|
+
const timeoutSeconds = this.getNodeParameter('timeout', i);
|
|
665
|
+
const timeout = timeoutSeconds * 1000;
|
|
666
|
+
let body = { output_filename: outputFilename };
|
|
667
|
+
if (operation === 'htmlToPdf') {
|
|
668
|
+
body.html_content = this.getNodeParameter('html_content', i);
|
|
669
|
+
body.css_content = this.getNodeParameter('css_content', i);
|
|
670
|
+
body.viewPortWidth = this.getNodeParameter('viewPortWidth', i);
|
|
671
|
+
body.viewPortHeight = this.getNodeParameter('viewPortHeight', i);
|
|
672
|
+
body.output_format = outputFormat;
|
|
673
|
+
const dynamicParams = this.getNodeParameter('dynamic_params', i, {});
|
|
674
|
+
if ((_a = dynamicParams.params) === null || _a === void 0 ? void 0 : _a.length) {
|
|
675
|
+
const mapped = dynamicParams.params
|
|
676
|
+
.filter((p) => { var _a; return ((_a = p.key) !== null && _a !== void 0 ? _a : '') !== ''; })
|
|
677
|
+
.map((p) => { var _a; return ({ [p.key]: (_a = p.value) !== null && _a !== void 0 ? _a : '' }); });
|
|
678
|
+
if (mapped.length) {
|
|
679
|
+
body.dynamic_params = mapped;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else if (operation === 'urlToPdf') {
|
|
684
|
+
body.url = this.getNodeParameter('url', i);
|
|
685
|
+
body.full_page = this.getNodeParameter('full_page', i);
|
|
686
|
+
body.wait_till = this.getNodeParameter('wait_till', i);
|
|
687
|
+
body.viewPortWidth = this.getNodeParameter('viewPortWidth', i);
|
|
688
|
+
body.viewPortHeight = this.getNodeParameter('viewPortHeight', i);
|
|
689
|
+
body.output_format = outputFormat;
|
|
690
|
+
}
|
|
691
|
+
if (outputFormat === 'file') {
|
|
692
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
693
|
+
method: 'POST',
|
|
694
|
+
url: 'https://pdfmunk.com/api/v1/generatePdf',
|
|
695
|
+
body,
|
|
696
|
+
json: true,
|
|
697
|
+
encoding: 'arraybuffer',
|
|
698
|
+
returnFullResponse: true,
|
|
699
|
+
timeout,
|
|
700
|
+
});
|
|
701
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), `${outputFilename}.pdf`, 'application/pdf');
|
|
702
|
+
returnData.push({
|
|
703
|
+
json: { success: true },
|
|
704
|
+
binary: { data: binaryData },
|
|
705
|
+
pairedItem: { item: i },
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
710
|
+
method: 'POST',
|
|
711
|
+
url: 'https://pdfmunk.com/api/v1/generatePdf',
|
|
712
|
+
body,
|
|
713
|
+
json: true,
|
|
714
|
+
timeout,
|
|
715
|
+
});
|
|
716
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
717
|
+
}
|
|
192
718
|
}
|
|
193
|
-
else if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
719
|
+
else if (resource === 'pdfManipulation') {
|
|
720
|
+
if (operation === 'mergePdfs') {
|
|
721
|
+
const pdfUrlsString = this.getNodeParameter('pdf_urls', i);
|
|
722
|
+
const urls = pdfUrlsString.split(',').map((url) => url.trim()).filter((url) => url);
|
|
723
|
+
const outputType = this.getNodeParameter('merge_output', i);
|
|
724
|
+
if (urls.length < 2) {
|
|
725
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least 2 PDF URLs are required for merging', { itemIndex: i });
|
|
726
|
+
}
|
|
727
|
+
if (urls.length > 15) {
|
|
728
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Maximum 15 PDF URLs allowed for merging', { itemIndex: i });
|
|
729
|
+
}
|
|
730
|
+
const body = {
|
|
731
|
+
urls,
|
|
732
|
+
output: outputType,
|
|
733
|
+
};
|
|
734
|
+
if (outputType === 'file') {
|
|
735
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
736
|
+
method: 'POST',
|
|
737
|
+
url: 'https://pdfmunk.com/api/v1/pdf/merge',
|
|
738
|
+
body,
|
|
739
|
+
json: true,
|
|
740
|
+
encoding: 'arraybuffer',
|
|
741
|
+
returnFullResponse: true,
|
|
742
|
+
});
|
|
743
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), 'merged.pdf', 'application/pdf');
|
|
744
|
+
returnData.push({
|
|
745
|
+
json: { success: true },
|
|
746
|
+
binary: { data: binaryData },
|
|
747
|
+
pairedItem: { item: i },
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
752
|
+
method: 'POST',
|
|
753
|
+
url: 'https://pdfmunk.com/api/v1/pdf/merge',
|
|
754
|
+
body,
|
|
755
|
+
json: true,
|
|
756
|
+
});
|
|
757
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
else if (operation === 'splitPdf') {
|
|
761
|
+
const pdfUrl = this.getNodeParameter('split_url', i);
|
|
762
|
+
const splitMode = this.getNodeParameter('split_mode', i);
|
|
763
|
+
const outputType = this.getNodeParameter('split_output', i);
|
|
764
|
+
const body = {
|
|
765
|
+
url: pdfUrl,
|
|
766
|
+
output: outputType,
|
|
767
|
+
};
|
|
768
|
+
if (splitMode === 'pages') {
|
|
769
|
+
body.pages = this.getNodeParameter('pages', i);
|
|
770
|
+
}
|
|
771
|
+
else if (splitMode === 'each') {
|
|
772
|
+
body.mode = 'each';
|
|
773
|
+
}
|
|
774
|
+
else if (splitMode === 'chunks') {
|
|
775
|
+
body.chunks = this.getNodeParameter('chunks', i);
|
|
776
|
+
}
|
|
777
|
+
if (outputType === 'file') {
|
|
778
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
779
|
+
method: 'POST',
|
|
780
|
+
url: 'https://pdfmunk.com/api/v1/pdf/split',
|
|
781
|
+
body,
|
|
782
|
+
json: true,
|
|
783
|
+
encoding: 'arraybuffer',
|
|
784
|
+
returnFullResponse: true,
|
|
785
|
+
});
|
|
786
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), 'split.pdf', 'application/pdf');
|
|
787
|
+
returnData.push({
|
|
788
|
+
json: { success: true },
|
|
789
|
+
binary: { data: binaryData },
|
|
790
|
+
pairedItem: { item: i },
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
795
|
+
method: 'POST',
|
|
796
|
+
url: 'https://pdfmunk.com/api/v1/pdf/split',
|
|
797
|
+
body,
|
|
798
|
+
json: true,
|
|
799
|
+
});
|
|
800
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else if (operation === 'compressPdf') {
|
|
804
|
+
const pdfUrl = this.getNodeParameter('compress_url', i);
|
|
805
|
+
const compression = this.getNodeParameter('compression', i);
|
|
806
|
+
const outputType = this.getNodeParameter('compress_output', i);
|
|
807
|
+
const outputName = this.getNodeParameter('compress_output_name', i);
|
|
808
|
+
const body = {
|
|
809
|
+
url: pdfUrl,
|
|
810
|
+
compression,
|
|
811
|
+
output: outputType,
|
|
812
|
+
output_name: outputName,
|
|
813
|
+
};
|
|
814
|
+
if (outputType === 'file') {
|
|
815
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
816
|
+
method: 'POST',
|
|
817
|
+
url: 'https://pdfmunk.com/api/v1/compressPdf',
|
|
818
|
+
body,
|
|
819
|
+
json: true,
|
|
820
|
+
encoding: 'arraybuffer',
|
|
821
|
+
returnFullResponse: true,
|
|
822
|
+
});
|
|
823
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), outputName, 'application/pdf');
|
|
824
|
+
returnData.push({
|
|
825
|
+
json: { success: true },
|
|
826
|
+
binary: { data: binaryData },
|
|
827
|
+
pairedItem: { item: i },
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
832
|
+
method: 'POST',
|
|
833
|
+
url: 'https://pdfmunk.com/api/v1/compressPdf',
|
|
834
|
+
body,
|
|
835
|
+
json: true,
|
|
836
|
+
});
|
|
837
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
838
|
+
}
|
|
839
|
+
}
|
|
200
840
|
}
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
841
|
+
else if (resource === 'pdfSecurity') {
|
|
842
|
+
if (operation === 'lockPdf') {
|
|
843
|
+
const pdfUrl = this.getNodeParameter('lock_url', i);
|
|
844
|
+
const password = this.getNodeParameter('lock_password', i);
|
|
845
|
+
const inputPassword = this.getNodeParameter('lock_input_password', i, '');
|
|
846
|
+
const outputType = this.getNodeParameter('lock_output', i);
|
|
847
|
+
const outputName = this.getNodeParameter('lock_output_name', i);
|
|
848
|
+
const body = {
|
|
849
|
+
url: pdfUrl,
|
|
850
|
+
password,
|
|
851
|
+
output: outputType,
|
|
852
|
+
output_name: outputName,
|
|
853
|
+
};
|
|
854
|
+
if (inputPassword) {
|
|
855
|
+
body.input_password = inputPassword;
|
|
856
|
+
}
|
|
857
|
+
if (outputType === 'file') {
|
|
858
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
859
|
+
method: 'POST',
|
|
860
|
+
url: 'https://pdfmunk.com/api/v1/lockPdf',
|
|
861
|
+
body,
|
|
862
|
+
json: true,
|
|
863
|
+
encoding: 'arraybuffer',
|
|
864
|
+
returnFullResponse: true,
|
|
865
|
+
});
|
|
866
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), outputName, 'application/pdf');
|
|
867
|
+
returnData.push({
|
|
868
|
+
json: { success: true },
|
|
869
|
+
binary: { data: binaryData },
|
|
870
|
+
pairedItem: { item: i },
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
875
|
+
method: 'POST',
|
|
876
|
+
url: 'https://pdfmunk.com/api/v1/lockPdf',
|
|
877
|
+
body,
|
|
878
|
+
json: true,
|
|
879
|
+
});
|
|
880
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
else if (operation === 'unlockPdf') {
|
|
884
|
+
const pdfUrl = this.getNodeParameter('unlock_url', i);
|
|
885
|
+
const password = this.getNodeParameter('unlock_password', i);
|
|
886
|
+
const outputType = this.getNodeParameter('unlock_output', i);
|
|
887
|
+
const outputName = this.getNodeParameter('unlock_output_name', i);
|
|
888
|
+
const body = {
|
|
889
|
+
url: pdfUrl,
|
|
890
|
+
password,
|
|
891
|
+
output: outputType,
|
|
892
|
+
output_name: outputName,
|
|
893
|
+
};
|
|
894
|
+
if (outputType === 'file') {
|
|
895
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
896
|
+
method: 'POST',
|
|
897
|
+
url: 'https://pdfmunk.com/api/v1/unlockPdf',
|
|
898
|
+
body,
|
|
899
|
+
json: true,
|
|
900
|
+
encoding: 'arraybuffer',
|
|
901
|
+
returnFullResponse: true,
|
|
902
|
+
});
|
|
903
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), outputName, 'application/pdf');
|
|
904
|
+
returnData.push({
|
|
905
|
+
json: { success: true },
|
|
906
|
+
binary: { data: binaryData },
|
|
907
|
+
pairedItem: { item: i },
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
else {
|
|
911
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
912
|
+
method: 'POST',
|
|
913
|
+
url: 'https://pdfmunk.com/api/v1/unlockPdf',
|
|
914
|
+
body,
|
|
915
|
+
json: true,
|
|
916
|
+
});
|
|
917
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
918
|
+
}
|
|
919
|
+
}
|
|
217
920
|
}
|
|
218
|
-
else {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
921
|
+
else if (resource === 'pdfParsing') {
|
|
922
|
+
if (operation === 'parsePdf') {
|
|
923
|
+
const pdfUrl = this.getNodeParameter('parse_url', i);
|
|
924
|
+
const mode = this.getNodeParameter('parse_mode', i);
|
|
925
|
+
const pages = this.getNodeParameter('parse_pages', i);
|
|
926
|
+
const body = {
|
|
927
|
+
url: pdfUrl,
|
|
928
|
+
mode,
|
|
929
|
+
pages,
|
|
930
|
+
};
|
|
931
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
932
|
+
method: 'POST',
|
|
933
|
+
url: 'https://pdfmunk.com/api/v1/pdf/parse',
|
|
934
|
+
body,
|
|
935
|
+
json: true,
|
|
936
|
+
});
|
|
937
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
938
|
+
}
|
|
227
939
|
}
|
|
228
940
|
}
|
|
229
941
|
catch (error) {
|