@custom-js/n8n-nodes-pdf-toolkit 1.48.0 → 1.50.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 +39 -0
- package/dist/nodes/CompressPDF/CompressPDF.node.js +63 -40
- package/dist/nodes/ExtractPages/ExtractPages.node.js +64 -41
- package/dist/nodes/GetFormFieldNames/GetFormFieldNames.node.js +50 -30
- package/dist/nodes/Html2Docx/Html2Docx.node.js +51 -28
- package/dist/nodes/Html2Pdf/Html2Pdf.node.js +51 -28
- package/dist/nodes/InvoiceGenerator/InvoiceGenerator.node.js +93 -70
- package/dist/nodes/Markdown2Html/Markdown2Html.node.js +42 -22
- package/dist/nodes/MergePdfs/MergePdfs.node.js +60 -37
- package/dist/nodes/PdfFormFill/PdfFormFill.node.js +60 -37
- package/dist/nodes/PdfToPng/PdfToPng.node.js +59 -36
- package/dist/nodes/PdfToText/PdfToText.node.js +50 -30
- package/dist/nodes/SSLChecker/SSLChecker.node.js +41 -21
- package/dist/nodes/Scraper/Scraper.node.js +75 -49
- package/dist/nodes/WebsiteScreenshot/WebsiteScreenshot.node.js +51 -28
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -23,6 +23,45 @@ Use the package at [here](https://www.npmjs.com/package/@custom-js/n8n-nodes-pdf
|
|
|
23
23
|
|
|
24
24
|
Add your Api Key and store securely
|
|
25
25
|
|
|
26
|
+
## Local Development with Docker
|
|
27
|
+
|
|
28
|
+
To test your local changes using Docker:
|
|
29
|
+
|
|
30
|
+
### Prerequisites
|
|
31
|
+
- Docker and Docker Compose installed
|
|
32
|
+
- Node.js and npm installed
|
|
33
|
+
|
|
34
|
+
### Setup Steps
|
|
35
|
+
|
|
36
|
+
1. **Build the package:**
|
|
37
|
+
```bash
|
|
38
|
+
npm run build
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. **Start n8n with Docker:**
|
|
42
|
+
```bash
|
|
43
|
+
docker compose up -d
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Development Workflow
|
|
47
|
+
|
|
48
|
+
After making code changes:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run build && docker restart n8n-dev
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To view logs:
|
|
55
|
+
```bash
|
|
56
|
+
docker logs n8n-dev -f
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
To stop the environment:
|
|
60
|
+
```bash
|
|
61
|
+
docker compose down
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
26
65
|
## Usage
|
|
27
66
|
|
|
28
67
|
### "HTML to PDF" node
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CompressPDF = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class CompressPDF {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -13,8 +14,8 @@ class CompressPDF {
|
|
|
13
14
|
defaults: {
|
|
14
15
|
name: "Compress PDF file",
|
|
15
16
|
},
|
|
16
|
-
inputs: [
|
|
17
|
-
outputs: [
|
|
17
|
+
inputs: ['main'],
|
|
18
|
+
outputs: ['main'],
|
|
18
19
|
credentials: [
|
|
19
20
|
{
|
|
20
21
|
name: "customJsApi",
|
|
@@ -61,48 +62,70 @@ class CompressPDF {
|
|
|
61
62
|
return Buffer.from(file.data, "base64");
|
|
62
63
|
};
|
|
63
64
|
for (let i = 0; i < items.length; i++) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
!
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
try {
|
|
66
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
67
|
+
const field_name = this.getNodeParameter("field_name", i);
|
|
68
|
+
const isBinary = this.getNodeParameter("resource", i) === "binary";
|
|
69
|
+
const file = isBinary ? getFile(field_name, i) : "";
|
|
70
|
+
if (!isBinary &&
|
|
71
|
+
!field_name.startsWith("http://") &&
|
|
72
|
+
!field_name.startsWith("https://")) {
|
|
73
|
+
throw new Error(`Invalid URL: ${field_name}`);
|
|
74
|
+
}
|
|
75
|
+
const options = {
|
|
76
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: {
|
|
79
|
+
"customjs-origin": "n8n/compressPdf",
|
|
80
|
+
},
|
|
81
|
+
body: {
|
|
82
|
+
input: isBinary ? { file: file } : { urls: field_name },
|
|
83
|
+
code: `
|
|
84
|
+
const { PDF_COMPRESS } = require('./utils');
|
|
85
|
+
input = input.file || input.urls;
|
|
86
|
+
return PDF_COMPRESS(input);`,
|
|
87
|
+
returnBinary: "true",
|
|
88
|
+
},
|
|
89
|
+
encoding: null,
|
|
90
|
+
json: true,
|
|
91
|
+
};
|
|
92
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
93
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
94
|
+
// No binary data returned; emit only JSON without a binary property
|
|
95
|
+
returnData.push({
|
|
96
|
+
json: items[i].json,
|
|
97
|
+
pairedItem: {
|
|
98
|
+
item: i,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
|
|
94
104
|
returnData.push({
|
|
95
105
|
json: items[i].json,
|
|
106
|
+
binary: {
|
|
107
|
+
data: binaryData,
|
|
108
|
+
},
|
|
109
|
+
pairedItem: {
|
|
110
|
+
item: i,
|
|
111
|
+
},
|
|
96
112
|
});
|
|
97
|
-
continue;
|
|
98
113
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
catch (error) {
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
116
|
+
if (this.continueOnFail()) {
|
|
117
|
+
returnData.push({
|
|
118
|
+
json: {
|
|
119
|
+
error: errorMessage,
|
|
120
|
+
},
|
|
121
|
+
pairedItem: {
|
|
122
|
+
item: i,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
128
|
+
}
|
|
106
129
|
}
|
|
107
130
|
return [returnData];
|
|
108
131
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExtractPages = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class ExtractPages {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -13,8 +14,8 @@ class ExtractPages {
|
|
|
13
14
|
defaults: {
|
|
14
15
|
name: "Extract Pages From PDF",
|
|
15
16
|
},
|
|
16
|
-
inputs: [
|
|
17
|
-
outputs: [
|
|
17
|
+
inputs: ['main'],
|
|
18
|
+
outputs: ['main'],
|
|
18
19
|
credentials: [
|
|
19
20
|
{
|
|
20
21
|
name: "customJsApi",
|
|
@@ -68,51 +69,73 @@ class ExtractPages {
|
|
|
68
69
|
return Buffer.from(file.data, "base64");
|
|
69
70
|
};
|
|
70
71
|
for (let i = 0; i < items.length; i++) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
!
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const { EXTRACT_PAGES_FROM_PDF } =
|
|
72
|
+
try {
|
|
73
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
74
|
+
const field_name = this.getNodeParameter("field_name", i);
|
|
75
|
+
const pageRange = this.getNodeParameter("pageRange", i);
|
|
76
|
+
const isBinary = this.getNodeParameter("resource", i) === "binary";
|
|
77
|
+
const file = isBinary ? getFile(field_name, i) : "";
|
|
78
|
+
if (!isBinary &&
|
|
79
|
+
!field_name.startsWith("http://") &&
|
|
80
|
+
!field_name.startsWith("https://")) {
|
|
81
|
+
throw new Error(`Invalid URL: ${field_name}`);
|
|
82
|
+
}
|
|
83
|
+
const options = {
|
|
84
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
85
|
+
method: 'POST',
|
|
86
|
+
headers: {
|
|
87
|
+
"customjs-origin": "n8n/extractPages",
|
|
88
|
+
},
|
|
89
|
+
body: {
|
|
90
|
+
input: isBinary
|
|
91
|
+
? { file: file, pageRange }
|
|
92
|
+
: { urls: field_name, pageRange },
|
|
93
|
+
code: `
|
|
94
|
+
const { EXTRACT_PAGES_FROM_PDF } = require('./utils');
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
returnBinary: "true",
|
|
98
|
+
},
|
|
99
|
+
encoding: null,
|
|
100
|
+
json: true,
|
|
101
|
+
};
|
|
102
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
103
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
104
|
+
// No binary data returned; emit only JSON without a binary property
|
|
105
|
+
returnData.push({
|
|
106
|
+
json: items[i].json,
|
|
107
|
+
pairedItem: {
|
|
108
|
+
item: i,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
|
|
104
114
|
returnData.push({
|
|
105
115
|
json: items[i].json,
|
|
116
|
+
binary: {
|
|
117
|
+
data: binaryData,
|
|
118
|
+
},
|
|
119
|
+
pairedItem: {
|
|
120
|
+
item: i,
|
|
121
|
+
},
|
|
106
122
|
});
|
|
107
|
-
continue;
|
|
108
123
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
catch (error) {
|
|
125
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
126
|
+
if (this.continueOnFail()) {
|
|
127
|
+
returnData.push({
|
|
128
|
+
json: {
|
|
129
|
+
error: errorMessage,
|
|
130
|
+
},
|
|
131
|
+
pairedItem: {
|
|
132
|
+
item: i,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
138
|
+
}
|
|
116
139
|
}
|
|
117
140
|
return [returnData];
|
|
118
141
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetFormFieldNames = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class GetFormFieldNames {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -13,8 +14,8 @@ class GetFormFieldNames {
|
|
|
13
14
|
defaults: {
|
|
14
15
|
name: "Get PDF Form Fields",
|
|
15
16
|
},
|
|
16
|
-
inputs: [
|
|
17
|
-
outputs: [
|
|
17
|
+
inputs: ['main'],
|
|
18
|
+
outputs: ['main'],
|
|
18
19
|
credentials: [
|
|
19
20
|
{
|
|
20
21
|
name: "customJsApi",
|
|
@@ -57,36 +58,55 @@ class GetFormFieldNames {
|
|
|
57
58
|
return Buffer.from(file.data, "base64");
|
|
58
59
|
};
|
|
59
60
|
for (let i = 0; i < items.length; i++) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const { PDF_GET_FORM_FIELD_NAMES } =
|
|
61
|
+
try {
|
|
62
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
63
|
+
const field_name = this.getNodeParameter("field_name", i);
|
|
64
|
+
const isBinary = this.getNodeParameter("resource", i) === "binary";
|
|
65
|
+
const file = isBinary ? getFile(field_name, i) : "";
|
|
66
|
+
if (!isBinary) {
|
|
67
|
+
throw new Error(`Invalid binary data`);
|
|
68
|
+
}
|
|
69
|
+
const options = {
|
|
70
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: {
|
|
73
|
+
"customjs-origin": "n8n/getFormFieldNames",
|
|
74
|
+
},
|
|
75
|
+
body: {
|
|
76
|
+
input: { file: file },
|
|
77
|
+
code: `
|
|
78
|
+
const { PDF_GET_FORM_FIELD_NAMES } = require('./utils');
|
|
78
79
|
const pdfInput = input.file;
|
|
79
80
|
return PDF_GET_FORM_FIELD_NAMES(pdfInput);`,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
returnBinary: "false",
|
|
82
|
+
},
|
|
83
|
+
json: true,
|
|
84
|
+
};
|
|
85
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
86
|
+
returnData.push({
|
|
87
|
+
json: {
|
|
88
|
+
output: JSON.parse(response.toString()),
|
|
89
|
+
},
|
|
90
|
+
pairedItem: {
|
|
91
|
+
item: i,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
97
|
+
if (this.continueOnFail()) {
|
|
98
|
+
returnData.push({
|
|
99
|
+
json: {
|
|
100
|
+
error: errorMessage,
|
|
101
|
+
},
|
|
102
|
+
pairedItem: {
|
|
103
|
+
item: i,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
109
|
+
}
|
|
90
110
|
}
|
|
91
111
|
return [returnData];
|
|
92
112
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Html2Docx = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class Html2Docx {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -40,38 +41,60 @@ class Html2Docx {
|
|
|
40
41
|
const items = this.getInputData();
|
|
41
42
|
const returnData = [];
|
|
42
43
|
for (let i = 0; i < items.length; i++) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
try {
|
|
45
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
46
|
+
const htmlInput = this.getNodeParameter("htmlInput", i);
|
|
47
|
+
const options = {
|
|
48
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
"customjs-origin": "n8n/html2Docx",
|
|
52
|
+
},
|
|
53
|
+
body: {
|
|
54
|
+
input: htmlInput,
|
|
55
|
+
code: "const { HTML2DOCX } = require('./utils'); return HTML2DOCX(input)",
|
|
56
|
+
returnBinary: "true",
|
|
57
|
+
},
|
|
58
|
+
encoding: null,
|
|
59
|
+
json: true,
|
|
60
|
+
};
|
|
61
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
62
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
63
|
+
// No binary data returned; emit only JSON without a binary property
|
|
64
|
+
returnData.push({
|
|
65
|
+
json: items[i].json,
|
|
66
|
+
pairedItem: {
|
|
67
|
+
item: i,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.docx");
|
|
63
73
|
returnData.push({
|
|
64
74
|
json: items[i].json,
|
|
75
|
+
binary: {
|
|
76
|
+
data: binaryData,
|
|
77
|
+
},
|
|
78
|
+
pairedItem: {
|
|
79
|
+
item: i,
|
|
80
|
+
},
|
|
65
81
|
});
|
|
66
|
-
continue;
|
|
67
82
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
catch (error) {
|
|
84
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
85
|
+
if (this.continueOnFail()) {
|
|
86
|
+
returnData.push({
|
|
87
|
+
json: {
|
|
88
|
+
error: errorMessage,
|
|
89
|
+
},
|
|
90
|
+
pairedItem: {
|
|
91
|
+
item: i,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
97
|
+
}
|
|
75
98
|
}
|
|
76
99
|
return [returnData];
|
|
77
100
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Html2Pdf = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class Html2Pdf {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -40,38 +41,60 @@ class Html2Pdf {
|
|
|
40
41
|
const items = this.getInputData();
|
|
41
42
|
const returnData = [];
|
|
42
43
|
for (let i = 0; i < items.length; i++) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
try {
|
|
45
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
46
|
+
const htmlInput = this.getNodeParameter("htmlInput", i);
|
|
47
|
+
const options = {
|
|
48
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
"customjs-origin": "n8n/generatePDF",
|
|
52
|
+
},
|
|
53
|
+
body: {
|
|
54
|
+
input: htmlInput,
|
|
55
|
+
code: "const { HTML2PDF } = require('./utils'); return HTML2PDF(input)",
|
|
56
|
+
returnBinary: "true",
|
|
57
|
+
},
|
|
58
|
+
encoding: null,
|
|
59
|
+
json: true,
|
|
60
|
+
};
|
|
61
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
62
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
63
|
+
// No binary data returned; emit only JSON without a binary property
|
|
64
|
+
returnData.push({
|
|
65
|
+
json: items[i].json,
|
|
66
|
+
pairedItem: {
|
|
67
|
+
item: i,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.pdf");
|
|
63
73
|
returnData.push({
|
|
64
74
|
json: items[i].json,
|
|
75
|
+
binary: {
|
|
76
|
+
data: binaryData,
|
|
77
|
+
},
|
|
78
|
+
pairedItem: {
|
|
79
|
+
item: i,
|
|
80
|
+
},
|
|
65
81
|
});
|
|
66
|
-
continue;
|
|
67
82
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
catch (error) {
|
|
84
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
85
|
+
if (this.continueOnFail()) {
|
|
86
|
+
returnData.push({
|
|
87
|
+
json: {
|
|
88
|
+
error: errorMessage,
|
|
89
|
+
},
|
|
90
|
+
pairedItem: {
|
|
91
|
+
item: i,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
97
|
+
}
|
|
75
98
|
}
|
|
76
99
|
return [returnData];
|
|
77
100
|
}
|