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. Users can specify which pages to process by defining page sequences or leave it empty to process all pages. The output is a modified PDF file with the specified text replaced.

This operation is beneficial in scenarios such as:

  • Automatically updating contract terms or dates in PDF documents.
  • Correcting typos or outdated information in bulk PDF files.
  • Customizing PDF templates by replacing placeholder text dynamically.

Practical example: A user receives invoices as PDFs and wants to update the company name on all pages before sending them out. They can use this node to find the old company name and replace it with the new one across selected pages or the entire document.

Properties

Name Meaning
PDF Input Data Type Choose how to provide the PDF file: Binary Data (from previous node), Base64 String, or URL to PDF file.
PDF Binary Field Name of the binary property containing the PDF file (used if input type is Binary Data).
PDF Base64 Content Base64 encoded content of the PDF (used if input type is Base64 String).
PDF URL URL pointing to the PDF file (used if input type is URL).
Old Text The text string to search for inside the PDF that will be replaced.
New Text The text string that will replace the old text in the PDF.
Page Sequence Comma-separated list or ranges of page indices to process (e.g., "1, 2, 3-7"). Leave empty for all pages.
Output File Name Desired filename for the output PDF after text replacement.
Async Enable asynchronous processing (true/false).
Binary Data Output Name Custom name for the binary data field in the node's output containing the updated PDF.

Output

The node outputs the modified PDF file with the specified text replaced. The output contains a binary data field (default named "data" or custom named via "Binary Data Output Name") holding the updated PDF file content. This binary data can be used downstream in workflows for saving, emailing, or further processing.

The JSON output typically includes metadata about the operation and references to the binary data but primarily focuses on delivering the updated PDF content.

Dependencies

  • Requires access to the PDF file either as binary data, base64 string, or accessible URL.
  • Likely depends on an external PDF processing service or library capable of parsing and modifying PDF content.
  • May require an API key or authentication token configured in n8n credentials to interact with the PDF processing backend (not explicitly shown in code).
  • Network access is needed if using URL input type or asynchronous processing.

Troubleshooting

  • Common issues:

    • Providing incorrect or inaccessible PDF URLs will cause failures in fetching the PDF.
    • Incorrect binary property names may result in missing input data errors.
    • Specifying invalid page sequences (e.g., out-of-range pages) might lead to partial or no replacements.
    • Large PDFs or complex documents may cause timeouts or performance delays, especially if async is disabled.
  • Error messages and resolutions:

    • "PDF file not found or inaccessible": Verify the binary property name or URL correctness and accessibility.
    • "Text to replace not found": Confirm the exact old text matches the PDF content; consider case sensitivity.
    • "Invalid page sequence": Ensure page indices are valid numbers and ranges within the document's page count.
    • Timeout or processing errors: Enable asynchronous processing or split large PDFs into smaller chunks.

Links and References

Discussion