How to find the source bytes behind text in a PDF
By Anton Samper · Reviewed
This invoice shows the payment reference INV-2048. Search its page text for “reference”, find the match on the rendered page, then follow it to the bytes that draw it. The PDF stores the word in two pieces inside a compressed content stream.
Open this exampleDownload sample PDF
1. Search the page text
Open the example and press Ctrl/Cmd+K. Choose Page text in the search menu, enter reference, and run the search. The results show 1 page with 1 text match. Page text search reads the words the page displays, so it finds the match even though the file never stores them as one string.

2. Find the match on the page
Select Open page preview. The preview highlights the word on the rendered page. This highlight comes from the renderer, so it shows where the word appears, not which bytes draw it.
3. Show the bytes
Back in the results, select Show bytes. The inspector opens the page's content stream, 4 0 R, and highlights refer and ence in the Decoded bytes view. The status line reports 9 bytes selected in 2 ranges. The stream is Flate-compressed, so these offsets are within the decoded stream. Switch to Original bytes and only the containing stream is highlighted: compressed bytes do not contain readable letters.
4. Read the instruction
Open Decoded → Decoded byte text for stream 4 0 R. The line is written as:
BT /F1 20 Tf 72 600 Td [(Payment refer) 12 (ence: INV-2048)] TJ ETTJ draws an array of strings and spacing numbers. Here the word is cut in two, with the number 12 between the pieces to adjust the gap. A Decoded streams search for reference finds nothing, because the bytes read refer) 12 (ence. Page text search joins the pieces; the highlighted ranges leave out the parenthesis, the number and the operator.
5. Inspect the character codes
In the hex view, the first highlighted range is 72 65 66 65 72 (refer) and the second is 65 6E 63 65 (ence). Each letter is one byte, because the sample's Helvetica font uses WinAnsi encoding and the string stores character codes directly. Other fonts may store glyph codes that only the font's /ToUnicode map turns into text. The incorrect text example shows what happens when that map is wrong.
When the bytes cannot be found
Page text search can find a word that the byte mapper cannot trace. Text with unsupported font encodings or inside a Form XObject is labelled as a candidate stream, with no word bytes highlighted. Repeated phrases can have several source locations, and a location is a candidate rather than a proof of which occurrence it draws. See the search guide for causes and what to check next, and limitations for supported fonts. PDF Internals does not run OCR, so scanned pages without a text layer have nothing to search.