n8n-nodes-make-pdf 1.0.0 → 1.0.2
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/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/nodes/MakePdf/MakePdf.node.d.ts +0 -1
- package/dist/nodes/MakePdf/MakePdf.node.js +70 -24
- package/package.json +21 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Frank Schelhorn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# n8n-nodes-make-pdf
|
|
2
|
+
|
|
3
|
+
This is an n8n community node that allows you to generate PDF files from HTML using [Gotenberg](https://gotenberg.dev/).
|
|
4
|
+
|
|
5
|
+
[n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
10
|
+
|
|
11
|
+
### Community Nodes (Recommended)
|
|
12
|
+
|
|
13
|
+
1. Go to **Settings > Community Nodes**
|
|
14
|
+
2. Select **Install**
|
|
15
|
+
3. Enter `n8n-nodes-make-pdf` in **Enter npm package name**
|
|
16
|
+
4. Agree to the risks of using community nodes
|
|
17
|
+
5. Select **Install**
|
|
18
|
+
|
|
19
|
+
### Manual Installation
|
|
20
|
+
|
|
21
|
+
To get started install the package in your n8n root directory:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install n8n-nodes-make-pdf
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For Docker-based deployments add the package to your `package.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"n8n-nodes-make-pdf": "^1.0.1"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Prerequisites
|
|
38
|
+
|
|
39
|
+
This node requires a running [Gotenberg](https://gotenberg.dev/) instance. Gotenberg is a Docker-powered stateless API for PDF generation.
|
|
40
|
+
|
|
41
|
+
### Quick Start with Docker
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
docker run -d --name gotenberg -p 3000:3000 gotenberg/gotenberg:8
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Operations
|
|
48
|
+
|
|
49
|
+
### Make PDF
|
|
50
|
+
|
|
51
|
+
Converts HTML content to PDF format.
|
|
52
|
+
|
|
53
|
+
**Input:**
|
|
54
|
+
- Binary data containing HTML content
|
|
55
|
+
- Gotenberg server URL (default: `http://gotenberg:3000/forms/chromium/convert/html`)
|
|
56
|
+
|
|
57
|
+
**Output:**
|
|
58
|
+
- Binary data containing the generated PDF
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
### Node Parameters
|
|
63
|
+
|
|
64
|
+
| Parameter | Type | Required | Description |
|
|
65
|
+
|-----------|------|----------|-------------|
|
|
66
|
+
| Input Binary Property | string | Yes | Name of the binary property containing HTML data (default: `data`) |
|
|
67
|
+
| Output Binary Property | string | Yes | Name of the binary property to store the PDF result (default: `data`) |
|
|
68
|
+
| Gotenberg URL | string | Yes | URL of your Gotenberg instance |
|
|
69
|
+
|
|
70
|
+
## Example Workflow
|
|
71
|
+
|
|
72
|
+
1. **HTTP Request** - Fetch HTML content or read from file
|
|
73
|
+
2. **Make PDF** - Convert HTML to PDF
|
|
74
|
+
3. **Write Binary File** - Save the PDF to disk
|
|
75
|
+
|
|
76
|
+
## Compatibility
|
|
77
|
+
|
|
78
|
+
Tested with n8n version 1.x
|
|
79
|
+
|
|
80
|
+
## Resources
|
|
81
|
+
|
|
82
|
+
* [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
|
|
83
|
+
* [Gotenberg documentation](https://gotenberg.dev/)
|
|
84
|
+
|
|
85
|
+
## Version History
|
|
86
|
+
|
|
87
|
+
### 1.0.1
|
|
88
|
+
- Improved error handling
|
|
89
|
+
- Added proper binary data handling
|
|
90
|
+
- Better TypeScript support
|
|
91
|
+
- Enhanced property descriptions
|
|
92
|
+
|
|
93
|
+
### 1.0.0
|
|
94
|
+
- Initial release
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
[MIT](LICENSE.md)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class MakePdf implements INodeType {
|
|
3
|
-
constructor();
|
|
4
3
|
description: INodeTypeDescription;
|
|
5
4
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
6
5
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MakePdf = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class MakePdf {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -17,16 +18,31 @@ class MakePdf {
|
|
|
17
18
|
outputs: ['main'],
|
|
18
19
|
properties: [
|
|
19
20
|
{
|
|
20
|
-
displayName: 'Binary Property',
|
|
21
|
-
name: '
|
|
21
|
+
displayName: 'Input Binary Property',
|
|
22
|
+
name: 'binaryPropertyName',
|
|
22
23
|
type: 'string',
|
|
23
24
|
default: 'data',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'Name of the binary property which contains the HTML data',
|
|
27
|
+
placeholder: 'e.g. data',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Output Binary Property',
|
|
31
|
+
name: 'outputBinaryPropertyName',
|
|
32
|
+
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',
|
|
24
37
|
},
|
|
25
38
|
{
|
|
26
39
|
displayName: 'Gotenberg URL',
|
|
27
40
|
name: 'gotenbergUrl',
|
|
28
41
|
type: 'string',
|
|
29
42
|
default: 'http://gotenberg:3000/forms/chromium/convert/html',
|
|
43
|
+
required: true,
|
|
44
|
+
description: 'The URL of your Gotenberg instance',
|
|
45
|
+
placeholder: 'http://gotenberg:3000/forms/chromium/convert/html',
|
|
30
46
|
},
|
|
31
47
|
],
|
|
32
48
|
};
|
|
@@ -35,30 +51,60 @@ class MakePdf {
|
|
|
35
51
|
var _a;
|
|
36
52
|
const items = this.getInputData();
|
|
37
53
|
const returnData = [];
|
|
38
|
-
for (let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
55
|
+
try {
|
|
56
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex);
|
|
57
|
+
const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', itemIndex);
|
|
58
|
+
const gotenbergUrl = this.getNodeParameter('gotenbergUrl', itemIndex);
|
|
59
|
+
const binaryData = (_a = items[itemIndex].binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
|
|
60
|
+
if (!binaryData) {
|
|
61
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex });
|
|
62
|
+
}
|
|
63
|
+
if (!binaryData.data) {
|
|
64
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary property "${binaryPropertyName}" has no data`, { itemIndex });
|
|
65
|
+
}
|
|
66
|
+
// Convert base64 to Buffer
|
|
67
|
+
const htmlBuffer = Buffer.from(binaryData.data, 'base64');
|
|
68
|
+
// Make request to Gotenberg
|
|
69
|
+
const response = await this.helpers.httpRequest({
|
|
70
|
+
method: 'POST',
|
|
71
|
+
url: gotenbergUrl,
|
|
72
|
+
body: htmlBuffer,
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'text/html',
|
|
75
|
+
},
|
|
76
|
+
encoding: 'arraybuffer',
|
|
77
|
+
returnFullResponse: false,
|
|
78
|
+
});
|
|
79
|
+
// Create new binary data for PDF
|
|
80
|
+
const newBinaryData = {
|
|
56
81
|
data: Buffer.from(response).toString('base64'),
|
|
57
82
|
mimeType: 'application/pdf',
|
|
58
|
-
fileName: 'output.pdf',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
fileName: binaryData.fileName ? binaryData.fileName.replace(/\.[^.]+$/, '.pdf') : 'output.pdf',
|
|
84
|
+
};
|
|
85
|
+
// Prepare output item
|
|
86
|
+
const newItem = {
|
|
87
|
+
json: items[itemIndex].json,
|
|
88
|
+
binary: {
|
|
89
|
+
...items[itemIndex].binary,
|
|
90
|
+
[outputBinaryPropertyName]: newBinaryData,
|
|
91
|
+
},
|
|
92
|
+
pairedItem: itemIndex,
|
|
93
|
+
};
|
|
94
|
+
returnData.push(newItem);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (this.continueOnFail()) {
|
|
98
|
+
returnData.push({
|
|
99
|
+
json: {
|
|
100
|
+
error: error.message,
|
|
101
|
+
},
|
|
102
|
+
pairedItem: itemIndex,
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
62
108
|
}
|
|
63
109
|
return [returnData];
|
|
64
110
|
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-make-pdf",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "n8n node to generate PDFs via Gotenberg - Convert HTML to PDF with ease",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n",
|
|
7
|
+
"n8n-node",
|
|
8
|
+
"n8n-community-node-package",
|
|
9
|
+
"pdf",
|
|
10
|
+
"gotenberg",
|
|
11
|
+
"html-to-pdf",
|
|
12
|
+
"pdf-generation"
|
|
13
|
+
],
|
|
5
14
|
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Frank Schelhorn",
|
|
17
|
+
"email": "n8n.schelhorn@gmail.com"
|
|
18
|
+
},
|
|
6
19
|
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
7
21
|
"files": [
|
|
8
22
|
"dist"
|
|
9
23
|
],
|
|
10
24
|
"scripts": {
|
|
11
25
|
"build": "tsc -p tsconfig.json && mkdir -p dist/nodes/MakePdf && cp src/nodes/MakePdf/icon.svg dist/nodes/MakePdf/icon.svg",
|
|
12
|
-
"prepare": "npm run build"
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"dev": "npm run build -- --watch",
|
|
28
|
+
"lint": "tsc --noEmit"
|
|
13
29
|
},
|
|
14
30
|
"dependencies": {
|
|
15
|
-
"n8n-workflow": "^1.0.0"
|
|
31
|
+
"n8n-workflow": "^1.0.0 || ^2.0.0"
|
|
16
32
|
},
|
|
17
33
|
"devDependencies": {
|
|
18
34
|
"@types/node": "^25.0.3",
|
|
19
35
|
"typescript": "^5.0.0"
|
|
20
36
|
},
|
|
21
37
|
"n8n": {
|
|
38
|
+
"n8nNodesApiVersion": 1,
|
|
22
39
|
"nodes": [
|
|
23
40
|
"dist/index.js"
|
|
24
41
|
]
|