Find and Replace Text
Find & Search → Find 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
Endpoint: POST /api/v2/FindAndReplace · Required: api-key, docContent, docName, oldText, newText, pageSequence
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.
Overview, parameters, and use cases
- Overview
- Parameters
- 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 match – oldText is the exact string to find (case-sensitive).
- Replacement – newText is the string to insert in place of oldText.
- Page targeting – pageSequence: 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.
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.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| docContent | base64 | Yes | PDF file content (Base64). |
| docName | string | Yes | PDF file name with .pdf extension. |
| oldText | string | Yes | Exact text to find and replace. |
| newText | string | Yes | Replacement text. |
| pageSequence | string | Yes | Page range: 1, 1-3, 1,3,5, 1,3,7-10, 1-. |
| async | boolean | No | Enable asynchronous processing. |
When to use Find and Replace Text
- Corrections – Fix typos, names, or dates in a PDF.
- Templates – Replace placeholders (e.g. {{name}}, {{date}}) with actual values.
- Bulk updates – Update the same text across many pages (e.g. version numbers, company name).
- Redaction – Replace sensitive text with a fixed string (e.g. "[REDACTED]").
For request/response schemas and code samples, see Find and Replace Text in the PDF4me API docs.
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.