Actions80
- Add Attachment To PDF
- Add Barcode To PDF
- Add Form Fields To PDF
- Add HTML Header Footer
- Add Image Stamp To PDF
- Add Image Watermark To Image
- Add Margin To PDF
- Add Page Number To PDF
- Add Text Stamp To PDF
- Add Text Watermark To Image
- AI-Invoice Parser
- AI-Process Contract
- AI-Process HealthCard
- Classify Document
- Compress Image
- Compress PDF
- Convert HTML To PDF
- Convert Image Format
- Convert JSON To Excel
- Convert Markdown To PDF
- Convert PDF To Editable PDF Using OCR
- Convert PDF To Excel
- Convert PDF To PowerPoint
- Convert PDF To Word
- Convert To PDF
- Convert URL to PDF
- Convert VISIO
- Convert Word to PDF Form
- Create Images From PDF
- Create PDF/A
- Create Swiss QR Bill
- Crop Image
- Delete Blank Pages From PDF
- Delete Unwanted Pages From PDF
- Disable Tracking Changes In Word
- Enable Tracking Changes In Word
- Extract Attachment From PDF
- Extract Form Data From PDF
- Extract Pages From PDF
- Extract Resources
- Extract Table From PDF
- Extract Text By Expression
- Extract Text From Word
- Fill PDF Form
- Find And Replace Text
- Flip Image
- Flatten PDF
- Generate Barcode
- Generate Document Single
- Generate Documents Multiple
- Get Document From Pdf4me
- Get Image Metadata
- Get PDF Metadata
- Get Tracking Changes In Word
- Image Extract Text
- Linearize PDF
- Merge Multiple PDFs
- Overlay PDFs
- Parse Document
- Protect PDF
- Read Barcode From Image
- Read Barcode From PDF
- Read SwissQR Code
- Remove EXIF Tags From Image
- Repair PDF Document
- Replace Text With Image
- Replace Text With Image In Word
- Resize Image
- Rotate Document
- Rotate Image
- Rotate Image By EXIF Data
- Rotate PDF Page
- Sign PDF
- Split PDF By Barcode
- Split PDF By Swiss QR
- Split PDF By Text
- Split PDF Regular
- Unlock PDF
- Update Hyperlinks Annotation
- Upload File To PDF4me
Overview
The node operation "Replace Text With Image" allows users to replace specific text occurrences within a PDF document with an image. This is useful in scenarios where you want to dynamically insert logos, signatures, or other images into predefined placeholders in PDF files. For example, replacing a placeholder text like "[SIGNATURE]" with an actual signature image on certain pages of a contract PDF.
This operation supports multiple ways to provide both the PDF and the replacement image: as binary data from previous nodes, base64 encoded strings, or URLs pointing to the files. Users can specify which pages to apply the replacement on, control the size of the inserted image, and define the output file name.
Properties
| Name | Meaning |
|---|---|
| PDF Input Data Type | How the PDF file is provided. Options: "Binary Data" (from previous node), "Base64 String" (base64 encoded content), or "URL" (link to PDF file). |
| PDF Binary Field | The name of the binary property containing the PDF file when using "Binary Data" input type. |
| PDF Base64 Content | Base64 encoded string of the PDF content when using "Base64 String" input type. |
| PDF URL | URL to the PDF file when using "URL" input type. |
| Image Input Data Type | How the replacement image is provided. Options: "Binary Data" (from previous node), "Base64 String" (base64 encoded content), or "URL" (link to image file). |
| Image Binary Field | The name of the binary property containing the image file when using "Binary Data" input type. |
| Image Base64 Content | Base64 encoded string of the image content when using "Base64 String" input type. |
| Image URL | URL to the image file when using "URL" input type. |
| Text to Replace | The exact text string in the PDF that should be replaced by the image. |
| Page Sequence | Specifies which pages to apply the replacement on. Can be "all", a single page number (e.g., "1"), a list of pages (e.g., "1,3,5"), or a range (e.g., "2-5"). |
| Image Height | Height of the replacement image in the PDF (integer value). |
| Image Width | Width of the replacement image in the PDF (integer value). |
| Output File Name | Desired file name for the resulting PDF after replacement. |
| Async | Boolean flag to enable asynchronous processing. |
| Binary Data Output Name | Custom name for the binary data field in the node's output. |
Output
The node outputs the modified PDF file with the specified text replaced by the image. The output is provided as binary data under a customizable binary property name (default is "data"). The JSON output contains metadata about the processed item, but the main content is the updated PDF binary data ready for further use or download.
If the node supports asynchronous processing, the output will still contain the final PDF once processing completes.
Dependencies
- Requires access to the PDF file and the replacement image either via binary data, base64 strings, or URLs.
- May require internet access if URLs are used to fetch PDF or image files.
- No explicit external API keys or credentials are indicated in the code snippet; however, depending on the environment, network permissions may be necessary.
- The node relies on internal PDF processing libraries bundled within the node's dependencies.
Troubleshooting
Common Issues:
- Providing incorrect binary property names for PDF or image data will cause failures in reading the input files.
- Invalid base64 strings or inaccessible URLs will result in errors fetching or decoding the files.
- Specifying a "Text to Replace" string that does not exist in the PDF will result in no changes to the document.
- Incorrect page sequences (e.g., invalid page numbers or formats) may cause the replacement to fail or be skipped.
Error Messages:
- Errors related to file reading or decoding usually indicate issues with input data types or content.
- Network errors when using URLs suggest connectivity problems or invalid URLs.
- If the node throws errors about missing parameters, verify all required fields are correctly set according to the selected input data types.
Resolutions:
- Double-check the binary property names match those from previous nodes.
- Validate base64 strings before input.
- Ensure URLs are accessible and point directly to valid PDF/image files.
- Confirm the "Text to Replace" exists exactly as typed in the PDF.
- Use correct page sequence syntax.
Links and References
- PDF4me Documentation
- n8n Documentation on Binary Data Handling
- Base64 Encoding Reference
- PDF Text Replacement Concepts (Adobe PDF specification)