Skip to main content

Find and Replace Text

Find & SearchFind and Replace Text

The Find and Replace Text API finds and replaces text in a PDF. You send the PDF as Base64 (docContent), docName, oldText (text to find), newText (replacement), pageSequence (e.g. 1, 1-3, 1,3,5, 1-), and optionally async. The API returns the PDF with the specified text replaced on the target pages. Use the tester below to try it; more details are in the sections that follow.

Try the Find and Replace Text API

Quick reference

Endpoint: POST /api/v2/FindAndReplace · Required: api-key, docContent, docName, oldText, newText, pageSequence

Try it live

Use the form below to send your API key, PDF (Base64), text to find, replacement text, and page range. The response is the PDF with text replaced. No code required—fill the fields and click Send request.

Loading API Tester...

Overview, parameters, and use cases

What is Find and Replace Text?

This endpoint finds specific text in a PDF and replaces it with new content on the pages you choose. You provide oldText (exact text to find), newText (replacement), and pageSequence (e.g. 1, 1-3, 1,3,5, 1- for all from page 1). The API returns the PDF with the replacements applied. Use it to correct typos, update names, dates, or placeholders across selected pages.

Key features

  • Exact matcholdText is the exact string to find (case-sensitive).
  • ReplacementnewText is the string to insert in place of oldText.
  • Page targetingpageSequence: 1 (single page), 1-3 (range), 1,3,5 (specific pages), 1- (from page 1 to end).
  • Async – Use async for large PDFs or many replacements.
Best for

Use when you need to correct or update specific text in a PDF (typos, names, dates). For pattern-based extraction use Extract Text by Expression; for replacing text with an image use Replace Text with Image.

Prerequisites

Before using this endpoint, make sure you have:

  • A valid PDF4me API key (Get your API Key)
  • A PDF document in Base64 format or a public URL to a PDF file

Response Format

The API returns a PDF document with the specified text replaced on the target pages.

Get Help