API V2

Find and Replace Text

Automatically find and replace text in PDF documents using the PDF4me Find and Replace Text API. This powerful tool enables you to search for specific text patterns and replace them with new content across your PDF files. Perfect for document updates, content management, and automated text processing workflows. You can specify which pages to process, making it ideal for targeted text replacements in large documents.

  • Method: POST
  • Endpoint: /api/v2/FindAndReplace

Parameters

File Contentbase64, Required

The content of the input file

File Namestring, Required

Source PDF file name with .pdf extension

Old Textstring, Required

The text pattern to search for in the PDF document. This can be a specific word, phrase, or text pattern that you want to replace. The search is case-sensitive and will find exact matches.

Example:input_old_text

New Textstring, Required

The replacement text that will substitute the found text pattern. This is the new content that will replace all instances of the old text found in the PDF document.

Example:output_new_text

Pagesstring, Required

Specify which pages to process for text replacement. You can target specific pages or page ranges to optimize performance and focus on relevant content.

Format Options:

  • Individual pages: "1, 3, 5"
  • Page ranges: "1-5, 10-15"
  • Mixed format: "1, 3-7, 10"
  • All pages: Leave empty (default behavior)

Note: Page indices start from 1. Input must be in string format.

Output

File ContentBinary, Required

Output file content from the PDF4me Connect

Header
Content-Type:application/json
Authorization: Please copy key from the link.

Payload

{
  "docContent": "Please put PDF base64 content",
  "docName": "output.pdf",
  "oldText": "input_old_text",
  "newText": "output_new_text",
  "pageSequence": "1"
}

PDF4me API Code Samples

CSharp(C#)
Java
JavaScript
Python
Salesforce
n8n
Google Script
AWS Lambda