How to find and replace text in a PDF
Short answer: In a PDF with a text layer, find and replace searches the stored text and writes the new text in place of each match; "Replace All" does this for every match at once. A scanned page has no text layer, so there is nothing to find until it has been recognized. After replacing, check the font, missing characters and text that runs past its space.
Steps
- Check that the page has textTry to select a word with the text selection tool, or open the file in the PDF text layer checker. If no text can be selected or found, the page may be an image, and find and replace will not work on it. The free browser tools on this site can check and compare, but cannot replace text.
- Open the replace functionIn Adobe Acrobat Pro or Standard, open the PDF, choose the Edit a PDF tool, press Ctrl+F (Cmd+F on a Mac) and expand "Replace with". A free option is LibreOffice Draw: open the PDF and choose Edit › Find & Replace (Ctrl+H). Menu names can differ between versions.
- Search before replacingEnter the old and the new text, then step through the matches with "Next" so you know which places will change.
- Replace one, then the restReplace the first match and zoom in on it. If the font, size and position look right, replace the remaining matches: Acrobat replaces one match at a time; LibreOffice Draw also offers "Replace All".
- Check and save a copySearch for the old text again to confirm that no match is left, look at the replaced places, and save the result as a new file (in LibreOffice Draw: File › Export as PDF) so the original stays unchanged.
How find and replace works in a PDF with a text layer
Find and replace in a PDF works on the text layer: the characters the file stores, each placed at a position on the page in a given font. Search compares what you type with these stored characters. Replace removes the matched characters and writes the new ones at the same position, and “Replace All” repeats this for every match in the document.
Unlike a Word document, a PDF page has no paragraph flow, so the rest of the line usually does not move to make room. The background is explained in Why you cannot find and replace in a PDF the way you do in Word.
Some matches are missed even when the text is there:
- a word split across a line break or a hyphen;
- a word stored as several separate text fragments;
- letter case or whole-word options that exclude the match;
- characters stored as ligatures, such as “fi” written as one glyph.
Programs that can do it today
The browser tools on this site cannot replace text. They can help around the edit: the PDF text layer checker tells you whether there is text to replace, and Compare PDF text shows afterwards which words changed. For the replacement itself you need a desktop editor, for example:
- Adobe Acrobat Pro (paid subscription, free trial available): open the file, choose Edit a PDF, press Ctrl+F (Cmd+F on a Mac) and expand Replace with. Enter the new text and use Replace for one match at a time. It edits the text in place. To keep the original font, that font usually has to be installed on your computer: a font that is only embedded in the PDF allows just limited changes, such as colour or size, so for new text you pick an installed font that matches. Compare the replaced text with the text around it. The free Acrobat Reader cannot edit text.
- LibreOffice Draw (free): open the PDF with Draw, choose Edit › Find & Replace (Ctrl+H), then save the result with File › Export as PDF. Draw imports every line as a separate text box and uses fonts installed on your computer, so the layout and fonts often change; it suits simple documents and drafts better than final copies.
Plain find and replace in either program does not change words that are part of an image, such as a scanned page. Acrobat Pro can, however, run text recognition (OCR) on a scanned page when you open it with Edit a PDF and turn the page into editable text; if this does not happen, turn on text recognition in the Edit a PDF settings. Then edit the words and compare the result with the original scan, because recognition and the font Acrobat chooses can both be wrong.
Why it fails on scanned pages
A scanned page is an image, so search on it returns no matches at all. Before you look for a fix, check whether the file has a text layer with the PDF text layer checker. A result of “no text found” means no text could be read from the file; it does not by itself prove that the file is a scan.
Some scans already carry an invisible recognized text layer. Search then finds the words, but replacing them changes only the invisible text: the visible image still shows the old word. Changing a scan means either recognizing the page and laying it out again, or changing the image itself. The two approaches are compared in Full-page OCR reflow vs in-place correction.
What to check after replacing
Check every replaced place after “Replace All”, because the editor reports how many matches it replaced, not how they look.
- Substitute font: the new text may appear in another font or weight than the words around it.
- Missing characters: PDFs often embed only the characters they use. A new character that is not in the embedded font may show as a blank or a box, or the editor may refuse the replacement.
- Overflow: longer new text can run into the next word or past the edge of a table cell; shorter text can leave a gap.
- Leftovers: search for the old text again. Headers, footers, form fields, bookmarks and document properties may not be included in the search.
- Copy test: select the new text and paste it into a text editor to confirm it was written as text.
Save the result as a new file and keep the original until you have finished checking.
Many files
Find and replace inside one PDF works on one open document at a time. For changing the same words across many files, see Find and replace text in multiple PDFs.
FAQ
Why does search find nothing in my PDF?
Usually the page is a scan or another image with no text layer. Less often, the text layer stores characters in an unusual encoding, so what you type does not match what is stored. The PDF text layer checker shows whether any text can be read from the file.
Does replacing keep the original font?
Not always. Editors usually need the font installed on the computer to write new text with it; an embedded font may be a subset that lacks the new characters. Otherwise another font is used. Compare each replaced line with the text around it.
Does find and replace change text inside images?
No. Find and replace works on the text layer. Words that are part of an image, such as a scanned page, a logo or a screenshot, are not searched.