Actions10
Overview
The node "PDF Tools" provides a variety of operations to manipulate PDF files within n8n workflows. It supports adding images or watermarks, deleting, extracting, reordering, rotating, splitting pages, merging multiple PDFs, reading metadata, and extracting text from PDFs.
For the Add Image operation specifically, the node allows users to add an image (PNG or JPEG) onto specified pages of an existing PDF. This is useful for stamping logos, signatures, or other graphics onto documents automatically.
Practical examples:
- Adding a company logo to all pages of a contract PDF.
- Stamping a signature image on specific pages of a report.
- Overlaying a QR code image on selected pages of a brochure.
Properties
| Name | Meaning |
|---|---|
| PDF Binary Field | Name of the binary field containing the PDF file to be processed. |
| Image Binary Field | Name of the binary field containing the image (PNG or JPEG) to add to the PDF. |
| Page Target | Target pages where the image will be added. Accepts single page ("1"), ranges ("1,3-5"), or "all". |
| Image Options | Collection of options controlling image placement and scaling: |
| - X Position: X coordinate for image placement (default 50). | |
| - Y Position: Y coordinate for image placement (default 400). | |
| - Scale: Scale factor for resizing the image (default 0.5). |
Output
The output contains the modified PDF as binary data in the binary property of the output item. The binary data includes:
data: Base64 encoded PDF content after the image has been added.fileName: The filename assigned to the output PDF (defaulted to "output.pdf").mimeType: Always"application/pdf"indicating the file type.
No additional JSON fields are returned for this operation; the main result is the updated PDF binary.
Dependencies
- Uses the
pdf-liblibrary for PDF manipulation. - Uses
n8n-workflowutilities for error handling. - Requires input PDFs and images to be provided as binary data fields in the workflow.
- No external API calls or services are required.
- The node expects valid PDF and image binary inputs with correct MIME types (
application/pdf,image/png,image/jpeg).
Troubleshooting
- Missing binary data: If the specified PDF or image binary field is not found in the input item, the node throws an error indicating the missing field.
- Invalid MIME types: The node validates that the PDF is indeed a PDF and the image is PNG or JPEG. Errors occur if unsupported formats are provided.
- Invalid page targets: Specifying pages outside the range of the PDF's page count results in an error.
- Empty image options: If no position or scale is provided, defaults are used (X=50, Y=400, scale=0.5).
- General errors: Any unexpected issues during PDF processing will throw errors logged in the node execution logs.
To resolve common errors:
- Ensure the binary fields exist and contain valid data.
- Confirm the MIME types match expected formats.
- Verify page numbers are within the document's page count.
- Use proper formatting for page target strings (e.g., "1", "1,3-5", "all").
Links and References
- pdf-lib GitHub repository – Library used for PDF manipulation.
- n8n Documentation – For general guidance on using custom nodes and binary data handling.