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, 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

Discussion