@custom-js/n8n-nodes-pdf-toolkit 1.30.0 → 1.32.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.
@@ -4,9 +4,9 @@ exports.InvoiceGenerator = void 0;
4
4
  class InvoiceGenerator {
5
5
  constructor() {
6
6
  this.description = {
7
- displayName: 'Invoice Generator',
7
+ displayName: 'Invoice Generator (CustomJS)',
8
8
  name: 'invoiceGenerator',
9
- icon: 'file:invoice.svg',
9
+ icon: "file:customJs.svg",
10
10
  group: ['transform'],
11
11
  version: 1,
12
12
  description: 'Create PDF invoices from data and templates',
@@ -176,8 +176,11 @@ class InvoiceGenerator {
176
176
  const templateString = await fetch(tpl).then(r => r.text());
177
177
  const renderedHtml = await nunjucks.renderString(
178
178
  templateString,
179
- { invoiceData: JSON.stringify(input).replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') }
179
+ { invoiceData: JSON.stringify(input).replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\").replace(/\\n/g, '\\\\n')
180
+
181
+ }
180
182
  );
183
+ console.log('renderedHtml', renderedHtml);
181
184
  return HTML2PDF(renderedHtml);
182
185
  `;
183
186
  const options = {
@@ -195,13 +198,20 @@ class InvoiceGenerator {
195
198
  encoding: 'binary',
196
199
  json: true,
197
200
  };
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');
201
+ const response = await this.helpers.request(options);
202
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
203
+ // No binary data returned; emit only JSON without a binary property
204
+ returnData.push({
205
+ json: items[i].json,
206
+ });
207
+ continue;
208
+ }
209
+ const binaryData = await this.helpers.prepareBinaryData(response, "Invoice.pdf");
202
210
  returnData.push({
203
- json: {},
204
- binary: { data: binary },
211
+ json: items[i].json,
212
+ binary: {
213
+ data: binaryData,
214
+ },
205
215
  });
206
216
  }
207
217
  return [returnData];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.30.0",
3
+ "version": "1.32.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",