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

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, stamps, or any graphical content in place of certain text placeholders inside PDFs.

Practical examples include:

  • Replacing a placeholder text like "[SIGNATURE]" with an actual signature image on contract documents.
  • Inserting company logos in place of text tags in marketing brochures.
  • Adding watermarks or stamps by replacing designated text markers.

This operation supports flexible input methods for both the PDF and the replacement image, including binary data from previous nodes, base64 encoded strings, or URLs.

Properties

Name Meaning
PDF Input Data Type How the PDF file is provided:
- Binary Data (from previous node)
- Base64 String (encoded PDF content)
- URL (link to PDF file)
PDF Binary Field Name of the binary property containing the PDF file (used if PDF Input Data Type is Binary Data)
PDF Base64 Content Base64 encoded string of the PDF content (used if PDF Input Data Type is Base64 String)
PDF URL URL to the PDF file (used if PDF Input Data Type is URL)
Image Input Data Type How the replacement image is provided:
- Binary Data (from previous node)
- Base64 String (encoded image content)
- URL (link to image file)
Image Binary Field Name of the binary property containing the image file (used if Image Input Data Type is Binary Data)
Image Base64 Content Base64 encoded string of the image content (used if Image Input Data Type is Base64 String)
Image URL URL to the image file (used if Image Input Data Type is URL)
Text to Replace The exact text string in the PDF that should be replaced with 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 a range (e.g., "2-5")
Image Height Height of the replacement image in pixels (integer)
Image Width Width of the replacement image in pixels (integer)
Output File Name Desired filename for the output PDF after replacement (e.g., "my-replaced-pdf.pdf")
Async Whether to enable asynchronous processing (true/false)
Binary Data Output Name Custom name for the binary data field in the node's output (default is "data")

Output

The node outputs the modified PDF as binary data under the specified binary data output name (default "data"). The output JSON contains metadata about the processed file, and the binary data holds the updated PDF content with the specified text replaced by the image.

If asynchronous processing is enabled, the node handles the operation accordingly but ultimately returns the updated PDF binary data.

Dependencies

  • Requires access to the PDF and image files either via binary data from previous nodes, base64 encoded strings, or accessible URLs.
  • No explicit external API keys or services are mentioned; the operation appears to be handled internally or via bundled dependencies.
  • Proper configuration of input data fields is necessary to ensure correct file retrieval.

Troubleshooting

  • Common Issues:

    • Incorrect or missing binary property names when using binary data inputs can cause failures in reading the PDF or image.
    • Invalid base64 strings or inaccessible URLs will prevent loading the PDF or image.
    • Specifying a text to replace that does not exist in the PDF will result in no changes.
    • Improper page sequence format may cause the replacement to be skipped or applied incorrectly.
  • Error Messages:

    • Errors related to file loading usually indicate issues with input data type or source.
    • If the node throws errors about missing parameters, verify all required properties are set according to the selected input types.
    • Timeout or async-related errors might occur if asynchronous processing is enabled but the environment does not support it properly.
  • Resolutions:

    • Double-check the binary property names and ensure the previous node outputs the expected binary data.
    • Validate base64 strings and URLs before running the workflow.
    • Confirm the text to replace exactly matches the target text in the PDF, including case and whitespace.
    • Use correct page sequence syntax as described.

Links and References

Discussion