@custom-js/n8n-nodes-pdf-toolkit 1.37.0 → 1.39.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.
@@ -76,18 +76,21 @@ class CompressPDF {
76
76
  headers: {
77
77
  "customjs-origin": "n8n/compressPdf",
78
78
  "x-api-key": credentials.apiKey,
79
+ "Content-Type": "application/json",
79
80
  },
80
- body: {
81
+ body: JSON.stringify({
81
82
  input: isBinary ? { file: file } : { urls: field_name },
82
83
  code: `
83
84
  const { PDF_COMPRESS } = require('./utils');
84
85
  input = input.file || input.urls;
85
86
  return PDF_COMPRESS(input);`,
86
87
  returnBinary: "true",
87
- },
88
- json: true,
88
+ }),
89
+ returnFullResponse: true,
90
+ responseType: 'arraybuffer',
89
91
  };
90
- const response = await this.helpers.httpRequest(options);
92
+ const responseData = await this.helpers.httpRequest(options);
93
+ const response = responseData.body;
91
94
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
92
95
  // No binary data returned; emit only JSON without a binary property
93
96
  returnData.push({
@@ -84,8 +84,9 @@ class ExtractPages {
84
84
  headers: {
85
85
  "customjs-origin": "n8n/extractPages",
86
86
  "x-api-key": credentials.apiKey,
87
+ "Content-Type": "application/json",
87
88
  },
88
- body: {
89
+ body: JSON.stringify({
89
90
  input: isBinary
90
91
  ? { file: file, pageRange }
91
92
  : { urls: field_name, pageRange },
@@ -94,10 +95,12 @@ class ExtractPages {
94
95
  const pdfBuffer = input.file ? Buffer.from(input.file, 'base64') : input.urls;
95
96
  return EXTRACT_PAGES_FROM_PDF(pdfBuffer, input.pageRange);`,
96
97
  returnBinary: "true",
97
- },
98
- json: true,
98
+ }),
99
+ returnFullResponse: true,
100
+ responseType: 'arraybuffer',
99
101
  };
100
- const response = await this.helpers.httpRequest(options);
102
+ const responseData = await this.helpers.httpRequest(options);
103
+ const response = responseData.body;
101
104
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
102
105
  // No binary data returned; emit only JSON without a binary property
103
106
  returnData.push({
@@ -48,15 +48,18 @@ class Html2Docx {
48
48
  headers: {
49
49
  "customjs-origin": "n8n/html2Docx",
50
50
  "x-api-key": credentials.apiKey,
51
+ "Content-Type": "application/json",
51
52
  },
52
- body: {
53
+ body: JSON.stringify({
53
54
  input: htmlInput,
54
55
  code: "const { HTML2DOCX } = require('./utils'); return HTML2DOCX(input)",
55
56
  returnBinary: "true",
56
- },
57
- json: true,
57
+ }),
58
+ returnFullResponse: true,
59
+ responseType: 'arraybuffer',
58
60
  };
59
- const response = await this.helpers.httpRequest(options);
61
+ const responseData = await this.helpers.httpRequest(options);
62
+ const response = responseData.body;
60
63
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
61
64
  // No binary data returned; emit only JSON without a binary property
62
65
  returnData.push({
@@ -48,15 +48,18 @@ class Html2Pdf {
48
48
  headers: {
49
49
  "customjs-origin": "n8n/generatePDF",
50
50
  "x-api-key": credentials.apiKey,
51
+ "Content-Type": "application/json",
51
52
  },
52
- body: {
53
+ body: JSON.stringify({
53
54
  input: htmlInput,
54
55
  code: "const { HTML2PDF } = require('./utils'); return HTML2PDF(input)",
55
56
  returnBinary: "true",
56
- },
57
- json: true,
57
+ }),
58
+ returnFullResponse: true,
59
+ responseType: 'arraybuffer',
58
60
  };
59
- const response = await this.helpers.httpRequest(options);
61
+ const responseData = await this.helpers.httpRequest(options);
62
+ const response = responseData.body;
60
63
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
61
64
  // No binary data returned; emit only JSON without a binary property
62
65
  returnData.push({
@@ -254,21 +254,22 @@ class InvoiceGenerator {
254
254
  headers: {
255
255
  'customjs-origin': 'n8n/invoice-generator',
256
256
  'x-api-key': credentials.apiKey,
257
+ 'Content-Type': 'application/json',
257
258
  },
258
- body: {
259
+ body: JSON.stringify({
259
260
  input: invoiceData,
260
261
  code: code,
261
262
  returnBinary: 'true',
262
- },
263
- json: true,
263
+ }),
264
+ returnFullResponse: true,
265
+ responseType: 'arraybuffer',
264
266
  };
265
- const response = await this.helpers.httpRequest(options);
267
+ const responseData = await this.helpers.httpRequest(options);
268
+ const response = responseData.body;
266
269
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
267
- // No binary data returned; emit only JSON without a binary property
268
270
  returnData.push({
269
271
  json: items[i].json,
270
272
  });
271
- continue;
272
273
  }
273
274
  const binaryData = await this.helpers.prepareBinaryData(response, "Invoice.pdf");
274
275
  returnData.push({
@@ -68,18 +68,21 @@ class MergePdfs {
68
68
  headers: {
69
69
  "customjs-origin": "n8n/mergePDFs",
70
70
  "x-api-key": credentials.apiKey,
71
+ "Content-Type": "application/json",
71
72
  },
72
- body: {
73
+ body: JSON.stringify({
73
74
  input: isBinary ? { files } : { urls },
74
75
  code: `
75
76
  const { PDF_MERGE } = require('./utils');
76
77
  input = [...input.files || [],...input.urls || []].filter(i => i);
77
78
  return PDF_MERGE(input);`,
78
79
  returnBinary: "true",
79
- },
80
- json: true,
80
+ }),
81
+ returnFullResponse: true,
82
+ responseType: 'arraybuffer',
81
83
  };
82
- const response = await this.helpers.httpRequest(options);
84
+ const responseData = await this.helpers.httpRequest(options);
85
+ const response = responseData.body;
83
86
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
84
87
  // No binary data returned; emit only JSON without a binary property
85
88
  returnData.push({
@@ -103,8 +103,9 @@ class PdfFormFill {
103
103
  headers: {
104
104
  "customjs-origin": "n8n/pdfFormFill",
105
105
  "x-api-key": credentials.apiKey,
106
+ "Content-Type": "application/json",
106
107
  },
107
- body: {
108
+ body: JSON.stringify({
108
109
  input: {
109
110
  file: file,
110
111
  // n8n fixedCollection with multipleValues returns an object like { field: [{ name, value }, ...] }
@@ -116,10 +117,12 @@ class PdfFormFill {
116
117
  const fieldValues = Object.fromEntries((input.fields || []).map(x => [x.name, x.value]));
117
118
  return PDF_FILL_FORM(pdfInput, fieldValues);`,
118
119
  returnBinary: "true",
119
- },
120
- json: true,
120
+ }),
121
+ returnFullResponse: true,
122
+ responseType: 'arraybuffer',
121
123
  };
122
- const response = await this.helpers.httpRequest(options);
124
+ const responseData = await this.helpers.httpRequest(options);
125
+ const response = responseData.body;
123
126
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
124
127
  // No binary data returned; emit only JSON without a binary property
125
128
  returnData.push({
@@ -76,18 +76,21 @@ class PdfToPng {
76
76
  headers: {
77
77
  "customjs-origin": "n8n/pdfToPng",
78
78
  "x-api-key": credentials.apiKey,
79
+ "Content-Type": "application/json",
79
80
  },
80
- body: {
81
+ body: JSON.stringify({
81
82
  input: isBinary ? { file: file } : { urls: field_name },
82
83
  code: `
83
84
  const { PDF2PNG } = require('./utils');
84
85
  input = input.file || input.urls;
85
86
  return PDF2PNG(input);`,
86
87
  returnBinary: "true",
87
- },
88
- json: true,
88
+ }),
89
+ returnFullResponse: true,
90
+ responseType: 'arraybuffer',
89
91
  };
90
- const response = await this.helpers.httpRequest(options);
92
+ const responseData = await this.helpers.httpRequest(options);
93
+ const response = responseData.body;
91
94
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
92
95
  // No binary data returned; emit only JSON without a binary property
93
96
  returnData.push({
@@ -137,17 +137,20 @@ class Scraper {
137
137
  headers: {
138
138
  "customjs-origin": "n8n/scraper",
139
139
  "x-api-key": credentials.apiKey,
140
+ "Content-Type": "application/json",
140
141
  },
141
- body: {
142
+ body: JSON.stringify({
142
143
  input: JSON.stringify(payload),
143
144
  code: `const { SCRAPER } = require('./utils'); ` +
144
145
  `const payload = input; ` +
145
146
  `return SCRAPER(payload.url, payload.commands || [], "${returnValueType === "binary" ? "image" : "html"}", ${debug ? "true" : "false"});`,
146
147
  returnBinary: returnValueType === "binary" ? "true" : "false",
147
- },
148
- json: true,
148
+ }),
149
+ returnFullResponse: returnValueType === "binary",
150
+ responseType: returnValueType === "binary" ? 'arraybuffer' : undefined,
149
151
  };
150
- const response = await this.helpers.httpRequest(options);
152
+ const responseData = await this.helpers.httpRequest(options);
153
+ const response = returnValueType === "binary" ? responseData.body : responseData;
151
154
  if (returnValueType === "binary") {
152
155
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
153
156
  // No binary data returned; emit only JSON without a binary property
@@ -45,15 +45,18 @@ class WebsiteScreenshot {
45
45
  headers: {
46
46
  "customjs-origin": "n8n/screenshot",
47
47
  "x-api-key": credentials.apiKey,
48
+ "Content-Type": "application/json",
48
49
  },
49
- body: {
50
+ body: JSON.stringify({
50
51
  input: urlInput,
51
52
  code: "const { SCREENSHOT } = require('./utils'); return SCREENSHOT(input);",
52
53
  returnBinary: "true",
53
- },
54
- json: true,
54
+ }),
55
+ returnFullResponse: true,
56
+ responseType: 'arraybuffer',
55
57
  };
56
- const response = await this.helpers.httpRequest(options);
58
+ const responseData = await this.helpers.httpRequest(options);
59
+ const response = responseData.body;
57
60
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
58
61
  // No binary data returned; emit only JSON without a binary property
59
62
  returnData.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",