Overview
This node edits an existing PDF file by adding custom text at specified coordinates on a chosen page. It is useful when you need to annotate or stamp PDFs dynamically, such as adding signatures, comments, or labels without manually editing the document.
Practical examples include:
- Adding a date or approval stamp to a contract PDF.
- Inserting a note or comment on a specific page of a report.
- Marking a PDF with a custom identifier or code at precise locations.
Properties
| Name | Meaning |
|---|---|
| PDF File URL | URL pointing to the PDF file that will be edited. |
| Text | The text string to add onto the PDF. |
| Page Number | The zero-based index of the page where the text will be added (0 = first page). |
| X Coordinate | The horizontal position (in PDF units) where the text will start on the specified page. |
| Y Coordinate | The vertical position (in PDF units) where the text will start on the specified page. |
Output
The node outputs a JSON object with one field:
editedPdf: A base64-encoded data URI string representing the modified PDF file with the added text. This can be used directly for download, further processing, or storage.
No binary output is produced; the PDF content is embedded as a base64 string in the JSON output.
Dependencies
- The node requires internet access to fetch the PDF from the provided URL.
- It uses the
pdf-liblibrary to load and modify the PDF document. - It uses
node-fetchto retrieve the PDF file from the given URL.
No special API keys or credentials are required beyond access to the PDF URL.
Troubleshooting
- Invalid PDF URL or inaccessible file: If the URL is incorrect or the file cannot be fetched, the node will fail. Ensure the URL is publicly accessible or reachable from the n8n environment.
- Page number out of range: Specifying a page number that does not exist in the PDF will cause an error. Verify the page count before setting this parameter.
- Coordinates outside page bounds: Placing text outside the visible area may result in invisible text. Use coordinates within the page size.
- Large PDFs or slow network: Fetching and processing large PDFs might take time or cause timeouts.
Common error messages typically relate to fetching the PDF or invalid page references. To resolve, check URL accessibility and input parameters.
Links and References
- pdf-lib GitHub repository – Library used for PDF manipulation.
- node-fetch GitHub repository – Library used to fetch remote files.