n8n-nodes-pdfops 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -25
- package/dist/nodes/Pdfops/Pdfops.node.js +1073 -118
- package/dist/nodes/Pdfops/Pdfops.node.js.map +1 -1
- package/dist/nodes/Pdfops/Pdfops.node.json +25 -1
- package/dist/package.json +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -4,7 +4,10 @@ exports.Pdfops = void 0;
|
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const decodeApiError_1 = require("./decodeApiError");
|
|
6
6
|
const BASE_URL = 'https://pdfops.dev';
|
|
7
|
-
const NODE_PACKAGE_VERSION = '0.
|
|
7
|
+
const NODE_PACKAGE_VERSION = '0.5.0';
|
|
8
|
+
function headerTrue(value) {
|
|
9
|
+
return typeof value === 'string' && value.split(',')[0].trim().toLowerCase() === 'true';
|
|
10
|
+
}
|
|
8
11
|
function withApiMessage(wrapped, apiError, itemIndex) {
|
|
9
12
|
var _a;
|
|
10
13
|
if (itemIndex !== undefined)
|
|
@@ -26,7 +29,313 @@ const DOC_OPS = {
|
|
|
26
29
|
protect: { path: 'protect', output: 'pdf', defaultFile: 'protected.pdf' },
|
|
27
30
|
metadata: { path: 'metadata', output: 'json', defaultFile: '' },
|
|
28
31
|
setMetadata: { path: 'set-metadata', output: 'pdf', defaultFile: 'metadata-updated.pdf' },
|
|
32
|
+
addFields: { path: 'add-fields', output: 'pdf', defaultFile: 'fields-added.pdf' },
|
|
33
|
+
attach: { path: 'attach', output: 'pdf', defaultFile: 'attached.pdf' },
|
|
34
|
+
edit: { path: 'edit', output: 'pdf', defaultFile: 'edited.pdf' },
|
|
35
|
+
extractText: { path: 'extract-text', output: 'extract', defaultFile: 'tables.xlsx' },
|
|
36
|
+
findText: { path: 'find-text', output: 'json', defaultFile: '' },
|
|
29
37
|
};
|
|
38
|
+
const XLSX_MIME_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
39
|
+
const OPERATION_PROPERTIES = [
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Operation',
|
|
42
|
+
name: 'operation',
|
|
43
|
+
type: 'options',
|
|
44
|
+
noDataExpression: true,
|
|
45
|
+
displayOptions: { show: { '@version': [1] } },
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
name: 'Fill Form',
|
|
49
|
+
value: 'fill',
|
|
50
|
+
action: 'Fill form fields in a PDF',
|
|
51
|
+
description: 'Fill AcroForm form fields in a PDF and output the filled PDF',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Generate Invoice',
|
|
55
|
+
value: 'invoice',
|
|
56
|
+
action: 'Generate an invoice PDF',
|
|
57
|
+
description: 'Generate a complete invoice PDF from structured JSON — no template needed',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Get Usage',
|
|
61
|
+
value: 'usage',
|
|
62
|
+
action: 'Get quota usage',
|
|
63
|
+
description: 'Check tier, limit, used, remaining, and reset date (requires an API key)',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'Inspect Fields',
|
|
67
|
+
value: 'inspect',
|
|
68
|
+
action: 'List the form fields of a PDF',
|
|
69
|
+
description: 'List a PDF’s AcroForm fields — names, types, options, current values — plus a paste-ready fill template',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Merge',
|
|
73
|
+
value: 'merge',
|
|
74
|
+
action: 'Merge many PDF files into one',
|
|
75
|
+
description: 'Merge the PDFs from all incoming items (in item order) into a single PDF',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
default: 'fill',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Resource',
|
|
82
|
+
name: 'resource',
|
|
83
|
+
type: 'options',
|
|
84
|
+
noDataExpression: true,
|
|
85
|
+
displayOptions: { show: { '@version': [2] } },
|
|
86
|
+
options: [
|
|
87
|
+
{ name: 'Account', value: 'account' },
|
|
88
|
+
{ name: 'Attachment', value: 'attachment' },
|
|
89
|
+
{ name: 'Convert', value: 'convert' },
|
|
90
|
+
{ name: 'Document', value: 'document' },
|
|
91
|
+
{ name: 'Form', value: 'form' },
|
|
92
|
+
{ name: 'Invoice', value: 'invoice' },
|
|
93
|
+
{ name: 'Metadata', value: 'metadata' },
|
|
94
|
+
{ name: 'Security', value: 'security' },
|
|
95
|
+
{ name: 'Stamp', value: 'stamp' },
|
|
96
|
+
{ name: 'Text', value: 'text' },
|
|
97
|
+
],
|
|
98
|
+
default: 'form',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Operation',
|
|
102
|
+
name: 'operation',
|
|
103
|
+
type: 'options',
|
|
104
|
+
noDataExpression: true,
|
|
105
|
+
displayOptions: { show: { '@version': [2], resource: ['account'] } },
|
|
106
|
+
options: [
|
|
107
|
+
{
|
|
108
|
+
name: 'Get Usage',
|
|
109
|
+
value: 'usage',
|
|
110
|
+
action: 'Get quota usage',
|
|
111
|
+
description: 'Check tier, limit, used, remaining, and reset date (requires an API key)',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
default: 'usage',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Operation',
|
|
118
|
+
name: 'operation',
|
|
119
|
+
type: 'options',
|
|
120
|
+
noDataExpression: true,
|
|
121
|
+
displayOptions: { show: { '@version': [2], resource: ['attachment'] } },
|
|
122
|
+
options: [
|
|
123
|
+
{
|
|
124
|
+
name: 'Attach',
|
|
125
|
+
value: 'attach',
|
|
126
|
+
action: 'Attach files to a PDF',
|
|
127
|
+
description: 'Embed files (an XML invoice, a spreadsheet, a source file) inside a PDF and output the updated PDF',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
default: 'attach',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Operation',
|
|
134
|
+
name: 'operation',
|
|
135
|
+
type: 'options',
|
|
136
|
+
noDataExpression: true,
|
|
137
|
+
displayOptions: { show: { '@version': [2], resource: ['convert'] } },
|
|
138
|
+
options: [
|
|
139
|
+
{
|
|
140
|
+
name: 'HTML to PDF',
|
|
141
|
+
value: 'htmlToPdf',
|
|
142
|
+
action: 'Convert HTML to a PDF',
|
|
143
|
+
description: 'Render an HTML string to a PDF with a headless browser, so CSS, images and web fonts come out as in a browser print. Each call counts as 5 requests against your quota.',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'Images to PDF',
|
|
147
|
+
value: 'imageToPdf',
|
|
148
|
+
action: 'Convert images to a PDF',
|
|
149
|
+
description: 'Turn the JPG or PNG images from all incoming items (in item order) into one PDF, one image per page',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Text to PDF',
|
|
153
|
+
value: 'textToPdf',
|
|
154
|
+
action: 'Convert text to a PDF',
|
|
155
|
+
description: 'Turn Markdown, plain text or CSV into a PDF on A4 or Letter pages, without a template',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
default: 'htmlToPdf',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
displayName: 'Operation',
|
|
162
|
+
name: 'operation',
|
|
163
|
+
type: 'options',
|
|
164
|
+
noDataExpression: true,
|
|
165
|
+
displayOptions: { show: { '@version': [2], resource: ['document'] } },
|
|
166
|
+
options: [
|
|
167
|
+
{
|
|
168
|
+
name: 'Delete Pages',
|
|
169
|
+
value: 'deletePages',
|
|
170
|
+
action: 'Delete pages from a PDF',
|
|
171
|
+
description: 'Remove the listed pages from a PDF and output the remaining pages in original order',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'Extract Pages',
|
|
175
|
+
value: 'extractPages',
|
|
176
|
+
action: 'Extract pages from a PDF',
|
|
177
|
+
description: 'Keep only the listed pages of a PDF, in the order given, and output them as a new PDF (also reorders and duplicates pages)',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'Merge',
|
|
181
|
+
value: 'merge',
|
|
182
|
+
action: 'Merge many PDF files into one',
|
|
183
|
+
description: 'Merge the PDFs from all incoming items (in item order) into a single PDF',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'Rotate Pages',
|
|
187
|
+
value: 'rotate',
|
|
188
|
+
action: 'Rotate pages of a PDF',
|
|
189
|
+
description: 'Rotate all or selected pages of a PDF by 90, 180 or 270 degrees',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'Split PDF',
|
|
193
|
+
value: 'split',
|
|
194
|
+
action: 'Split a PDF into several pdfs',
|
|
195
|
+
description: 'Split a PDF by page ranges or fixed chunk size; outputs one item per part, each with its own PDF binary',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
default: 'merge',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
displayName: 'Operation',
|
|
202
|
+
name: 'operation',
|
|
203
|
+
type: 'options',
|
|
204
|
+
noDataExpression: true,
|
|
205
|
+
displayOptions: { show: { '@version': [2], resource: ['form'] } },
|
|
206
|
+
options: [
|
|
207
|
+
{
|
|
208
|
+
name: 'Add Fields',
|
|
209
|
+
value: 'addFields',
|
|
210
|
+
action: 'Add form fields to a PDF',
|
|
211
|
+
description: 'Create fillable form fields (text, checkbox, radio group, dropdown, signature box) at exact positions in a PDF',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'Fill',
|
|
215
|
+
value: 'fill',
|
|
216
|
+
action: 'Fill form fields in a PDF',
|
|
217
|
+
description: 'Fill AcroForm form fields in a PDF and output the filled PDF',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: 'Inspect Fields',
|
|
221
|
+
value: 'inspect',
|
|
222
|
+
action: 'List the form fields of a PDF',
|
|
223
|
+
description: 'List a PDF’s AcroForm fields — names, types, options, current values — plus a paste-ready fill template',
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
default: 'fill',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
displayName: 'Operation',
|
|
230
|
+
name: 'operation',
|
|
231
|
+
type: 'options',
|
|
232
|
+
noDataExpression: true,
|
|
233
|
+
displayOptions: { show: { '@version': [2], resource: ['invoice'] } },
|
|
234
|
+
options: [
|
|
235
|
+
{
|
|
236
|
+
name: 'Generate',
|
|
237
|
+
value: 'invoice',
|
|
238
|
+
action: 'Generate an invoice PDF',
|
|
239
|
+
description: 'Generate a complete invoice PDF from structured JSON — no template needed',
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
default: 'invoice',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Operation',
|
|
246
|
+
name: 'operation',
|
|
247
|
+
type: 'options',
|
|
248
|
+
noDataExpression: true,
|
|
249
|
+
displayOptions: { show: { '@version': [2], resource: ['metadata'] } },
|
|
250
|
+
options: [
|
|
251
|
+
{
|
|
252
|
+
name: 'Get',
|
|
253
|
+
value: 'metadata',
|
|
254
|
+
action: 'Get PDF metadata',
|
|
255
|
+
description: 'Read page count, page sizes, title, author, dates, encryption and form-field count of a PDF as JSON',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'Set',
|
|
259
|
+
value: 'setMetadata',
|
|
260
|
+
action: 'Set PDF metadata',
|
|
261
|
+
description: 'Set the title, author, subject, keywords or creator of a PDF and output the updated PDF',
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
default: 'metadata',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
displayName: 'Operation',
|
|
268
|
+
name: 'operation',
|
|
269
|
+
type: 'options',
|
|
270
|
+
noDataExpression: true,
|
|
271
|
+
displayOptions: { show: { '@version': [2], resource: ['security'] } },
|
|
272
|
+
options: [
|
|
273
|
+
{
|
|
274
|
+
name: 'Protect',
|
|
275
|
+
value: 'protect',
|
|
276
|
+
action: 'Password protect a PDF',
|
|
277
|
+
description: 'Encrypt a PDF with an open password and/or an owner password that restricts printing, copying and editing',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'Unlock',
|
|
281
|
+
value: 'unlock',
|
|
282
|
+
action: 'Remove password protection from a PDF',
|
|
283
|
+
description: 'Remove encryption and print/copy/edit restrictions from a PDF you can already open (give the password if it needs one to open)',
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
default: 'protect',
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
displayName: 'Operation',
|
|
290
|
+
name: 'operation',
|
|
291
|
+
type: 'options',
|
|
292
|
+
noDataExpression: true,
|
|
293
|
+
displayOptions: { show: { '@version': [2], resource: ['stamp'] } },
|
|
294
|
+
options: [
|
|
295
|
+
{
|
|
296
|
+
name: 'Add Page Numbers',
|
|
297
|
+
value: 'pageNumbers',
|
|
298
|
+
action: 'Add page numbers to a PDF',
|
|
299
|
+
description: 'Stamp page numbers (for example "3 / 12") onto the pages of a PDF and output the numbered PDF',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: 'Add Watermark',
|
|
303
|
+
value: 'watermark',
|
|
304
|
+
action: 'Add a text watermark to a PDF',
|
|
305
|
+
description: 'Stamp diagonal or horizontal text (DRAFT, CONFIDENTIAL, a name) over the pages of a PDF and output the watermarked PDF',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: 'Edit',
|
|
309
|
+
value: 'edit',
|
|
310
|
+
action: 'Add text images or barcodes to a PDF',
|
|
311
|
+
description: 'Draw text, images (a logo, a signature), QR codes and barcodes at exact positions on the pages of a PDF and output the edited PDF',
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
default: 'watermark',
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
displayName: 'Operation',
|
|
318
|
+
name: 'operation',
|
|
319
|
+
type: 'options',
|
|
320
|
+
noDataExpression: true,
|
|
321
|
+
displayOptions: { show: { '@version': [2], resource: ['text'] } },
|
|
322
|
+
options: [
|
|
323
|
+
{
|
|
324
|
+
name: 'Extract',
|
|
325
|
+
value: 'extractText',
|
|
326
|
+
action: 'Extract text and tables from a PDF',
|
|
327
|
+
description: 'Read the text of a PDF with a text layer, page by page, plus the tables found on the pages, as JSON, plain text or an Excel workbook. Scanned pages are not read (no OCR).',
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'Find',
|
|
331
|
+
value: 'findText',
|
|
332
|
+
action: 'Find text in a PDF',
|
|
333
|
+
description: 'Search a PDF with a text layer for a word, phrase or pattern and return every hit with its page and its box in PDF points',
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
default: 'extractText',
|
|
337
|
+
},
|
|
338
|
+
];
|
|
30
339
|
class Pdfops {
|
|
31
340
|
constructor() {
|
|
32
341
|
this.description = {
|
|
@@ -34,9 +343,10 @@ class Pdfops {
|
|
|
34
343
|
name: 'pdfops',
|
|
35
344
|
icon: { light: 'file:pdfops.svg', dark: 'file:pdfops.dark.svg' },
|
|
36
345
|
group: ['transform'],
|
|
37
|
-
version: 1,
|
|
38
|
-
|
|
39
|
-
|
|
346
|
+
version: [1, 2],
|
|
347
|
+
defaultVersion: 2,
|
|
348
|
+
subtitle: '={{ ($parameter["resource"] ? $parameter["resource"] + ": " : "") + $parameter["operation"] }}',
|
|
349
|
+
description: 'Fill, merge, split, rotate, watermark, number, protect, unlock, edit, read and search PDFs, add form fields and attachments, convert HTML, text and images to PDF, and generate invoices. Works without an API key (100 calls/month).',
|
|
40
350
|
defaults: {
|
|
41
351
|
name: 'PDFops',
|
|
42
352
|
},
|
|
@@ -50,105 +360,7 @@ class Pdfops {
|
|
|
50
360
|
},
|
|
51
361
|
],
|
|
52
362
|
properties: [
|
|
53
|
-
|
|
54
|
-
displayName: 'Operation',
|
|
55
|
-
name: 'operation',
|
|
56
|
-
type: 'options',
|
|
57
|
-
noDataExpression: true,
|
|
58
|
-
options: [
|
|
59
|
-
{
|
|
60
|
-
name: 'Add Page Numbers',
|
|
61
|
-
value: 'pageNumbers',
|
|
62
|
-
action: 'Add page numbers to a PDF',
|
|
63
|
-
description: 'Stamp page numbers (for example "3 / 12") onto the pages of a PDF and output the numbered PDF',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'Add Watermark',
|
|
67
|
-
value: 'watermark',
|
|
68
|
-
action: 'Add a text watermark to a PDF',
|
|
69
|
-
description: 'Stamp diagonal or horizontal text (DRAFT, CONFIDENTIAL, a name) over the pages of a PDF and output the watermarked PDF',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'Delete Pages',
|
|
73
|
-
value: 'deletePages',
|
|
74
|
-
action: 'Delete pages from a PDF',
|
|
75
|
-
description: 'Remove the listed pages from a PDF and output the remaining pages in original order',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'Extract Pages',
|
|
79
|
-
value: 'extractPages',
|
|
80
|
-
action: 'Extract pages from a PDF',
|
|
81
|
-
description: 'Keep only the listed pages of a PDF, in the order given, and output them as a new PDF (also reorders and duplicates pages)',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'Fill Form',
|
|
85
|
-
value: 'fill',
|
|
86
|
-
action: 'Fill form fields in a PDF',
|
|
87
|
-
description: 'Fill AcroForm form fields in a PDF and output the filled PDF',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'Generate Invoice',
|
|
91
|
-
value: 'invoice',
|
|
92
|
-
action: 'Generate an invoice PDF',
|
|
93
|
-
description: 'Generate a complete invoice PDF from structured JSON — no template needed',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'Get Metadata',
|
|
97
|
-
value: 'metadata',
|
|
98
|
-
action: 'Get PDF metadata',
|
|
99
|
-
description: 'Read page count, page sizes, title, author, dates, encryption and form-field count of a PDF as JSON',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'Get Usage',
|
|
103
|
-
value: 'usage',
|
|
104
|
-
action: 'Get quota usage',
|
|
105
|
-
description: 'Check tier, limit, used, remaining, and reset date (requires an API key)',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'Inspect Fields',
|
|
109
|
-
value: 'inspect',
|
|
110
|
-
action: 'List the form fields of a PDF',
|
|
111
|
-
description: 'List a PDF’s AcroForm fields — names, types, options, current values — plus a paste-ready fill template',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'Merge',
|
|
115
|
-
value: 'merge',
|
|
116
|
-
action: 'Merge many PDF files into one',
|
|
117
|
-
description: 'Merge the PDFs from all incoming items (in item order) into a single PDF',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'Protect PDF',
|
|
121
|
-
value: 'protect',
|
|
122
|
-
action: 'Password protect a PDF',
|
|
123
|
-
description: 'Encrypt a PDF with an open password and/or an owner password that restricts printing, copying and editing',
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'Rotate Pages',
|
|
127
|
-
value: 'rotate',
|
|
128
|
-
action: 'Rotate pages of a PDF',
|
|
129
|
-
description: 'Rotate all or selected pages of a PDF by 90, 180 or 270 degrees',
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
name: 'Set Metadata',
|
|
133
|
-
value: 'setMetadata',
|
|
134
|
-
action: 'Set PDF metadata',
|
|
135
|
-
description: 'Set the title, author, subject, keywords or creator of a PDF and output the updated PDF',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: 'Split PDF',
|
|
139
|
-
value: 'split',
|
|
140
|
-
action: 'Split a PDF into several pdfs',
|
|
141
|
-
description: 'Split a PDF by page ranges or fixed chunk size; outputs one item per part, each with its own PDF binary',
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'Unlock PDF',
|
|
145
|
-
value: 'unlock',
|
|
146
|
-
action: 'Remove password protection from a PDF',
|
|
147
|
-
description: 'Remove encryption and print/copy/edit restrictions from a PDF you can already open (give the password if it needs one to open)',
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
default: 'fill',
|
|
151
|
-
},
|
|
363
|
+
...OPERATION_PROPERTIES,
|
|
152
364
|
{
|
|
153
365
|
displayName: 'Input Binary Field',
|
|
154
366
|
name: 'binaryPropertyName',
|
|
@@ -158,10 +370,19 @@ class Pdfops {
|
|
|
158
370
|
hint: 'The name of the input item’s binary field containing the PDF',
|
|
159
371
|
displayOptions: {
|
|
160
372
|
show: {
|
|
161
|
-
operation: ['fill', 'inspect', 'merge', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'metadata', 'setMetadata'],
|
|
373
|
+
operation: ['fill', 'inspect', 'merge', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'metadata', 'setMetadata', 'addFields', 'attach', 'edit', 'extractText', 'findText'],
|
|
162
374
|
},
|
|
163
375
|
},
|
|
164
376
|
},
|
|
377
|
+
{
|
|
378
|
+
displayName: 'Input Binary Field',
|
|
379
|
+
name: 'binaryPropertyName',
|
|
380
|
+
type: 'string',
|
|
381
|
+
default: 'data',
|
|
382
|
+
required: true,
|
|
383
|
+
hint: 'The name of the input item’s binary field containing the image (JPG or PNG)',
|
|
384
|
+
displayOptions: { show: { operation: ['imageToPdf'] } },
|
|
385
|
+
},
|
|
165
386
|
{
|
|
166
387
|
displayName: 'Fields',
|
|
167
388
|
name: 'fields',
|
|
@@ -198,6 +419,11 @@ class Pdfops {
|
|
|
198
419
|
'protect',
|
|
199
420
|
'metadata',
|
|
200
421
|
'setMetadata',
|
|
422
|
+
'addFields',
|
|
423
|
+
'attach',
|
|
424
|
+
'edit',
|
|
425
|
+
'extractText',
|
|
426
|
+
'findText',
|
|
201
427
|
],
|
|
202
428
|
},
|
|
203
429
|
},
|
|
@@ -229,7 +455,7 @@ class Pdfops {
|
|
|
229
455
|
default: '',
|
|
230
456
|
placeholder: 'e.g. 1-3,5 (empty = all pages)',
|
|
231
457
|
description: '1-based page spec such as "1-3,5". Leave empty to apply to every page.',
|
|
232
|
-
displayOptions: { show: { operation: ['rotate', 'watermark', 'pageNumbers'] } },
|
|
458
|
+
displayOptions: { show: { operation: ['rotate', 'watermark', 'pageNumbers', 'extractText', 'findText'] } },
|
|
233
459
|
},
|
|
234
460
|
{
|
|
235
461
|
displayName: 'Degrees',
|
|
@@ -405,7 +631,7 @@ class Pdfops {
|
|
|
405
631
|
type: 'string',
|
|
406
632
|
typeOptions: { password: true },
|
|
407
633
|
default: '',
|
|
408
|
-
description: 'Password required to open the output PDF (
|
|
634
|
+
description: 'Password required to open the output PDF (1-32 characters, Latin-1 only). Set this and/or the Owner Password; at least one is required.',
|
|
409
635
|
displayOptions: { show: { operation: ['protect'] } },
|
|
410
636
|
},
|
|
411
637
|
{
|
|
@@ -414,7 +640,7 @@ class Pdfops {
|
|
|
414
640
|
type: 'string',
|
|
415
641
|
typeOptions: { password: true },
|
|
416
642
|
default: '',
|
|
417
|
-
description: 'Password that lifts the permission restrictions (
|
|
643
|
+
description: 'Password that lifts the permission restrictions (1-32 characters, Latin-1 only). Restrictions only bind a viewer when an owner password is set.',
|
|
418
644
|
displayOptions: { show: { operation: ['protect'] } },
|
|
419
645
|
},
|
|
420
646
|
{
|
|
@@ -463,19 +689,471 @@ class Pdfops {
|
|
|
463
689
|
{ displayName: 'Title', name: 'title', type: 'string', default: '' },
|
|
464
690
|
],
|
|
465
691
|
},
|
|
692
|
+
{
|
|
693
|
+
displayName: 'Fields to Add',
|
|
694
|
+
name: 'formFields',
|
|
695
|
+
type: 'json',
|
|
696
|
+
default: '[\n { "type": "text", "name": "customer_name", "page": 1, "x": 72, "y": 700, "width": 200, "height": 20 }\n]',
|
|
697
|
+
required: true,
|
|
698
|
+
description: 'JSON array (up to 200 entries) of fields to create. Every entry needs type (text, checkbox, radio, dropdown or signature), name (1-200 characters, no dot, unique, also against fields already in the PDF) and page (1-based). Every type except radio also needs x, y, width and height in PDF points from the bottom-left of the page as displayed; the box must lie inside the page. Optional on all types: required, read_only, border, background. text takes multiline, max_length, default, font_size (1-200 or "auto"); checkbox takes checked; radio takes options[] of { value, x, y, width, height } and default; dropdown takes options[] of strings, default, font_size.',
|
|
699
|
+
displayOptions: { show: { operation: ['addFields'] } },
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
displayName: 'Files to Attach',
|
|
703
|
+
name: 'attachments',
|
|
704
|
+
type: 'fixedCollection',
|
|
705
|
+
typeOptions: { multipleValues: true },
|
|
706
|
+
placeholder: 'Add File',
|
|
707
|
+
default: {},
|
|
708
|
+
required: true,
|
|
709
|
+
description: 'Files to embed, in order (1 to 10, up to 3 MB combined). Each one is read from a binary field of the input item.',
|
|
710
|
+
displayOptions: { show: { operation: ['attach'] } },
|
|
711
|
+
options: [
|
|
712
|
+
{
|
|
713
|
+
displayName: 'File',
|
|
714
|
+
name: 'file',
|
|
715
|
+
values: [
|
|
716
|
+
{
|
|
717
|
+
displayName: 'Binary Field',
|
|
718
|
+
name: 'binaryPropertyName',
|
|
719
|
+
type: 'string',
|
|
720
|
+
default: 'attachment',
|
|
721
|
+
required: true,
|
|
722
|
+
description: 'The name of the input item’s binary field holding the file to embed',
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
displayName: 'Description',
|
|
726
|
+
name: 'description',
|
|
727
|
+
type: 'string',
|
|
728
|
+
default: '',
|
|
729
|
+
description: 'Free text description stored with the file (optional)',
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
displayName: 'MIME Type',
|
|
733
|
+
name: 'mimeType',
|
|
734
|
+
type: 'string',
|
|
735
|
+
default: '',
|
|
736
|
+
placeholder: 'e.g. text/xml',
|
|
737
|
+
description: 'Defaults to the MIME type of the binary data',
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
displayName: 'Name',
|
|
741
|
+
name: 'name',
|
|
742
|
+
type: 'string',
|
|
743
|
+
default: '',
|
|
744
|
+
placeholder: 'e.g. factur-x.xml',
|
|
745
|
+
description: 'File name inside the PDF (1-255 characters, no / or \\). Defaults to the binary data’s file name. Must be unique within the PDF.',
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
displayName: 'Relationship',
|
|
749
|
+
name: 'relationship',
|
|
750
|
+
type: 'options',
|
|
751
|
+
options: [
|
|
752
|
+
{ name: 'Alternative', value: 'Alternative' },
|
|
753
|
+
{ name: 'Data', value: 'Data' },
|
|
754
|
+
{ name: 'Source', value: 'Source' },
|
|
755
|
+
{ name: 'Supplement', value: 'Supplement' },
|
|
756
|
+
{ name: 'Unspecified', value: 'Unspecified' },
|
|
757
|
+
],
|
|
758
|
+
default: 'Unspecified',
|
|
759
|
+
description: 'PDF/A-3 relationship of the file to the document',
|
|
760
|
+
},
|
|
761
|
+
],
|
|
762
|
+
},
|
|
763
|
+
],
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
displayName: 'Items',
|
|
767
|
+
name: 'editItems',
|
|
768
|
+
type: 'json',
|
|
769
|
+
default: '[\n { "type": "text", "page": 1, "x": 72, "y": 720, "text": "Approved", "size": 14 }\n]',
|
|
770
|
+
required: true,
|
|
771
|
+
description: 'JSON array (up to 100 entries) of things to draw, in order (later ones draw on top). x and y are PDF points from the bottom-left of the page as displayed. type "text": page, x, y, text (WinAnsi characters only), optional size, color, font, opacity, rotation, maxWidth, lineHeight. type "image": page, x, y, image (the Field Name of one of the Image Files below), optional width, height, opacity. type "barcode": page, x, y, format (qrcode, datamatrix, pdf417, azteccode, code128, code39, ean13, ean8, upca, itf14, interleaved2of5, gs1-128), value, optional width, height, color, background, includeText, errorCorrection, opacity.',
|
|
772
|
+
displayOptions: { show: { operation: ['edit'] } },
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
displayName: 'Image Files',
|
|
776
|
+
name: 'imageFiles',
|
|
777
|
+
type: 'fixedCollection',
|
|
778
|
+
typeOptions: { multipleValues: true },
|
|
779
|
+
placeholder: 'Add Image',
|
|
780
|
+
default: {},
|
|
781
|
+
description: 'PNG or JPEG images that "image" items refer to (up to 10, 2 MB each). Only needed when Items contains image entries.',
|
|
782
|
+
displayOptions: { show: { operation: ['edit'] } },
|
|
783
|
+
options: [
|
|
784
|
+
{
|
|
785
|
+
displayName: 'Image',
|
|
786
|
+
name: 'image',
|
|
787
|
+
values: [
|
|
788
|
+
{
|
|
789
|
+
displayName: 'Binary Field',
|
|
790
|
+
name: 'binaryPropertyName',
|
|
791
|
+
type: 'string',
|
|
792
|
+
default: 'logo',
|
|
793
|
+
required: true,
|
|
794
|
+
description: 'The name of the input item’s binary field holding the PNG or JPEG',
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
displayName: 'Field Name',
|
|
798
|
+
name: 'fieldName',
|
|
799
|
+
type: 'string',
|
|
800
|
+
default: 'logo',
|
|
801
|
+
required: true,
|
|
802
|
+
description: 'The name an Items entry uses in its "image" property to refer to this file. Must not be pdf, password or items.',
|
|
803
|
+
},
|
|
804
|
+
],
|
|
805
|
+
},
|
|
806
|
+
],
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
displayName: 'Query',
|
|
810
|
+
name: 'query',
|
|
811
|
+
type: 'string',
|
|
812
|
+
default: '',
|
|
813
|
+
required: true,
|
|
814
|
+
description: 'Text to find, or a regular expression when the Regex option is on. A match never spans two lines. Regex uses a safe subset of JavaScript syntax: backreferences, lookahead, lookbehind, named groups and inline flags are rejected.',
|
|
815
|
+
displayOptions: { show: { operation: ['findText'] } },
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
displayName: 'Find Options',
|
|
819
|
+
name: 'findOptions',
|
|
820
|
+
type: 'collection',
|
|
821
|
+
placeholder: 'Add Option',
|
|
822
|
+
default: {},
|
|
823
|
+
displayOptions: { show: { operation: ['findText'] } },
|
|
824
|
+
options: [
|
|
825
|
+
{
|
|
826
|
+
displayName: 'Case Sensitive',
|
|
827
|
+
name: 'case_sensitive',
|
|
828
|
+
type: 'boolean',
|
|
829
|
+
default: false,
|
|
830
|
+
description: 'Whether upper and lower case must match (off by default)',
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
displayName: 'Max Hits',
|
|
834
|
+
name: 'max_hits',
|
|
835
|
+
type: 'number',
|
|
836
|
+
typeOptions: { minValue: 1, maxValue: 1000 },
|
|
837
|
+
default: 100,
|
|
838
|
+
description: 'Most hits to return (1-1000). When the result has truncated true and nextPage is not null, the search stopped early: run it again with the same Query and options and Pages set to nextPage followed by a dash (for example 4-), keeping any page filter you used before and dropping pages below nextPage. No hit is repeated. Check pagesSkipped on every response: a page listed there held more hits than Max Hits (or was too large), only its first hits were returned, and no later request returns the rest, so raise Max Hits or narrow the Query for that page.',
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
displayName: 'Regex',
|
|
842
|
+
name: 'regex',
|
|
843
|
+
type: 'boolean',
|
|
844
|
+
default: false,
|
|
845
|
+
description: 'Whether the Query is a regular expression instead of literal text',
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
displayName: 'Whole Word',
|
|
849
|
+
name: 'whole_word',
|
|
850
|
+
type: 'boolean',
|
|
851
|
+
default: false,
|
|
852
|
+
description: 'Whether a hit must not touch a letter, digit or underscore on either side',
|
|
853
|
+
},
|
|
854
|
+
],
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
displayName: 'Result Format',
|
|
858
|
+
name: 'textFormat',
|
|
859
|
+
type: 'options',
|
|
860
|
+
options: [
|
|
861
|
+
{
|
|
862
|
+
name: 'JSON (Pages, Lines and Tables)',
|
|
863
|
+
value: 'json',
|
|
864
|
+
description: 'Returns pageCount, pages[] (text, lines with positions, tables as rows), pagesWithoutText and truncated',
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
name: 'Plain Text',
|
|
868
|
+
value: 'text',
|
|
869
|
+
description: 'The text of all pages in the item JSON field "text", pages separated by a form feed',
|
|
870
|
+
},
|
|
871
|
+
],
|
|
872
|
+
default: 'json',
|
|
873
|
+
displayOptions: { show: { operation: ['extractText'] } },
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
displayName: 'Tables As',
|
|
877
|
+
name: 'tablesFormat',
|
|
878
|
+
type: 'options',
|
|
879
|
+
options: [
|
|
880
|
+
{
|
|
881
|
+
name: 'CSV (Added to Each Table in the JSON)',
|
|
882
|
+
value: 'csv',
|
|
883
|
+
description: 'Each table also carries a "csv" string (RFC 4180); rows is unchanged',
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
name: 'Excel Workbook (Binary Output)',
|
|
887
|
+
value: 'xlsx',
|
|
888
|
+
description: 'Returns one .xlsx workbook as binary data instead of JSON: one sheet per table, every cell text. Fails with no_tables when the selected pages hold no table.',
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
name: 'JSON Rows',
|
|
892
|
+
value: 'json',
|
|
893
|
+
description: 'Tables as rows of cells in the JSON',
|
|
894
|
+
},
|
|
895
|
+
],
|
|
896
|
+
default: 'json',
|
|
897
|
+
displayOptions: { show: { operation: ['extractText'], textFormat: ['json'] } },
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
displayName: 'HTML',
|
|
901
|
+
name: 'html',
|
|
902
|
+
type: 'string',
|
|
903
|
+
typeOptions: { rows: 8 },
|
|
904
|
+
default: '<h1>Hello</h1>\n<p>Rendered by PDFops.</p>',
|
|
905
|
+
required: true,
|
|
906
|
+
description: 'The HTML document to render, up to 1 MB. Text only: there is no URL input and JavaScript is switched off. External images, stylesheets and fonts load over https from public hosts only; data: URIs are the safest way to include images.',
|
|
907
|
+
displayOptions: { show: { operation: ['htmlToPdf'] } },
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
displayName: 'HTML Options',
|
|
911
|
+
name: 'htmlOptions',
|
|
912
|
+
type: 'collection',
|
|
913
|
+
placeholder: 'Add Option',
|
|
914
|
+
default: {},
|
|
915
|
+
displayOptions: { show: { operation: ['htmlToPdf'] } },
|
|
916
|
+
options: [
|
|
917
|
+
{
|
|
918
|
+
displayName: 'Landscape',
|
|
919
|
+
name: 'landscape',
|
|
920
|
+
type: 'boolean',
|
|
921
|
+
default: false,
|
|
922
|
+
description: 'Whether to lay the pages out in landscape',
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
displayName: 'Margin',
|
|
926
|
+
name: 'margin',
|
|
927
|
+
type: 'number',
|
|
928
|
+
typeOptions: { minValue: 0, maxValue: 144 },
|
|
929
|
+
default: 36,
|
|
930
|
+
description: 'Page margin in points on all four sides (0-144)',
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
displayName: 'Page Size',
|
|
934
|
+
name: 'page_size',
|
|
935
|
+
type: 'options',
|
|
936
|
+
options: [
|
|
937
|
+
{ name: 'A4', value: 'a4' },
|
|
938
|
+
{ name: 'Letter', value: 'letter' },
|
|
939
|
+
],
|
|
940
|
+
default: 'letter',
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
displayName: 'Print Background',
|
|
944
|
+
name: 'print_background',
|
|
945
|
+
type: 'boolean',
|
|
946
|
+
default: true,
|
|
947
|
+
description: 'Whether to print CSS backgrounds and background images',
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
displayName: 'Scale',
|
|
951
|
+
name: 'scale',
|
|
952
|
+
type: 'number',
|
|
953
|
+
typeOptions: { minValue: 0.1, maxValue: 2, numberPrecision: 2 },
|
|
954
|
+
default: 1,
|
|
955
|
+
description: 'Rendering scale from 0.1 to 2',
|
|
956
|
+
},
|
|
957
|
+
],
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
displayName: 'Content',
|
|
961
|
+
name: 'content',
|
|
962
|
+
type: 'string',
|
|
963
|
+
typeOptions: { rows: 8 },
|
|
964
|
+
default: '',
|
|
965
|
+
required: true,
|
|
966
|
+
description: 'The document, up to 512 KiB of UTF-8. Latin (WinAnsi) characters only; other scripts are rejected with the character and its line and column named. Not HTML: use HTML to PDF for that.',
|
|
967
|
+
displayOptions: { show: { operation: ['textToPdf'] } },
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
displayName: 'Text Options',
|
|
971
|
+
name: 'textOptions',
|
|
972
|
+
type: 'collection',
|
|
973
|
+
placeholder: 'Add Option',
|
|
974
|
+
default: {},
|
|
975
|
+
displayOptions: { show: { operation: ['textToPdf'] } },
|
|
976
|
+
options: [
|
|
977
|
+
{
|
|
978
|
+
displayName: 'Font Size',
|
|
979
|
+
name: 'font_size',
|
|
980
|
+
type: 'number',
|
|
981
|
+
typeOptions: { minValue: 6, maxValue: 36 },
|
|
982
|
+
default: 11,
|
|
983
|
+
description: 'Body text size in points (6-36)',
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
displayName: 'Format',
|
|
987
|
+
name: 'format',
|
|
988
|
+
type: 'options',
|
|
989
|
+
options: [
|
|
990
|
+
{
|
|
991
|
+
name: 'CSV',
|
|
992
|
+
value: 'csv',
|
|
993
|
+
description: 'A table whose first row is the header',
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
name: 'Markdown',
|
|
997
|
+
value: 'markdown',
|
|
998
|
+
description: 'Headings, lists, tables, code blocks and links',
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
name: 'Plain Text',
|
|
1002
|
+
value: 'text',
|
|
1003
|
+
description: 'Spaces and line breaks kept exactly',
|
|
1004
|
+
},
|
|
1005
|
+
],
|
|
1006
|
+
default: 'markdown',
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
displayName: 'Margin',
|
|
1010
|
+
name: 'margin',
|
|
1011
|
+
type: 'number',
|
|
1012
|
+
typeOptions: { minValue: 18, maxValue: 144 },
|
|
1013
|
+
default: 54,
|
|
1014
|
+
description: 'Page margin in points on all four sides (18-144)',
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
displayName: 'Monospace',
|
|
1018
|
+
name: 'monospace',
|
|
1019
|
+
type: 'boolean',
|
|
1020
|
+
default: false,
|
|
1021
|
+
description: 'Whether to set plain text in Courier (Plain Text format only)',
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
displayName: 'Page Numbers',
|
|
1025
|
+
name: 'page_numbers',
|
|
1026
|
+
type: 'boolean',
|
|
1027
|
+
default: false,
|
|
1028
|
+
description: 'Whether to print "Page n of N" in the bottom margin',
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
displayName: 'Page Size',
|
|
1032
|
+
name: 'page_size',
|
|
1033
|
+
type: 'options',
|
|
1034
|
+
options: [
|
|
1035
|
+
{ name: 'A4', value: 'a4' },
|
|
1036
|
+
{ name: 'Letter', value: 'letter' },
|
|
1037
|
+
],
|
|
1038
|
+
default: 'letter',
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
displayName: 'Title',
|
|
1042
|
+
name: 'title',
|
|
1043
|
+
type: 'string',
|
|
1044
|
+
default: '',
|
|
1045
|
+
description: 'PDF title metadata, up to 200 characters. Not printed on the page.',
|
|
1046
|
+
},
|
|
1047
|
+
],
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
displayName: 'Image Options',
|
|
1051
|
+
name: 'imageOptions',
|
|
1052
|
+
type: 'collection',
|
|
1053
|
+
placeholder: 'Add Option',
|
|
1054
|
+
default: {},
|
|
1055
|
+
displayOptions: { show: { operation: ['imageToPdf'] } },
|
|
1056
|
+
options: [
|
|
1057
|
+
{
|
|
1058
|
+
displayName: 'Margin',
|
|
1059
|
+
name: 'margin',
|
|
1060
|
+
type: 'number',
|
|
1061
|
+
typeOptions: { minValue: 0, maxValue: 200 },
|
|
1062
|
+
default: 0,
|
|
1063
|
+
description: 'Margin in points (0-200). The API default is 0 for Fit to Image and 36 for A4 and Letter; for Fit to Image the page grows by the margin on each side.',
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
displayName: 'Orientation',
|
|
1067
|
+
name: 'orientation',
|
|
1068
|
+
type: 'options',
|
|
1069
|
+
options: [
|
|
1070
|
+
{ name: 'Auto (Per Image)', value: 'auto' },
|
|
1071
|
+
{ name: 'Landscape', value: 'landscape' },
|
|
1072
|
+
{ name: 'Portrait', value: 'portrait' },
|
|
1073
|
+
],
|
|
1074
|
+
default: 'auto',
|
|
1075
|
+
description: 'Ignored for Fit to Image',
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
displayName: 'Page Size',
|
|
1079
|
+
name: 'page_size',
|
|
1080
|
+
type: 'options',
|
|
1081
|
+
options: [
|
|
1082
|
+
{ name: 'A4', value: 'a4' },
|
|
1083
|
+
{ name: 'Fit to Image', value: 'fit' },
|
|
1084
|
+
{ name: 'Letter', value: 'letter' },
|
|
1085
|
+
],
|
|
1086
|
+
default: 'fit',
|
|
1087
|
+
description: 'Fit to Image makes each page the size of its image; A4 and Letter scale images down to fit, never up',
|
|
1088
|
+
},
|
|
1089
|
+
],
|
|
1090
|
+
},
|
|
466
1091
|
{
|
|
467
1092
|
displayName: 'Invoice',
|
|
468
1093
|
name: 'invoice',
|
|
469
1094
|
type: 'json',
|
|
470
1095
|
default: '{\n "from": "Acme Inc",\n "to": "Customer LLC",\n "items": [\n { "description": "Consulting", "quantity": 2, "unit_price": 100 }\n ]\n}',
|
|
471
1096
|
required: true,
|
|
472
|
-
description: 'Invoice data: from, to, items[] (description, quantity?, unit_price), and optionally invoice_number, date, due, currency, tax_rate, notes. Deterministic: the same input produces a byte-identical PDF.',
|
|
1097
|
+
description: 'Invoice data: from, to, items[] (description, quantity?, unit_price), and optionally invoice_number, date, due, currency, tax_rate, notes. Deterministic: the same input produces a byte-identical PDF. For a Factur-X e-invoice (node version 2), from and to also take country, street, postcode, city, vat_id (and from.tax_id with registration_id), and every item needs a unit.',
|
|
473
1098
|
displayOptions: {
|
|
474
1099
|
show: {
|
|
475
1100
|
operation: ['invoice'],
|
|
476
1101
|
},
|
|
477
1102
|
},
|
|
478
1103
|
},
|
|
1104
|
+
{
|
|
1105
|
+
displayName: 'Factur-X E-Invoice',
|
|
1106
|
+
name: 'eInvoice',
|
|
1107
|
+
type: 'boolean',
|
|
1108
|
+
default: false,
|
|
1109
|
+
description: 'Whether to produce a Factur-X (ZUGFeRD) e-invoice: a PDF/A-3 with the invoice data embedded as factur-x.xml, profile EN 16931. Required in the Invoice JSON then: invoice_number, date (YYYY-MM-DD), currency, due or payment_terms, from.country and to.country (ISO 3166-1 alpha-2), from.vat_id (or from.tax_id with from.registration_id; with tax category O, no VAT ID at all and from.registration_id instead), a buyer to.vat_id or to.registration_id for tax category AE, a UN/ECE Recommendation 20 unit on every item (C62 one, HUR hour, KGM kilogram), and tax_category when tax_rate is 0. Text is limited to Latin letters, Latin Extended-A, the euro sign and common punctuation. Tested with the Mustang validator; this is not a statement of legal compliance, and XRechnung and Peppol output are not produced.',
|
|
1110
|
+
displayOptions: { show: { '@version': [2], operation: ['invoice'] } },
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
displayName: 'E-Invoice Options',
|
|
1114
|
+
name: 'eInvoiceOptions',
|
|
1115
|
+
type: 'collection',
|
|
1116
|
+
placeholder: 'Add Option',
|
|
1117
|
+
default: {},
|
|
1118
|
+
displayOptions: { show: { '@version': [2], operation: ['invoice'], eInvoice: [true] } },
|
|
1119
|
+
options: [
|
|
1120
|
+
{
|
|
1121
|
+
displayName: 'IBAN',
|
|
1122
|
+
name: 'iban',
|
|
1123
|
+
type: 'string',
|
|
1124
|
+
default: '',
|
|
1125
|
+
description: 'Seller bank account for the payment instructions (spaces are ignored)',
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
displayName: 'Payment Terms',
|
|
1129
|
+
name: 'payment_terms',
|
|
1130
|
+
type: 'string',
|
|
1131
|
+
default: '',
|
|
1132
|
+
description: 'Payment terms text. Either this or a due date in the Invoice JSON is required.',
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
displayName: 'Tax Category',
|
|
1136
|
+
name: 'tax_category',
|
|
1137
|
+
type: 'options',
|
|
1138
|
+
options: [
|
|
1139
|
+
{ name: 'Exempt (E)', value: 'E' },
|
|
1140
|
+
{ name: 'Not Subject to VAT (O)', value: 'O' },
|
|
1141
|
+
{ name: 'Reverse Charge (AE)', value: 'AE' },
|
|
1142
|
+
{ name: 'Standard Rate (S)', value: 'S' },
|
|
1143
|
+
{ name: 'Zero Rate (Z)', value: 'Z' },
|
|
1144
|
+
],
|
|
1145
|
+
default: 'S',
|
|
1146
|
+
description: 'EN 16931 VAT category for the whole invoice. S is the default when tax_rate is above 0; required when tax_rate is 0 or missing.',
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
displayName: 'Tax Exemption Reason',
|
|
1150
|
+
name: 'tax_exemption_reason',
|
|
1151
|
+
type: 'string',
|
|
1152
|
+
default: '',
|
|
1153
|
+
description: 'Reason text, required for the Exempt, Reverse Charge and Not Subject to VAT categories',
|
|
1154
|
+
},
|
|
1155
|
+
],
|
|
1156
|
+
},
|
|
479
1157
|
{
|
|
480
1158
|
displayName: 'Flatten',
|
|
481
1159
|
name: 'flatten',
|
|
@@ -496,7 +1174,7 @@ class Pdfops {
|
|
|
496
1174
|
hint: 'The name of the output item’s binary field to write the resulting PDF to',
|
|
497
1175
|
displayOptions: {
|
|
498
1176
|
show: {
|
|
499
|
-
operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata'],
|
|
1177
|
+
operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata', 'addFields', 'attach', 'edit', 'htmlToPdf', 'imageToPdf', 'textToPdf'],
|
|
500
1178
|
},
|
|
501
1179
|
},
|
|
502
1180
|
},
|
|
@@ -509,15 +1187,36 @@ class Pdfops {
|
|
|
509
1187
|
description: 'File name for the output PDF. Defaults per operation. For Split PDF it is the prefix: parts are named prefix-1.pdf, prefix-2.pdf and so on',
|
|
510
1188
|
displayOptions: {
|
|
511
1189
|
show: {
|
|
512
|
-
operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata'],
|
|
1190
|
+
operation: ['fill', 'merge', 'invoice', 'extractPages', 'deletePages', 'rotate', 'split', 'watermark', 'pageNumbers', 'unlock', 'protect', 'setMetadata', 'addFields', 'attach', 'edit', 'htmlToPdf', 'imageToPdf', 'textToPdf'],
|
|
513
1191
|
},
|
|
514
1192
|
},
|
|
515
1193
|
},
|
|
1194
|
+
{
|
|
1195
|
+
displayName: 'Output Binary Field',
|
|
1196
|
+
name: 'outputBinaryPropertyName',
|
|
1197
|
+
type: 'string',
|
|
1198
|
+
default: 'data',
|
|
1199
|
+
hint: 'The name of the output item’s binary field to write the Excel workbook to',
|
|
1200
|
+
displayOptions: {
|
|
1201
|
+
show: { operation: ['extractText'], textFormat: ['json'], tablesFormat: ['xlsx'] },
|
|
1202
|
+
},
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
displayName: 'Output File Name',
|
|
1206
|
+
name: 'fileName',
|
|
1207
|
+
type: 'string',
|
|
1208
|
+
default: 'tables.xlsx',
|
|
1209
|
+
placeholder: 'e.g. tables.xlsx',
|
|
1210
|
+
description: 'File name for the output Excel workbook',
|
|
1211
|
+
displayOptions: {
|
|
1212
|
+
show: { operation: ['extractText'], textFormat: ['json'], tablesFormat: ['xlsx'] },
|
|
1213
|
+
},
|
|
1214
|
+
},
|
|
516
1215
|
],
|
|
517
1216
|
};
|
|
518
1217
|
}
|
|
519
1218
|
async execute() {
|
|
520
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1219
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
521
1220
|
const items = this.getInputData();
|
|
522
1221
|
const returnData = [];
|
|
523
1222
|
const operation = this.getNodeParameter('operation', 0);
|
|
@@ -528,6 +1227,7 @@ class Pdfops {
|
|
|
528
1227
|
'X-Pdfops-Client': 'n8n',
|
|
529
1228
|
'X-Pdfops-Client-Version': NODE_PACKAGE_VERSION,
|
|
530
1229
|
};
|
|
1230
|
+
options.disableFollowRedirect = true;
|
|
531
1231
|
if (hasCredential) {
|
|
532
1232
|
return await this.helpers.httpRequestWithAuthentication.call(this, 'pdfopsApi', options);
|
|
533
1233
|
}
|
|
@@ -551,11 +1251,41 @@ class Pdfops {
|
|
|
551
1251
|
}
|
|
552
1252
|
return value;
|
|
553
1253
|
};
|
|
1254
|
+
const jsonArrayParam = (name, itemIndex) => {
|
|
1255
|
+
const raw = this.getNodeParameter(name, itemIndex);
|
|
1256
|
+
let value = raw;
|
|
1257
|
+
if (typeof raw === 'string') {
|
|
1258
|
+
try {
|
|
1259
|
+
value = JSON.parse(raw);
|
|
1260
|
+
}
|
|
1261
|
+
catch {
|
|
1262
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Parameter "${name}" is not valid JSON`, {
|
|
1263
|
+
itemIndex,
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
if (!Array.isArray(value)) {
|
|
1268
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Parameter "${name}" must be a JSON array`, {
|
|
1269
|
+
itemIndex,
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
return value;
|
|
1273
|
+
};
|
|
554
1274
|
const pdfBlob = async (itemIndex, binaryPropertyName) => {
|
|
555
1275
|
this.helpers.assertBinaryData(itemIndex, binaryPropertyName);
|
|
556
1276
|
const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
|
557
1277
|
return new Blob([new Uint8Array(buffer)], { type: 'application/pdf' });
|
|
558
1278
|
};
|
|
1279
|
+
const fileBlob = async (itemIndex, binaryPropertyName, mimeType) => {
|
|
1280
|
+
const meta = this.helpers.assertBinaryData(itemIndex, binaryPropertyName);
|
|
1281
|
+
const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
|
1282
|
+
return {
|
|
1283
|
+
blob: new Blob([new Uint8Array(buffer)], {
|
|
1284
|
+
type: mimeType || meta.mimeType || 'application/octet-stream',
|
|
1285
|
+
}),
|
|
1286
|
+
fileName: meta.fileName || binaryPropertyName,
|
|
1287
|
+
};
|
|
1288
|
+
};
|
|
559
1289
|
if (operation === 'merge') {
|
|
560
1290
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
|
|
561
1291
|
const fileName = this.getNodeParameter('fileName', 0) || 'merged.pdf';
|
|
@@ -599,6 +1329,52 @@ class Pdfops {
|
|
|
599
1329
|
}
|
|
600
1330
|
return [returnData];
|
|
601
1331
|
}
|
|
1332
|
+
if (operation === 'imageToPdf') {
|
|
1333
|
+
const formData = new FormData();
|
|
1334
|
+
try {
|
|
1335
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
|
|
1336
|
+
const fileName = this.getNodeParameter('fileName', 0) || 'images.pdf';
|
|
1337
|
+
const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', 0);
|
|
1338
|
+
for (let i = 0; i < items.length; i++) {
|
|
1339
|
+
const image = await fileBlob(i, binaryPropertyName);
|
|
1340
|
+
formData.append('pdf', image.blob, image.fileName);
|
|
1341
|
+
}
|
|
1342
|
+
const imageOptions = this.getNodeParameter('imageOptions', 0, {});
|
|
1343
|
+
for (const [k, v] of Object.entries(imageOptions)) {
|
|
1344
|
+
if (v !== undefined && v !== null && v !== '')
|
|
1345
|
+
formData.append(k, String(v));
|
|
1346
|
+
}
|
|
1347
|
+
const response = (await request({
|
|
1348
|
+
method: 'POST',
|
|
1349
|
+
url: `${BASE_URL}/api/image-to-pdf`,
|
|
1350
|
+
body: formData,
|
|
1351
|
+
encoding: 'arraybuffer',
|
|
1352
|
+
}));
|
|
1353
|
+
returnData.push({
|
|
1354
|
+
json: { fileName, imageCount: items.length },
|
|
1355
|
+
binary: {
|
|
1356
|
+
[outputBinaryPropertyName]: await this.helpers.prepareBinaryData(response, fileName, 'application/pdf'),
|
|
1357
|
+
},
|
|
1358
|
+
pairedItem: items.map((_, i) => ({ item: i })),
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
catch (error) {
|
|
1362
|
+
const apiError = (0, decodeApiError_1.decodeApiError)(error);
|
|
1363
|
+
if (this.continueOnFail()) {
|
|
1364
|
+
returnData.push({
|
|
1365
|
+
json: {
|
|
1366
|
+
error: (_d = apiError === null || apiError === void 0 ? void 0 : apiError.message) !== null && _d !== void 0 ? _d : error.message,
|
|
1367
|
+
...((apiError === null || apiError === void 0 ? void 0 : apiError.details) ? { message: apiError.details } : {}),
|
|
1368
|
+
},
|
|
1369
|
+
pairedItem: items.map((_, i) => ({ item: i })),
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
else {
|
|
1373
|
+
throw withApiMessage(new n8n_workflow_1.NodeApiError(this.getNode(), error), apiError);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return [returnData];
|
|
1377
|
+
}
|
|
602
1378
|
if (operation === 'usage' && !hasCredential) {
|
|
603
1379
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The Get Usage operation requires a PDFops API credential (free key at https://pdfops.dev/pricing)');
|
|
604
1380
|
}
|
|
@@ -606,6 +1382,7 @@ class Pdfops {
|
|
|
606
1382
|
let options;
|
|
607
1383
|
let binaryOut;
|
|
608
1384
|
let splitOut = false;
|
|
1385
|
+
let textOut = false;
|
|
609
1386
|
try {
|
|
610
1387
|
if (operation === 'inspect') {
|
|
611
1388
|
const formData = new FormData();
|
|
@@ -637,10 +1414,19 @@ class Pdfops {
|
|
|
637
1414
|
};
|
|
638
1415
|
}
|
|
639
1416
|
else if (operation === 'invoice') {
|
|
1417
|
+
const invoiceBody = { ...jsonParam('invoice', i) };
|
|
1418
|
+
if (this.getNodeParameter('eInvoice', i, false)) {
|
|
1419
|
+
invoiceBody.e_invoice = 'factur-x';
|
|
1420
|
+
const eInvoiceOptions = this.getNodeParameter('eInvoiceOptions', i, {});
|
|
1421
|
+
for (const [k, v] of Object.entries(eInvoiceOptions)) {
|
|
1422
|
+
if (v !== undefined && v !== null && v !== '')
|
|
1423
|
+
invoiceBody[k] = v;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
640
1426
|
options = {
|
|
641
1427
|
method: 'POST',
|
|
642
1428
|
url: `${BASE_URL}/api/invoice`,
|
|
643
|
-
body:
|
|
1429
|
+
body: invoiceBody,
|
|
644
1430
|
json: true,
|
|
645
1431
|
encoding: 'arraybuffer',
|
|
646
1432
|
};
|
|
@@ -649,6 +1435,28 @@ class Pdfops {
|
|
|
649
1435
|
property: this.getNodeParameter('outputBinaryPropertyName', i),
|
|
650
1436
|
};
|
|
651
1437
|
}
|
|
1438
|
+
else if (operation === 'htmlToPdf' || operation === 'textToPdf') {
|
|
1439
|
+
const isHtml = operation === 'htmlToPdf';
|
|
1440
|
+
const body = isHtml
|
|
1441
|
+
? { html: this.getNodeParameter('html', i) }
|
|
1442
|
+
: { content: this.getNodeParameter('content', i) };
|
|
1443
|
+
const extra = this.getNodeParameter(isHtml ? 'htmlOptions' : 'textOptions', i, {});
|
|
1444
|
+
for (const [k, v] of Object.entries(extra)) {
|
|
1445
|
+
if (v !== undefined && v !== null && v !== '')
|
|
1446
|
+
body[k] = v;
|
|
1447
|
+
}
|
|
1448
|
+
options = {
|
|
1449
|
+
method: 'POST',
|
|
1450
|
+
url: `${BASE_URL}/api/${isHtml ? 'html-to-pdf' : 'text-to-pdf'}`,
|
|
1451
|
+
body,
|
|
1452
|
+
json: true,
|
|
1453
|
+
encoding: 'arraybuffer',
|
|
1454
|
+
};
|
|
1455
|
+
binaryOut = {
|
|
1456
|
+
fileName: this.getNodeParameter('fileName', i) || 'document.pdf',
|
|
1457
|
+
property: this.getNodeParameter('outputBinaryPropertyName', i),
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
652
1460
|
else if (DOC_OPS[operation]) {
|
|
653
1461
|
const spec = DOC_OPS[operation];
|
|
654
1462
|
const formData = new FormData();
|
|
@@ -694,7 +1502,99 @@ class Pdfops {
|
|
|
694
1502
|
formData.append(k, String(v !== null && v !== void 0 ? v : ''));
|
|
695
1503
|
}
|
|
696
1504
|
}
|
|
697
|
-
if (
|
|
1505
|
+
else if (operation === 'addFields') {
|
|
1506
|
+
formData.append('fields', JSON.stringify(jsonArrayParam('formFields', i)));
|
|
1507
|
+
}
|
|
1508
|
+
else if (operation === 'edit') {
|
|
1509
|
+
formData.append('items', JSON.stringify(jsonArrayParam('editItems', i)));
|
|
1510
|
+
const images = this.getNodeParameter('imageFiles', i, {}).image;
|
|
1511
|
+
const seenImageNames = new Set();
|
|
1512
|
+
for (const image of images !== null && images !== void 0 ? images : []) {
|
|
1513
|
+
if (!/^[A-Za-z0-9_.-]{1,64}$/.test((_e = image.fieldName) !== null && _e !== void 0 ? _e : '')) {
|
|
1514
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${(_f = image.fieldName) !== null && _f !== void 0 ? _f : ''}" is not allowed: use 1-64 letters, digits, "_", "." or "-"`, { itemIndex: i });
|
|
1515
|
+
}
|
|
1516
|
+
if (['pdf', 'password', 'items'].includes(image.fieldName)) {
|
|
1517
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${image.fieldName}" is reserved; use another name`, { itemIndex: i });
|
|
1518
|
+
}
|
|
1519
|
+
if (seenImageNames.has(image.fieldName)) {
|
|
1520
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Image field name "${image.fieldName}" is used twice; each image needs its own name`, { itemIndex: i });
|
|
1521
|
+
}
|
|
1522
|
+
seenImageNames.add(image.fieldName);
|
|
1523
|
+
const file = await fileBlob(i, image.binaryPropertyName);
|
|
1524
|
+
formData.append(image.fieldName, file.blob, file.fileName);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
else if (operation === 'attach') {
|
|
1528
|
+
const files = this.getNodeParameter('attachments', i, {}).file;
|
|
1529
|
+
if (!(files === null || files === void 0 ? void 0 : files.length)) {
|
|
1530
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Add at least one file to attach', {
|
|
1531
|
+
itemIndex: i,
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
const perFile = [];
|
|
1535
|
+
for (const f of files) {
|
|
1536
|
+
const file = await fileBlob(i, f.binaryPropertyName, f.mimeType);
|
|
1537
|
+
const name = f.name || file.fileName;
|
|
1538
|
+
formData.append('file', file.blob, name);
|
|
1539
|
+
const entry = { name };
|
|
1540
|
+
if (f.mimeType)
|
|
1541
|
+
entry.mime_type = f.mimeType;
|
|
1542
|
+
if (f.description)
|
|
1543
|
+
entry.description = f.description;
|
|
1544
|
+
if (f.relationship)
|
|
1545
|
+
entry.relationship = f.relationship;
|
|
1546
|
+
perFile.push(entry);
|
|
1547
|
+
}
|
|
1548
|
+
formData.append('options', JSON.stringify(perFile));
|
|
1549
|
+
}
|
|
1550
|
+
else if (operation === 'findText') {
|
|
1551
|
+
add('query', this.getNodeParameter('query', i));
|
|
1552
|
+
add('pages', this.getNodeParameter('pages', i));
|
|
1553
|
+
for (const [k, v] of Object.entries(collection('findOptions')))
|
|
1554
|
+
add(k, v);
|
|
1555
|
+
}
|
|
1556
|
+
else if (operation === 'extractText') {
|
|
1557
|
+
add('pages', this.getNodeParameter('pages', i));
|
|
1558
|
+
}
|
|
1559
|
+
if (spec.output === 'extract') {
|
|
1560
|
+
const format = this.getNodeParameter('textFormat', i);
|
|
1561
|
+
const tablesFormat = format === 'json' ? this.getNodeParameter('tablesFormat', i) : 'json';
|
|
1562
|
+
if (format === 'text')
|
|
1563
|
+
formData.append('format', 'text');
|
|
1564
|
+
if (tablesFormat !== 'json')
|
|
1565
|
+
formData.append('tables_format', tablesFormat);
|
|
1566
|
+
if (tablesFormat === 'xlsx') {
|
|
1567
|
+
options = {
|
|
1568
|
+
method: 'POST',
|
|
1569
|
+
url: `${BASE_URL}/api/${spec.path}`,
|
|
1570
|
+
body: formData,
|
|
1571
|
+
encoding: 'arraybuffer',
|
|
1572
|
+
};
|
|
1573
|
+
binaryOut = {
|
|
1574
|
+
fileName: this.getNodeParameter('fileName', i) || spec.defaultFile,
|
|
1575
|
+
property: this.getNodeParameter('outputBinaryPropertyName', i),
|
|
1576
|
+
mimeType: XLSX_MIME_TYPE,
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
else if (format === 'text') {
|
|
1580
|
+
textOut = true;
|
|
1581
|
+
options = {
|
|
1582
|
+
method: 'POST',
|
|
1583
|
+
url: `${BASE_URL}/api/${spec.path}`,
|
|
1584
|
+
body: formData,
|
|
1585
|
+
encoding: 'text',
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
else {
|
|
1589
|
+
options = {
|
|
1590
|
+
method: 'POST',
|
|
1591
|
+
url: `${BASE_URL}/api/${spec.path}`,
|
|
1592
|
+
body: formData,
|
|
1593
|
+
json: true,
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
else if (spec.output === 'pdf') {
|
|
698
1598
|
options = {
|
|
699
1599
|
method: 'POST',
|
|
700
1600
|
url: `${BASE_URL}/api/${spec.path}`,
|
|
@@ -739,7 +1639,7 @@ class Pdfops {
|
|
|
739
1639
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
740
1640
|
}
|
|
741
1641
|
try {
|
|
742
|
-
if (binaryOut && !splitOut)
|
|
1642
|
+
if ((binaryOut && !splitOut) || textOut)
|
|
743
1643
|
options.returnFullResponse = true;
|
|
744
1644
|
const response = await request(options);
|
|
745
1645
|
if (splitOut && binaryOut) {
|
|
@@ -760,10 +1660,20 @@ class Pdfops {
|
|
|
760
1660
|
});
|
|
761
1661
|
}
|
|
762
1662
|
}
|
|
1663
|
+
else if (textOut) {
|
|
1664
|
+
const full = response;
|
|
1665
|
+
returnData.push({
|
|
1666
|
+
json: {
|
|
1667
|
+
text: full.body,
|
|
1668
|
+
truncated: headerTrue((_g = full.headers) === null || _g === void 0 ? void 0 : _g['x-pdfops-truncated']),
|
|
1669
|
+
},
|
|
1670
|
+
pairedItem: { item: i },
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
763
1673
|
else if (binaryOut) {
|
|
764
1674
|
const full = response;
|
|
765
1675
|
const json = { fileName: binaryOut.fileName };
|
|
766
|
-
const fieldMap = (
|
|
1676
|
+
const fieldMap = (_h = full.headers) === null || _h === void 0 ? void 0 : _h['x-pdfops-field-map'];
|
|
767
1677
|
if (fieldMap) {
|
|
768
1678
|
try {
|
|
769
1679
|
json.field_map = JSON.parse(fieldMap);
|
|
@@ -772,13 +1682,58 @@ class Pdfops {
|
|
|
772
1682
|
json.field_map = fieldMap;
|
|
773
1683
|
}
|
|
774
1684
|
}
|
|
775
|
-
const note = (
|
|
1685
|
+
const note = (_j = full.headers) === null || _j === void 0 ? void 0 : _j['x-pdfops-note'];
|
|
776
1686
|
if (note)
|
|
777
1687
|
json.note = note;
|
|
1688
|
+
if (operation === 'attach') {
|
|
1689
|
+
let keys = [];
|
|
1690
|
+
try {
|
|
1691
|
+
const parsed = JSON.parse(String((_k = full.headers) === null || _k === void 0 ? void 0 : _k['x-pdfops-attachment-keys']));
|
|
1692
|
+
if (Array.isArray(parsed)) {
|
|
1693
|
+
keys = parsed
|
|
1694
|
+
.filter((e) => typeof (e === null || e === void 0 ? void 0 : e.name) === 'string' && typeof (e === null || e === void 0 ? void 0 : e.key) === 'string')
|
|
1695
|
+
.map((e) => ({ name: e.name, key: e.key }));
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
catch {
|
|
1699
|
+
keys = [];
|
|
1700
|
+
}
|
|
1701
|
+
json.attachment_keys = keys;
|
|
1702
|
+
}
|
|
1703
|
+
if (operation === 'extractText') {
|
|
1704
|
+
if (headerTrue((_l = full.headers) === null || _l === void 0 ? void 0 : _l['x-pdfops-truncated'])) {
|
|
1705
|
+
json.truncated = true;
|
|
1706
|
+
const truncatedBy = (_m = full.headers) === null || _m === void 0 ? void 0 : _m['x-pdfops-truncated-by'];
|
|
1707
|
+
if (typeof truncatedBy === 'string' && truncatedBy) {
|
|
1708
|
+
json.truncated_by = truncatedBy.split(',');
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
if (headerTrue((_o = full.headers) === null || _o === void 0 ? void 0 : _o['x-pdfops-cells-truncated']))
|
|
1712
|
+
json.cells_truncated = true;
|
|
1713
|
+
const body = Buffer.from(full.body);
|
|
1714
|
+
if (body.length < 4 || body.readUInt32BE(0) !== 0x504b0304) {
|
|
1715
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The API did not return an Excel workbook (the response is not a zip file)', { itemIndex: i });
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (operation === 'addFields') {
|
|
1719
|
+
const warning = (_p = full.headers) === null || _p === void 0 ? void 0 : _p['x-pdfops-warning'];
|
|
1720
|
+
if (typeof warning === 'string' && warning)
|
|
1721
|
+
json.warning = warning;
|
|
1722
|
+
}
|
|
1723
|
+
if (operation === 'htmlToPdf') {
|
|
1724
|
+
for (const [header, key] of [
|
|
1725
|
+
['x-pdfops-pages', 'pages'],
|
|
1726
|
+
['x-pdfops-blocked-requests', 'blocked_requests'],
|
|
1727
|
+
]) {
|
|
1728
|
+
const value = (_q = full.headers) === null || _q === void 0 ? void 0 : _q[header];
|
|
1729
|
+
if (typeof value === 'string' && /^\d+$/.test(value))
|
|
1730
|
+
json[key] = Number(value);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
778
1733
|
returnData.push({
|
|
779
1734
|
json,
|
|
780
1735
|
binary: {
|
|
781
|
-
[binaryOut.property]: await this.helpers.prepareBinaryData(full.body, binaryOut.fileName, 'application/pdf'),
|
|
1736
|
+
[binaryOut.property]: await this.helpers.prepareBinaryData(full.body, binaryOut.fileName, (_r = binaryOut.mimeType) !== null && _r !== void 0 ? _r : 'application/pdf'),
|
|
782
1737
|
},
|
|
783
1738
|
pairedItem: { item: i },
|
|
784
1739
|
});
|
|
@@ -792,7 +1747,7 @@ class Pdfops {
|
|
|
792
1747
|
if (this.continueOnFail()) {
|
|
793
1748
|
returnData.push({
|
|
794
1749
|
json: {
|
|
795
|
-
error: (
|
|
1750
|
+
error: (_s = apiError === null || apiError === void 0 ? void 0 : apiError.message) !== null && _s !== void 0 ? _s : error.message,
|
|
796
1751
|
...((apiError === null || apiError === void 0 ? void 0 : apiError.details) ? { message: apiError.details } : {}),
|
|
797
1752
|
},
|
|
798
1753
|
pairedItem: { item: i },
|