PDF4me icon

PDF4me

Comprehensive PDF and document processing: generate barcodes, convert files, extract data, manipulate images, and automate workflows with the PDF4ME API

Actions80

Overview

This node operation "Replace Text With Image" allows users to replace specific text occurrences within a PDF document with an image. It is useful in scenarios where you want to dynamically insert logos, signatures, stamps, or any graphical content in place of certain text placeholders inside PDFs. For example, replacing the word "SIGN_HERE" with a signature image on contract documents, or substituting a placeholder text with a company logo on invoices.

Properties

Name Meaning
PDF Input Data Type How the input PDF file is provided. Options: Binary Data (from previous node), Base64 String (encoded PDF 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 pointing 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 (encoded image 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 pointing 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"), multiple pages separated by commas (e.g., "1,3,5"), or ranges (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 filename for the output PDF after replacement. Defaults to "replace_text_with_image.pdf".
Async Boolean flag to enable asynchronous processing. When true, the operation may run asynchronously depending on backend support.

Output

The node outputs a JSON object containing the modified PDF file with the specified text replaced by the image. The PDF is typically returned as binary data attached to the output item, ready for further use or saving. The output includes the updated PDF content reflecting the replacements made.

If the node supports binary output, the binary data represents the new PDF file with images replacing the specified text.

Dependencies

  • Requires access to the PDF processing service or API capable of performing text-to-image replacement.
  • Needs proper authentication via an API key or token configured in n8n credentials.
  • Internet access if URLs are used for PDF or image inputs.
  • The node depends on the bundled action module responsible for "Replace Text With Image" functionality.

Troubleshooting

  • Common Issues:

    • Incorrect text string in "Text to Replace" property may result in no replacements.
    • Invalid or inaccessible URLs for PDF or image inputs can cause failures.
    • Mismatched binary property names will lead to missing input files.
    • Specifying invalid page sequences might cause errors or no changes.
    • Image dimensions too large or zero may produce unexpected results.
  • Error Messages and Resolutions:

    • "Input PDF not found" — Verify the PDF input source and binary field name.
    • "Image data invalid or missing" — Check the image input type and ensure correct data is provided.
    • "Text to replace not found in PDF" — Confirm the exact text exists in the PDF and matches case and spacing.
    • "Page sequence format invalid" — Use correct syntax like "all", "1", "1,3,5", or "2-5".
    • Timeout or async processing errors — Try disabling async or check network connectivity.

Links and References

Discussion