@custom-js/n8n-nodes-pdf-toolkit 1.28.0 → 1.30.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 CHANGED
@@ -127,3 +127,12 @@ Add your Api Key and store securely
127
127
  - Configure your CustomJS API credentials.
128
128
  - Input the PDF file you want to get form field names from.
129
129
  - Execute the workflow to get the form field names.
130
+
131
+ ### "Invoice Generator" node
132
+
133
+ - Add the **Invoice Generator** node to your workflow.
134
+ - Configure your CustomJS API credentials.
135
+ - Select a PDF template.
136
+ - Fill in the issuer, payment, recipient, and billing information.
137
+ - Add items to the invoice.
138
+ - Execute the workflow to generate the PDF invoice.
@@ -89,6 +89,13 @@ class CompressPDF {
89
89
  json: true,
90
90
  };
91
91
  const response = await this.helpers.request(options);
92
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
93
+ // No binary data returned; emit only JSON without a binary property
94
+ returnData.push({
95
+ json: items[i].json,
96
+ });
97
+ continue;
98
+ }
92
99
  const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
93
100
  returnData.push({
94
101
  json: items[i].json,
@@ -99,6 +99,13 @@ class ExtractPages {
99
99
  json: true,
100
100
  };
101
101
  const response = await this.helpers.request(options);
102
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
103
+ // No binary data returned; emit only JSON without a binary property
104
+ returnData.push({
105
+ json: items[i].json,
106
+ });
107
+ continue;
108
+ }
102
109
  const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
103
110
  returnData.push({
104
111
  json: items[i].json,
@@ -58,6 +58,13 @@ class Html2Docx {
58
58
  json: true,
59
59
  };
60
60
  const response = await this.helpers.request(options);
61
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
62
+ // No binary data returned; emit only JSON without a binary property
63
+ returnData.push({
64
+ json: items[i].json,
65
+ });
66
+ continue;
67
+ }
61
68
  const binaryData = await this.helpers.prepareBinaryData(response, "output.docx");
62
69
  returnData.push({
63
70
  json: items[i].json,
@@ -58,6 +58,13 @@ class Html2Pdf {
58
58
  json: true,
59
59
  };
60
60
  const response = await this.helpers.request(options);
61
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
62
+ // No binary data returned; emit only JSON without a binary property
63
+ returnData.push({
64
+ json: items[i].json,
65
+ });
66
+ continue;
67
+ }
61
68
  const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
62
69
  returnData.push({
63
70
  json: items[i].json,
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoiceGenerator = void 0;
4
+ class InvoiceGenerator {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Invoice Generator',
8
+ name: 'invoiceGenerator',
9
+ icon: 'file:invoice.svg',
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Create PDF invoices from data and templates',
13
+ defaults: {
14
+ name: 'Invoice Generator',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ credentials: [
19
+ {
20
+ name: 'customJsApi',
21
+ required: true,
22
+ },
23
+ ],
24
+ properties: [
25
+ {
26
+ displayName: 'PDF Template',
27
+ name: 'pdfTemplate',
28
+ type: 'options',
29
+ required: true,
30
+ default: '1-en',
31
+ options: [
32
+ {
33
+ name: 'Template 1 (EN)',
34
+ value: '1-en',
35
+ },
36
+ ],
37
+ },
38
+ {
39
+ displayName: 'Issuer (Sender Information)',
40
+ name: 'issuer',
41
+ type: 'fixedCollection',
42
+ typeOptions: {
43
+ multipleValues: false,
44
+ },
45
+ default: {},
46
+ placeholder: 'Add Issuer',
47
+ options: [
48
+ {
49
+ name: 'issuerValues',
50
+ displayName: 'Issuer',
51
+ values: [
52
+ { displayName: 'Company Name', name: 'companyName', type: 'string', default: '' },
53
+ { displayName: 'Address (Multiline)', name: 'address', type: 'string', typeOptions: { multiLine: true }, default: '' },
54
+ { displayName: 'Email (optional)', name: 'email', type: 'string', default: '' },
55
+ { displayName: 'Phone (optional)', name: 'phone', type: 'string', default: '' },
56
+ { displayName: 'Tax ID (optional)', name: 'taxId', type: 'string', default: '' },
57
+ { displayName: 'Logo URL (optional)', name: 'logoUrl', type: 'string', default: '' },
58
+ ]
59
+ }
60
+ ],
61
+ },
62
+ {
63
+ displayName: 'Payment Information',
64
+ name: 'payment',
65
+ type: 'fixedCollection',
66
+ typeOptions: {
67
+ multipleValues: false,
68
+ },
69
+ default: {},
70
+ placeholder: 'Add Payment Information',
71
+ options: [
72
+ {
73
+ name: 'paymentValues',
74
+ displayName: 'Payment',
75
+ values: [
76
+ { displayName: 'Account Number (IBAN / US Account / SWIFT depending on country)', name: 'accountNumber', type: 'string', default: '' },
77
+ { displayName: 'BIC / SWIFT Code (optional)', name: 'BIC', type: 'string', default: '' },
78
+ { displayName: 'Bank Name', name: 'bankName', type: 'string', default: '' },
79
+ { displayName: 'Reference Prefix', name: 'referencePrefix', type: 'string', default: '' },
80
+ ]
81
+ }
82
+ ],
83
+ },
84
+ {
85
+ displayName: 'Recipient (Customer Information)',
86
+ name: 'recipient',
87
+ type: 'fixedCollection',
88
+ typeOptions: {
89
+ multipleValues: false,
90
+ },
91
+ default: {},
92
+ placeholder: 'Add Recipient',
93
+ options: [
94
+ {
95
+ name: 'recipientValues',
96
+ displayName: 'Recipient',
97
+ values: [
98
+ { displayName: 'Customer Name', name: 'name', type: 'string', default: '' },
99
+ { displayName: 'Address (Multiline)', name: 'address', type: 'string', typeOptions: { multiLine: true }, default: '' },
100
+ { displayName: 'Tax ID (optional)', name: 'taxId', type: 'string', default: '' },
101
+ ]
102
+ }
103
+ ],
104
+ },
105
+ {
106
+ displayName: 'Billing Information',
107
+ name: 'billing',
108
+ type: 'fixedCollection',
109
+ typeOptions: {
110
+ multipleValues: false,
111
+ },
112
+ default: {},
113
+ placeholder: 'Add Billing Information',
114
+ options: [
115
+ {
116
+ name: 'billingValues',
117
+ displayName: 'Billing',
118
+ values: [
119
+ { displayName: 'Invoice Number', name: 'invoiceNumber', type: 'string', default: '' },
120
+ { displayName: 'Invoice Date', name: 'invoiceDate', type: 'string', default: '' },
121
+ { displayName: 'Due Date (optional)', name: 'dueDate', type: 'string', default: '' },
122
+ { displayName: 'Currency (e.g. EUR, USD)', name: 'currency', type: 'string', default: '' },
123
+ { displayName: 'Tax Rate (%)', name: 'taxRate', type: 'number', default: 0 },
124
+ { displayName: 'Notes (optional)', name: 'notes', type: 'string', typeOptions: { multiLine: true }, default: '' },
125
+ ]
126
+ }
127
+ ],
128
+ },
129
+ {
130
+ displayName: 'Items',
131
+ name: 'items',
132
+ type: 'fixedCollection',
133
+ typeOptions: {
134
+ multipleValues: true,
135
+ },
136
+ default: {},
137
+ placeholder: 'Add Item',
138
+ options: [
139
+ {
140
+ name: 'itemsValues',
141
+ displayName: 'Items',
142
+ values: [
143
+ { displayName: 'Description', name: 'description', type: 'string', default: '' },
144
+ { displayName: 'Quantity', name: 'quantity', type: 'number', default: 1 },
145
+ { displayName: 'Unit Price', name: 'unitPrice', type: 'number', default: 0 },
146
+ ]
147
+ }
148
+ ],
149
+ },
150
+ ],
151
+ };
152
+ }
153
+ async execute() {
154
+ const items = this.getInputData();
155
+ const returnData = [];
156
+ for (let i = 0; i < items.length; i++) {
157
+ const credentials = await this.getCredentials('customJsApi');
158
+ const pdfTemplate = this.getNodeParameter('pdfTemplate', i);
159
+ const issuer = this.getNodeParameter('issuer.issuerValues', i);
160
+ const payment = this.getNodeParameter('payment.paymentValues', i);
161
+ const recipient = this.getNodeParameter('recipient.recipientValues', i);
162
+ const billing = this.getNodeParameter('billing.billingValues', i);
163
+ const invoiceItems = this.getNodeParameter('items.itemsValues', i);
164
+ const invoiceData = {
165
+ issuer,
166
+ payment,
167
+ recipient,
168
+ billing,
169
+ items: invoiceItems,
170
+ };
171
+ const code = `
172
+ const { HTML2PDF } = require('./utils');
173
+ const nunjucks = require('nunjucks');
174
+ const fetch = require('node-fetch');
175
+ const tpl = 'https://www.customjs.space/pdf-templates/Invoice1.html';
176
+ const templateString = await fetch(tpl).then(r => r.text());
177
+ const renderedHtml = await nunjucks.renderString(
178
+ templateString,
179
+ { invoiceData: JSON.stringify(input).replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') }
180
+ );
181
+ return HTML2PDF(renderedHtml);
182
+ `;
183
+ const options = {
184
+ url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
185
+ method: 'POST',
186
+ headers: {
187
+ 'customjs-origin': 'n8n/invoice-generator',
188
+ 'x-api-key': credentials.apiKey,
189
+ },
190
+ body: {
191
+ input: invoiceData,
192
+ code: code,
193
+ returnBinary: 'true',
194
+ },
195
+ encoding: 'binary',
196
+ json: true,
197
+ };
198
+ const responseData = await this.helpers.request(options);
199
+ const fileData = responseData.fileData;
200
+ const binaryData = Buffer.from(fileData, 'base64');
201
+ const binary = await this.helpers.prepareBinaryData(binaryData, 'Invoice.pdf', 'application/pdf');
202
+ returnData.push({
203
+ json: {},
204
+ binary: { data: binary },
205
+ });
206
+ }
207
+ return [returnData];
208
+ }
209
+ }
210
+ exports.InvoiceGenerator = InvoiceGenerator;
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1080" height="1080" viewBox="-4.05 0.71 1080 1080" xml:space="preserve">
4
+ <desc>Created with Fabric.js 5.2.4</desc>
5
+ <defs>
6
+ </defs>
7
+ <g transform="matrix(1 0 0 1 540 540)" id="7b7fdf64-c054-4bb3-b5ef-d6fe7aa96b80" >
8
+ </g>
9
+ <g transform="matrix(1 0 0 1 540 540)" id="2321b111-224a-48e9-80a9-902df05610a3" >
10
+ <rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke" x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
11
+ </g>
12
+ <g transform="matrix(4.13 0 0 4.13 647.9 542.9)" >
13
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(48,54,66); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(0.18, -33.93)" d="M 0 0 C 0.95519531 -0.02449219 1.91039062 -0.04898438 2.89453125 -0.07421875 C 10.75518323 -0.10656711 15.93854482 1.68421562 21.9375 6.75 C 26.17018533 11.82922239 27.125 14.6375154 27.125 21.375 C 21.845 21.375 16.565 21.375 11.125 21.375 C 10.795 19.725 10.465 18.075 10.125 16.375 C 6.92258427 13.91160329 3.06611543 13.64219427 -0.875 13.375 C -5.89692506 14.39355354 -5.89692506 14.39355354 -9.875 17.375 C -9.93401922 19.39577346 -9.93401922 19.39577346 -8.875 21.375 C -4.97022671 24.22403829 -1.41266547 25.02415633 3.3125 25.8125 C 12.98753164 27.5907989 20.69236359 29.62284843 27.125 37.375 C 29.08446946 43.25340839 28.91830377 49.95101626 27 55.8125 C 22.43966545 62.04495721 16.63551271 65.68083127 9.125 67.375 C -2.61215098 68.64064057 -13.5103272 68.21287726 -23.3125 61.0625 C -27.71010172 56.45038113 -28.875 52.69781875 -28.875 46.375 C -23.595 46.375 -18.315 46.375 -12.875 46.375 C -12.215 47.695 -11.555 49.015 -10.875 50.375 C -5.78345043 53.35673199 -0.54227389 53.66361208 5.1796875 52.89453125 C 7.42635563 52.40609382 7.42635563 52.40609382 10.125 50.375 C 10.37515873 46.79142759 10.37515873 46.79142759 10.125 43.375 C 9.57714844 43.27703125 9.02929688 43.1790625 8.46484375 43.078125 C -17.41488576 38.19674513 -17.41488576 38.19674513 -24.1875 30.875 C -24.744375 30.05 -25.30125 29.225 -25.875 28.375 C -26.2875 27.776875 -26.7 27.17875 -27.125 26.5625 C -28.84418454 21.54821175 -28.43469544 17.00444643 -26.3125 12.25 C -23.48323329 7.1713163 -19.62629451 3.60717484 -14.328125 1.234375 C -9.52745168 0.0396373 -4.92945889 0.00659901 0 0 Z" stroke-linecap="round" />
14
+ </g>
15
+ <g transform="matrix(4.13 0 0 4.13 928.17 539.82)" >
16
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(100,93,232); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-18.57, -40.8)" d="M 0 0 C 15.4154719 -0.84597102 15.4154719 -0.84597102 21 4 C 25.06368486 8.87350357 25.58279783 12.54788736 25.625 18.625 C 25.45573423 25.19052179 25.45573423 25.19052179 28 31 C 29.89870478 32.07978487 29.89870478 32.07978487 32.0625 32.6875 C 35.94385027 33.94385027 35.94385027 33.94385027 37 35 C 37.09879565 36.810285 37.12971514 38.62452727 37.125 40.4375 C 37.12886719 41.92056641 37.12886719 41.92056641 37.1328125 43.43359375 C 37 46 37 46 36 48 C 33.98520282 48.55794383 31.97029439 48.89073018 29.91015625 49.2421875 C 27.90623469 49.85384843 27.90623469 49.85384843 26.765625 51.55078125 C 25.65607384 55.10021277 25.74653168 58.62876465 25.6875 62.3125 C 25.43034016 68.99865595 25.10546095 73.23490311 20 78 C 13.44010105 82.09993684 7.51058045 82.11209822 0 82 C 0 78.04 0 74.08 0 70 C 1.134375 69.71125 2.26875 69.4225 3.4375 69.125 C 4.613125 68.75375 5.78875 68.3825 7 68 C 8.25632496 65.48735008 8.15398868 63.25590872 8.23950195 60.48901367 C 8.64668723 48.34835569 8.64668723 48.34835569 13 43 C 15.25 41.0625 15.25 41.0625 17 40 C 16.236875 39.62875 15.47375 39.2575 14.6875 38.875 C 11.33373962 36.53516717 10.52691928 34.78467172 9 31 C 8.55767009 28.25130909 8.44629424 25.53047551 8.375 22.75 C 8.39497409 17.72129005 8.39497409 17.72129005 7 13 C 4.67843403 12.59270772 2.3431213 12.25561323 0 12 C 0 8.04 0 4.08 0 0 Z" stroke-linecap="round" />
17
+ </g>
18
+ <g transform="matrix(4.13 0 0 4.13 149.69 540.72)" >
19
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(94,86,231); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(11.7, -41.08)" d="M 0 0 C 1.75570313 0.01353516 1.75570313 0.01353516 3.546875 0.02734375 C 4.43890625 0.03894531 5.3309375 0.05054687 6.25 0.0625 C 6.25 3.6925 6.25 7.3225 6.25 11.0625 C 5.115625 11.35125 3.98125 11.64 2.8125 11.9375 C 1.636875 12.30875 0.46125 12.68 -0.75 13.0625 C -2.24215637 16.04681274 -1.98735138 18.93004634 -2.125 22.25 C -2.43666193 27.77348756 -2.73652838 32.32704459 -5.75 37.0625 C -8.4375 39 -8.4375 39 -10.75 40.0625 C -9.986875 40.578125 -9.22375 41.09375 -8.4375 41.625 C -4.27259808 45.40246919 -2.68701725 49.67149825 -2.30859375 55.17578125 C -2.25502591 56.57507775 -2.21474855 57.97494367 -2.1875 59.375 C -2.35499664 64.70839017 -2.35499664 64.70839017 0.25 69.0625 C 2.23821313 69.46014263 4.23944339 69.80025349 6.25 70.0625 C 6.27687279 71.87492052 6.29633715 73.68745233 6.3125 75.5 C 6.32410156 76.50933594 6.33570313 77.51867187 6.34765625 78.55859375 C 6.25 81.0625 6.25 81.0625 5.25 82.0625 C -2.32464922 82.60354637 -9.17557982 81.37262698 -15.25 76.5625 C -19.80461172 72.00788828 -19.05763186 66.37850593 -19.26757812 60.31054688 C -19.38990221 54.84257441 -19.38990221 54.84257441 -21.75 50.0625 C -23.68981618 49.15640008 -23.68981618 49.15640008 -25.875 48.8125 C -27.15375 48.565 -28.4325 48.3175 -29.75 48.0625 C -29.75 43.4425 -29.75 38.8225 -29.75 34.0625 C -27.43880208 33.11848958 -25.12760417 32.17447917 -22.81640625 31.23046875 C -20.41627512 30.17846912 -20.41627512 30.17846912 -19.75 27.0625 C -19.58691355 23.53620844 -19.453885 20.01601458 -19.40820312 16.48632812 C -19.21063493 11.25306836 -18.14493176 8.25361651 -14.75 4.0625 C -10.18531329 -0.07424733 -6.00456455 -0.06004565 0 0 Z" stroke-linecap="round" />
20
+ </g>
21
+ <g transform="matrix(4.13 0 0 4.13 400.2 543.8)" >
22
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(43,48,61); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(7.3, -33.77)" d="M 0 0 C 2.47923801 -0.02685095 4.9581884 -0.04676547 7.4375 -0.0625 C 8.14455078 -0.07087891 8.85160156 -0.07925781 9.58007812 -0.08789062 C 11.38693559 -0.09653588 13.19387603 -0.05220011 15 0 C 16.63250229 1.63250229 16.16872849 3.49008236 16.20874023 5.74414062 C 16.22803085 6.75609497 16.24732147 7.76804932 16.26719666 8.81066895 C 16.32488713 13.47302889 16.37428059 18.13522937 16.4050293 22.79785156 C 16.42655207 25.25177126 16.46058591 27.70561539 16.50756836 30.15917969 C 16.57478207 33.70021823 16.60207198 37.23966222 16.62109375 40.78125 C 16.64892441 41.8690979 16.67675507 42.9569458 16.70542908 44.07775879 C 16.68552495 51.51836273 15.13219782 56.48869158 10 62 C 2.5308992 67.80202095 -5.97170003 68.13040294 -15.08837891 67.29101562 C -19.4631827 66.6250174 -22.66465564 64.81817861 -26 62 C -26.54269531 61.5771875 -27.08539063 61.154375 -27.64453125 60.71875 C -30.04154058 58.44720396 -30.95650141 56.41438127 -31.296875 53.171875 C -31.31094808 50.42762393 -31.21897411 47.73474339 -31 45 C -26.28715138 44.65976761 -21.70082374 44.44728382 -17 45 C -14.5625 47.9375 -14.5625 47.9375 -13 51 C -9.27256275 52.13154345 -7.18419111 52.56093263 -3.625 50.875 C 0.20150211 46.45980525 -0.78258786 39.43477346 -0.68359375 33.88671875 C -0.66281265 32.91716751 -0.64203156 31.94761627 -0.62062073 30.94868469 C -0.55541059 27.86169293 -0.4963732 24.77461848 -0.4375 21.6875 C -0.39428763 19.59048636 -0.35067248 17.49348097 -0.30664062 15.39648438 C -0.19975849 10.26440693 -0.09841104 5.13224659 0 0 Z" stroke-linecap="round" />
23
+ </g>
24
+ </svg>
@@ -81,6 +81,13 @@ class MergePdfs {
81
81
  json: true,
82
82
  };
83
83
  const response = await this.helpers.request(options);
84
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
85
+ // No binary data returned; emit only JSON without a binary property
86
+ returnData.push({
87
+ json: {},
88
+ });
89
+ return [returnData];
90
+ }
84
91
  const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
85
92
  returnData.push({
86
93
  json: {},
@@ -121,6 +121,13 @@ class PdfFormFill {
121
121
  json: true,
122
122
  };
123
123
  const response = await this.helpers.request(options);
124
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
125
+ // No binary data returned; emit only JSON without a binary property
126
+ returnData.push({
127
+ json: items[i].json,
128
+ });
129
+ continue;
130
+ }
124
131
  const binaryData = await this.helpers.prepareBinaryData(response, "document.pdf");
125
132
  returnData.push({
126
133
  json: items[i].json,
@@ -89,6 +89,13 @@ class PdfToPng {
89
89
  json: true,
90
90
  };
91
91
  const response = await this.helpers.request(options);
92
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
93
+ // No binary data returned; emit only JSON without a binary property
94
+ returnData.push({
95
+ json: items[i].json,
96
+ });
97
+ continue;
98
+ }
92
99
  const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
93
100
  returnData.push({
94
101
  json: items[i].json,
@@ -150,6 +150,13 @@ class Scraper {
150
150
  };
151
151
  const response = await this.helpers.request(options);
152
152
  if (returnValueType === "binary") {
153
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
154
+ // No binary data returned; emit only JSON without a binary property
155
+ returnData.push({
156
+ json: items[i].json,
157
+ });
158
+ continue;
159
+ }
153
160
  const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
154
161
  returnData.push({
155
162
  json: items[i].json,
@@ -55,6 +55,13 @@ class WebsiteScreenshot {
55
55
  json: true,
56
56
  };
57
57
  const response = await this.helpers.request(options);
58
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
59
+ // No binary data returned; emit only JSON without a binary property
60
+ returnData.push({
61
+ json: items[i].json,
62
+ });
63
+ continue;
64
+ }
58
65
  const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
59
66
  returnData.push({
60
67
  json: items[i].json,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",
@@ -35,9 +35,14 @@
35
35
  "dist/nodes/Markdown2Html/Markdown2Html.node.js",
36
36
  "dist/nodes/Html2Docx/Html2Docx.node.js",
37
37
  "dist/nodes/GetFormFieldNames/GetFormFieldNames.node.js",
38
- "dist/nodes/PdfFormFill/PdfFormFill.node.js"
38
+ "dist/nodes/PdfFormFill/PdfFormFill.node.js",
39
+ "dist/nodes/InvoiceGenerator/InvoiceGenerator.node.js"
39
40
  ]
40
41
  },
42
+ "dependencies": {
43
+ "node-fetch": "^2.6.7",
44
+ "nunjucks": "^3.2.4"
45
+ },
41
46
  "devDependencies": {
42
47
  "n8n-workflow": "^0.141.0",
43
48
  "typescript": "~4.8.4",