n8n-nodes-htmlcsstopdf 3.1.7 → 3.1.9
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.
|
@@ -90,6 +90,24 @@ class Htmlcsstopdf {
|
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
options: [
|
|
93
|
+
{
|
|
94
|
+
name: 'Compress PDF',
|
|
95
|
+
value: 'compressPdf',
|
|
96
|
+
description: 'Compress a PDF to reduce file size',
|
|
97
|
+
action: 'Compress PDF',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Convert Image to PDF',
|
|
101
|
+
value: 'convertImageToPdf',
|
|
102
|
+
description: 'Convert one or more images into a PDF',
|
|
103
|
+
action: 'Convert image to PDF',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'Convert PDF to Image',
|
|
107
|
+
value: 'convertPdfToImage',
|
|
108
|
+
description: 'Convert PDF pages into image files',
|
|
109
|
+
action: 'Convert PDF to image',
|
|
110
|
+
},
|
|
93
111
|
{
|
|
94
112
|
name: 'Merge PDFs',
|
|
95
113
|
value: 'mergePdfs',
|
|
@@ -103,10 +121,10 @@ class Htmlcsstopdf {
|
|
|
103
121
|
action: 'Split PDF',
|
|
104
122
|
},
|
|
105
123
|
{
|
|
106
|
-
name: '
|
|
107
|
-
value: '
|
|
108
|
-
description: '
|
|
109
|
-
action: '
|
|
124
|
+
name: 'Watermark PDF',
|
|
125
|
+
value: 'watermarkPdf',
|
|
126
|
+
description: 'Add a text watermark to a PDF',
|
|
127
|
+
action: 'Watermark PDF',
|
|
110
128
|
},
|
|
111
129
|
],
|
|
112
130
|
default: 'mergePdfs',
|
|
@@ -151,9 +169,15 @@ class Htmlcsstopdf {
|
|
|
151
169
|
{
|
|
152
170
|
name: 'Parse PDF',
|
|
153
171
|
value: 'parsePdf',
|
|
154
|
-
description: 'Extract structured data from PDF',
|
|
172
|
+
description: 'Extract structured data from text-based PDF',
|
|
155
173
|
action: 'Parse PDF to JSON',
|
|
156
174
|
},
|
|
175
|
+
{
|
|
176
|
+
name: 'Parse PDF with OCR',
|
|
177
|
+
value: 'parsePdfOcr',
|
|
178
|
+
description: 'Extract text using ocr from scanned pdf pages',
|
|
179
|
+
action: 'Parse PDF with OCR',
|
|
180
|
+
},
|
|
157
181
|
],
|
|
158
182
|
default: 'parsePdf',
|
|
159
183
|
},
|
|
@@ -318,6 +342,22 @@ class Htmlcsstopdf {
|
|
|
318
342
|
},
|
|
319
343
|
],
|
|
320
344
|
},
|
|
345
|
+
{
|
|
346
|
+
displayName: 'Input Type',
|
|
347
|
+
name: 'merge_input_type',
|
|
348
|
+
type: 'options',
|
|
349
|
+
options: [
|
|
350
|
+
{ name: 'URL', value: 'url' },
|
|
351
|
+
{ name: 'File', value: 'file' },
|
|
352
|
+
],
|
|
353
|
+
default: 'url',
|
|
354
|
+
description: 'Choose whether to merge by URL or binary file input',
|
|
355
|
+
displayOptions: {
|
|
356
|
+
show: {
|
|
357
|
+
operation: ['mergePdfs'],
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
321
361
|
{
|
|
322
362
|
displayName: 'PDF URLs',
|
|
323
363
|
name: 'pdf_urls',
|
|
@@ -327,6 +367,20 @@ class Htmlcsstopdf {
|
|
|
327
367
|
displayOptions: {
|
|
328
368
|
show: {
|
|
329
369
|
operation: ['mergePdfs'],
|
|
370
|
+
merge_input_type: ['url'],
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
displayName: 'File Binary Properties',
|
|
376
|
+
name: 'merge_file_binary_properties',
|
|
377
|
+
type: 'string',
|
|
378
|
+
default: 'data',
|
|
379
|
+
description: 'Comma-separated binary property names to merge (minimum 2), for example data1,data2',
|
|
380
|
+
displayOptions: {
|
|
381
|
+
show: {
|
|
382
|
+
operation: ['mergePdfs'],
|
|
383
|
+
merge_input_type: ['file'],
|
|
330
384
|
},
|
|
331
385
|
},
|
|
332
386
|
},
|
|
@@ -347,6 +401,22 @@ class Htmlcsstopdf {
|
|
|
347
401
|
},
|
|
348
402
|
},
|
|
349
403
|
},
|
|
404
|
+
{
|
|
405
|
+
displayName: 'Input Type',
|
|
406
|
+
name: 'split_input_type',
|
|
407
|
+
type: 'options',
|
|
408
|
+
options: [
|
|
409
|
+
{ name: 'URL', value: 'url' },
|
|
410
|
+
{ name: 'File', value: 'file' },
|
|
411
|
+
],
|
|
412
|
+
default: 'url',
|
|
413
|
+
description: 'Choose whether to split by URL or binary file input',
|
|
414
|
+
displayOptions: {
|
|
415
|
+
show: {
|
|
416
|
+
operation: ['splitPdf'],
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
},
|
|
350
420
|
{
|
|
351
421
|
displayName: 'PDF URL',
|
|
352
422
|
name: 'split_url',
|
|
@@ -356,6 +426,20 @@ class Htmlcsstopdf {
|
|
|
356
426
|
displayOptions: {
|
|
357
427
|
show: {
|
|
358
428
|
operation: ['splitPdf'],
|
|
429
|
+
split_input_type: ['url'],
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
displayName: 'File Binary Property',
|
|
435
|
+
name: 'split_file_binary_property',
|
|
436
|
+
type: 'string',
|
|
437
|
+
default: 'data',
|
|
438
|
+
description: 'Binary property containing the PDF file',
|
|
439
|
+
displayOptions: {
|
|
440
|
+
show: {
|
|
441
|
+
operation: ['splitPdf'],
|
|
442
|
+
split_input_type: ['file'],
|
|
359
443
|
},
|
|
360
444
|
},
|
|
361
445
|
},
|
|
@@ -419,6 +503,22 @@ class Htmlcsstopdf {
|
|
|
419
503
|
},
|
|
420
504
|
},
|
|
421
505
|
},
|
|
506
|
+
{
|
|
507
|
+
displayName: 'Input Type',
|
|
508
|
+
name: 'compress_input_type',
|
|
509
|
+
type: 'options',
|
|
510
|
+
options: [
|
|
511
|
+
{ name: 'URL', value: 'url' },
|
|
512
|
+
{ name: 'File', value: 'file' },
|
|
513
|
+
],
|
|
514
|
+
default: 'url',
|
|
515
|
+
description: 'Choose whether to compress by URL or binary file input',
|
|
516
|
+
displayOptions: {
|
|
517
|
+
show: {
|
|
518
|
+
operation: ['compressPdf'],
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
},
|
|
422
522
|
{
|
|
423
523
|
displayName: 'PDF URL',
|
|
424
524
|
name: 'compress_url',
|
|
@@ -428,6 +528,20 @@ class Htmlcsstopdf {
|
|
|
428
528
|
displayOptions: {
|
|
429
529
|
show: {
|
|
430
530
|
operation: ['compressPdf'],
|
|
531
|
+
compress_input_type: ['url'],
|
|
532
|
+
},
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
displayName: 'File Binary Property',
|
|
537
|
+
name: 'compress_file_binary_property',
|
|
538
|
+
type: 'string',
|
|
539
|
+
default: 'data',
|
|
540
|
+
description: 'Binary property containing the PDF file',
|
|
541
|
+
displayOptions: {
|
|
542
|
+
show: {
|
|
543
|
+
operation: ['compressPdf'],
|
|
544
|
+
compress_input_type: ['file'],
|
|
431
545
|
},
|
|
432
546
|
},
|
|
433
547
|
},
|
|
@@ -474,19 +588,325 @@ class Htmlcsstopdf {
|
|
|
474
588
|
description: 'Custom name for the output file',
|
|
475
589
|
displayOptions: {
|
|
476
590
|
show: {
|
|
477
|
-
operation: ['compressPdf'],
|
|
591
|
+
operation: ['compressPdf'],
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
displayName: 'Input Type',
|
|
597
|
+
name: 'watermark_input_type',
|
|
598
|
+
type: 'options',
|
|
599
|
+
options: [
|
|
600
|
+
{ name: 'URL', value: 'url' },
|
|
601
|
+
{ name: 'File', value: 'file' },
|
|
602
|
+
],
|
|
603
|
+
default: 'url',
|
|
604
|
+
description: 'Choose whether to watermark by URL or binary file input',
|
|
605
|
+
displayOptions: {
|
|
606
|
+
show: {
|
|
607
|
+
operation: ['watermarkPdf'],
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
displayName: 'PDF URL',
|
|
613
|
+
name: 'watermark_file_url',
|
|
614
|
+
type: 'string',
|
|
615
|
+
default: '',
|
|
616
|
+
description: 'Public URL of the PDF to watermark',
|
|
617
|
+
displayOptions: {
|
|
618
|
+
show: {
|
|
619
|
+
operation: ['watermarkPdf'],
|
|
620
|
+
watermark_input_type: ['url'],
|
|
621
|
+
},
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
displayName: 'File Binary Property',
|
|
626
|
+
name: 'watermark_file_binary_property',
|
|
627
|
+
type: 'string',
|
|
628
|
+
default: 'data',
|
|
629
|
+
description: 'Binary property containing the PDF file',
|
|
630
|
+
displayOptions: {
|
|
631
|
+
show: {
|
|
632
|
+
operation: ['watermarkPdf'],
|
|
633
|
+
watermark_input_type: ['file'],
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
displayName: 'Output Format',
|
|
639
|
+
name: 'watermark_output_format',
|
|
640
|
+
type: 'options',
|
|
641
|
+
options: [
|
|
642
|
+
{ name: 'File', value: 'file' },
|
|
643
|
+
{ name: 'URL', value: 'url' },
|
|
644
|
+
{ name: 'Base64', value: 'base64' },
|
|
645
|
+
{ name: 'Both', value: 'both' },
|
|
646
|
+
],
|
|
647
|
+
default: 'file',
|
|
648
|
+
description: 'Format of the watermarked output',
|
|
649
|
+
displayOptions: {
|
|
650
|
+
show: {
|
|
651
|
+
operation: ['watermarkPdf'],
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
displayName: 'Watermark Text',
|
|
657
|
+
name: 'watermark_text',
|
|
658
|
+
type: 'string',
|
|
659
|
+
default: 'CONFIDENTIAL',
|
|
660
|
+
description: 'Watermark text to apply',
|
|
661
|
+
displayOptions: {
|
|
662
|
+
show: {
|
|
663
|
+
operation: ['watermarkPdf'],
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
displayName: 'Opacity',
|
|
669
|
+
name: 'watermark_opacity',
|
|
670
|
+
type: 'number',
|
|
671
|
+
default: 0.15,
|
|
672
|
+
description: 'Watermark opacity from 0.0 to 1.0',
|
|
673
|
+
displayOptions: {
|
|
674
|
+
show: {
|
|
675
|
+
operation: ['watermarkPdf'],
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
displayName: 'Angle',
|
|
681
|
+
name: 'watermark_angle',
|
|
682
|
+
type: 'number',
|
|
683
|
+
default: 30,
|
|
684
|
+
description: 'Watermark rotation angle in degrees',
|
|
685
|
+
displayOptions: {
|
|
686
|
+
show: {
|
|
687
|
+
operation: ['watermarkPdf'],
|
|
688
|
+
},
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
displayName: 'Font Size',
|
|
693
|
+
name: 'watermark_font_size',
|
|
694
|
+
type: 'number',
|
|
695
|
+
default: 0,
|
|
696
|
+
description: 'Optional font size override (set 0 to use API default)',
|
|
697
|
+
displayOptions: {
|
|
698
|
+
show: {
|
|
699
|
+
operation: ['watermarkPdf'],
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
displayName: 'Input Type',
|
|
705
|
+
name: 'convert_pdf_image_input_type',
|
|
706
|
+
type: 'options',
|
|
707
|
+
options: [
|
|
708
|
+
{ name: 'URL', value: 'url' },
|
|
709
|
+
{ name: 'File', value: 'file' },
|
|
710
|
+
],
|
|
711
|
+
default: 'url',
|
|
712
|
+
description: 'Choose whether to convert by URL or binary file input',
|
|
713
|
+
displayOptions: {
|
|
714
|
+
show: {
|
|
715
|
+
operation: ['convertPdfToImage'],
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
displayName: 'PDF URL',
|
|
721
|
+
name: 'convert_pdf_image_url',
|
|
722
|
+
type: 'string',
|
|
723
|
+
default: '',
|
|
724
|
+
description: 'Public URL of the PDF to convert',
|
|
725
|
+
displayOptions: {
|
|
726
|
+
show: {
|
|
727
|
+
operation: ['convertPdfToImage'],
|
|
728
|
+
convert_pdf_image_input_type: ['url'],
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
displayName: 'File Binary Property',
|
|
734
|
+
name: 'convert_pdf_image_file_binary_property',
|
|
735
|
+
type: 'string',
|
|
736
|
+
default: 'data',
|
|
737
|
+
description: 'Binary property containing the PDF file',
|
|
738
|
+
displayOptions: {
|
|
739
|
+
show: {
|
|
740
|
+
operation: ['convertPdfToImage'],
|
|
741
|
+
convert_pdf_image_input_type: ['file'],
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
displayName: 'Page',
|
|
747
|
+
name: 'convert_pdf_image_page',
|
|
748
|
+
type: 'number',
|
|
749
|
+
default: 1,
|
|
750
|
+
description: 'Single page number to convert (used when Pages is empty)',
|
|
751
|
+
displayOptions: {
|
|
752
|
+
show: {
|
|
753
|
+
operation: ['convertPdfToImage'],
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
displayName: 'Pages',
|
|
759
|
+
name: 'convert_pdf_image_pages',
|
|
760
|
+
type: 'string',
|
|
761
|
+
default: '',
|
|
762
|
+
description: 'Optional pages selection, for example 1-3 or 1,3,5',
|
|
763
|
+
displayOptions: {
|
|
764
|
+
show: {
|
|
765
|
+
operation: ['convertPdfToImage'],
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
displayName: 'Image Format',
|
|
771
|
+
name: 'convert_pdf_image_format',
|
|
772
|
+
type: 'options',
|
|
773
|
+
options: [
|
|
774
|
+
{ name: 'PNG', value: 'png' },
|
|
775
|
+
{ name: 'JPG', value: 'jpg' },
|
|
776
|
+
{ name: 'JPEG', value: 'jpeg' },
|
|
777
|
+
{ name: 'WEBP', value: 'webp' },
|
|
778
|
+
],
|
|
779
|
+
default: 'png',
|
|
780
|
+
description: 'Output image format',
|
|
781
|
+
displayOptions: {
|
|
782
|
+
show: {
|
|
783
|
+
operation: ['convertPdfToImage'],
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
displayName: 'DPI',
|
|
789
|
+
name: 'convert_pdf_image_dpi',
|
|
790
|
+
type: 'number',
|
|
791
|
+
default: 150,
|
|
792
|
+
description: 'Rasterization DPI (72-300)',
|
|
793
|
+
displayOptions: {
|
|
794
|
+
show: {
|
|
795
|
+
operation: ['convertPdfToImage'],
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
displayName: 'Quality',
|
|
801
|
+
name: 'convert_pdf_image_quality',
|
|
802
|
+
type: 'number',
|
|
803
|
+
default: 85,
|
|
804
|
+
description: 'Image quality from 1 to 100',
|
|
805
|
+
displayOptions: {
|
|
806
|
+
show: {
|
|
807
|
+
operation: ['convertPdfToImage'],
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
displayName: 'Output Type',
|
|
813
|
+
name: 'convert_pdf_image_output',
|
|
814
|
+
type: 'options',
|
|
815
|
+
options: [
|
|
816
|
+
{ name: 'URL', value: 'url' },
|
|
817
|
+
{ name: 'Base64', value: 'base64' },
|
|
818
|
+
{ name: 'Both', value: 'both' },
|
|
819
|
+
{ name: 'File', value: 'file' },
|
|
820
|
+
],
|
|
821
|
+
default: 'url',
|
|
822
|
+
description: 'Format of the converted image output',
|
|
823
|
+
displayOptions: {
|
|
824
|
+
show: {
|
|
825
|
+
operation: ['convertPdfToImage'],
|
|
826
|
+
},
|
|
827
|
+
},
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
displayName: 'Image URLs',
|
|
831
|
+
name: 'convert_image_pdf_urls',
|
|
832
|
+
type: 'string',
|
|
833
|
+
default: '',
|
|
834
|
+
description: 'Single URL or comma-separated image URLs (max 100)',
|
|
835
|
+
displayOptions: {
|
|
836
|
+
show: {
|
|
837
|
+
operation: ['convertImageToPdf'],
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
displayName: 'Output Type',
|
|
843
|
+
name: 'convert_image_pdf_output',
|
|
844
|
+
type: 'options',
|
|
845
|
+
options: [
|
|
846
|
+
{ name: 'URL', value: 'url' },
|
|
847
|
+
{ name: 'Base64', value: 'base64' },
|
|
848
|
+
{ name: 'Both', value: 'both' },
|
|
849
|
+
{ name: 'File', value: 'file' },
|
|
850
|
+
],
|
|
851
|
+
default: 'url',
|
|
852
|
+
description: 'Format of the generated PDF output',
|
|
853
|
+
displayOptions: {
|
|
854
|
+
show: {
|
|
855
|
+
operation: ['convertImageToPdf'],
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
displayName: 'Output Filename',
|
|
861
|
+
name: 'convert_image_pdf_filename',
|
|
862
|
+
type: 'string',
|
|
863
|
+
default: 'combined-images.pdf',
|
|
864
|
+
description: 'Optional output filename for file mode',
|
|
865
|
+
displayOptions: {
|
|
866
|
+
show: {
|
|
867
|
+
operation: ['convertImageToPdf'],
|
|
868
|
+
},
|
|
869
|
+
},
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
displayName: 'Input Type',
|
|
873
|
+
name: 'lock_input_type',
|
|
874
|
+
type: 'options',
|
|
875
|
+
options: [
|
|
876
|
+
{ name: 'URL', value: 'url' },
|
|
877
|
+
{ name: 'File', value: 'file' },
|
|
878
|
+
],
|
|
879
|
+
default: 'url',
|
|
880
|
+
description: 'Choose whether to lock by URL or binary file input',
|
|
881
|
+
displayOptions: {
|
|
882
|
+
show: {
|
|
883
|
+
operation: ['lockPdf'],
|
|
884
|
+
},
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
displayName: 'PDF URL',
|
|
889
|
+
name: 'lock_url',
|
|
890
|
+
type: 'string',
|
|
891
|
+
default: '',
|
|
892
|
+
description: 'URL of the PDF to lock (max 10MB)',
|
|
893
|
+
displayOptions: {
|
|
894
|
+
show: {
|
|
895
|
+
operation: ['lockPdf'],
|
|
896
|
+
lock_input_type: ['url'],
|
|
478
897
|
},
|
|
479
898
|
},
|
|
480
899
|
},
|
|
481
900
|
{
|
|
482
|
-
displayName: '
|
|
483
|
-
name: '
|
|
901
|
+
displayName: 'File Binary Property',
|
|
902
|
+
name: 'lock_file_binary_property',
|
|
484
903
|
type: 'string',
|
|
485
|
-
default: '',
|
|
486
|
-
description: '
|
|
904
|
+
default: 'data',
|
|
905
|
+
description: 'Binary property containing the PDF file',
|
|
487
906
|
displayOptions: {
|
|
488
907
|
show: {
|
|
489
908
|
operation: ['lockPdf'],
|
|
909
|
+
lock_input_type: ['file'],
|
|
490
910
|
},
|
|
491
911
|
},
|
|
492
912
|
},
|
|
@@ -549,6 +969,22 @@ class Htmlcsstopdf {
|
|
|
549
969
|
},
|
|
550
970
|
},
|
|
551
971
|
},
|
|
972
|
+
{
|
|
973
|
+
displayName: 'Input Type',
|
|
974
|
+
name: 'unlock_input_type',
|
|
975
|
+
type: 'options',
|
|
976
|
+
options: [
|
|
977
|
+
{ name: 'URL', value: 'url' },
|
|
978
|
+
{ name: 'File', value: 'file' },
|
|
979
|
+
],
|
|
980
|
+
default: 'url',
|
|
981
|
+
description: 'Choose whether to unlock by URL or binary file input',
|
|
982
|
+
displayOptions: {
|
|
983
|
+
show: {
|
|
984
|
+
operation: ['unlockPdf'],
|
|
985
|
+
},
|
|
986
|
+
},
|
|
987
|
+
},
|
|
552
988
|
{
|
|
553
989
|
displayName: 'PDF URL',
|
|
554
990
|
name: 'unlock_url',
|
|
@@ -558,6 +994,20 @@ class Htmlcsstopdf {
|
|
|
558
994
|
displayOptions: {
|
|
559
995
|
show: {
|
|
560
996
|
operation: ['unlockPdf'],
|
|
997
|
+
unlock_input_type: ['url'],
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
displayName: 'File Binary Property',
|
|
1003
|
+
name: 'unlock_file_binary_property',
|
|
1004
|
+
type: 'string',
|
|
1005
|
+
default: 'data',
|
|
1006
|
+
description: 'Binary property containing the PDF file',
|
|
1007
|
+
displayOptions: {
|
|
1008
|
+
show: {
|
|
1009
|
+
operation: ['unlockPdf'],
|
|
1010
|
+
unlock_input_type: ['file'],
|
|
561
1011
|
},
|
|
562
1012
|
},
|
|
563
1013
|
},
|
|
@@ -605,15 +1055,45 @@ class Htmlcsstopdf {
|
|
|
605
1055
|
},
|
|
606
1056
|
},
|
|
607
1057
|
},
|
|
1058
|
+
{
|
|
1059
|
+
displayName: 'Input Type',
|
|
1060
|
+
name: 'parse_input_type',
|
|
1061
|
+
type: 'options',
|
|
1062
|
+
options: [
|
|
1063
|
+
{ name: 'URL', value: 'url' },
|
|
1064
|
+
{ name: 'File', value: 'file' },
|
|
1065
|
+
],
|
|
1066
|
+
default: 'url',
|
|
1067
|
+
description: 'Choose whether to parse by URL or binary file input',
|
|
1068
|
+
displayOptions: {
|
|
1069
|
+
show: {
|
|
1070
|
+
operation: ['parsePdf', 'parsePdfOcr'],
|
|
1071
|
+
},
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
608
1074
|
{
|
|
609
1075
|
displayName: 'PDF URL',
|
|
610
1076
|
name: 'parse_url',
|
|
611
1077
|
type: 'string',
|
|
612
1078
|
default: '',
|
|
613
|
-
description: 'URL of the PDF to parse',
|
|
1079
|
+
description: 'Public URL of the PDF to parse',
|
|
614
1080
|
displayOptions: {
|
|
615
1081
|
show: {
|
|
616
|
-
operation: ['parsePdf'],
|
|
1082
|
+
operation: ['parsePdf', 'parsePdfOcr'],
|
|
1083
|
+
parse_input_type: ['url'],
|
|
1084
|
+
},
|
|
1085
|
+
},
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
displayName: 'File Binary Property',
|
|
1089
|
+
name: 'parse_file_binary_property',
|
|
1090
|
+
type: 'string',
|
|
1091
|
+
default: 'data',
|
|
1092
|
+
description: 'Binary property containing the PDF file',
|
|
1093
|
+
displayOptions: {
|
|
1094
|
+
show: {
|
|
1095
|
+
operation: ['parsePdf', 'parsePdfOcr'],
|
|
1096
|
+
parse_input_type: ['file'],
|
|
617
1097
|
},
|
|
618
1098
|
},
|
|
619
1099
|
},
|
|
@@ -635,15 +1115,63 @@ class Htmlcsstopdf {
|
|
|
635
1115
|
},
|
|
636
1116
|
},
|
|
637
1117
|
},
|
|
1118
|
+
{
|
|
1119
|
+
displayName: 'Language',
|
|
1120
|
+
name: 'lang',
|
|
1121
|
+
type: 'string',
|
|
1122
|
+
default: 'eng',
|
|
1123
|
+
description: 'Tesseract language code(s), for example eng or eng+hin',
|
|
1124
|
+
displayOptions: {
|
|
1125
|
+
show: {
|
|
1126
|
+
operation: ['parsePdfOcr'],
|
|
1127
|
+
},
|
|
1128
|
+
},
|
|
1129
|
+
},
|
|
638
1130
|
{
|
|
639
1131
|
displayName: 'Pages',
|
|
640
1132
|
name: 'parse_pages',
|
|
641
1133
|
type: 'string',
|
|
642
1134
|
default: 'all',
|
|
643
|
-
description: 'Page selection:
|
|
1135
|
+
description: 'Page selection: all, a range like 1-3, or a list like 1,3,5-7',
|
|
644
1136
|
displayOptions: {
|
|
645
1137
|
show: {
|
|
646
|
-
operation: ['parsePdf'],
|
|
1138
|
+
operation: ['parsePdf', 'parsePdfOcr'],
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
displayName: 'DPI',
|
|
1144
|
+
name: 'dpi',
|
|
1145
|
+
type: 'number',
|
|
1146
|
+
default: 200,
|
|
1147
|
+
description: 'Rasterization DPI before OCR (72-400)',
|
|
1148
|
+
displayOptions: {
|
|
1149
|
+
show: {
|
|
1150
|
+
operation: ['parsePdfOcr'],
|
|
1151
|
+
},
|
|
1152
|
+
},
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
displayName: 'PSM',
|
|
1156
|
+
name: 'psm',
|
|
1157
|
+
type: 'number',
|
|
1158
|
+
default: 3,
|
|
1159
|
+
description: 'Tesseract page segmentation mode (0-13)',
|
|
1160
|
+
displayOptions: {
|
|
1161
|
+
show: {
|
|
1162
|
+
operation: ['parsePdfOcr'],
|
|
1163
|
+
},
|
|
1164
|
+
},
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
displayName: 'OEM',
|
|
1168
|
+
name: 'oem',
|
|
1169
|
+
type: 'number',
|
|
1170
|
+
default: 3,
|
|
1171
|
+
description: 'Tesseract OCR engine mode (0-3)',
|
|
1172
|
+
displayOptions: {
|
|
1173
|
+
show: {
|
|
1174
|
+
operation: ['parsePdfOcr'],
|
|
647
1175
|
},
|
|
648
1176
|
},
|
|
649
1177
|
},
|
|
@@ -651,7 +1179,7 @@ class Htmlcsstopdf {
|
|
|
651
1179
|
};
|
|
652
1180
|
}
|
|
653
1181
|
async execute() {
|
|
654
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1182
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
655
1183
|
const items = this.getInputData();
|
|
656
1184
|
const returnData = [];
|
|
657
1185
|
const toJsonObject = (body) => {
|
|
@@ -679,6 +1207,93 @@ class Htmlcsstopdf {
|
|
|
679
1207
|
return { error: 'Unable to parse error response' };
|
|
680
1208
|
}
|
|
681
1209
|
};
|
|
1210
|
+
const prepareBinaryResponse = async (itemIndex, responseData, fallbackFileName, fallbackMimeType) => {
|
|
1211
|
+
var _a, _b, _c;
|
|
1212
|
+
const headers = (_a = responseData.headers) !== null && _a !== void 0 ? _a : {};
|
|
1213
|
+
const contentTypeHeader = (_b = (typeof headers['content-type'] === 'string' ? headers['content-type'] : undefined)) !== null && _b !== void 0 ? _b : (typeof headers['Content-Type'] === 'string' ? headers['Content-Type'] : undefined);
|
|
1214
|
+
const contentType = ((_c = contentTypeHeader === null || contentTypeHeader === void 0 ? void 0 : contentTypeHeader.split(';')[0]) === null || _c === void 0 ? void 0 : _c.trim()) || fallbackMimeType;
|
|
1215
|
+
let fileName = fallbackFileName;
|
|
1216
|
+
if (!fileName) {
|
|
1217
|
+
fileName = 'output';
|
|
1218
|
+
}
|
|
1219
|
+
if (!fileName.includes('.') && contentType.includes('/')) {
|
|
1220
|
+
const ext = contentType.includes('pdf')
|
|
1221
|
+
? 'pdf'
|
|
1222
|
+
: contentType.includes('zip')
|
|
1223
|
+
? 'zip'
|
|
1224
|
+
: 'bin';
|
|
1225
|
+
fileName = `${fileName}.${ext}`;
|
|
1226
|
+
}
|
|
1227
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), fileName, contentType);
|
|
1228
|
+
returnData.push({
|
|
1229
|
+
json: { success: true },
|
|
1230
|
+
binary: { data: binaryData },
|
|
1231
|
+
pairedItem: { item: itemIndex },
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
const createMultipartBody = (fields, files) => {
|
|
1235
|
+
const boundary = `----n8nBoundary${Date.now().toString(16)}${Math.random().toString(16).slice(2)}`;
|
|
1236
|
+
const chunks = [];
|
|
1237
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
1238
|
+
if (value === undefined || value === null)
|
|
1239
|
+
continue;
|
|
1240
|
+
chunks.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="${key}"\r\n\r\n${String(value)}\r\n`));
|
|
1241
|
+
}
|
|
1242
|
+
for (const file of files) {
|
|
1243
|
+
chunks.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="${file.fieldName}"; filename="${file.fileName}"\r\nContent-Type: ${file.contentType}\r\n\r\n`));
|
|
1244
|
+
chunks.push(file.data);
|
|
1245
|
+
chunks.push(Buffer.from('\r\n'));
|
|
1246
|
+
}
|
|
1247
|
+
chunks.push(Buffer.from(`--${boundary}--\r\n`));
|
|
1248
|
+
return {
|
|
1249
|
+
body: Buffer.concat(chunks),
|
|
1250
|
+
headers: {
|
|
1251
|
+
'Content-Type': `multipart/form-data; boundary=${boundary}`,
|
|
1252
|
+
},
|
|
1253
|
+
};
|
|
1254
|
+
};
|
|
1255
|
+
const createSingleFileMultipart = async (itemIndex, binaryPropertyName, fileFieldName, fields) => {
|
|
1256
|
+
var _a, _b, _c;
|
|
1257
|
+
const binaryItem = (_a = items[itemIndex].binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
|
|
1258
|
+
if (!binaryItem) {
|
|
1259
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary property "${binaryPropertyName}" not found`, { itemIndex });
|
|
1260
|
+
}
|
|
1261
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
|
1262
|
+
return createMultipartBody(fields, [
|
|
1263
|
+
{
|
|
1264
|
+
fieldName: fileFieldName,
|
|
1265
|
+
fileName: (_b = binaryItem.fileName) !== null && _b !== void 0 ? _b : `${fileFieldName}.pdf`,
|
|
1266
|
+
contentType: (_c = binaryItem.mimeType) !== null && _c !== void 0 ? _c : 'application/pdf',
|
|
1267
|
+
data: fileBuffer,
|
|
1268
|
+
},
|
|
1269
|
+
]);
|
|
1270
|
+
};
|
|
1271
|
+
const createMultiFileMultipart = async (itemIndex, binaryPropertyNames, fileFieldName, fields) => {
|
|
1272
|
+
var _a, _b, _c;
|
|
1273
|
+
const files = [];
|
|
1274
|
+
for (const binaryPropertyName of binaryPropertyNames) {
|
|
1275
|
+
const trimmed = binaryPropertyName.trim();
|
|
1276
|
+
if (!trimmed)
|
|
1277
|
+
continue;
|
|
1278
|
+
const binaryItem = (_a = items[itemIndex].binary) === null || _a === void 0 ? void 0 : _a[trimmed];
|
|
1279
|
+
if (!binaryItem) {
|
|
1280
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary property "${trimmed}" not found`, { itemIndex });
|
|
1281
|
+
}
|
|
1282
|
+
const fileBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, trimmed);
|
|
1283
|
+
files.push({
|
|
1284
|
+
fieldName: fileFieldName,
|
|
1285
|
+
fileName: (_b = binaryItem.fileName) !== null && _b !== void 0 ? _b : `${trimmed}.pdf`,
|
|
1286
|
+
contentType: (_c = binaryItem.mimeType) !== null && _c !== void 0 ? _c : 'application/pdf',
|
|
1287
|
+
data: fileBuffer,
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
if (files.length < 2) {
|
|
1291
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least 2 binary PDF properties are required', {
|
|
1292
|
+
itemIndex,
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
return createMultipartBody(fields, files);
|
|
1296
|
+
};
|
|
682
1297
|
for (let i = 0; i < items.length; i++) {
|
|
683
1298
|
try {
|
|
684
1299
|
const resource = this.getNodeParameter('resource', i);
|
|
@@ -732,12 +1347,7 @@ class Htmlcsstopdf {
|
|
|
732
1347
|
});
|
|
733
1348
|
continue;
|
|
734
1349
|
}
|
|
735
|
-
|
|
736
|
-
returnData.push({
|
|
737
|
-
json: { success: true },
|
|
738
|
-
binary: { data: binaryData },
|
|
739
|
-
pairedItem: { item: i },
|
|
740
|
-
});
|
|
1350
|
+
await prepareBinaryResponse(i, responseData, `${outputFilename}.pdf`, 'application/pdf');
|
|
741
1351
|
}
|
|
742
1352
|
else {
|
|
743
1353
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
@@ -758,25 +1368,36 @@ class Htmlcsstopdf {
|
|
|
758
1368
|
}
|
|
759
1369
|
else if (resource === 'pdfManipulation') {
|
|
760
1370
|
if (operation === 'mergePdfs') {
|
|
761
|
-
const
|
|
762
|
-
const urls = pdfUrlsString.split(',').map((url) => url.trim()).filter((url) => url);
|
|
1371
|
+
const mergeInputType = this.getNodeParameter('merge_input_type', i);
|
|
763
1372
|
const outputType = this.getNodeParameter('merge_output', i);
|
|
764
|
-
if (urls.length < 2) {
|
|
765
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least 2 PDF URLs are required for merging', { itemIndex: i });
|
|
766
|
-
}
|
|
767
|
-
if (urls.length > 15) {
|
|
768
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Maximum 15 PDF URLs allowed for merging', { itemIndex: i });
|
|
769
|
-
}
|
|
770
1373
|
const body = {
|
|
771
|
-
urls,
|
|
772
1374
|
output: outputType,
|
|
773
1375
|
};
|
|
1376
|
+
const requestOptions = mergeInputType === 'file'
|
|
1377
|
+
? await createMultiFileMultipart(i, this.getNodeParameter('merge_file_binary_properties', i)
|
|
1378
|
+
.split(',')
|
|
1379
|
+
.map((name) => name.trim())
|
|
1380
|
+
.filter((name) => name), 'files', body)
|
|
1381
|
+
: (() => {
|
|
1382
|
+
const pdfUrlsString = this.getNodeParameter('pdf_urls', i);
|
|
1383
|
+
const urls = pdfUrlsString
|
|
1384
|
+
.split(',')
|
|
1385
|
+
.map((url) => url.trim())
|
|
1386
|
+
.filter((url) => url);
|
|
1387
|
+
if (urls.length < 2) {
|
|
1388
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least 2 PDF URLs are required for merging', { itemIndex: i });
|
|
1389
|
+
}
|
|
1390
|
+
if (urls.length > 15) {
|
|
1391
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Maximum 15 PDF URLs allowed for merging', { itemIndex: i });
|
|
1392
|
+
}
|
|
1393
|
+
body.urls = urls;
|
|
1394
|
+
return { body, json: true };
|
|
1395
|
+
})();
|
|
774
1396
|
if (outputType === 'file') {
|
|
775
1397
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
776
1398
|
method: 'POST',
|
|
777
1399
|
url: 'https://pdfmunk.com/api/v1/pdf/merge',
|
|
778
|
-
|
|
779
|
-
json: true,
|
|
1400
|
+
...requestOptions,
|
|
780
1401
|
encoding: 'arraybuffer',
|
|
781
1402
|
returnFullResponse: true,
|
|
782
1403
|
});
|
|
@@ -789,19 +1410,13 @@ class Htmlcsstopdf {
|
|
|
789
1410
|
});
|
|
790
1411
|
continue;
|
|
791
1412
|
}
|
|
792
|
-
|
|
793
|
-
returnData.push({
|
|
794
|
-
json: { success: true },
|
|
795
|
-
binary: { data: binaryData },
|
|
796
|
-
pairedItem: { item: i },
|
|
797
|
-
});
|
|
1413
|
+
await prepareBinaryResponse(i, responseData, 'merged.pdf', 'application/pdf');
|
|
798
1414
|
}
|
|
799
1415
|
else {
|
|
800
1416
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
801
1417
|
method: 'POST',
|
|
802
1418
|
url: 'https://pdfmunk.com/api/v1/pdf/merge',
|
|
803
|
-
|
|
804
|
-
json: true,
|
|
1419
|
+
...requestOptions,
|
|
805
1420
|
returnFullResponse: true,
|
|
806
1421
|
});
|
|
807
1422
|
const statusCode = (_e = responseData.statusCode) !== null && _e !== void 0 ? _e : 0;
|
|
@@ -813,13 +1428,15 @@ class Htmlcsstopdf {
|
|
|
813
1428
|
}
|
|
814
1429
|
}
|
|
815
1430
|
else if (operation === 'splitPdf') {
|
|
816
|
-
const
|
|
1431
|
+
const splitInputType = this.getNodeParameter('split_input_type', i);
|
|
817
1432
|
const splitMode = this.getNodeParameter('split_mode', i);
|
|
818
1433
|
const outputType = this.getNodeParameter('split_output', i);
|
|
819
1434
|
const body = {
|
|
820
|
-
url: pdfUrl,
|
|
821
1435
|
output: outputType,
|
|
822
1436
|
};
|
|
1437
|
+
if (splitInputType === 'url') {
|
|
1438
|
+
body.url = this.getNodeParameter('split_url', i);
|
|
1439
|
+
}
|
|
823
1440
|
if (splitMode === 'pages') {
|
|
824
1441
|
body.pages = this.getNodeParameter('pages', i);
|
|
825
1442
|
}
|
|
@@ -829,12 +1446,14 @@ class Htmlcsstopdf {
|
|
|
829
1446
|
else if (splitMode === 'chunks') {
|
|
830
1447
|
body.chunks = this.getNodeParameter('chunks', i);
|
|
831
1448
|
}
|
|
1449
|
+
const requestOptions = splitInputType === 'file'
|
|
1450
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('split_file_binary_property', i), 'file', body)
|
|
1451
|
+
: { body, json: true };
|
|
832
1452
|
if (outputType === 'file') {
|
|
833
1453
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
834
1454
|
method: 'POST',
|
|
835
1455
|
url: 'https://pdfmunk.com/api/v1/pdf/split',
|
|
836
|
-
|
|
837
|
-
json: true,
|
|
1456
|
+
...requestOptions,
|
|
838
1457
|
encoding: 'arraybuffer',
|
|
839
1458
|
returnFullResponse: true,
|
|
840
1459
|
});
|
|
@@ -847,19 +1466,13 @@ class Htmlcsstopdf {
|
|
|
847
1466
|
});
|
|
848
1467
|
continue;
|
|
849
1468
|
}
|
|
850
|
-
|
|
851
|
-
returnData.push({
|
|
852
|
-
json: { success: true },
|
|
853
|
-
binary: { data: binaryData },
|
|
854
|
-
pairedItem: { item: i },
|
|
855
|
-
});
|
|
1469
|
+
await prepareBinaryResponse(i, responseData, 'split.pdf', 'application/pdf');
|
|
856
1470
|
}
|
|
857
1471
|
else {
|
|
858
1472
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
859
1473
|
method: 'POST',
|
|
860
1474
|
url: 'https://pdfmunk.com/api/v1/pdf/split',
|
|
861
|
-
|
|
862
|
-
json: true,
|
|
1475
|
+
...requestOptions,
|
|
863
1476
|
returnFullResponse: true,
|
|
864
1477
|
});
|
|
865
1478
|
const statusCode = (_g = responseData.statusCode) !== null && _g !== void 0 ? _g : 0;
|
|
@@ -871,22 +1484,26 @@ class Htmlcsstopdf {
|
|
|
871
1484
|
}
|
|
872
1485
|
}
|
|
873
1486
|
else if (operation === 'compressPdf') {
|
|
874
|
-
const
|
|
1487
|
+
const compressInputType = this.getNodeParameter('compress_input_type', i);
|
|
875
1488
|
const compression = this.getNodeParameter('compression', i);
|
|
876
1489
|
const outputType = this.getNodeParameter('compress_output', i);
|
|
877
1490
|
const outputName = this.getNodeParameter('compress_output_name', i);
|
|
878
1491
|
const body = {
|
|
879
|
-
url: pdfUrl,
|
|
880
1492
|
compression,
|
|
881
1493
|
output: outputType,
|
|
882
1494
|
output_name: outputName,
|
|
883
1495
|
};
|
|
1496
|
+
if (compressInputType === 'url') {
|
|
1497
|
+
body.url = this.getNodeParameter('compress_url', i);
|
|
1498
|
+
}
|
|
1499
|
+
const requestOptions = compressInputType === 'file'
|
|
1500
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('compress_file_binary_property', i), 'file', body)
|
|
1501
|
+
: { body, json: true };
|
|
884
1502
|
if (outputType === 'file') {
|
|
885
1503
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
886
1504
|
method: 'POST',
|
|
887
1505
|
url: 'https://pdfmunk.com/api/v1/compressPdf',
|
|
888
|
-
|
|
889
|
-
json: true,
|
|
1506
|
+
...requestOptions,
|
|
890
1507
|
encoding: 'arraybuffer',
|
|
891
1508
|
returnFullResponse: true,
|
|
892
1509
|
});
|
|
@@ -899,22 +1516,196 @@ class Htmlcsstopdf {
|
|
|
899
1516
|
});
|
|
900
1517
|
continue;
|
|
901
1518
|
}
|
|
902
|
-
|
|
1519
|
+
await prepareBinaryResponse(i, responseData, outputName, 'application/pdf');
|
|
1520
|
+
}
|
|
1521
|
+
else {
|
|
1522
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1523
|
+
method: 'POST',
|
|
1524
|
+
url: 'https://pdfmunk.com/api/v1/compressPdf',
|
|
1525
|
+
...requestOptions,
|
|
1526
|
+
returnFullResponse: true,
|
|
1527
|
+
});
|
|
1528
|
+
const statusCode = (_j = responseData.statusCode) !== null && _j !== void 0 ? _j : 0;
|
|
1529
|
+
const bodyData = toJsonObject(responseData.body);
|
|
1530
|
+
returnData.push({
|
|
1531
|
+
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
1532
|
+
pairedItem: { item: i },
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
else if (operation === 'watermarkPdf') {
|
|
1537
|
+
const watermarkInputType = this.getNodeParameter('watermark_input_type', i);
|
|
1538
|
+
const outputFormat = this.getNodeParameter('watermark_output_format', i);
|
|
1539
|
+
const text = this.getNodeParameter('watermark_text', i);
|
|
1540
|
+
const opacity = this.getNodeParameter('watermark_opacity', i);
|
|
1541
|
+
const angle = this.getNodeParameter('watermark_angle', i);
|
|
1542
|
+
const fontSize = this.getNodeParameter('watermark_font_size', i);
|
|
1543
|
+
const body = {
|
|
1544
|
+
output_format: outputFormat,
|
|
1545
|
+
text,
|
|
1546
|
+
opacity,
|
|
1547
|
+
angle,
|
|
1548
|
+
};
|
|
1549
|
+
if (watermarkInputType === 'url') {
|
|
1550
|
+
body.file_url = this.getNodeParameter('watermark_file_url', i);
|
|
1551
|
+
}
|
|
1552
|
+
if (fontSize > 0) {
|
|
1553
|
+
body.font_size = fontSize;
|
|
1554
|
+
}
|
|
1555
|
+
const requestOptions = watermarkInputType === 'file'
|
|
1556
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('watermark_file_binary_property', i), 'file', body)
|
|
1557
|
+
: { body, json: true };
|
|
1558
|
+
if (outputFormat === 'file') {
|
|
1559
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1560
|
+
method: 'POST',
|
|
1561
|
+
url: 'https://pdfmunk.com/api/v1/watermark',
|
|
1562
|
+
...requestOptions,
|
|
1563
|
+
encoding: 'arraybuffer',
|
|
1564
|
+
returnFullResponse: true,
|
|
1565
|
+
});
|
|
1566
|
+
const statusCode = (_k = responseData.statusCode) !== null && _k !== void 0 ? _k : 0;
|
|
1567
|
+
if (statusCode >= 400) {
|
|
1568
|
+
const errorBody = parseArrayBufferBody(responseData.body);
|
|
1569
|
+
returnData.push({
|
|
1570
|
+
json: { ...errorBody, statusCode },
|
|
1571
|
+
pairedItem: { item: i },
|
|
1572
|
+
});
|
|
1573
|
+
continue;
|
|
1574
|
+
}
|
|
1575
|
+
await prepareBinaryResponse(i, responseData, 'watermarked.pdf', 'application/pdf');
|
|
1576
|
+
}
|
|
1577
|
+
else {
|
|
1578
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1579
|
+
method: 'POST',
|
|
1580
|
+
url: 'https://pdfmunk.com/api/v1/watermark',
|
|
1581
|
+
...requestOptions,
|
|
1582
|
+
returnFullResponse: true,
|
|
1583
|
+
});
|
|
1584
|
+
const statusCode = (_l = responseData.statusCode) !== null && _l !== void 0 ? _l : 0;
|
|
1585
|
+
const bodyData = toJsonObject(responseData.body);
|
|
903
1586
|
returnData.push({
|
|
904
|
-
json: {
|
|
905
|
-
binary: { data: binaryData },
|
|
1587
|
+
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
906
1588
|
pairedItem: { item: i },
|
|
907
1589
|
});
|
|
908
1590
|
}
|
|
1591
|
+
}
|
|
1592
|
+
else if (operation === 'convertPdfToImage') {
|
|
1593
|
+
const convertInputType = this.getNodeParameter('convert_pdf_image_input_type', i);
|
|
1594
|
+
const page = this.getNodeParameter('convert_pdf_image_page', i);
|
|
1595
|
+
const pages = this.getNodeParameter('convert_pdf_image_pages', i, '');
|
|
1596
|
+
const imageFormat = this.getNodeParameter('convert_pdf_image_format', i);
|
|
1597
|
+
const dpi = this.getNodeParameter('convert_pdf_image_dpi', i);
|
|
1598
|
+
const quality = this.getNodeParameter('convert_pdf_image_quality', i);
|
|
1599
|
+
const output = this.getNodeParameter('convert_pdf_image_output', i);
|
|
1600
|
+
const body = {
|
|
1601
|
+
image_format: imageFormat,
|
|
1602
|
+
dpi,
|
|
1603
|
+
quality,
|
|
1604
|
+
output,
|
|
1605
|
+
};
|
|
1606
|
+
if (convertInputType === 'url') {
|
|
1607
|
+
body.url = this.getNodeParameter('convert_pdf_image_url', i);
|
|
1608
|
+
}
|
|
1609
|
+
if ((pages !== null && pages !== void 0 ? pages : '').trim() !== '') {
|
|
1610
|
+
body.pages = pages;
|
|
1611
|
+
}
|
|
1612
|
+
else if (page > 0) {
|
|
1613
|
+
body.page = page;
|
|
1614
|
+
}
|
|
1615
|
+
const requestOptions = convertInputType === 'file'
|
|
1616
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('convert_pdf_image_file_binary_property', i), 'file', body)
|
|
1617
|
+
: { body, json: true };
|
|
1618
|
+
if (output === 'file') {
|
|
1619
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1620
|
+
method: 'POST',
|
|
1621
|
+
url: 'https://pdfmunk.com/api/v1/convert/pdf/image',
|
|
1622
|
+
...requestOptions,
|
|
1623
|
+
encoding: 'arraybuffer',
|
|
1624
|
+
returnFullResponse: true,
|
|
1625
|
+
});
|
|
1626
|
+
const statusCode = (_m = responseData.statusCode) !== null && _m !== void 0 ? _m : 0;
|
|
1627
|
+
if (statusCode >= 400) {
|
|
1628
|
+
const errorBody = parseArrayBufferBody(responseData.body);
|
|
1629
|
+
returnData.push({
|
|
1630
|
+
json: { ...errorBody, statusCode },
|
|
1631
|
+
pairedItem: { item: i },
|
|
1632
|
+
});
|
|
1633
|
+
continue;
|
|
1634
|
+
}
|
|
1635
|
+
await prepareBinaryResponse(i, responseData, `pdf-page.${imageFormat === 'jpg' ? 'jpg' : imageFormat}`, 'application/octet-stream');
|
|
1636
|
+
}
|
|
909
1637
|
else {
|
|
910
1638
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
911
1639
|
method: 'POST',
|
|
912
|
-
url: 'https://pdfmunk.com/api/v1/
|
|
1640
|
+
url: 'https://pdfmunk.com/api/v1/convert/pdf/image',
|
|
1641
|
+
...requestOptions,
|
|
1642
|
+
returnFullResponse: true,
|
|
1643
|
+
});
|
|
1644
|
+
const statusCode = (_o = responseData.statusCode) !== null && _o !== void 0 ? _o : 0;
|
|
1645
|
+
const bodyData = toJsonObject(responseData.body);
|
|
1646
|
+
returnData.push({
|
|
1647
|
+
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
1648
|
+
pairedItem: { item: i },
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
else if (operation === 'convertImageToPdf') {
|
|
1653
|
+
const urlsInput = this.getNodeParameter('convert_image_pdf_urls', i);
|
|
1654
|
+
const output = this.getNodeParameter('convert_image_pdf_output', i);
|
|
1655
|
+
const outputFilename = this.getNodeParameter('convert_image_pdf_filename', i);
|
|
1656
|
+
const urls = urlsInput
|
|
1657
|
+
.split(',')
|
|
1658
|
+
.map((url) => url.trim())
|
|
1659
|
+
.filter((url) => url);
|
|
1660
|
+
if (urls.length === 0) {
|
|
1661
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one image URL is required', {
|
|
1662
|
+
itemIndex: i,
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
if (urls.length > 100) {
|
|
1666
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Maximum 100 image URLs are allowed', {
|
|
1667
|
+
itemIndex: i,
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
const body = {
|
|
1671
|
+
output,
|
|
1672
|
+
output_filename: outputFilename,
|
|
1673
|
+
};
|
|
1674
|
+
if (urls.length === 1) {
|
|
1675
|
+
body.image_url = urls[0];
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
body.image_urls = urls;
|
|
1679
|
+
}
|
|
1680
|
+
if (output === 'file') {
|
|
1681
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1682
|
+
method: 'POST',
|
|
1683
|
+
url: 'https://pdfmunk.com/api/v1/convert/image/pdf',
|
|
913
1684
|
body,
|
|
914
1685
|
json: true,
|
|
1686
|
+
encoding: 'arraybuffer',
|
|
915
1687
|
returnFullResponse: true,
|
|
916
1688
|
});
|
|
917
|
-
const statusCode = (
|
|
1689
|
+
const statusCode = (_p = responseData.statusCode) !== null && _p !== void 0 ? _p : 0;
|
|
1690
|
+
if (statusCode >= 400) {
|
|
1691
|
+
const errorBody = parseArrayBufferBody(responseData.body);
|
|
1692
|
+
returnData.push({
|
|
1693
|
+
json: { ...errorBody, statusCode },
|
|
1694
|
+
pairedItem: { item: i },
|
|
1695
|
+
});
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
await prepareBinaryResponse(i, responseData, outputFilename.endsWith('.pdf') ? outputFilename : `${outputFilename}.pdf`, 'application/pdf');
|
|
1699
|
+
}
|
|
1700
|
+
else {
|
|
1701
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1702
|
+
method: 'POST',
|
|
1703
|
+
url: 'https://pdfmunk.com/api/v1/convert/image/pdf',
|
|
1704
|
+
body,
|
|
1705
|
+
json: true,
|
|
1706
|
+
returnFullResponse: true,
|
|
1707
|
+
});
|
|
1708
|
+
const statusCode = (_q = responseData.statusCode) !== null && _q !== void 0 ? _q : 0;
|
|
918
1709
|
const bodyData = toJsonObject(responseData.body);
|
|
919
1710
|
returnData.push({
|
|
920
1711
|
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
@@ -925,30 +1716,34 @@ class Htmlcsstopdf {
|
|
|
925
1716
|
}
|
|
926
1717
|
else if (resource === 'pdfSecurity') {
|
|
927
1718
|
if (operation === 'lockPdf') {
|
|
928
|
-
const
|
|
1719
|
+
const lockInputType = this.getNodeParameter('lock_input_type', i);
|
|
929
1720
|
const password = this.getNodeParameter('lock_password', i);
|
|
930
1721
|
const inputPassword = this.getNodeParameter('lock_input_password', i, '');
|
|
931
1722
|
const outputType = this.getNodeParameter('lock_output', i);
|
|
932
1723
|
const outputName = this.getNodeParameter('lock_output_name', i);
|
|
933
1724
|
const body = {
|
|
934
|
-
url: pdfUrl,
|
|
935
1725
|
password,
|
|
936
1726
|
output: outputType,
|
|
937
1727
|
output_name: outputName,
|
|
938
1728
|
};
|
|
1729
|
+
if (lockInputType === 'url') {
|
|
1730
|
+
body.url = this.getNodeParameter('lock_url', i);
|
|
1731
|
+
}
|
|
939
1732
|
if (inputPassword) {
|
|
940
1733
|
body.input_password = inputPassword;
|
|
941
1734
|
}
|
|
1735
|
+
const requestOptions = lockInputType === 'file'
|
|
1736
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('lock_file_binary_property', i), 'file', body)
|
|
1737
|
+
: { body, json: true };
|
|
942
1738
|
if (outputType === 'file') {
|
|
943
1739
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
944
1740
|
method: 'POST',
|
|
945
1741
|
url: 'https://pdfmunk.com/api/v1/lockPdf',
|
|
946
|
-
|
|
947
|
-
json: true,
|
|
1742
|
+
...requestOptions,
|
|
948
1743
|
encoding: 'arraybuffer',
|
|
949
1744
|
returnFullResponse: true,
|
|
950
1745
|
});
|
|
951
|
-
const statusCode = (
|
|
1746
|
+
const statusCode = (_r = responseData.statusCode) !== null && _r !== void 0 ? _r : 0;
|
|
952
1747
|
if (statusCode >= 400) {
|
|
953
1748
|
const errorBody = parseArrayBufferBody(responseData.body);
|
|
954
1749
|
returnData.push({
|
|
@@ -957,22 +1752,16 @@ class Htmlcsstopdf {
|
|
|
957
1752
|
});
|
|
958
1753
|
continue;
|
|
959
1754
|
}
|
|
960
|
-
|
|
961
|
-
returnData.push({
|
|
962
|
-
json: { success: true },
|
|
963
|
-
binary: { data: binaryData },
|
|
964
|
-
pairedItem: { item: i },
|
|
965
|
-
});
|
|
1755
|
+
await prepareBinaryResponse(i, responseData, outputName, 'application/pdf');
|
|
966
1756
|
}
|
|
967
1757
|
else {
|
|
968
1758
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
969
1759
|
method: 'POST',
|
|
970
1760
|
url: 'https://pdfmunk.com/api/v1/lockPdf',
|
|
971
|
-
|
|
972
|
-
json: true,
|
|
1761
|
+
...requestOptions,
|
|
973
1762
|
returnFullResponse: true,
|
|
974
1763
|
});
|
|
975
|
-
const statusCode = (
|
|
1764
|
+
const statusCode = (_s = responseData.statusCode) !== null && _s !== void 0 ? _s : 0;
|
|
976
1765
|
const bodyData = toJsonObject(responseData.body);
|
|
977
1766
|
returnData.push({
|
|
978
1767
|
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
@@ -981,26 +1770,30 @@ class Htmlcsstopdf {
|
|
|
981
1770
|
}
|
|
982
1771
|
}
|
|
983
1772
|
else if (operation === 'unlockPdf') {
|
|
984
|
-
const
|
|
1773
|
+
const unlockInputType = this.getNodeParameter('unlock_input_type', i);
|
|
985
1774
|
const password = this.getNodeParameter('unlock_password', i);
|
|
986
1775
|
const outputType = this.getNodeParameter('unlock_output', i);
|
|
987
1776
|
const outputName = this.getNodeParameter('unlock_output_name', i);
|
|
988
1777
|
const body = {
|
|
989
|
-
url: pdfUrl,
|
|
990
1778
|
password,
|
|
991
1779
|
output: outputType,
|
|
992
1780
|
output_name: outputName,
|
|
993
1781
|
};
|
|
1782
|
+
if (unlockInputType === 'url') {
|
|
1783
|
+
body.url = this.getNodeParameter('unlock_url', i);
|
|
1784
|
+
}
|
|
1785
|
+
const requestOptions = unlockInputType === 'file'
|
|
1786
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('unlock_file_binary_property', i), 'file', body)
|
|
1787
|
+
: { body, json: true };
|
|
994
1788
|
if (outputType === 'file') {
|
|
995
1789
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
996
1790
|
method: 'POST',
|
|
997
1791
|
url: 'https://pdfmunk.com/api/v1/unlockPdf',
|
|
998
|
-
|
|
999
|
-
json: true,
|
|
1792
|
+
...requestOptions,
|
|
1000
1793
|
encoding: 'arraybuffer',
|
|
1001
1794
|
returnFullResponse: true,
|
|
1002
1795
|
});
|
|
1003
|
-
const statusCode = (
|
|
1796
|
+
const statusCode = (_t = responseData.statusCode) !== null && _t !== void 0 ? _t : 0;
|
|
1004
1797
|
if (statusCode >= 400) {
|
|
1005
1798
|
const errorBody = parseArrayBufferBody(responseData.body);
|
|
1006
1799
|
returnData.push({
|
|
@@ -1009,22 +1802,16 @@ class Htmlcsstopdf {
|
|
|
1009
1802
|
});
|
|
1010
1803
|
continue;
|
|
1011
1804
|
}
|
|
1012
|
-
|
|
1013
|
-
returnData.push({
|
|
1014
|
-
json: { success: true },
|
|
1015
|
-
binary: { data: binaryData },
|
|
1016
|
-
pairedItem: { item: i },
|
|
1017
|
-
});
|
|
1805
|
+
await prepareBinaryResponse(i, responseData, outputName, 'application/pdf');
|
|
1018
1806
|
}
|
|
1019
1807
|
else {
|
|
1020
1808
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1021
1809
|
method: 'POST',
|
|
1022
1810
|
url: 'https://pdfmunk.com/api/v1/unlockPdf',
|
|
1023
|
-
|
|
1024
|
-
json: true,
|
|
1811
|
+
...requestOptions,
|
|
1025
1812
|
returnFullResponse: true,
|
|
1026
1813
|
});
|
|
1027
|
-
const statusCode = (
|
|
1814
|
+
const statusCode = (_u = responseData.statusCode) !== null && _u !== void 0 ? _u : 0;
|
|
1028
1815
|
const bodyData = toJsonObject(responseData.body);
|
|
1029
1816
|
returnData.push({
|
|
1030
1817
|
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
@@ -1035,22 +1822,59 @@ class Htmlcsstopdf {
|
|
|
1035
1822
|
}
|
|
1036
1823
|
else if (resource === 'pdfParsing') {
|
|
1037
1824
|
if (operation === 'parsePdf') {
|
|
1038
|
-
const
|
|
1825
|
+
const parseInputType = this.getNodeParameter('parse_input_type', i);
|
|
1039
1826
|
const mode = this.getNodeParameter('parse_mode', i);
|
|
1040
1827
|
const pages = this.getNodeParameter('parse_pages', i);
|
|
1041
1828
|
const body = {
|
|
1042
|
-
url: pdfUrl,
|
|
1043
1829
|
mode,
|
|
1044
1830
|
pages,
|
|
1045
1831
|
};
|
|
1832
|
+
if (parseInputType === 'url') {
|
|
1833
|
+
body.url = this.getNodeParameter('parse_url', i);
|
|
1834
|
+
}
|
|
1835
|
+
const requestOptions = parseInputType === 'file'
|
|
1836
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('parse_file_binary_property', i), 'file', body)
|
|
1837
|
+
: { body, json: true };
|
|
1046
1838
|
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1047
1839
|
method: 'POST',
|
|
1048
1840
|
url: 'https://pdfmunk.com/api/v1/pdf/parse',
|
|
1049
|
-
|
|
1050
|
-
|
|
1841
|
+
...requestOptions,
|
|
1842
|
+
returnFullResponse: true,
|
|
1843
|
+
});
|
|
1844
|
+
const statusCode = (_v = responseData.statusCode) !== null && _v !== void 0 ? _v : 0;
|
|
1845
|
+
const bodyData = toJsonObject(responseData.body);
|
|
1846
|
+
returnData.push({
|
|
1847
|
+
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|
|
1848
|
+
pairedItem: { item: i },
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
else if (operation === 'parsePdfOcr') {
|
|
1852
|
+
const parseInputType = this.getNodeParameter('parse_input_type', i);
|
|
1853
|
+
const pages = this.getNodeParameter('parse_pages', i);
|
|
1854
|
+
const lang = this.getNodeParameter('lang', i);
|
|
1855
|
+
const dpi = this.getNodeParameter('dpi', i);
|
|
1856
|
+
const psm = this.getNodeParameter('psm', i);
|
|
1857
|
+
const oem = this.getNodeParameter('oem', i);
|
|
1858
|
+
const body = {
|
|
1859
|
+
pages,
|
|
1860
|
+
lang,
|
|
1861
|
+
dpi,
|
|
1862
|
+
psm,
|
|
1863
|
+
oem,
|
|
1864
|
+
};
|
|
1865
|
+
if (parseInputType === 'url') {
|
|
1866
|
+
body.url = this.getNodeParameter('parse_url', i);
|
|
1867
|
+
}
|
|
1868
|
+
const requestOptions = parseInputType === 'file'
|
|
1869
|
+
? await createSingleFileMultipart(i, this.getNodeParameter('parse_file_binary_property', i), 'file', body)
|
|
1870
|
+
: { body, json: true };
|
|
1871
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'htmlcsstopdfApi', {
|
|
1872
|
+
method: 'POST',
|
|
1873
|
+
url: 'https://pdfmunk.com/api/v1/pdf/ocr/parse',
|
|
1874
|
+
...requestOptions,
|
|
1051
1875
|
returnFullResponse: true,
|
|
1052
1876
|
});
|
|
1053
|
-
const statusCode = (
|
|
1877
|
+
const statusCode = (_w = responseData.statusCode) !== null && _w !== void 0 ? _w : 0;
|
|
1054
1878
|
const bodyData = toJsonObject(responseData.body);
|
|
1055
1879
|
returnData.push({
|
|
1056
1880
|
json: statusCode >= 400 ? { ...bodyData, statusCode } : bodyData,
|