@pdfgeneratorapi/n8n-nodes-pdf-generator-api 0.2.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.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright 2022 n8n
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # n8n-nodes-pdf-generator-api
2
+
3
+ This is an n8n community node. It lets you use PDF Generator API in your n8n workflows.
4
+
5
+ PDF Generator API is a powerful service that allows you to generate PDFs from templates, convert HTML/URLs to PDF, and perform various PDF operations like watermarking, encryption, optimization, and form field manipulation.
6
+
7
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
8
+
9
+ [Installation](#installation)
10
+ [Operations](#operations)
11
+ [Credentials](#credentials)
12
+ [Compatibility](#compatibility)
13
+ [Usage](#usage)
14
+ [Resources](#resources)
15
+ [Version history](#version-history)
16
+
17
+ ## Installation
18
+
19
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
20
+
21
+ Use the package name: `n8n-nodes-pdf-generator-api`
22
+
23
+ ## Operations
24
+
25
+ This node supports the following operations organized by resource:
26
+
27
+ ### Document
28
+ - **Generate** - Generate a PDF document from a template with data
29
+ - **Generate (Async)** - Generate a PDF document asynchronously with callback
30
+ - **Generate (Batch)** - Generate multiple PDF documents in batch
31
+ - **Generate (Batch + Async)** - Generate multiple PDF documents in batch asynchronously
32
+ - **List** - List generated documents stored in the API
33
+ - **Get** - Retrieve a specific document by public ID
34
+ - **Delete** - Delete a document from storage
35
+
36
+ ### Template
37
+ - **Create** - Create a new PDF template
38
+ - **Update** - Update an existing template configuration
39
+ - **Get** - Retrieve template configuration
40
+ - **Delete** - Delete a template
41
+ - **List** - List available templates
42
+ - **Copy** - Create a copy of an existing template
43
+ - **Get Data Fields** - Extract data fields used in a template
44
+ - **Open Editor** - Get URL to open template editor
45
+ - **Validate** - Validate template configuration
46
+
47
+ ### Conversion
48
+ - **HTML to PDF** - Convert HTML content directly to PDF
49
+ - **URL to PDF** - Convert a public URL to PDF
50
+
51
+ ### PDF Services
52
+ - **Add Watermark** - Add text or image watermarks to PDF documents
53
+ - **Encrypt Document** - Encrypt PDF documents with password protection
54
+ - **Decrypt Document** - Decrypt encrypted PDF documents
55
+ - **Optimize Document** - Optimize PDF file size for better performance
56
+ - **Extract Form Fields** - Extract form fields and metadata from PDF documents
57
+ - **Fill Form Fields** - Fill form fields in PDF documents with provided data
58
+
59
+ ### Workspace
60
+ - **Create** - Create a new workspace for organizing templates
61
+ - **List** - List all workspaces in organization
62
+ - **Get** - Get workspace information
63
+ - **Delete** - Delete a workspace
64
+
65
+ ## Credentials
66
+
67
+ To use this node, you need to authenticate with PDF Generator API:
68
+
69
+ ### Prerequisites
70
+ 1. Sign up for a [PDF Generator API account](https://pdfgeneratorapi.com/signup)
71
+ 2. Get your API Key and API Secret from Account Settings
72
+
73
+ ### Authentication Setup
74
+ 1. In n8n, create new credentials for "PDF Generator API"
75
+ 2. Enter your **API Key** and **API Secret**
76
+
77
+ ### JWT Authentication
78
+ The node automatically handles JWT token generation using your API credentials. Tokens are generated server-side and include:
79
+ - Issuer (iss): Your API Key
80
+ - Subject (sub): Workspace identifier
81
+ - Expiration (exp): Short-lived tokens for security
82
+
83
+ ## Compatibility
84
+
85
+ - **Minimum n8n version**: 0.199.0
86
+ - **Tested with**: n8n versions 0.199.0+
87
+ - **Node API version**: 1
88
+
89
+ ## Usage
90
+
91
+ ### Basic Document Generation
92
+ 1. Select **Resource**: Document
93
+ 2. Select **Operation**: Generate
94
+ 3. Choose your template from the dropdown
95
+ 4. Provide JSON data to merge with the template
96
+ 5. Select output format (Base64, URL, or File)
97
+
98
+ ### HTML to PDF Conversion
99
+ 1. Select **Resource**: Conversion
100
+ 2. Select **Operation**: HTML to PDF
101
+ 3. Enter your HTML content
102
+ 4. Configure paper size and orientation
103
+ 5. Specify filename and output format
104
+
105
+ ### PDF Processing
106
+ - **Watermarking**: Add text or image watermarks with positioning options
107
+ - **Encryption**: Protect PDFs with owner and user passwords
108
+ - **Decryption**: Remove password protection from encrypted PDFs
109
+ - **Optimization**: Reduce file size while maintaining quality
110
+ - **Form Fields**: Extract form field metadata and fill PDF forms with data
111
+
112
+ #### Form Fields Operations
113
+ 1. **Extract Form Fields**: Analyze PDF forms to discover available fields
114
+ 2. **Fill Form Fields**: Populate PDF forms with data
115
+
116
+ Example form data:
117
+ ```json
118
+ {
119
+ "firstName": "John",
120
+ "lastName": "Doe",
121
+ "email": "john.doe@example.com",
122
+ "subscribe": true
123
+ }
124
+ ```
125
+
126
+ ### Output Formats
127
+ - **Base64**: Returns PDF as base64 encoded string in JSON
128
+ - **URL**: Returns download URL (files stored for 30 days)
129
+ - **File**: Returns binary PDF data for direct download
130
+
131
+ ### Error Handling
132
+ The node includes comprehensive error handling for:
133
+ - Authentication failures
134
+ - Invalid template configurations
135
+ - Missing required parameters
136
+ - API rate limiting
137
+ - Network connectivity issues
138
+
139
+ For workflows that should continue on errors, enable "Continue on Fail" in node settings.
140
+
141
+ ## Resources
142
+
143
+ * [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
144
+ * [PDF Generator API Documentation](https://docs.pdfgeneratorapi.com)
145
+ * [PDF Generator API Support](https://support.pdfgeneratorapi.com)
146
+ * [Template Editor Guide](https://support.pdfgeneratorapi.com/en/category/components-1ffseaj/)
147
+ * [Expression Language Documentation](https://support.pdfgeneratorapi.com/en/category/expression-language-q203pa/)
148
+
149
+ ## Version history
150
+
151
+ ### 0.2.2
152
+ - 🧹 **Cleanup**: Removed example nodes and credentials from package
153
+ - 🔧 **Improved**: Build process now only includes production files
154
+ - 📦 **Optimized**: Package structure for better n8n compatibility
155
+
156
+ ### 0.2.1
157
+ - 🐛 **Fixed**: Fixed npm publish script in package.json
158
+ - 📝 **Updated**: Package metadata and repository information
159
+
160
+ ### 0.2.0
161
+ - ✨ **New**: Added PDF form fields operations
162
+ - Extract Form Fields: Analyze and extract form field metadata
163
+ - Fill Form Fields: Populate PDF forms with data
164
+ - 🐛 **Fixed**: Improved error handling for PDF services operations
165
+ - 📝 **Docs**: Enhanced documentation and examples
166
+
167
+ ### 0.1.0
168
+ - 🎉 **Initial Release**: Complete PDF Generator API integration
169
+ - Document generation from templates
170
+ - HTML/URL to PDF conversion
171
+ - PDF processing (watermark, encrypt, decrypt, optimize)
172
+ - Template and workspace management
173
+ - Support for all output formats (Base64, URL, File)
174
+ - Comprehensive error handling and validation
@@ -0,0 +1,11 @@
1
+ import { ICredentialDataDecryptedObject, ICredentialTestRequest, ICredentialType, IHttpRequestOptions, INodeProperties } from 'n8n-workflow';
2
+ export declare class PdfGeneratorApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ private validateCredentials;
8
+ authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
9
+ private generateJWT;
10
+ test: ICredentialTestRequest;
11
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PdfGeneratorApi = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class PdfGeneratorApi {
6
+ constructor() {
7
+ this.name = 'pdfGeneratorApi';
8
+ this.displayName = 'PDF Generator API';
9
+ this.documentationUrl = 'https://docs.pdfgeneratorapi.com/v4';
10
+ this.properties = [
11
+ {
12
+ displayName: 'API KEY',
13
+ name: 'jwtIss',
14
+ type: 'string',
15
+ required: true,
16
+ default: '',
17
+ description: 'JWT issuer claim',
18
+ },
19
+ {
20
+ displayName: 'Secret',
21
+ name: 'jwtSecret',
22
+ type: 'string',
23
+ required: true,
24
+ default: '',
25
+ typeOptions: {
26
+ password: true,
27
+ },
28
+ description: 'Your JWT secret key for signing tokens',
29
+ },
30
+ {
31
+ displayName: 'Email/workspace',
32
+ name: 'workspace',
33
+ type: 'string',
34
+ required: true,
35
+ default: '',
36
+ description: 'Your email address (workspace identifier and JWT subject)',
37
+ },
38
+ {
39
+ displayName: 'Base URL',
40
+ name: 'baseUrl',
41
+ type: 'string',
42
+ required: false,
43
+ default: 'https://us1.pdfgeneratorapi.com/api/v4',
44
+ description: 'API base URL (leave default for production, change for local development)',
45
+ },
46
+ ];
47
+ this.test = {
48
+ request: {
49
+ baseURL: '={{$credentials.baseUrl || "https://us1.pdfgeneratorapi.com/api/v4"}}',
50
+ url: '/workspaces',
51
+ method: 'GET',
52
+ },
53
+ rules: [
54
+ {
55
+ type: 'responseSuccessBody',
56
+ properties: {
57
+ key: 'response',
58
+ value: {},
59
+ message: 'Invalid credentials. Please check your API Key, Secret, and Email/workspace.',
60
+ },
61
+ },
62
+ ],
63
+ };
64
+ }
65
+ validateCredentials(credentials) {
66
+ if (!credentials.jwtIss || !credentials.jwtSecret || !credentials.workspace) {
67
+ throw new n8n_workflow_1.NodeOperationError({}, 'Missing required credentials. Please provide API Key, Secret, and Email/workspace.');
68
+ }
69
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
70
+ if (!emailRegex.test(credentials.workspace)) {
71
+ throw new n8n_workflow_1.NodeOperationError({}, 'Email/workspace must be a valid email address.');
72
+ }
73
+ }
74
+ async authenticate(credentials, requestOptions) {
75
+ this.validateCredentials(credentials);
76
+ const token = this.generateJWT(credentials);
77
+ requestOptions.headers = {
78
+ ...requestOptions.headers,
79
+ 'Authorization': `Bearer ${token}`,
80
+ };
81
+ return requestOptions;
82
+ }
83
+ generateJWT(credentials) {
84
+ const crypto = require('crypto');
85
+ const header = {
86
+ 'typ': 'JWT',
87
+ 'alg': 'HS256'
88
+ };
89
+ const currentTimestamp = Math.floor(Date.now() / 1000);
90
+ const data = {
91
+ 'iss': credentials.jwtIss,
92
+ 'sub': credentials.workspace,
93
+ 'exp': currentTimestamp + 60,
94
+ 'partner_id': 'n8n-node',
95
+ };
96
+ function base64url(source) {
97
+ let encodedSource = source.toString('base64');
98
+ encodedSource = encodedSource.replace(/=+$/, '');
99
+ encodedSource = encodedSource.replace(/\+/g, '-');
100
+ encodedSource = encodedSource.replace(/\//g, '_');
101
+ return encodedSource;
102
+ }
103
+ const stringifiedHeader = Buffer.from(JSON.stringify(header));
104
+ const encodedHeader = base64url(stringifiedHeader);
105
+ const stringifiedData = Buffer.from(JSON.stringify(data));
106
+ const encodedData = base64url(stringifiedData);
107
+ const token = `${encodedHeader}.${encodedData}`;
108
+ const signature = crypto.createHmac('sha256', credentials.jwtSecret).update(token).digest();
109
+ const encodedSignature = base64url(signature);
110
+ const signedToken = `${token}.${encodedSignature}`;
111
+ return signedToken;
112
+ }
113
+ }
114
+ exports.PdfGeneratorApi = PdfGeneratorApi;
115
+ //# sourceMappingURL=PdfGeneratorApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdfGeneratorApi.credentials.js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AAI,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAG9C,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAGjD,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAClD,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAElD,OAAO,aAAa,CAAC;QACtB,CAAC;QAGD,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAGnD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;QAG/C,MAAM,KAAK,GAAG,GAAG,aAAa,IAAI,WAAW,EAAE,CAAC;QAGhD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAmB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QACtG,MAAM,gBAAgB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,GAAG,KAAK,IAAI,gBAAgB,EAAE,CAAC;QAEnD,OAAO,WAAW,CAAC;IACpB,CAAC;CAoBD;AAzJD,0CAyJC"}
@@ -0,0 +1 @@
1
+ export { PdfGeneratorApi } from './nodes/PdfGeneratorApi/PdfGeneratorApi.node';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PdfGeneratorApi = void 0;
4
+ var PdfGeneratorApi_node_1 = require("./nodes/PdfGeneratorApi/PdfGeneratorApi.node");
5
+ Object.defineProperty(exports, "PdfGeneratorApi", { enumerable: true, get: function () { return PdfGeneratorApi_node_1.PdfGeneratorApi; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qFAA+E;AAAtE,uHAAA,eAAe,OAAA"}
@@ -0,0 +1,10 @@
1
+ import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeType, INodeTypeDescription, INodeListSearchResult } from 'n8n-workflow';
2
+ export declare class PdfGeneratorApi implements INodeType {
3
+ description: INodeTypeDescription;
4
+ methods: {
5
+ listSearch: {
6
+ searchTemplates(this: ILoadOptionsFunctions, filter?: string): Promise<INodeListSearchResult>;
7
+ };
8
+ };
9
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
10
+ }