Actions7
- Account Actions
- Image Actions
- PDF Actions
- Transaction Actions
Overview
The node integrates with the CraftMyPDF API to create PDF documents from templates. It allows users to generate PDFs by providing a template ID and JSON data to populate the template. The node supports creating PDFs synchronously or asynchronously, resizing images within the PDF to optimize file size, applying password protection, and choosing between receiving the output as a JSON object (with a CDN link) or as a binary file directly.
This node is beneficial in scenarios where automated PDF generation is needed, such as generating invoices, reports, certificates, or any templated document dynamically filled with user data. For example, a business could use this node to automatically create customer invoices based on order data, or an HR system could generate employee contracts using predefined templates.
Properties
| Name | Meaning |
|---|---|
| Region | Selects the API endpoint region to use. Options include Default Endpoint, Australia, Europe (Frankfurt), US East (N. Virginia), alternative endpoints for Europe, Singapore, US East, and a staging endpoint. |
| Template ID | The identifier of the PDF template to use for generating the document. |
| Data | JSON data used to fill the template. Can be provided as a stringified JSON or a JSON object. |
| Version | Specifies which version of the template to use. Defaults to the latest version if not specified. |
| Export Type | Determines the format of the output: "JSON" returns a JSON object with a CDN URL to the PDF; "File" returns the binary PDF data directly. |
| Expiration | Time in minutes before the generated PDF expires (valid for CDN links). Minimum 1 minute, maximum 10080 minutes (7 days). |
| Output File | Filename to assign to the output PDF when exporting as a file. |
| Password Protected | Enables password protection on the generated PDF (requires professional subscription or higher). |
| Password | The password to protect the PDF file if password protection is enabled. |
| Image Resample Resolution | Downsamples images inside the PDF to the specified DPI to reduce file size. Suggested values are 1200, 600, 300, 150, or 72. Set to 0 to disable resampling. |
| Resize Images | Enables resizing of all images in the PDF to reduce file size, useful for templates with many or large images. |
| Resize Max Width | Maximum width in pixels for resized images (effective only if Resize Images is enabled). |
| Resize Max Height | Maximum height in pixels for resized images (effective only if Resize Images is enabled). |
| Resize Format | Format to convert resized images into, either JPEG or PNG (effective only if Resize Images is enabled). |
Output
- When Export Type is set to JSON, the node outputs a JSON object containing metadata about the generated PDF, including a URL pointing to the PDF stored on a CDN. This URL is valid until the expiration time.
- When Export Type is set to File, the node outputs the binary content of the generated PDF file. The HTTP response header is set to indicate an attachment with the specified output filename.
- If password protection is enabled, the generated PDF will require the specified password to open.
- Image optimization options affect the size and quality of images embedded in the PDF.
Dependencies
- Requires an active connection to the CraftMyPDF API via an API key credential configured in n8n.
- The node depends on network access to the selected regional API endpoint.
- Professional subscription may be required to enable password protection features.
Troubleshooting
- Invalid JSON Data: If the
Dataproperty contains invalid JSON, the node throws an error indicating "Data: Invalid JSON". Ensure that the JSON input is correctly formatted. - API Authentication Errors: Failure to authenticate with the API will result in errors. Verify that the API key credential is correctly configured and has necessary permissions.
- Unsupported Export Type: Selecting an unsupported export type or mismatched output handling may cause failures. Use only "json" or "file" as export types.
- Password Protection Not Working: Password protection requires a professional subscription. If enabled without proper subscription, the API may reject the request.
- Image Resizing Issues: Setting inappropriate values for image resampling or resizing may lead to unexpected PDF output or increased processing time. Use recommended DPI values and reasonable max dimensions.
- Expiration Too Low or High: The expiration value must be between 1 and 10080 minutes. Values outside this range will cause errors.