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 "Find And Replace Text" allows users to search for specific text within a PDF document and replace it with new text. It supports multiple ways of providing the input PDF, including binary data from a previous node, a base64 encoded string, or a URL pointing to the PDF file.

Common scenarios where this node is beneficial include:

  • Automatically updating contract terms or dates in PDF documents.
  • Correcting typos or outdated information in PDFs without manual editing.
  • Customizing PDF templates by replacing placeholder text dynamically.
  • Batch processing PDFs to update branding or contact details.

For example, you could use this node to replace all instances of "Company A" with "Company B" in a set of PDF contracts fetched from URLs or uploaded as binary data.

Properties

Name Meaning
PDF Input Data Type Choose how to provide the PDF file. Options:
• Binary Data (from previous node)
• Base64 String (provide PDF content as base64 encoded string)
• URL (provide URL to PDF file)
PDF Binary Field Name of the binary property that contains the PDF file. Used only if "PDF Input Data Type" is "Binary Data".
PDF Base64 Content Base64 encoded PDF content. Used only if "PDF Input Data Type" is "Base64 String".
PDF URL URL to the PDF file. Used only if "PDF Input Data Type" is "URL".
Old Text The text string to be searched for and replaced in the PDF document.
New Text The text string that will replace the old text in the PDF document.
Page Sequence Optional specification of which pages to process. Accepts comma-separated page indices or ranges (e.g., "0, 1, 2-" means pages 0, 1, and from 2 to the end). Leave empty to process all pages.
Output File Name The desired filename for the output PDF after text replacement. Defaults to "find_and_replace_output.pdf".
Async Boolean flag to enable asynchronous processing. Defaults to true.

Output

The node outputs JSON data representing the processed PDF file with the specified text replaced. The output includes the modified PDF content, typically as binary data suitable for further processing or saving.

If the node supports binary output, the binary data corresponds to the updated PDF file after the find-and-replace operation.

Dependencies

  • Requires access to the PDF file either via binary data input, base64 string, or URL.
  • Likely depends on an external PDF processing service or library capable of performing text search and replacement inside PDFs.
  • Requires proper API authentication configured in n8n to interact with the PDF processing backend.
  • Network access is needed if using URL input type or if the processing service is remote.

Troubleshooting

  • Issue: PDF not found or inaccessible when using URL input.
    Resolution: Verify the URL is correct, publicly accessible, and does not require authentication.

  • Issue: No changes appear in the output PDF after running the node.
    Resolution: Confirm that the "Old Text" exactly matches the text in the PDF, including case and whitespace. Also check the "Page Sequence" to ensure the relevant pages are included.

  • Issue: Node throws errors related to invalid PDF format or corrupted input.
    Resolution: Ensure the input PDF is valid and correctly provided according to the selected input type (binary, base64, or URL).

  • Issue: Processing takes too long or times out.
    Resolution: Try enabling or disabling the "Async" option depending on your workflow needs. Also verify network connectivity and service availability.

Links and References

Discussion