Free plan

Find and replace text in a PDF

Find a word in a PDF and write another word in its place
POST
/v1/pdfs/replace-text

About this tool

This tool finds text in a PDF and writes new text over it. The old text is covered with a patch in the paper colour, and the new text is drawn in a standard font, made smaller if it does not fit. The PDF needs real text, not just a scan. By default the changed pages become pictures, so the old words are really gone. Results may not match the original font.
For example, your company changed its name and you replace the old name with the new one on every page of a price list.

How to use it

  1. Choose this tool.
  2. Add your PDF.
  3. Type the text to find and the text to put in its place, or add several pairs.
  4. Choose options such as which pages, matching upper and lower case, whole words only, and the font and colour of the new text.
  5. Press Generate, then download the new PDF.

What you get back

You get a new PDF with the replacements made, ready to download. Look it over, since the new text may look slightly different from the old.
GOOD TO KNOW
This is a patch, not a real edit of the text flow: layout does not reflow, the new text uses a standard Latin font, and a page with no text layer has nothing to find. With remove_original=false the old text is still in the file. Counts as one PDF operation.
TEST IT LIVE

Try Find and replace text in a PDF in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
PDFs
Plan
Free
Method
POST
Endpoint
/v1/pdfs/replace-text
Tool ID
pdfs.replace-text
Authentication
API key
Accepts
PDF
Background jobs
Yes
Usage group
Pdf
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/pdfs/replace-text" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'find=Acme Ltd' \
  -F 'replace=Acme Inc' \
  -F 'rules=[{"find":"2025","replace":"2026"}]'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.pdfs.replaceText({
    "file": 'document.pdf',
    "find": "Acme Ltd",
    "replace": "Acme Inc",
    "rules": "[{\"find\":\"2025\",\"replace\":\"2026\"}]"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->pdfs()->replaceText([
    'file' => 'document.pdf',
    'find' => 'Acme Ltd',
    'replace' => 'Acme Inc',
    'rules' => '[{"find":"2025","replace":"2026"}]',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Find text in a PDF and write other text in its place: each found run is covered with a patch of the paper colour and the new text is drawn over it in a standard font, shrunk to fit. By default the changed pages are drawn as pictures so the old text is gone from the file.

Find and replace text in a PDF accepts PDF. You can send several files in one request.

Find and replace text in a PDF is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/pdfs/replace-text with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.