n8n-nodes-make-pdf 1.1.0 → 1.2.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.
@@ -10,7 +10,8 @@ class MakePdf {
10
10
  icon: 'file:MakePdf.svg',
11
11
  group: ['transform'],
12
12
  version: 1,
13
- description: 'Generate PDF via Gotenberg (HTML → PDF)',
13
+ subtitle: '={{$parameter["method"] + ": " + $parameter["url"]}}',
14
+ description: 'Make HTTP requests to Gotenberg for PDF generation',
14
15
  defaults: {
15
16
  name: 'Make PDF',
16
17
  },
@@ -18,31 +19,273 @@ class MakePdf {
18
19
  outputs: ['main'],
19
20
  properties: [
20
21
  {
21
- displayName: 'Input Binary Property',
22
- name: 'binaryPropertyName',
22
+ displayName: 'Method',
23
+ name: 'method',
24
+ type: 'options',
25
+ options: [
26
+ { name: 'DELETE', value: 'DELETE' },
27
+ { name: 'GET', value: 'GET' },
28
+ { name: 'HEAD', value: 'HEAD' },
29
+ { name: 'PATCH', value: 'PATCH' },
30
+ { name: 'POST', value: 'POST' },
31
+ { name: 'PUT', value: 'PUT' },
32
+ ],
33
+ default: 'POST',
34
+ description: 'The request method to use',
35
+ },
36
+ {
37
+ displayName: 'URL',
38
+ name: 'url',
23
39
  type: 'string',
24
- default: 'data',
40
+ default: 'http://gotenberg:3000/forms/chromium/convert/html',
41
+ placeholder: 'http://gotenberg:3000/forms/chromium/convert/html',
42
+ description: 'The URL to make the request to',
25
43
  required: true,
26
- description: 'Name of the binary property which contains the HTML data',
27
- placeholder: 'e.g. data',
28
44
  },
29
45
  {
30
- displayName: 'Output Binary Property',
31
- name: 'outputBinaryPropertyName',
46
+ displayName: 'Authentication',
47
+ name: 'authentication',
48
+ type: 'options',
49
+ options: [
50
+ { name: 'None', value: 'none' },
51
+ { name: 'Header Auth', value: 'headerAuth' },
52
+ { name: 'Query Auth', value: 'queryAuth' },
53
+ ],
54
+ default: 'none',
55
+ description: 'Authentication method to use',
56
+ },
57
+ {
58
+ displayName: 'Send Query Parameters',
59
+ name: 'sendQuery',
60
+ type: 'boolean',
61
+ default: false,
62
+ description: 'Whether the request has query params or not',
63
+ },
64
+ {
65
+ displayName: 'Query Parameters',
66
+ name: 'queryParameters',
67
+ type: 'fixedCollection',
68
+ typeOptions: {
69
+ multipleValues: true,
70
+ },
71
+ placeholder: 'Add Parameter',
72
+ default: { parameters: [] },
73
+ displayOptions: {
74
+ show: {
75
+ sendQuery: [true],
76
+ },
77
+ },
78
+ options: [
79
+ {
80
+ name: 'parameters',
81
+ displayName: 'Parameter',
82
+ values: [
83
+ {
84
+ displayName: 'Name',
85
+ name: 'name',
86
+ type: 'string',
87
+ default: '',
88
+ description: 'Name of the parameter',
89
+ },
90
+ {
91
+ displayName: 'Value',
92
+ name: 'value',
93
+ type: 'string',
94
+ default: '',
95
+ description: 'Value of the parameter',
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ description: 'The query parameters to send',
101
+ },
102
+ {
103
+ displayName: 'Send Headers',
104
+ name: 'sendHeaders',
105
+ type: 'boolean',
106
+ default: false,
107
+ description: 'Whether the request has headers or not',
108
+ },
109
+ {
110
+ displayName: 'Header Parameters',
111
+ name: 'headerParameters',
112
+ type: 'fixedCollection',
113
+ typeOptions: {
114
+ multipleValues: true,
115
+ },
116
+ placeholder: 'Add Header',
117
+ default: { parameters: [] },
118
+ displayOptions: {
119
+ show: {
120
+ sendHeaders: [true],
121
+ },
122
+ },
123
+ options: [
124
+ {
125
+ name: 'parameters',
126
+ displayName: 'Header',
127
+ values: [
128
+ {
129
+ displayName: 'Name',
130
+ name: 'name',
131
+ type: 'string',
132
+ default: '',
133
+ description: 'Name of the header',
134
+ },
135
+ {
136
+ displayName: 'Value',
137
+ name: 'value',
138
+ type: 'string',
139
+ default: '',
140
+ description: 'Value of the header',
141
+ },
142
+ ],
143
+ },
144
+ ],
145
+ description: 'The headers to send',
146
+ },
147
+ {
148
+ displayName: 'Send Body',
149
+ name: 'sendBody',
150
+ type: 'boolean',
151
+ default: true,
152
+ description: 'Whether the request has a body or not',
153
+ },
154
+ {
155
+ displayName: 'Body Content Type',
156
+ name: 'contentType',
157
+ type: 'options',
158
+ displayOptions: {
159
+ show: {
160
+ sendBody: [true],
161
+ },
162
+ },
163
+ options: [
164
+ {
165
+ name: 'Form-Data Multipart',
166
+ value: 'multipart-form-data',
167
+ },
168
+ {
169
+ name: 'Form Urlencoded',
170
+ value: 'form-urlencoded',
171
+ },
172
+ {
173
+ name: 'JSON',
174
+ value: 'json',
175
+ },
176
+ {
177
+ name: 'RAW/Custom',
178
+ value: 'raw',
179
+ },
180
+ {
181
+ name: 'n8n Binary Data',
182
+ value: 'binaryData',
183
+ },
184
+ ],
185
+ default: 'multipart-form-data',
186
+ description: 'Content-Type to use for body',
187
+ },
188
+ {
189
+ displayName: 'Body Parameters',
190
+ name: 'bodyParameters',
191
+ type: 'fixedCollection',
192
+ typeOptions: {
193
+ multipleValues: true,
194
+ },
195
+ placeholder: 'Add Parameter',
196
+ default: { parameters: [] },
197
+ displayOptions: {
198
+ show: {
199
+ sendBody: [true],
200
+ contentType: ['multipart-form-data', 'form-urlencoded'],
201
+ },
202
+ },
203
+ options: [
204
+ {
205
+ name: 'parameters',
206
+ displayName: 'Parameter',
207
+ values: [
208
+ {
209
+ displayName: 'Parameter Type',
210
+ name: 'parameterType',
211
+ type: 'options',
212
+ options: [
213
+ {
214
+ name: 'n8n Binary Data',
215
+ value: 'formBinaryData',
216
+ },
217
+ {
218
+ name: 'Form Data',
219
+ value: 'formData',
220
+ },
221
+ ],
222
+ default: 'formData',
223
+ },
224
+ {
225
+ displayName: 'Name',
226
+ name: 'name',
227
+ type: 'string',
228
+ default: '',
229
+ description: 'Name of the parameter',
230
+ },
231
+ {
232
+ displayName: 'Input Data Field Name',
233
+ name: 'inputDataFieldName',
234
+ type: 'string',
235
+ displayOptions: {
236
+ show: {
237
+ parameterType: ['formBinaryData'],
238
+ },
239
+ },
240
+ default: '',
241
+ description: 'The name of the incoming field containing the binary file data',
242
+ },
243
+ {
244
+ displayName: 'Value',
245
+ name: 'value',
246
+ type: 'string',
247
+ displayOptions: {
248
+ show: {
249
+ parameterType: ['formData'],
250
+ },
251
+ },
252
+ default: '',
253
+ description: 'Value of the parameter',
254
+ },
255
+ ],
256
+ },
257
+ ],
258
+ description: 'Body parameters to send',
259
+ },
260
+ {
261
+ displayName: 'JSON/RAW Body',
262
+ name: 'jsonBody',
32
263
  type: 'string',
33
- default: 'data',
34
- required: true,
35
- description: 'Name of the binary property to store the PDF result',
36
- placeholder: 'e.g. data',
264
+ displayOptions: {
265
+ show: {
266
+ sendBody: [true],
267
+ contentType: ['json', 'raw'],
268
+ },
269
+ },
270
+ default: '',
271
+ typeOptions: {
272
+ alwaysOpenEditWindow: true,
273
+ },
274
+ description: 'JSON or RAW body content',
37
275
  },
38
276
  {
39
- displayName: 'Gotenberg URL',
40
- name: 'gotenbergUrl',
277
+ displayName: 'Input Binary Field',
278
+ name: 'inputBinaryField',
41
279
  type: 'string',
42
- default: 'http://gotenberg:3000/forms/chromium/convert/html',
280
+ displayOptions: {
281
+ show: {
282
+ sendBody: [true],
283
+ contentType: ['binaryData'],
284
+ },
285
+ },
286
+ default: 'data',
43
287
  required: true,
44
- description: 'The URL of your Gotenberg instance',
45
- placeholder: 'http://gotenberg:3000/forms/chromium/convert/html',
288
+ description: 'The name of the incoming field containing the binary file data',
46
289
  },
47
290
  {
48
291
  displayName: 'Options',
@@ -52,119 +295,126 @@ class MakePdf {
52
295
  default: {},
53
296
  options: [
54
297
  {
55
- displayName: 'Paper Format',
56
- name: 'paperFormat',
57
- type: 'options',
298
+ displayName: 'Batching',
299
+ name: 'batching',
300
+ placeholder: 'Add Batching',
301
+ type: 'fixedCollection',
302
+ typeOptions: {
303
+ multipleValues: false,
304
+ },
305
+ default: {},
58
306
  options: [
59
- { name: 'A3', value: 'A3' },
60
- { name: 'A4', value: 'A4' },
61
- { name: 'A5', value: 'A5' },
62
- { name: 'A6', value: 'A6' },
63
- { name: 'Letter', value: 'Letter' },
64
- { name: 'Legal', value: 'Legal' },
65
- { name: 'Tabloid', value: 'Tabloid' },
307
+ {
308
+ displayName: 'Batch',
309
+ name: 'batch',
310
+ values: [
311
+ {
312
+ displayName: 'Items per Batch',
313
+ name: 'batchSize',
314
+ type: 'number',
315
+ typeOptions: {
316
+ minValue: 1,
317
+ },
318
+ default: 50,
319
+ description: 'Input will be split into multiple batches to throttle requests. -1 for disabled.',
320
+ },
321
+ {
322
+ displayName: 'Batch Interval',
323
+ name: 'batchInterval',
324
+ type: 'number',
325
+ typeOptions: {
326
+ minValue: 0,
327
+ },
328
+ default: 1000,
329
+ description: 'Time (in milliseconds) between each batch of requests. 0 for disabled.',
330
+ },
331
+ ],
332
+ },
66
333
  ],
67
- default: 'A4',
68
- description: 'The paper format for the PDF',
69
334
  },
70
335
  {
71
- displayName: 'Landscape',
72
- name: 'landscape',
336
+ displayName: 'Ignore SSL Issues',
337
+ name: 'allowUnauthorizedCerts',
73
338
  type: 'boolean',
74
339
  default: false,
75
- description: 'Whether to use landscape orientation',
340
+ description: 'Whether to download the response even if SSL certificate validation is not possible',
76
341
  },
77
342
  {
78
- displayName: 'Print Background',
79
- name: 'printBackground',
343
+ displayName: 'Follow Redirect',
344
+ name: 'followRedirect',
80
345
  type: 'boolean',
81
346
  default: true,
82
- description: 'Whether to print background graphics',
347
+ description: 'Whether to follow redirects',
83
348
  },
84
349
  {
85
- displayName: 'Scale',
86
- name: 'scale',
350
+ displayName: 'Redirect Count',
351
+ name: 'maxRedirects',
87
352
  type: 'number',
88
- default: 1,
89
353
  typeOptions: {
90
- minValue: 0.1,
91
- maxValue: 2,
92
- numberStepSize: 0.1,
354
+ minValue: 0,
355
+ },
356
+ displayOptions: {
357
+ show: {
358
+ followRedirect: [true],
359
+ },
93
360
  },
94
- description: 'Scale of the webpage rendering (0.1 - 2)',
361
+ default: 21,
362
+ description: 'Maximum number of redirects to follow',
95
363
  },
96
364
  {
97
- displayName: 'Margins',
98
- name: 'margins',
99
- type: 'fixedCollection',
100
- placeholder: 'Add Margin',
101
- default: {},
365
+ displayName: 'Response Format',
366
+ name: 'responseFormat',
367
+ type: 'options',
102
368
  options: [
103
369
  {
104
- displayName: 'Margin Values',
105
- name: 'marginValues',
106
- values: [
107
- {
108
- displayName: 'Top',
109
- name: 'top',
110
- type: 'string',
111
- default: '0',
112
- description: 'Top margin (e.g., "1cm", "10mm", "0.5in")',
113
- },
114
- {
115
- displayName: 'Bottom',
116
- name: 'bottom',
117
- type: 'string',
118
- default: '0',
119
- description: 'Bottom margin',
120
- },
121
- {
122
- displayName: 'Left',
123
- name: 'left',
124
- type: 'string',
125
- default: '0',
126
- description: 'Left margin',
127
- },
128
- {
129
- displayName: 'Right',
130
- name: 'right',
131
- type: 'string',
132
- default: '0',
133
- description: 'Right margin',
134
- },
135
- ],
370
+ name: 'Autodetect',
371
+ value: 'autodetect',
372
+ },
373
+ {
374
+ name: 'File',
375
+ value: 'file',
376
+ },
377
+ {
378
+ name: 'JSON',
379
+ value: 'json',
380
+ },
381
+ {
382
+ name: 'Text',
383
+ value: 'text',
136
384
  },
137
385
  ],
386
+ default: 'autodetect',
387
+ description: 'The format in which the data gets returned from the URL',
138
388
  },
139
389
  {
140
- displayName: 'Wait Delay',
141
- name: 'waitDelay',
142
- type: 'number',
143
- default: 0,
144
- typeOptions: {
145
- minValue: 0,
146
- maxValue: 30,
390
+ displayName: 'Output Binary Field Name',
391
+ name: 'outputBinaryField',
392
+ displayOptions: {
393
+ show: {
394
+ responseFormat: ['file'],
395
+ },
147
396
  },
148
- description: 'Wait delay in seconds before PDF generation (0-30)',
397
+ type: 'string',
398
+ default: 'data',
399
+ description: 'Name of the binary property to write the file to',
149
400
  },
150
401
  {
151
402
  displayName: 'Timeout',
152
403
  name: 'timeout',
153
404
  type: 'number',
154
- default: 30,
155
405
  typeOptions: {
156
406
  minValue: 1,
157
- maxValue: 300,
158
407
  },
159
- description: 'Timeout in seconds for the HTTP request (1-300)',
408
+ default: 10000,
409
+ description: 'Time in ms to wait for a response before giving up on the request',
160
410
  },
161
411
  {
162
- displayName: 'Output Filename',
163
- name: 'outputFilename',
412
+ displayName: 'Proxy',
413
+ name: 'proxy',
164
414
  type: 'string',
165
415
  default: '',
166
- description: 'Custom filename for the PDF (leave empty to use input filename)',
167
- placeholder: 'document.pdf',
416
+ placeholder: 'http://myproxy:3128',
417
+ description: 'HTTP proxy to use',
168
418
  },
169
419
  ],
170
420
  },
@@ -172,111 +422,151 @@ class MakePdf {
172
422
  };
173
423
  }
174
424
  async execute() {
175
- var _a;
425
+ var _a, _b;
176
426
  const items = this.getInputData();
177
427
  const returnData = [];
178
428
  for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
179
429
  try {
180
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex);
181
- const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', itemIndex);
182
- const gotenbergUrl = this.getNodeParameter('gotenbergUrl', itemIndex);
430
+ const method = this.getNodeParameter('method', itemIndex, 'POST');
431
+ const url = this.getNodeParameter('url', itemIndex, '');
432
+ const sendQuery = this.getNodeParameter('sendQuery', itemIndex, false);
433
+ const sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false);
434
+ const sendBody = this.getNodeParameter('sendBody', itemIndex, false);
435
+ const contentType = this.getNodeParameter('contentType', itemIndex, '');
183
436
  const options = this.getNodeParameter('options', itemIndex, {});
184
- const binaryData = (_a = items[itemIndex].binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
185
- if (!binaryData) {
186
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex });
437
+ // Build request options
438
+ const requestOptions = {
439
+ method,
440
+ url,
441
+ headers: {},
442
+ returnFullResponse: false,
443
+ };
444
+ // Add query parameters
445
+ if (sendQuery) {
446
+ const queryParams = this.getNodeParameter('queryParameters.parameters', itemIndex, []);
447
+ if (queryParams && queryParams.length > 0) {
448
+ const qs = {};
449
+ for (const param of queryParams) {
450
+ qs[param.name] = param.value;
451
+ }
452
+ requestOptions.qs = qs;
453
+ }
187
454
  }
188
- if (!binaryData.data) {
189
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary property "${binaryPropertyName}" has no data`, { itemIndex });
455
+ // Add headers
456
+ if (sendHeaders) {
457
+ const headerParams = this.getNodeParameter('headerParameters.parameters', itemIndex, []);
458
+ if (headerParams && headerParams.length > 0) {
459
+ for (const param of headerParams) {
460
+ requestOptions.headers[param.name] = param.value;
461
+ }
462
+ }
190
463
  }
191
- // Convert base64 to Buffer
192
- const htmlBuffer = Buffer.from(binaryData.data, 'base64');
193
- // Prepare form data for Gotenberg
194
- const FormData = require('form-data');
195
- const formData = new FormData();
196
- // Add HTML file
197
- formData.append('files', htmlBuffer, {
198
- filename: 'index.html',
199
- contentType: 'text/html',
200
- });
201
- // Add Gotenberg options if specified
202
- if (options.paperFormat) {
203
- const paperSizes = {
204
- 'A3': { width: '11.7in', height: '16.5in' },
205
- 'A4': { width: '8.27in', height: '11.7in' },
206
- 'A5': { width: '5.83in', height: '8.27in' },
207
- 'A6': { width: '4.13in', height: '5.83in' },
208
- 'Letter': { width: '8.5in', height: '11in' },
209
- 'Legal': { width: '8.5in', height: '14in' },
210
- 'Tabloid': { width: '11in', height: '17in' },
211
- };
212
- const format = options.paperFormat;
213
- if (paperSizes[format]) {
214
- formData.append('paperWidth', paperSizes[format].width);
215
- formData.append('paperHeight', paperSizes[format].height);
464
+ // Add body
465
+ if (sendBody && contentType) {
466
+ if (contentType === 'json') {
467
+ const jsonBody = this.getNodeParameter('jsonBody', itemIndex, '');
468
+ requestOptions.body = jsonBody;
469
+ requestOptions.headers['Content-Type'] = 'application/json';
470
+ }
471
+ else if (contentType === 'raw') {
472
+ const rawBody = this.getNodeParameter('jsonBody', itemIndex, '');
473
+ requestOptions.body = rawBody;
474
+ }
475
+ else if (contentType === 'form-urlencoded') {
476
+ const bodyParams = this.getNodeParameter('bodyParameters.parameters', itemIndex, []);
477
+ const form = {};
478
+ for (const param of bodyParams) {
479
+ form[param.name] = param.value;
480
+ }
481
+ requestOptions.form = form;
482
+ }
483
+ else if (contentType === 'multipart-form-data') {
484
+ const FormData = require('form-data');
485
+ const formData = new FormData();
486
+ const bodyParams = this.getNodeParameter('bodyParameters.parameters', itemIndex, []);
487
+ for (const param of bodyParams) {
488
+ const paramName = param.name;
489
+ const paramType = param.parameterType;
490
+ if (paramType === 'formBinaryData') {
491
+ const inputDataFieldName = param.inputDataFieldName;
492
+ const binaryData = (_a = items[itemIndex].binary) === null || _a === void 0 ? void 0 : _a[inputDataFieldName];
493
+ if (binaryData && binaryData.data) {
494
+ const buffer = Buffer.from(binaryData.data, 'base64');
495
+ formData.append(paramName, buffer, {
496
+ filename: binaryData.fileName || 'file',
497
+ contentType: binaryData.mimeType || 'application/octet-stream',
498
+ });
499
+ }
500
+ }
501
+ else {
502
+ formData.append(paramName, param.value);
503
+ }
504
+ }
505
+ requestOptions.body = formData;
506
+ Object.assign(requestOptions.headers, formData.getHeaders());
507
+ }
508
+ else if (contentType === 'binaryData') {
509
+ const inputBinaryField = this.getNodeParameter('inputBinaryField', itemIndex, 'data');
510
+ const binaryData = (_b = items[itemIndex].binary) === null || _b === void 0 ? void 0 : _b[inputBinaryField];
511
+ if (!binaryData || !binaryData.data) {
512
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${inputBinaryField}"`, { itemIndex });
513
+ }
514
+ requestOptions.body = Buffer.from(binaryData.data, 'base64');
515
+ if (binaryData.mimeType) {
516
+ requestOptions.headers['Content-Type'] = binaryData.mimeType;
517
+ }
216
518
  }
217
519
  }
218
- if (options.landscape !== undefined) {
219
- formData.append('landscape', options.landscape.toString());
520
+ // Add options
521
+ if (options.allowUnauthorizedCerts === true) {
522
+ requestOptions.skipSslCertificateValidation = true;
220
523
  }
221
- if (options.printBackground !== undefined) {
222
- formData.append('printBackground', options.printBackground.toString());
524
+ if (options.followRedirect !== undefined) {
525
+ requestOptions.followRedirect = options.followRedirect;
526
+ if (options.followRedirect && options.maxRedirects) {
527
+ requestOptions.maxRedirects = options.maxRedirects;
528
+ }
223
529
  }
224
- if (options.scale !== undefined) {
225
- formData.append('scale', options.scale.toString());
530
+ if (options.timeout !== undefined) {
531
+ requestOptions.timeout = options.timeout;
226
532
  }
227
- // Add margins
228
- if (options.margins && typeof options.margins === 'object') {
229
- const margins = options.margins.marginValues;
230
- if (margins) {
231
- if (margins.top)
232
- formData.append('marginTop', margins.top);
233
- if (margins.bottom)
234
- formData.append('marginBottom', margins.bottom);
235
- if (margins.left)
236
- formData.append('marginLeft', margins.left);
237
- if (margins.right)
238
- formData.append('marginRight', margins.right);
239
- }
533
+ if (options.proxy) {
534
+ requestOptions.proxy = options.proxy;
240
535
  }
241
- if (options.waitDelay !== undefined && options.waitDelay !== 0) {
242
- formData.append('waitDelay', `${options.waitDelay}s`);
536
+ const responseFormat = options.responseFormat || 'autodetect';
537
+ if (responseFormat === 'file') {
538
+ requestOptions.encoding = 'arraybuffer';
539
+ requestOptions.returnFullResponse = false;
243
540
  }
244
- // Make request to Gotenberg
245
- const timeout = (options.timeout || 30) * 1000;
246
- const response = await this.helpers.httpRequest({
247
- method: 'POST',
248
- url: gotenbergUrl,
249
- body: formData,
250
- headers: formData.getHeaders(),
251
- encoding: 'arraybuffer',
252
- returnFullResponse: false,
253
- timeout,
254
- });
255
- // Determine output filename
256
- let outputFilename = options.outputFilename || '';
257
- if (!outputFilename) {
258
- outputFilename = binaryData.fileName
259
- ? binaryData.fileName.replace(/\.[^.]+$/, '.pdf')
260
- : 'output.pdf';
541
+ else if (responseFormat === 'json') {
542
+ requestOptions.json = true;
261
543
  }
262
- if (!outputFilename.endsWith('.pdf')) {
263
- outputFilename += '.pdf';
544
+ // Make the request
545
+ const response = await this.helpers.httpRequest(requestOptions);
546
+ // Process response
547
+ let newItem;
548
+ if (responseFormat === 'file') {
549
+ const outputBinaryField = options.outputBinaryField || 'data';
550
+ const binaryData = {
551
+ data: Buffer.from(response).toString('base64'),
552
+ mimeType: 'application/pdf',
553
+ fileName: 'output.pdf',
554
+ };
555
+ newItem = {
556
+ json: items[itemIndex].json,
557
+ binary: {
558
+ ...items[itemIndex].binary,
559
+ [outputBinaryField]: binaryData,
560
+ },
561
+ pairedItem: itemIndex,
562
+ };
563
+ }
564
+ else {
565
+ newItem = {
566
+ json: typeof response === 'object' ? response : { data: response },
567
+ pairedItem: itemIndex,
568
+ };
264
569
  }
265
- // Create new binary data for PDF
266
- const newBinaryData = {
267
- data: Buffer.from(response).toString('base64'),
268
- mimeType: 'application/pdf',
269
- fileName: outputFilename,
270
- };
271
- // Prepare output item
272
- const newItem = {
273
- json: items[itemIndex].json,
274
- binary: {
275
- ...items[itemIndex].binary,
276
- [outputBinaryPropertyName]: newBinaryData,
277
- },
278
- pairedItem: itemIndex,
279
- };
280
570
  returnData.push(newItem);
281
571
  }
282
572
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-make-pdf",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "n8n node to generate PDFs via Gotenberg - Convert HTML to PDF with ease",
5
5
  "keywords": [
6
6
  "n8n",