n8n-nodes-make-pdf 1.0.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.
@@ -0,0 +1,2 @@
1
+ import { MakePdf } from './nodes/MakePdf/MakePdf.node';
2
+ export declare const nodes: (typeof MakePdf)[];
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nodes = void 0;
4
+ const MakePdf_node_1 = require("./nodes/MakePdf/MakePdf.node");
5
+ exports.nodes = [MakePdf_node_1.MakePdf];
@@ -0,0 +1,6 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class MakePdf implements INodeType {
3
+ constructor();
4
+ description: INodeTypeDescription;
5
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
6
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MakePdf = void 0;
4
+ class MakePdf {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Make PDF',
8
+ name: 'makePdf',
9
+ icon: 'file:icon.svg',
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Generate PDF via Gotenberg (HTML → PDF)',
13
+ defaults: {
14
+ name: 'Make PDF',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ properties: [
19
+ {
20
+ displayName: 'Binary Property',
21
+ name: 'binaryProperty',
22
+ type: 'string',
23
+ default: 'data',
24
+ },
25
+ {
26
+ displayName: 'Gotenberg URL',
27
+ name: 'gotenbergUrl',
28
+ type: 'string',
29
+ default: 'http://gotenberg:3000/forms/chromium/convert/html',
30
+ },
31
+ ],
32
+ };
33
+ }
34
+ async execute() {
35
+ var _a;
36
+ const items = this.getInputData();
37
+ const returnData = [];
38
+ for (let i = 0; i < items.length; i++) {
39
+ const binaryProperty = this.getNodeParameter('binaryProperty', i);
40
+ const gotenbergUrl = this.getNodeParameter('gotenbergUrl', i);
41
+ const bin = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[binaryProperty];
42
+ if (!(bin === null || bin === void 0 ? void 0 : bin.data)) {
43
+ throw new Error('No binary data found');
44
+ }
45
+ const response = await this.helpers.httpRequest({
46
+ method: 'POST',
47
+ url: gotenbergUrl,
48
+ body: Buffer.from(bin.data, 'base64'),
49
+ headers: {
50
+ 'Content-Type': 'text/html',
51
+ },
52
+ encoding: null,
53
+ });
54
+ items[i].binary = {
55
+ data: {
56
+ data: Buffer.from(response).toString('base64'),
57
+ mimeType: 'application/pdf',
58
+ fileName: 'output.pdf',
59
+ },
60
+ };
61
+ returnData.push(items[i]);
62
+ }
63
+ return [returnData];
64
+ }
65
+ }
66
+ exports.MakePdf = MakePdf;
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class MakePdf implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MakePdf = void 0;
4
+ class MakePdf {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: 'Make PDF',
8
+ name: 'makePdf',
9
+ icon: 'file:icon.svg',
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Generate PDF via Gotenberg (HTML → PDF)',
13
+ defaults: {
14
+ name: 'Make PDF',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ properties: [
19
+ {
20
+ displayName: 'Binary Property',
21
+ name: 'binaryProperty',
22
+ type: 'string',
23
+ default: 'data',
24
+ description: 'Binary field containing the HTML file',
25
+ },
26
+ {
27
+ displayName: 'Gotenberg URL',
28
+ name: 'gotenbergUrl',
29
+ type: 'string',
30
+ default: 'http://gotenberg:3000/forms/chromium/convert/html',
31
+ description: 'Gotenberg endpoint for HTML → PDF',
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ async execute() {
37
+ var _a;
38
+ const items = this.getInputData();
39
+ const binaryProperty = this.getNodeParameter('binaryProperty', 0);
40
+ const gotenbergUrl = this.getNodeParameter('gotenbergUrl', 0);
41
+ const returnData = [];
42
+ for (let i = 0; i < items.length; i++) {
43
+ const bin = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[binaryProperty];
44
+ if (!(bin === null || bin === void 0 ? void 0 : bin.data)) {
45
+ throw new Error(`No binary data found in property "${binaryProperty}" on item ${i}`);
46
+ }
47
+ const pdfBuffer = await this.helpers.httpRequest({
48
+ method: 'POST',
49
+ url: gotenbergUrl,
50
+ formData: {
51
+ files: {
52
+ value: Buffer.from(bin.data, 'base64'),
53
+ options: {
54
+ filename: 'input.html',
55
+ contentType: 'text/html',
56
+ },
57
+ },
58
+ },
59
+ encoding: null,
60
+ });
61
+ items[i].binary = {
62
+ data: {
63
+ data: Buffer.from(pdfBuffer).toString('base64'),
64
+ mimeType: 'application/pdf',
65
+ fileName: 'output.pdf',
66
+ },
67
+ };
68
+ returnData.push(items[i]);
69
+ }
70
+ return [returnData];
71
+ }
72
+ }
73
+ exports.MakePdf = MakePdf;
@@ -0,0 +1,23 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
2
+ <defs>
3
+ <clipPath id="c">
4
+ <rect x="2" y="2" width="96" height="96" rx="14"/>
5
+ </clipPath>
6
+ </defs>
7
+ <g clip-path="url(#c)">
8
+ <polygon points="0,0 100,0 0,100" fill="#373d49"/>
9
+ <polygon points="100,0 100,100 0,100" fill="#f47610"/>
10
+ <path d="M18 18H40L50 28V52H18Z M40 18V28H50"
11
+ fill="none"
12
+ stroke="#ffffff"
13
+ stroke-width="5.5"
14
+ stroke-linecap="round"
15
+ stroke-linejoin="round"/>
16
+ <text x="67" y="70"
17
+ fill="#ffffff"
18
+ font-size="26"
19
+ font-weight="800"
20
+ text-anchor="middle">PDF</text>
21
+ </g>
22
+ </svg>
23
+
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "n8n-nodes-make-pdf",
3
+ "version": "1.0.0",
4
+ "description": "Make PDF – Gotenberg wrapper node for n8n",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "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"
13
+ },
14
+ "dependencies": {
15
+ "n8n-workflow": "^1.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^25.0.3",
19
+ "typescript": "^5.0.0"
20
+ },
21
+ "n8n": {
22
+ "nodes": [
23
+ "dist/index.js"
24
+ ]
25
+ }
26
+ }