Skip to main content

Find and Replace Text - Content Editor API

PDF4me Find and Replace Text enables you to find and replace specific text patterns in PDF documents. This API service processes PDF files and searches for text to replace with new content on specified pages. The API receives PDF content and replacement parameters through REST API calls, utilizing Base64 encoding for secure transmission. With support for flexible page targeting and text pattern matching, this solution is ideal for document updates and content management workflows.

Authenticating Your API Request

To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.

Key Features

  • Text Pattern Matching: Find and replace specific text patterns in PDF documents
  • Flexible Page Targeting: Process specific pages or entire documents with custom page sequences
  • Page Sequence Support: Target individual pages, page ranges, or mixed page selections
  • Base64 Encoding: Secure file content transmission using Base64 encoding
  • Simple API Integration: RESTful API designed for automated PDF text editing workflows

REST API Endpoint

The PDF4me REST API uses standard HTTP methods to interact with resources. All text find and replace operations are performed through a single endpoint:

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

REST API Parameters

Complete list of parameters for the Find and Replace Text REST API. Parameters are organized by category for better understanding and implementation.

Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.

Required Parameters

ParameterTypeDescriptionExample
docContent*Base64The content of the input PDF file encoded in Base64JVBERi...
docName*StringSource PDF file name with .pdf extensionoutput.pdf
oldText*StringText to be searched and replacedThis is some
newText*StringText to replace withHere is few
pageSequence*StringPage options: "1" for page 1, "1,3,5" for specific pages, "2-5" for page range, "1,3,7-10" for mixed, "1-" for pages from 1 to end1

Optional Parameters

ParameterTypeDescriptionExample
asyncBooleanEnable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location headertrue

Output

The PDF4me Find and Replace Text REST API returns different responses based on the processing mode. The API returns the PDF as binary data for synchronous processing or provides a polling URL for asynchronous processing.

Synchronous Processing (Default)

When async is not set or set to false, the API processes the request immediately:

Status Code: 200 OK

Content-Type: application/pdf or application/octet-stream

Response Body:

The API returns the PDF file directly as binary data (not JSON).

How to Use:

  1. The response body contains the binary PDF data
  2. Save the response content directly as a PDF file
  3. No Base64 decoding is needed for binary responses

Example (JavaScript):

const response = await fetch(url, options);
const pdfBlob = await response.blob();
// Save or process pdfBlob directly

Request Example

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Note: The API key must be Base64 encoded. Get your API key from the PDF4me Dashboard

Payload

{
"docContent": "JVBERi...",
"docName": "output.pdf",
"oldText": "input_old_text",
"newText": "output_new_text",
"pageSequence": "1"
}

Code Samples

The PDF4me Find and Replace Text REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:

C# (CSharp) Sample

Complete C# implementation for finding and replacing text in PDF:

Text Replacement Features

Text Pattern Processing

  • Exact Matching: Case-sensitive text pattern matching for precise identification
  • Pattern Recognition: Support for specific words, phrases, and text patterns
  • Custom Patterns: Flexible pattern creation for specific text replacement requirements
  • Professional Results: Reliable text replacement with accurate pattern matching
  • Advanced Processing: Support for complex text structures and formatting

Page Processing

  • Page Targeting: Replace text on specific pages or entire documents
  • Page Sequences: Support for custom page ranges and individual page selection
  • Flexible Processing: Process any combination of pages with precise control
  • Batch Processing: Handle multiple pages efficiently in single API calls
  • Professional Layout: Consistent text replacement across all target pages

Advanced Features

  • Text Analysis: Comprehensive text pattern analysis and identification
  • Content Management: Advanced content editing and text replacement options
  • Professional Editing: High-quality text replacement with clear visibility
  • Flexible Patterns: Support for any text pattern and replacement requirements

Industry Use Cases & Applications

Business & Enterprise Use Cases

  • Document Updates: Automatically update text content across multiple PDF documents
  • Content Management: Replace outdated information with current data in PDF files
  • Template Processing: Update placeholder text with actual content in document templates
  • Brand Management: Update company names, logos, and branding elements across PDFs

Get Help