n8n-nodes-pdf-api-hub 4.0.5 → 4.0.6
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.
|
@@ -5,14 +5,14 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
5
5
|
class PdfSplitMerge {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.description = {
|
|
8
|
-
displayName: 'PDF API Hub
|
|
8
|
+
displayName: 'PDF API Hub',
|
|
9
9
|
name: 'pdfSplitMerge',
|
|
10
10
|
icon: { light: 'file:../../icons/pdfhub.light.svg', dark: 'file:../../icons/pdfhub.dark.svg' },
|
|
11
11
|
group: ['transform'],
|
|
12
12
|
version: 1,
|
|
13
|
-
description: '
|
|
13
|
+
description: 'PDF and image tools: merge/split/compress, OCR, convert, lock/unlock, watermark, and URL/HTML processing.',
|
|
14
14
|
defaults: {
|
|
15
|
-
name: 'PDF API Hub
|
|
15
|
+
name: 'PDF API Hub',
|
|
16
16
|
},
|
|
17
17
|
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
18
|
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
@@ -31,25 +31,55 @@ class PdfSplitMerge {
|
|
|
31
31
|
noDataExpression: true,
|
|
32
32
|
options: [
|
|
33
33
|
{
|
|
34
|
-
name: '
|
|
35
|
-
value: '
|
|
36
|
-
description: '
|
|
34
|
+
name: 'Image to PDF',
|
|
35
|
+
value: 'imageToPdf',
|
|
36
|
+
description: 'Convert images (PNG, WebP, JPG) to PDF',
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
name: '
|
|
40
|
-
value: '
|
|
41
|
-
description: 'Extract text
|
|
39
|
+
name: 'OCR to Searchable Text (PDF/Image)',
|
|
40
|
+
value: 'ocrParsing',
|
|
41
|
+
description: 'Extract searchable text from scanned PDFs/images',
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
name: 'PDF Merge / Split / Compress',
|
|
45
45
|
value: 'pdfManipulation',
|
|
46
46
|
description: 'Merge, split, or compress PDF documents',
|
|
47
47
|
},
|
|
48
|
+
{
|
|
49
|
+
name: 'PDF Parse / Extract Text',
|
|
50
|
+
value: 'pdfParsing',
|
|
51
|
+
description: 'Extract text or structured data from PDFs',
|
|
52
|
+
},
|
|
48
53
|
{
|
|
49
54
|
name: 'PDF Security (Lock / Unlock)',
|
|
50
55
|
value: 'pdfSecurity',
|
|
51
56
|
description: 'Lock and unlock password-protected PDFs',
|
|
52
57
|
},
|
|
58
|
+
{
|
|
59
|
+
name: 'PDF to Image',
|
|
60
|
+
value: 'pdfToImage',
|
|
61
|
+
description: 'Convert PDF pages to images (PNG, WebP)',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'URL to HTML',
|
|
65
|
+
value: 'urlToHtml',
|
|
66
|
+
description: 'Fetch HTML content from a URL',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Watermark PDF',
|
|
70
|
+
value: 'watermark',
|
|
71
|
+
description: 'Add watermark to PDF or image',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Website / HTML to Image',
|
|
75
|
+
value: 'imageGeneration',
|
|
76
|
+
description: 'Capture a website screenshot to image or render HTML/CSS to image',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'Website / HTML to PDF',
|
|
80
|
+
value: 'pdfCreation',
|
|
81
|
+
description: 'Capture a website screenshot to PDF or render HTML/CSS to PDF',
|
|
82
|
+
},
|
|
53
83
|
],
|
|
54
84
|
default: 'pdfParsing',
|
|
55
85
|
},
|
|
@@ -79,6 +109,162 @@ class PdfSplitMerge {
|
|
|
79
109
|
],
|
|
80
110
|
default: 'urlToPdf',
|
|
81
111
|
},
|
|
112
|
+
{
|
|
113
|
+
displayName: 'Operation',
|
|
114
|
+
name: 'operation',
|
|
115
|
+
type: 'options',
|
|
116
|
+
noDataExpression: true,
|
|
117
|
+
displayOptions: {
|
|
118
|
+
show: {
|
|
119
|
+
resource: ['imageGeneration'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
options: [
|
|
123
|
+
{
|
|
124
|
+
name: 'URL to Image',
|
|
125
|
+
value: 'urlToImage',
|
|
126
|
+
description: 'Capture website screenshot as image',
|
|
127
|
+
action: 'Capture a screenshot of a website as an image',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'HTML to Image',
|
|
131
|
+
value: 'htmlToImage',
|
|
132
|
+
description: 'Generate image from HTML/CSS',
|
|
133
|
+
action: 'Convert HTML to image',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
default: 'urlToImage',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
displayName: 'Operation',
|
|
140
|
+
name: 'operation',
|
|
141
|
+
type: 'options',
|
|
142
|
+
noDataExpression: true,
|
|
143
|
+
displayOptions: {
|
|
144
|
+
show: {
|
|
145
|
+
resource: ['ocrParsing'],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
options: [
|
|
149
|
+
{
|
|
150
|
+
name: 'PDF OCR Parse',
|
|
151
|
+
value: 'pdfOcrParse',
|
|
152
|
+
description: 'Extract text from scanned PDF using OCR',
|
|
153
|
+
action: 'Ocr parse a pdf document',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'Image OCR Parse',
|
|
157
|
+
value: 'imageOcrParse',
|
|
158
|
+
description: 'Extract text from image using OCR',
|
|
159
|
+
action: 'Ocr parse an image',
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
default: 'pdfOcrParse',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Operation',
|
|
166
|
+
name: 'operation',
|
|
167
|
+
type: 'options',
|
|
168
|
+
noDataExpression: true,
|
|
169
|
+
displayOptions: {
|
|
170
|
+
show: {
|
|
171
|
+
resource: ['imageToPdf'],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
options: [
|
|
175
|
+
{
|
|
176
|
+
name: 'PNG to PDF',
|
|
177
|
+
value: 'pngToPdf',
|
|
178
|
+
description: 'Convert PNG image(s) to PDF',
|
|
179
|
+
action: 'Convert PNG images to PDF',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'WebP to PDF',
|
|
183
|
+
value: 'webpToPdf',
|
|
184
|
+
description: 'Convert WebP image(s) to PDF',
|
|
185
|
+
action: 'Convert web p images to pdf',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'JPG to PDF',
|
|
189
|
+
value: 'jpgToPdf',
|
|
190
|
+
description: 'Convert JPG image(s) to PDF',
|
|
191
|
+
action: 'Convert JPG images to PDF',
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
default: 'pngToPdf',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
displayName: 'Operation',
|
|
198
|
+
name: 'operation',
|
|
199
|
+
type: 'options',
|
|
200
|
+
noDataExpression: true,
|
|
201
|
+
displayOptions: {
|
|
202
|
+
show: {
|
|
203
|
+
resource: ['pdfToImage'],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
options: [
|
|
207
|
+
{
|
|
208
|
+
name: 'PDF to PNG',
|
|
209
|
+
value: 'pdfToPng',
|
|
210
|
+
description: 'Convert PDF pages to PNG images',
|
|
211
|
+
action: 'Convert PDF to PNG images',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'PDF to WebP',
|
|
215
|
+
value: 'pdfToWebp',
|
|
216
|
+
description: 'Convert PDF pages to WebP images',
|
|
217
|
+
action: 'Convert pdf to web p images',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: 'PDF to JPG',
|
|
221
|
+
value: 'pdfToJpg',
|
|
222
|
+
description: 'Convert PDF pages to JPG images',
|
|
223
|
+
action: 'Convert PDF to JPG images',
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
default: 'pdfToPng',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
displayName: 'Operation',
|
|
230
|
+
name: 'operation',
|
|
231
|
+
type: 'options',
|
|
232
|
+
noDataExpression: true,
|
|
233
|
+
displayOptions: {
|
|
234
|
+
show: {
|
|
235
|
+
resource: ['urlToHtml'],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
options: [
|
|
239
|
+
{
|
|
240
|
+
name: 'Fetch HTML',
|
|
241
|
+
value: 'fetchHtml',
|
|
242
|
+
description: 'Fetch HTML content from a URL',
|
|
243
|
+
action: 'Fetch HTML content from a URL',
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
default: 'fetchHtml',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
displayName: 'Operation',
|
|
250
|
+
name: 'operation',
|
|
251
|
+
type: 'options',
|
|
252
|
+
noDataExpression: true,
|
|
253
|
+
displayOptions: {
|
|
254
|
+
show: {
|
|
255
|
+
resource: ['watermark'],
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
options: [
|
|
259
|
+
{
|
|
260
|
+
name: 'Add Watermark',
|
|
261
|
+
value: 'addWatermark',
|
|
262
|
+
description: 'Add diagonal text watermark to PDF or image',
|
|
263
|
+
action: 'Add watermark to PDF or image',
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
default: 'addWatermark',
|
|
267
|
+
},
|
|
82
268
|
{
|
|
83
269
|
displayName: 'Operation',
|
|
84
270
|
name: 'operation',
|
|
@@ -729,143 +915,838 @@ class PdfSplitMerge {
|
|
|
729
915
|
},
|
|
730
916
|
},
|
|
731
917
|
},
|
|
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
|
-
|
|
918
|
+
{
|
|
919
|
+
displayName: 'URL',
|
|
920
|
+
name: 'image_gen_url',
|
|
921
|
+
type: 'string',
|
|
922
|
+
default: '',
|
|
923
|
+
description: 'The URL of the website to capture as image',
|
|
924
|
+
displayOptions: {
|
|
925
|
+
show: {
|
|
926
|
+
operation: ['urlToImage'],
|
|
927
|
+
},
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
displayName: 'HTML Content',
|
|
932
|
+
name: 'image_html_content',
|
|
933
|
+
type: 'string',
|
|
934
|
+
default: '',
|
|
935
|
+
description: 'HTML content to render as image',
|
|
936
|
+
displayOptions: {
|
|
937
|
+
show: {
|
|
938
|
+
operation: ['htmlToImage'],
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
displayName: 'CSS Content',
|
|
944
|
+
name: 'image_css_content',
|
|
945
|
+
type: 'string',
|
|
946
|
+
default: '',
|
|
947
|
+
description: 'CSS to style the HTML',
|
|
948
|
+
displayOptions: {
|
|
949
|
+
show: {
|
|
950
|
+
operation: ['htmlToImage'],
|
|
951
|
+
},
|
|
952
|
+
},
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
displayName: 'Output Format',
|
|
956
|
+
name: 'image_output_format',
|
|
957
|
+
type: 'options',
|
|
958
|
+
options: [
|
|
959
|
+
{ name: 'URL', value: 'url' },
|
|
960
|
+
{ name: 'Base64', value: 'base64' },
|
|
961
|
+
{ name: 'Both', value: 'both' },
|
|
962
|
+
{ name: 'File', value: 'file' },
|
|
963
|
+
],
|
|
964
|
+
default: 'url',
|
|
965
|
+
description: 'Format of the output image',
|
|
966
|
+
displayOptions: {
|
|
967
|
+
show: {
|
|
968
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
969
|
+
},
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
displayName: 'Width',
|
|
974
|
+
name: 'image_width',
|
|
975
|
+
type: 'number',
|
|
976
|
+
default: 1280,
|
|
977
|
+
description: 'Width of the output image in pixels',
|
|
978
|
+
displayOptions: {
|
|
979
|
+
show: {
|
|
980
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
981
|
+
},
|
|
982
|
+
},
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
displayName: 'Height',
|
|
986
|
+
name: 'image_height',
|
|
987
|
+
type: 'number',
|
|
988
|
+
default: 720,
|
|
989
|
+
description: 'Height of the output image in pixels',
|
|
990
|
+
displayOptions: {
|
|
991
|
+
show: {
|
|
992
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
displayName: 'Viewport Width',
|
|
998
|
+
name: 'image_viewport_width',
|
|
999
|
+
type: 'number',
|
|
1000
|
+
default: 1920,
|
|
1001
|
+
description: 'Viewport width for rendering',
|
|
1002
|
+
displayOptions: {
|
|
1003
|
+
show: {
|
|
1004
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
1005
|
+
},
|
|
1006
|
+
},
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
displayName: 'Viewport Height',
|
|
1010
|
+
name: 'image_viewport_height',
|
|
1011
|
+
type: 'number',
|
|
1012
|
+
default: 1080,
|
|
1013
|
+
description: 'Viewport height for rendering',
|
|
1014
|
+
displayOptions: {
|
|
1015
|
+
show: {
|
|
1016
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
displayName: 'Device Scale Factor',
|
|
1022
|
+
name: 'image_device_scale',
|
|
1023
|
+
type: 'number',
|
|
1024
|
+
default: 1,
|
|
1025
|
+
description: 'Device scale factor for higher resolution (1-3)',
|
|
1026
|
+
displayOptions: {
|
|
1027
|
+
show: {
|
|
1028
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
1029
|
+
},
|
|
1030
|
+
},
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
displayName: 'Quality',
|
|
1034
|
+
name: 'image_quality',
|
|
1035
|
+
type: 'number',
|
|
1036
|
+
default: 80,
|
|
1037
|
+
description: 'Image quality (30-100)',
|
|
1038
|
+
displayOptions: {
|
|
1039
|
+
show: {
|
|
1040
|
+
operation: ['htmlToImage', 'urlToImage'],
|
|
1041
|
+
},
|
|
1042
|
+
},
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
displayName: 'Full Page',
|
|
1046
|
+
name: 'image_full_page',
|
|
1047
|
+
type: 'boolean',
|
|
1048
|
+
default: false,
|
|
1049
|
+
description: 'Whether to capture the full page (for URLs only)',
|
|
1050
|
+
displayOptions: {
|
|
1051
|
+
show: {
|
|
1052
|
+
operation: ['urlToImage'],
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
displayName: 'Wait Time (Seconds)',
|
|
1058
|
+
name: 'image_wait_till',
|
|
1059
|
+
type: 'number',
|
|
1060
|
+
default: 0,
|
|
1061
|
+
description: 'Time to wait in seconds before capturing',
|
|
1062
|
+
displayOptions: {
|
|
1063
|
+
show: {
|
|
1064
|
+
operation: ['urlToImage'],
|
|
1065
|
+
},
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
displayName: 'Wait Until',
|
|
1070
|
+
name: 'image_wait_until',
|
|
1071
|
+
type: 'options',
|
|
1072
|
+
options: [
|
|
1073
|
+
{ name: 'Load', value: 'load' },
|
|
1074
|
+
{ name: 'DOM Content Loaded', value: 'domcontentloaded' },
|
|
1075
|
+
{ name: 'Network Idle', value: 'networkidle' },
|
|
1076
|
+
],
|
|
1077
|
+
default: 'load',
|
|
1078
|
+
description: 'When to consider navigation successful',
|
|
1079
|
+
displayOptions: {
|
|
1080
|
+
show: {
|
|
1081
|
+
operation: ['urlToImage'],
|
|
1082
|
+
},
|
|
1083
|
+
},
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
displayName: 'Google Font',
|
|
1087
|
+
name: 'image_font',
|
|
1088
|
+
type: 'string',
|
|
1089
|
+
default: '',
|
|
1090
|
+
description: 'Google Font name(s) to include (use | separator for multiple)',
|
|
1091
|
+
displayOptions: {
|
|
1092
|
+
show: {
|
|
1093
|
+
operation: ['htmlToImage'],
|
|
1094
|
+
},
|
|
1095
|
+
},
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
displayName: 'Dynamic Params',
|
|
1099
|
+
name: 'image_dynamic_params',
|
|
1100
|
+
type: 'fixedCollection',
|
|
1101
|
+
typeOptions: {
|
|
1102
|
+
multipleValues: true,
|
|
1103
|
+
},
|
|
1104
|
+
default: {},
|
|
1105
|
+
description: 'Dynamic parameters to replace in HTML',
|
|
1106
|
+
displayOptions: {
|
|
1107
|
+
show: {
|
|
1108
|
+
operation: ['htmlToImage'],
|
|
1109
|
+
},
|
|
1110
|
+
},
|
|
1111
|
+
options: [
|
|
1112
|
+
{
|
|
1113
|
+
name: 'params',
|
|
1114
|
+
displayName: 'Params',
|
|
1115
|
+
values: [
|
|
1116
|
+
{
|
|
1117
|
+
displayName: 'Key',
|
|
1118
|
+
name: 'key',
|
|
1119
|
+
type: 'string',
|
|
1120
|
+
default: '',
|
|
1121
|
+
description: 'Placeholder key',
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
displayName: 'Value',
|
|
1125
|
+
name: 'value',
|
|
1126
|
+
type: 'string',
|
|
1127
|
+
default: '',
|
|
1128
|
+
description: 'Replacement value',
|
|
1129
|
+
},
|
|
1130
|
+
],
|
|
1131
|
+
},
|
|
1132
|
+
],
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
displayName: 'PDF URL',
|
|
1136
|
+
name: 'ocr_pdf_url',
|
|
1137
|
+
type: 'string',
|
|
1138
|
+
default: '',
|
|
1139
|
+
description: 'URL of the PDF to OCR parse',
|
|
1140
|
+
displayOptions: {
|
|
1141
|
+
show: {
|
|
1142
|
+
operation: ['pdfOcrParse'],
|
|
1143
|
+
},
|
|
1144
|
+
},
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
displayName: 'Pages',
|
|
1148
|
+
name: 'ocr_pages',
|
|
1149
|
+
type: 'string',
|
|
1150
|
+
default: 'all',
|
|
1151
|
+
description: 'Page selection: "all", a range like "1-3", or comma list like "1,3,5-7"',
|
|
1152
|
+
displayOptions: {
|
|
1153
|
+
show: {
|
|
1154
|
+
operation: ['pdfOcrParse'],
|
|
1155
|
+
},
|
|
1156
|
+
},
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
displayName: 'Image URL',
|
|
1160
|
+
name: 'ocr_image_url',
|
|
1161
|
+
type: 'string',
|
|
1162
|
+
default: '',
|
|
1163
|
+
description: 'URL of the image to OCR parse',
|
|
1164
|
+
displayOptions: {
|
|
1165
|
+
show: {
|
|
1166
|
+
operation: ['imageOcrParse'],
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
displayName: 'Base64 Image',
|
|
1172
|
+
name: 'ocr_base64_image',
|
|
1173
|
+
type: 'string',
|
|
1174
|
+
default: '',
|
|
1175
|
+
description: 'Base64 image string (plain or data URL) - alternative to URL',
|
|
1176
|
+
displayOptions: {
|
|
1177
|
+
show: {
|
|
1178
|
+
operation: ['imageOcrParse'],
|
|
1179
|
+
},
|
|
1180
|
+
},
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
displayName: 'Language',
|
|
1184
|
+
name: 'ocr_lang',
|
|
1185
|
+
type: 'string',
|
|
1186
|
+
default: 'eng',
|
|
1187
|
+
description: 'OCR language code(s), for example "eng" or "eng+hin"',
|
|
1188
|
+
displayOptions: {
|
|
1189
|
+
show: {
|
|
1190
|
+
operation: ['pdfOcrParse', 'imageOcrParse'],
|
|
1191
|
+
},
|
|
1192
|
+
},
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
displayName: 'DPI',
|
|
1196
|
+
name: 'ocr_dpi',
|
|
1197
|
+
type: 'number',
|
|
1198
|
+
default: 200,
|
|
1199
|
+
description: 'Rasterization DPI before OCR (72-400)',
|
|
1200
|
+
displayOptions: {
|
|
1201
|
+
show: {
|
|
1202
|
+
operation: ['pdfOcrParse'],
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
displayName: 'Page Segmentation Mode (PSM)',
|
|
1208
|
+
name: 'ocr_psm',
|
|
1209
|
+
type: 'number',
|
|
1210
|
+
default: 3,
|
|
1211
|
+
description: 'Page segmentation mode (0-13)',
|
|
1212
|
+
displayOptions: {
|
|
1213
|
+
show: {
|
|
1214
|
+
operation: ['pdfOcrParse', 'imageOcrParse'],
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
displayName: 'OCR Engine Mode (OEM)',
|
|
1220
|
+
name: 'ocr_oem',
|
|
1221
|
+
type: 'number',
|
|
1222
|
+
default: 3,
|
|
1223
|
+
description: 'OCR engine mode (0-3)',
|
|
1224
|
+
displayOptions: {
|
|
1225
|
+
show: {
|
|
1226
|
+
operation: ['pdfOcrParse', 'imageOcrParse'],
|
|
1227
|
+
},
|
|
1228
|
+
},
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
displayName: 'Input Type',
|
|
1232
|
+
name: 'img2pdf_input_type',
|
|
1233
|
+
type: 'options',
|
|
1234
|
+
options: [
|
|
1235
|
+
{ name: 'URL(s)', value: 'url' },
|
|
1236
|
+
{ name: 'Base64', value: 'base64' },
|
|
1237
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1238
|
+
],
|
|
1239
|
+
default: 'url',
|
|
1240
|
+
description: 'How to provide the image(s)',
|
|
1241
|
+
displayOptions: {
|
|
1242
|
+
show: {
|
|
1243
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1244
|
+
},
|
|
1245
|
+
},
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
displayName: 'Image URLs',
|
|
1249
|
+
name: 'img2pdf_urls',
|
|
1250
|
+
type: 'string',
|
|
1251
|
+
typeOptions: {
|
|
1252
|
+
multipleValues: true,
|
|
1253
|
+
},
|
|
1254
|
+
default: [],
|
|
1255
|
+
description: 'Array of image URLs to convert (max 100)',
|
|
1256
|
+
placeholder: 'https://example.com/image.png',
|
|
1257
|
+
displayOptions: {
|
|
1258
|
+
show: {
|
|
1259
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1260
|
+
img2pdf_input_type: ['url'],
|
|
1261
|
+
},
|
|
1262
|
+
},
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
displayName: 'Base64 Image(s)',
|
|
1266
|
+
name: 'img2pdf_base64',
|
|
1267
|
+
type: 'string',
|
|
1268
|
+
typeOptions: {
|
|
1269
|
+
multipleValues: true,
|
|
1270
|
+
},
|
|
1271
|
+
default: [],
|
|
1272
|
+
description: 'Base64 image payload(s)',
|
|
1273
|
+
displayOptions: {
|
|
1274
|
+
show: {
|
|
1275
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1276
|
+
img2pdf_input_type: ['base64'],
|
|
1277
|
+
},
|
|
1278
|
+
},
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
displayName: 'Binary Property Names',
|
|
1282
|
+
name: 'img2pdf_binary_properties',
|
|
1283
|
+
type: 'string',
|
|
1284
|
+
typeOptions: {
|
|
1285
|
+
multipleValues: true,
|
|
1286
|
+
},
|
|
1287
|
+
default: ['data'],
|
|
1288
|
+
description: 'Binary property names containing images to convert',
|
|
1289
|
+
displayOptions: {
|
|
1290
|
+
show: {
|
|
1291
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1292
|
+
img2pdf_input_type: ['file'],
|
|
1293
|
+
},
|
|
1294
|
+
},
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
displayName: 'Output Format',
|
|
1298
|
+
name: 'img2pdf_output',
|
|
1299
|
+
type: 'options',
|
|
1300
|
+
options: [
|
|
1301
|
+
{ name: 'URL', value: 'url' },
|
|
1302
|
+
{ name: 'Base64', value: 'base64' },
|
|
1303
|
+
{ name: 'Both', value: 'both' },
|
|
1304
|
+
{ name: 'File', value: 'file' },
|
|
1305
|
+
],
|
|
1306
|
+
default: 'url',
|
|
1307
|
+
description: 'Format of the output PDF',
|
|
1308
|
+
displayOptions: {
|
|
1309
|
+
show: {
|
|
1310
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1311
|
+
},
|
|
1312
|
+
},
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
displayName: 'Output Filename',
|
|
1316
|
+
name: 'img2pdf_output_filename',
|
|
1317
|
+
type: 'string',
|
|
1318
|
+
default: 'converted.pdf',
|
|
1319
|
+
description: 'Filename for the output PDF',
|
|
1320
|
+
displayOptions: {
|
|
1321
|
+
show: {
|
|
1322
|
+
operation: ['pngToPdf', 'webpToPdf', 'jpgToPdf'],
|
|
1323
|
+
},
|
|
1324
|
+
},
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
displayName: 'PDF URL',
|
|
1328
|
+
name: 'pdf2img_url',
|
|
1329
|
+
type: 'string',
|
|
1330
|
+
default: '',
|
|
1331
|
+
description: 'URL of the PDF to convert',
|
|
1332
|
+
displayOptions: {
|
|
1333
|
+
show: {
|
|
1334
|
+
operation: ['pdfToPng', 'pdfToWebp', 'pdfToJpg'],
|
|
1335
|
+
},
|
|
1336
|
+
},
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
displayName: 'Pages',
|
|
1340
|
+
name: 'pdf2img_pages',
|
|
1341
|
+
type: 'string',
|
|
1342
|
+
default: '1',
|
|
1343
|
+
description: 'Page(s) to convert: single number like "1", range like "1-3", or comma list',
|
|
1344
|
+
displayOptions: {
|
|
1345
|
+
show: {
|
|
1346
|
+
operation: ['pdfToPng', 'pdfToWebp', 'pdfToJpg'],
|
|
1347
|
+
},
|
|
1348
|
+
},
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
displayName: 'DPI',
|
|
1352
|
+
name: 'pdf2img_dpi',
|
|
1353
|
+
type: 'number',
|
|
1354
|
+
default: 150,
|
|
1355
|
+
description: 'Output image DPI (72-300)',
|
|
1356
|
+
displayOptions: {
|
|
1357
|
+
show: {
|
|
1358
|
+
operation: ['pdfToPng', 'pdfToWebp', 'pdfToJpg'],
|
|
1359
|
+
},
|
|
1360
|
+
},
|
|
1361
|
+
},
|
|
1362
|
+
{
|
|
1363
|
+
displayName: 'Quality',
|
|
1364
|
+
name: 'pdf2img_quality',
|
|
1365
|
+
type: 'number',
|
|
1366
|
+
default: 85,
|
|
1367
|
+
description: 'Image quality (1-100)',
|
|
1368
|
+
displayOptions: {
|
|
1369
|
+
show: {
|
|
1370
|
+
operation: ['pdfToPng', 'pdfToWebp', 'pdfToJpg'],
|
|
1371
|
+
},
|
|
1372
|
+
},
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
displayName: 'Output Format',
|
|
1376
|
+
name: 'pdf2img_output',
|
|
1377
|
+
type: 'options',
|
|
1378
|
+
options: [
|
|
1379
|
+
{ name: 'URL', value: 'url' },
|
|
1380
|
+
{ name: 'Base64', value: 'base64' },
|
|
1381
|
+
{ name: 'Both', value: 'both' },
|
|
1382
|
+
{ name: 'File', value: 'file' },
|
|
1383
|
+
],
|
|
1384
|
+
default: 'url',
|
|
1385
|
+
description: 'Format of the output',
|
|
1386
|
+
displayOptions: {
|
|
1387
|
+
show: {
|
|
1388
|
+
operation: ['pdfToPng', 'pdfToWebp', 'pdfToJpg'],
|
|
1389
|
+
},
|
|
1390
|
+
},
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
displayName: 'URL',
|
|
1394
|
+
name: 'html_fetch_url',
|
|
1395
|
+
type: 'string',
|
|
1396
|
+
default: '',
|
|
1397
|
+
description: 'URL to fetch HTML from',
|
|
1398
|
+
displayOptions: {
|
|
1399
|
+
show: {
|
|
1400
|
+
operation: ['fetchHtml'],
|
|
1401
|
+
},
|
|
1402
|
+
},
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
displayName: 'Wait Until',
|
|
1406
|
+
name: 'html_wait_till',
|
|
1407
|
+
type: 'options',
|
|
1408
|
+
options: [
|
|
1409
|
+
{ name: 'Load', value: 'load' },
|
|
1410
|
+
{ name: 'DOM Content Loaded', value: 'domcontentloaded' },
|
|
1411
|
+
{ name: 'Network Idle', value: 'networkidle' },
|
|
1412
|
+
],
|
|
1413
|
+
default: 'load',
|
|
1414
|
+
description: 'When to consider navigation successful',
|
|
1415
|
+
displayOptions: {
|
|
1416
|
+
show: {
|
|
1417
|
+
operation: ['fetchHtml'],
|
|
1418
|
+
},
|
|
1419
|
+
},
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
displayName: 'Timeout (Ms)',
|
|
1423
|
+
name: 'html_timeout',
|
|
1424
|
+
type: 'number',
|
|
1425
|
+
default: 30000,
|
|
1426
|
+
description: 'Maximum wait time in milliseconds',
|
|
1427
|
+
displayOptions: {
|
|
1428
|
+
show: {
|
|
1429
|
+
operation: ['fetchHtml'],
|
|
1430
|
+
},
|
|
1431
|
+
},
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
displayName: 'Wait For Selector',
|
|
1435
|
+
name: 'html_wait_for_selector',
|
|
1436
|
+
type: 'string',
|
|
1437
|
+
default: '',
|
|
1438
|
+
description: 'CSS selector to wait for before returning HTML',
|
|
1439
|
+
displayOptions: {
|
|
1440
|
+
show: {
|
|
1441
|
+
operation: ['fetchHtml'],
|
|
1442
|
+
},
|
|
1443
|
+
},
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
displayName: 'Additional Wait (Ms)',
|
|
1447
|
+
name: 'html_wait_for_timeout',
|
|
1448
|
+
type: 'number',
|
|
1449
|
+
default: 0,
|
|
1450
|
+
description: 'Additional wait time in milliseconds after page load',
|
|
1451
|
+
displayOptions: {
|
|
1452
|
+
show: {
|
|
1453
|
+
operation: ['fetchHtml'],
|
|
1454
|
+
},
|
|
1455
|
+
},
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
displayName: 'Viewport Width',
|
|
1459
|
+
name: 'html_viewport_width',
|
|
1460
|
+
type: 'number',
|
|
1461
|
+
default: 1920,
|
|
1462
|
+
displayOptions: {
|
|
1463
|
+
show: {
|
|
1464
|
+
operation: ['fetchHtml'],
|
|
1465
|
+
},
|
|
1466
|
+
},
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
displayName: 'Viewport Height',
|
|
1470
|
+
name: 'html_viewport_height',
|
|
1471
|
+
type: 'number',
|
|
1472
|
+
default: 1080,
|
|
1473
|
+
displayOptions: {
|
|
1474
|
+
show: {
|
|
1475
|
+
operation: ['fetchHtml'],
|
|
1476
|
+
},
|
|
1477
|
+
},
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
displayName: 'User Agent',
|
|
1481
|
+
name: 'html_user_agent',
|
|
1482
|
+
type: 'string',
|
|
1483
|
+
default: '',
|
|
1484
|
+
description: 'Custom user agent string',
|
|
1485
|
+
displayOptions: {
|
|
1486
|
+
show: {
|
|
1487
|
+
operation: ['fetchHtml'],
|
|
1488
|
+
},
|
|
1489
|
+
},
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
displayName: 'Input Type',
|
|
1493
|
+
name: 'watermark_input_type',
|
|
1494
|
+
type: 'options',
|
|
1495
|
+
options: [
|
|
1496
|
+
{ name: 'URL', value: 'url' },
|
|
1497
|
+
{ name: 'Base64', value: 'base64' },
|
|
1498
|
+
{ name: 'File (Binary)', value: 'file' },
|
|
1499
|
+
],
|
|
1500
|
+
default: 'url',
|
|
1501
|
+
description: 'How to provide the file to watermark',
|
|
1502
|
+
displayOptions: {
|
|
1503
|
+
show: {
|
|
1504
|
+
operation: ['addWatermark'],
|
|
1505
|
+
},
|
|
1506
|
+
},
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
displayName: 'File URL',
|
|
1510
|
+
name: 'watermark_url',
|
|
1511
|
+
type: 'string',
|
|
1512
|
+
default: '',
|
|
1513
|
+
description: 'URL of the PDF or image to watermark',
|
|
1514
|
+
displayOptions: {
|
|
1515
|
+
show: {
|
|
1516
|
+
operation: ['addWatermark'],
|
|
1517
|
+
watermark_input_type: ['url'],
|
|
1518
|
+
},
|
|
1519
|
+
},
|
|
1520
|
+
},
|
|
1521
|
+
{
|
|
1522
|
+
displayName: 'Base64 File',
|
|
1523
|
+
name: 'watermark_base64',
|
|
1524
|
+
type: 'string',
|
|
1525
|
+
default: '',
|
|
1526
|
+
description: 'Base64-encoded file contents',
|
|
1527
|
+
displayOptions: {
|
|
1528
|
+
show: {
|
|
1529
|
+
operation: ['addWatermark'],
|
|
1530
|
+
watermark_input_type: ['base64'],
|
|
1531
|
+
},
|
|
1532
|
+
},
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
displayName: 'Binary Property Name',
|
|
1536
|
+
name: 'watermark_binary_property',
|
|
1537
|
+
type: 'string',
|
|
1538
|
+
default: 'data',
|
|
1539
|
+
description: 'Binary property name containing the file',
|
|
1540
|
+
displayOptions: {
|
|
1541
|
+
show: {
|
|
1542
|
+
operation: ['addWatermark'],
|
|
1543
|
+
watermark_input_type: ['file'],
|
|
1544
|
+
},
|
|
1545
|
+
},
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
displayName: 'Watermark Text',
|
|
1549
|
+
name: 'watermark_text',
|
|
1550
|
+
type: 'string',
|
|
1551
|
+
default: 'CONFIDENTIAL',
|
|
1552
|
+
description: 'Text to use as watermark',
|
|
1553
|
+
displayOptions: {
|
|
1554
|
+
show: {
|
|
1555
|
+
operation: ['addWatermark'],
|
|
1556
|
+
},
|
|
1557
|
+
},
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
displayName: 'Opacity',
|
|
1561
|
+
name: 'watermark_opacity',
|
|
1562
|
+
type: 'number',
|
|
1563
|
+
default: 0.15,
|
|
1564
|
+
description: 'Watermark opacity (0.0 to 1.0)',
|
|
1565
|
+
displayOptions: {
|
|
1566
|
+
show: {
|
|
1567
|
+
operation: ['addWatermark'],
|
|
1568
|
+
},
|
|
1569
|
+
},
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
displayName: 'Angle',
|
|
1573
|
+
name: 'watermark_angle',
|
|
1574
|
+
type: 'number',
|
|
1575
|
+
default: 30,
|
|
1576
|
+
description: 'Rotation angle in degrees',
|
|
1577
|
+
displayOptions: {
|
|
1578
|
+
show: {
|
|
1579
|
+
operation: ['addWatermark'],
|
|
1580
|
+
},
|
|
1581
|
+
},
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
displayName: 'Font Size',
|
|
1585
|
+
name: 'watermark_font_size',
|
|
1586
|
+
type: 'number',
|
|
1587
|
+
default: 0,
|
|
1588
|
+
description: 'Font size (0 for auto)',
|
|
1589
|
+
displayOptions: {
|
|
1590
|
+
show: {
|
|
1591
|
+
operation: ['addWatermark'],
|
|
1592
|
+
},
|
|
1593
|
+
},
|
|
1594
|
+
},
|
|
1595
|
+
{
|
|
1596
|
+
displayName: 'Output Format',
|
|
1597
|
+
name: 'watermark_output',
|
|
1598
|
+
type: 'options',
|
|
1599
|
+
options: [
|
|
1600
|
+
{ name: 'File', value: 'file' },
|
|
1601
|
+
{ name: 'URL', value: 'url' },
|
|
1602
|
+
{ name: 'Base64', value: 'base64' },
|
|
1603
|
+
{ name: 'Both', value: 'both' },
|
|
1604
|
+
],
|
|
1605
|
+
default: 'file',
|
|
1606
|
+
description: 'Format of the watermarked output',
|
|
1607
|
+
displayOptions: {
|
|
1608
|
+
show: {
|
|
1609
|
+
operation: ['addWatermark'],
|
|
1610
|
+
},
|
|
1611
|
+
},
|
|
1612
|
+
},
|
|
1613
|
+
],
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
async execute() {
|
|
1617
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1618
|
+
const items = this.getInputData();
|
|
1619
|
+
const returnData = [];
|
|
1620
|
+
const prepareBinaryResponse = async (itemIndex, responseData, fallbackFileName, fallbackMimeType) => {
|
|
1621
|
+
var _a, _b, _c;
|
|
1622
|
+
const headers = (_a = responseData.headers) !== null && _a !== void 0 ? _a : {};
|
|
1623
|
+
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);
|
|
1624
|
+
const contentType = ((_c = contentTypeHeader === null || contentTypeHeader === void 0 ? void 0 : contentTypeHeader.split(';')[0]) === null || _c === void 0 ? void 0 : _c.trim()) || fallbackMimeType;
|
|
1625
|
+
let fileName = fallbackFileName;
|
|
1626
|
+
if (!fileName) {
|
|
1627
|
+
fileName = 'output';
|
|
1628
|
+
}
|
|
1629
|
+
if (!fileName.includes('.') && contentType.includes('/')) {
|
|
1630
|
+
const ext = contentType.includes('pdf')
|
|
1631
|
+
? 'pdf'
|
|
1632
|
+
: contentType.includes('zip')
|
|
1633
|
+
? 'zip'
|
|
1634
|
+
: 'bin';
|
|
1635
|
+
fileName = `${fileName}.${ext}`;
|
|
1636
|
+
}
|
|
1637
|
+
const binaryData = await this.helpers.prepareBinaryData(Buffer.from(responseData.body), fileName, contentType);
|
|
1638
|
+
returnData.push({
|
|
1639
|
+
json: { success: true },
|
|
1640
|
+
binary: { data: binaryData },
|
|
1641
|
+
pairedItem: { item: itemIndex },
|
|
1642
|
+
});
|
|
1643
|
+
};
|
|
1644
|
+
for (let i = 0; i < items.length; i++) {
|
|
1645
|
+
try {
|
|
1646
|
+
const operation = this.getNodeParameter('operation', i);
|
|
1647
|
+
if (operation === 'htmlToPdf' || operation === 'urlToPdf') {
|
|
1648
|
+
const outputFormat = this.getNodeParameter('output_format', i);
|
|
1649
|
+
const outputFilename = this.getNodeParameter('output_filename', i);
|
|
1650
|
+
const timeoutSeconds = this.getNodeParameter('timeout', i);
|
|
1651
|
+
const timeout = timeoutSeconds * 1000;
|
|
1652
|
+
const body = { output_filename: outputFilename };
|
|
1653
|
+
if (operation === 'htmlToPdf') {
|
|
1654
|
+
body.html_content = this.getNodeParameter('html_content', i);
|
|
1655
|
+
body.css_content = this.getNodeParameter('css_content', i);
|
|
1656
|
+
body.viewPortWidth = this.getNodeParameter('viewPortWidth', i);
|
|
1657
|
+
body.viewPortHeight = this.getNodeParameter('viewPortHeight', i);
|
|
1658
|
+
body.output_format = outputFormat;
|
|
1659
|
+
const dynamicParams = this.getNodeParameter('dynamic_params', i, {});
|
|
1660
|
+
if ((_a = dynamicParams.params) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1661
|
+
const mapped = dynamicParams.params
|
|
1662
|
+
.filter((p) => { var _a; return ((_a = p.key) !== null && _a !== void 0 ? _a : '') !== ''; })
|
|
1663
|
+
.map((p) => { var _a; return ({ [p.key]: (_a = p.value) !== null && _a !== void 0 ? _a : '' }); });
|
|
1664
|
+
if (mapped.length) {
|
|
1665
|
+
body.dynamic_params = mapped;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
else {
|
|
1670
|
+
body.url = this.getNodeParameter('url_to_pdf', i);
|
|
1671
|
+
body.full_page = this.getNodeParameter('full_page', i);
|
|
1672
|
+
body.wait_till = this.getNodeParameter('wait_till', i);
|
|
1673
|
+
body.viewPortWidth = this.getNodeParameter('viewPortWidth', i);
|
|
1674
|
+
body.viewPortHeight = this.getNodeParameter('viewPortHeight', i);
|
|
1675
|
+
body.output_format = outputFormat;
|
|
1676
|
+
}
|
|
1677
|
+
if (outputFormat === 'file') {
|
|
1678
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
1679
|
+
method: 'POST',
|
|
1680
|
+
url: 'https://pdfapihub.com/api/v1/generatePdf',
|
|
1681
|
+
body,
|
|
1682
|
+
json: true,
|
|
1683
|
+
encoding: 'arraybuffer',
|
|
1684
|
+
returnFullResponse: true,
|
|
1685
|
+
timeout,
|
|
1686
|
+
});
|
|
1687
|
+
await prepareBinaryResponse(i, responseData, `${outputFilename}.pdf`, 'application/pdf');
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
1691
|
+
method: 'POST',
|
|
1692
|
+
url: 'https://pdfapihub.com/api/v1/generatePdf',
|
|
1693
|
+
body,
|
|
1694
|
+
json: true,
|
|
1695
|
+
timeout,
|
|
1696
|
+
});
|
|
1697
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
else if (operation === 'mergePdf') {
|
|
1701
|
+
const output = this.getNodeParameter('output', i);
|
|
1702
|
+
const mergeInputType = this.getNodeParameter('merge_input_type', i);
|
|
1703
|
+
const isFileInput = mergeInputType === 'file';
|
|
1704
|
+
const body = !isFileInput
|
|
1705
|
+
? {
|
|
1706
|
+
urls: this.getNodeParameter('urls', i),
|
|
1707
|
+
output,
|
|
1708
|
+
}
|
|
1709
|
+
: undefined;
|
|
1710
|
+
let multipartBody;
|
|
1711
|
+
let multipartBoundary;
|
|
1712
|
+
if (isFileInput) {
|
|
1713
|
+
const binaryPropertyNamesParam = this.getNodeParameter('merge_files_binary_properties', i);
|
|
1714
|
+
const binaryPropertyNames = (Array.isArray(binaryPropertyNamesParam)
|
|
1715
|
+
? binaryPropertyNamesParam
|
|
1716
|
+
: [binaryPropertyNamesParam])
|
|
1717
|
+
.map((v) => String(v !== null && v !== void 0 ? v : '').trim())
|
|
1718
|
+
.filter((v) => v !== '');
|
|
1719
|
+
if (!binaryPropertyNames.length) {
|
|
1720
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Please provide at least one Binary Property Name', { itemIndex: i });
|
|
1721
|
+
}
|
|
1722
|
+
multipartBoundary = `----n8nFormBoundary${Math.random().toString(36).slice(2)}`;
|
|
1723
|
+
const parts = [];
|
|
1724
|
+
for (const propertyName of binaryPropertyNames) {
|
|
1725
|
+
const binaryData = this.helpers.assertBinaryData(i, propertyName);
|
|
1726
|
+
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
|
|
1727
|
+
const fileName = (_b = binaryData.fileName) !== null && _b !== void 0 ? _b : 'file.pdf';
|
|
1728
|
+
const contentType = (_c = binaryData.mimeType) !== null && _c !== void 0 ? _c : 'application/pdf';
|
|
1729
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
1730
|
+
`Content-Disposition: form-data; name="files"; filename="${fileName}"\r\n` +
|
|
1731
|
+
`Content-Type: ${contentType}\r\n\r\n`));
|
|
1732
|
+
parts.push(Buffer.from(binaryDataBuffer));
|
|
1733
|
+
parts.push(Buffer.from('\r\n'));
|
|
1734
|
+
}
|
|
1735
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
1736
|
+
'Content-Disposition: form-data; name="output"\r\n\r\n' +
|
|
1737
|
+
`${output}\r\n`));
|
|
1738
|
+
parts.push(Buffer.from(`--${multipartBoundary}--\r\n`));
|
|
1739
|
+
multipartBody = Buffer.concat(parts);
|
|
1740
|
+
}
|
|
1741
|
+
if (output === 'file') {
|
|
1742
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
1743
|
+
method: 'POST',
|
|
1744
|
+
url: 'https://pdfapihub.com/api/v1/pdf/merge',
|
|
1745
|
+
...(isFileInput
|
|
1746
|
+
? {
|
|
1747
|
+
body: multipartBody,
|
|
1748
|
+
headers: {
|
|
1749
|
+
'Content-Type': `multipart/form-data; boundary=${multipartBoundary}`,
|
|
869
1750
|
},
|
|
870
1751
|
}
|
|
871
1752
|
: { body, json: true }),
|
|
@@ -1064,6 +1945,340 @@ class PdfSplitMerge {
|
|
|
1064
1945
|
});
|
|
1065
1946
|
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
1066
1947
|
}
|
|
1948
|
+
else if (operation === 'htmlToImage' || operation === 'urlToImage') {
|
|
1949
|
+
const outputFormat = this.getNodeParameter('image_output_format', i);
|
|
1950
|
+
const width = this.getNodeParameter('image_width', i);
|
|
1951
|
+
const height = this.getNodeParameter('image_height', i);
|
|
1952
|
+
const viewportWidth = this.getNodeParameter('image_viewport_width', i);
|
|
1953
|
+
const viewportHeight = this.getNodeParameter('image_viewport_height', i);
|
|
1954
|
+
const deviceScale = this.getNodeParameter('image_device_scale', i);
|
|
1955
|
+
const quality = this.getNodeParameter('image_quality', i);
|
|
1956
|
+
const body = {
|
|
1957
|
+
output_format: outputFormat,
|
|
1958
|
+
width,
|
|
1959
|
+
height,
|
|
1960
|
+
viewPortWidth: viewportWidth,
|
|
1961
|
+
viewPortHeight: viewportHeight,
|
|
1962
|
+
device_scale_factor: deviceScale,
|
|
1963
|
+
quality,
|
|
1964
|
+
};
|
|
1965
|
+
if (operation === 'htmlToImage') {
|
|
1966
|
+
body.html_content = this.getNodeParameter('image_html_content', i);
|
|
1967
|
+
body.css_content = this.getNodeParameter('image_css_content', i, '');
|
|
1968
|
+
const font = this.getNodeParameter('image_font', i, '');
|
|
1969
|
+
if (font)
|
|
1970
|
+
body.font = font;
|
|
1971
|
+
const dynamicParams = this.getNodeParameter('image_dynamic_params', i, {});
|
|
1972
|
+
if ((_d = dynamicParams.params) === null || _d === void 0 ? void 0 : _d.length) {
|
|
1973
|
+
const mapped = {};
|
|
1974
|
+
dynamicParams.params
|
|
1975
|
+
.filter((p) => { var _a; return ((_a = p.key) !== null && _a !== void 0 ? _a : '') !== ''; })
|
|
1976
|
+
.forEach((p) => {
|
|
1977
|
+
var _a;
|
|
1978
|
+
mapped[p.key] = (_a = p.value) !== null && _a !== void 0 ? _a : '';
|
|
1979
|
+
});
|
|
1980
|
+
if (Object.keys(mapped).length) {
|
|
1981
|
+
body.dynamic_params = mapped;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
else {
|
|
1986
|
+
body.url = this.getNodeParameter('image_gen_url', i);
|
|
1987
|
+
body.full_page = this.getNodeParameter('image_full_page', i);
|
|
1988
|
+
body.wait_till = this.getNodeParameter('image_wait_till', i);
|
|
1989
|
+
body.wait_until = this.getNodeParameter('image_wait_until', i);
|
|
1990
|
+
}
|
|
1991
|
+
if (outputFormat === 'file') {
|
|
1992
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
1993
|
+
method: 'POST',
|
|
1994
|
+
url: 'https://pdfapihub.com/api/v1/generateImage',
|
|
1995
|
+
body,
|
|
1996
|
+
json: true,
|
|
1997
|
+
encoding: 'arraybuffer',
|
|
1998
|
+
returnFullResponse: true,
|
|
1999
|
+
});
|
|
2000
|
+
await prepareBinaryResponse(i, responseData, 'image.png', 'image/png');
|
|
2001
|
+
}
|
|
2002
|
+
else {
|
|
2003
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2004
|
+
method: 'POST',
|
|
2005
|
+
url: 'https://pdfapihub.com/api/v1/generateImage',
|
|
2006
|
+
body,
|
|
2007
|
+
json: true,
|
|
2008
|
+
});
|
|
2009
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
else if (operation === 'pdfOcrParse') {
|
|
2013
|
+
const pdfUrl = this.getNodeParameter('ocr_pdf_url', i);
|
|
2014
|
+
const pages = this.getNodeParameter('ocr_pages', i);
|
|
2015
|
+
const lang = this.getNodeParameter('ocr_lang', i);
|
|
2016
|
+
const dpi = this.getNodeParameter('ocr_dpi', i);
|
|
2017
|
+
const psm = this.getNodeParameter('ocr_psm', i);
|
|
2018
|
+
const oem = this.getNodeParameter('ocr_oem', i);
|
|
2019
|
+
const body = { url: pdfUrl, pages, lang, dpi, psm, oem };
|
|
2020
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2021
|
+
method: 'POST',
|
|
2022
|
+
url: 'https://pdfapihub.com/api/v1/pdf/ocr/parse',
|
|
2023
|
+
body,
|
|
2024
|
+
json: true,
|
|
2025
|
+
});
|
|
2026
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2027
|
+
}
|
|
2028
|
+
else if (operation === 'imageOcrParse') {
|
|
2029
|
+
const imageUrl = this.getNodeParameter('ocr_image_url', i, '');
|
|
2030
|
+
const base64Image = this.getNodeParameter('ocr_base64_image', i, '');
|
|
2031
|
+
const lang = this.getNodeParameter('ocr_lang', i);
|
|
2032
|
+
const psm = this.getNodeParameter('ocr_psm', i);
|
|
2033
|
+
const oem = this.getNodeParameter('ocr_oem', i);
|
|
2034
|
+
const body = { lang, psm, oem };
|
|
2035
|
+
if (imageUrl)
|
|
2036
|
+
body.image_url = imageUrl;
|
|
2037
|
+
if (base64Image)
|
|
2038
|
+
body.base64_image = base64Image;
|
|
2039
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2040
|
+
method: 'POST',
|
|
2041
|
+
url: 'https://pdfapihub.com/api/v1/image/ocr/parse',
|
|
2042
|
+
body,
|
|
2043
|
+
json: true,
|
|
2044
|
+
});
|
|
2045
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2046
|
+
}
|
|
2047
|
+
else if (operation === 'pngToPdf' || operation === 'webpToPdf' || operation === 'jpgToPdf') {
|
|
2048
|
+
const inputType = this.getNodeParameter('img2pdf_input_type', i);
|
|
2049
|
+
const outputFormat = this.getNodeParameter('img2pdf_output', i);
|
|
2050
|
+
const outputFilename = this.getNodeParameter('img2pdf_output_filename', i);
|
|
2051
|
+
let multipartBody;
|
|
2052
|
+
let multipartBoundary;
|
|
2053
|
+
let body;
|
|
2054
|
+
if (inputType === 'file') {
|
|
2055
|
+
const binaryPropertyNamesParam = this.getNodeParameter('img2pdf_binary_properties', i);
|
|
2056
|
+
const binaryPropertyNames = (Array.isArray(binaryPropertyNamesParam)
|
|
2057
|
+
? binaryPropertyNamesParam
|
|
2058
|
+
: [binaryPropertyNamesParam])
|
|
2059
|
+
.map((v) => String(v !== null && v !== void 0 ? v : '').trim())
|
|
2060
|
+
.filter((v) => v !== '');
|
|
2061
|
+
if (!binaryPropertyNames.length) {
|
|
2062
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Please provide at least one Binary Property Name', { itemIndex: i });
|
|
2063
|
+
}
|
|
2064
|
+
multipartBoundary = `----n8nFormBoundary${Math.random().toString(36).slice(2)}`;
|
|
2065
|
+
const parts = [];
|
|
2066
|
+
for (const propertyName of binaryPropertyNames) {
|
|
2067
|
+
const binaryData = this.helpers.assertBinaryData(i, propertyName);
|
|
2068
|
+
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
|
|
2069
|
+
const fileName = (_e = binaryData.fileName) !== null && _e !== void 0 ? _e : 'image.png';
|
|
2070
|
+
const contentType = (_f = binaryData.mimeType) !== null && _f !== void 0 ? _f : 'image/png';
|
|
2071
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2072
|
+
`Content-Disposition: form-data; name="file"; filename="${fileName}"\r\n` +
|
|
2073
|
+
`Content-Type: ${contentType}\r\n\r\n`));
|
|
2074
|
+
parts.push(Buffer.from(binaryDataBuffer));
|
|
2075
|
+
parts.push(Buffer.from('\r\n'));
|
|
2076
|
+
}
|
|
2077
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2078
|
+
'Content-Disposition: form-data; name="output"\r\n\r\n' +
|
|
2079
|
+
`${outputFormat}\r\n`));
|
|
2080
|
+
if (outputFilename) {
|
|
2081
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2082
|
+
'Content-Disposition: form-data; name="output_filename"\r\n\r\n' +
|
|
2083
|
+
`${outputFilename}\r\n`));
|
|
2084
|
+
}
|
|
2085
|
+
parts.push(Buffer.from(`--${multipartBoundary}--\r\n`));
|
|
2086
|
+
multipartBody = Buffer.concat(parts);
|
|
2087
|
+
}
|
|
2088
|
+
else if (inputType === 'url') {
|
|
2089
|
+
const urls = this.getNodeParameter('img2pdf_urls', i);
|
|
2090
|
+
body = { urls, output: outputFormat, output_filename: outputFilename };
|
|
2091
|
+
}
|
|
2092
|
+
else {
|
|
2093
|
+
const base64Images = this.getNodeParameter('img2pdf_base64', i);
|
|
2094
|
+
body = base64Images.length === 1
|
|
2095
|
+
? { image_base64: base64Images[0], output: outputFormat, output_filename: outputFilename }
|
|
2096
|
+
: { images_base64: base64Images, output: outputFormat, output_filename: outputFilename };
|
|
2097
|
+
}
|
|
2098
|
+
if (outputFormat === 'file') {
|
|
2099
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2100
|
+
method: 'POST',
|
|
2101
|
+
url: 'https://pdfapihub.com/api/v1/convert/image/pdf',
|
|
2102
|
+
...(inputType === 'file'
|
|
2103
|
+
? {
|
|
2104
|
+
body: multipartBody,
|
|
2105
|
+
headers: { 'Content-Type': `multipart/form-data; boundary=${multipartBoundary}` },
|
|
2106
|
+
}
|
|
2107
|
+
: { body, json: true }),
|
|
2108
|
+
encoding: 'arraybuffer',
|
|
2109
|
+
returnFullResponse: true,
|
|
2110
|
+
});
|
|
2111
|
+
await prepareBinaryResponse(i, responseData, outputFilename || 'converted.pdf', 'application/pdf');
|
|
2112
|
+
}
|
|
2113
|
+
else {
|
|
2114
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2115
|
+
method: 'POST',
|
|
2116
|
+
url: 'https://pdfapihub.com/api/v1/convert/image/pdf',
|
|
2117
|
+
...(inputType === 'file'
|
|
2118
|
+
? {
|
|
2119
|
+
body: multipartBody,
|
|
2120
|
+
headers: { 'Content-Type': `multipart/form-data; boundary=${multipartBoundary}` },
|
|
2121
|
+
}
|
|
2122
|
+
: { body, json: true }),
|
|
2123
|
+
});
|
|
2124
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
else if (operation === 'pdfToPng' || operation === 'pdfToWebp' || operation === 'pdfToJpg') {
|
|
2128
|
+
const pdfUrl = this.getNodeParameter('pdf2img_url', i);
|
|
2129
|
+
const pages = this.getNodeParameter('pdf2img_pages', i);
|
|
2130
|
+
const dpi = this.getNodeParameter('pdf2img_dpi', i);
|
|
2131
|
+
const quality = this.getNodeParameter('pdf2img_quality', i);
|
|
2132
|
+
const outputFormat = this.getNodeParameter('pdf2img_output', i);
|
|
2133
|
+
const imageFormatMap = {
|
|
2134
|
+
pdfToPng: 'png',
|
|
2135
|
+
pdfToWebp: 'webp',
|
|
2136
|
+
pdfToJpg: 'jpg',
|
|
2137
|
+
};
|
|
2138
|
+
const imageFormat = imageFormatMap[operation];
|
|
2139
|
+
const body = {
|
|
2140
|
+
url: pdfUrl,
|
|
2141
|
+
pages,
|
|
2142
|
+
image_format: imageFormat,
|
|
2143
|
+
dpi,
|
|
2144
|
+
quality,
|
|
2145
|
+
output: outputFormat,
|
|
2146
|
+
};
|
|
2147
|
+
if (outputFormat === 'file') {
|
|
2148
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2149
|
+
method: 'POST',
|
|
2150
|
+
url: 'https://pdfapihub.com/api/v1/convert/pdf/image',
|
|
2151
|
+
body,
|
|
2152
|
+
json: true,
|
|
2153
|
+
encoding: 'arraybuffer',
|
|
2154
|
+
returnFullResponse: true,
|
|
2155
|
+
});
|
|
2156
|
+
const mimeType = imageFormat === 'png' ? 'image/png' : imageFormat === 'webp' ? 'image/webp' : 'image/jpeg';
|
|
2157
|
+
await prepareBinaryResponse(i, responseData, `output.${imageFormat}`, mimeType);
|
|
2158
|
+
}
|
|
2159
|
+
else {
|
|
2160
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2161
|
+
method: 'POST',
|
|
2162
|
+
url: 'https://pdfapihub.com/api/v1/convert/pdf/image',
|
|
2163
|
+
body,
|
|
2164
|
+
json: true,
|
|
2165
|
+
});
|
|
2166
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
else if (operation === 'fetchHtml') {
|
|
2170
|
+
const url = this.getNodeParameter('html_fetch_url', i);
|
|
2171
|
+
const waitTill = this.getNodeParameter('html_wait_till', i);
|
|
2172
|
+
const timeout = this.getNodeParameter('html_timeout', i);
|
|
2173
|
+
const waitForSelector = this.getNodeParameter('html_wait_for_selector', i, '');
|
|
2174
|
+
const waitForTimeout = this.getNodeParameter('html_wait_for_timeout', i);
|
|
2175
|
+
const viewportWidth = this.getNodeParameter('html_viewport_width', i);
|
|
2176
|
+
const viewportHeight = this.getNodeParameter('html_viewport_height', i);
|
|
2177
|
+
const userAgent = this.getNodeParameter('html_user_agent', i, '');
|
|
2178
|
+
const body = {
|
|
2179
|
+
url,
|
|
2180
|
+
wait_till: waitTill,
|
|
2181
|
+
timeout,
|
|
2182
|
+
wait_for_timeout: waitForTimeout,
|
|
2183
|
+
viewport_width: viewportWidth,
|
|
2184
|
+
viewport_height: viewportHeight,
|
|
2185
|
+
};
|
|
2186
|
+
if (waitForSelector)
|
|
2187
|
+
body.wait_for_selector = waitForSelector;
|
|
2188
|
+
if (userAgent)
|
|
2189
|
+
body.user_agent = userAgent;
|
|
2190
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2191
|
+
method: 'POST',
|
|
2192
|
+
url: 'https://pdfapihub.com/api/v1/url-to-html',
|
|
2193
|
+
body,
|
|
2194
|
+
json: true,
|
|
2195
|
+
});
|
|
2196
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2197
|
+
}
|
|
2198
|
+
else if (operation === 'addWatermark') {
|
|
2199
|
+
const inputType = this.getNodeParameter('watermark_input_type', i);
|
|
2200
|
+
const text = this.getNodeParameter('watermark_text', i);
|
|
2201
|
+
const opacity = this.getNodeParameter('watermark_opacity', i);
|
|
2202
|
+
const angle = this.getNodeParameter('watermark_angle', i);
|
|
2203
|
+
const fontSize = this.getNodeParameter('watermark_font_size', i);
|
|
2204
|
+
const outputFormat = this.getNodeParameter('watermark_output', i);
|
|
2205
|
+
let multipartBody;
|
|
2206
|
+
let multipartBoundary;
|
|
2207
|
+
let body;
|
|
2208
|
+
if (inputType === 'file') {
|
|
2209
|
+
const binaryPropertyName = this.getNodeParameter('watermark_binary_property', i);
|
|
2210
|
+
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
|
2211
|
+
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
2212
|
+
const fileName = (_g = binaryData.fileName) !== null && _g !== void 0 ? _g : 'file.pdf';
|
|
2213
|
+
const contentType = (_h = binaryData.mimeType) !== null && _h !== void 0 ? _h : 'application/pdf';
|
|
2214
|
+
multipartBoundary = `----n8nFormBoundary${Math.random().toString(36).slice(2)}`;
|
|
2215
|
+
const parts = [];
|
|
2216
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2217
|
+
`Content-Disposition: form-data; name="file"; filename="${fileName}"\r\n` +
|
|
2218
|
+
`Content-Type: ${contentType}\r\n\r\n`));
|
|
2219
|
+
parts.push(Buffer.from(binaryDataBuffer));
|
|
2220
|
+
parts.push(Buffer.from('\r\n'));
|
|
2221
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2222
|
+
'Content-Disposition: form-data; name="text"\r\n\r\n' +
|
|
2223
|
+
`${text}\r\n`));
|
|
2224
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2225
|
+
'Content-Disposition: form-data; name="opacity"\r\n\r\n' +
|
|
2226
|
+
`${opacity}\r\n`));
|
|
2227
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2228
|
+
'Content-Disposition: form-data; name="angle"\r\n\r\n' +
|
|
2229
|
+
`${angle}\r\n`));
|
|
2230
|
+
if (fontSize > 0) {
|
|
2231
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2232
|
+
'Content-Disposition: form-data; name="font_size"\r\n\r\n' +
|
|
2233
|
+
`${fontSize}\r\n`));
|
|
2234
|
+
}
|
|
2235
|
+
parts.push(Buffer.from(`--${multipartBoundary}\r\n` +
|
|
2236
|
+
'Content-Disposition: form-data; name="output_format"\r\n\r\n' +
|
|
2237
|
+
`${outputFormat}\r\n`));
|
|
2238
|
+
parts.push(Buffer.from(`--${multipartBoundary}--\r\n`));
|
|
2239
|
+
multipartBody = Buffer.concat(parts);
|
|
2240
|
+
}
|
|
2241
|
+
else if (inputType === 'url') {
|
|
2242
|
+
const fileUrl = this.getNodeParameter('watermark_url', i);
|
|
2243
|
+
body = { file_url: fileUrl, text, opacity, angle, output_format: outputFormat };
|
|
2244
|
+
if (fontSize > 0)
|
|
2245
|
+
body.font_size = fontSize;
|
|
2246
|
+
}
|
|
2247
|
+
else {
|
|
2248
|
+
const base64File = this.getNodeParameter('watermark_base64', i);
|
|
2249
|
+
body = { base64_file: base64File, text, opacity, angle, output_format: outputFormat };
|
|
2250
|
+
if (fontSize > 0)
|
|
2251
|
+
body.font_size = fontSize;
|
|
2252
|
+
}
|
|
2253
|
+
if (outputFormat === 'file') {
|
|
2254
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2255
|
+
method: 'POST',
|
|
2256
|
+
url: 'https://pdfapihub.com/api/v1/watermark',
|
|
2257
|
+
...(inputType === 'file'
|
|
2258
|
+
? {
|
|
2259
|
+
body: multipartBody,
|
|
2260
|
+
headers: { 'Content-Type': `multipart/form-data; boundary=${multipartBoundary}` },
|
|
2261
|
+
}
|
|
2262
|
+
: { body, json: true }),
|
|
2263
|
+
encoding: 'arraybuffer',
|
|
2264
|
+
returnFullResponse: true,
|
|
2265
|
+
});
|
|
2266
|
+
await prepareBinaryResponse(i, responseData, 'watermarked.pdf', 'application/pdf');
|
|
2267
|
+
}
|
|
2268
|
+
else {
|
|
2269
|
+
const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
|
|
2270
|
+
method: 'POST',
|
|
2271
|
+
url: 'https://pdfapihub.com/api/v1/watermark',
|
|
2272
|
+
...(inputType === 'file'
|
|
2273
|
+
? {
|
|
2274
|
+
body: multipartBody,
|
|
2275
|
+
headers: { 'Content-Type': `multipart/form-data; boundary=${multipartBoundary}` },
|
|
2276
|
+
}
|
|
2277
|
+
: { body, json: true }),
|
|
2278
|
+
});
|
|
2279
|
+
returnData.push({ json: responseData, pairedItem: { item: i } });
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
1067
2282
|
else {
|
|
1068
2283
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported operation: ${operation}`, {
|
|
1069
2284
|
itemIndex: i,
|