Garbled Copied Text from IronOCR Searchable PDFs
OCR a document with IronOCR and save it as a searchable PDF, and the recognized text can look correct on screen yet turn into garbled characters when you copy or extract it. This happens when the font used by the PDF has no glyphs for the script you recognized, which is common with non-Latin and complex scripts. Save the PDF with a font that supports your script to fix it; the example below uses Gujarati.
The font in the searchable PDF must contain glyphs for the recognized script. When it does not, the recognized text has no matching characters to map to, so copied text comes out garbled even though OCR read the page correctly. A Latin-only font will not fix this, and the font you supply has to support the script you recognized.
Minimum version: 2026.3.3.
Prerequisites
- IronOCR with the language pack for your script; this example uses
OcrLanguage.GujaratiBest. - A TrueType font that supports your target script; this example uses AnekGujarati, freely available from Google Fonts.
- The full file path to that font.
Solution
1. Place the font and note its path
Find a font that covers your target script, put it on the machine, and record its full path. For the Gujarati example:
C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf
The AnekGujarati variable-font filename contains a comma, so copy it precisely; the path must point to the exact font file.
2. Pass the font and language to SaveAsSearchablePdf()
When saving the searchable PDF, give the font path and the language name to SaveAsSearchablePdf():
ocrResult.SaveAsSearchablePdf(
strOutputFile,
false,
@"C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf",
"Gujarati");
ocrResult.SaveAsSearchablePdf(
strOutputFile,
false,
@"C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf",
"Gujarati");
ocrResult.SaveAsSearchablePdf( _
strOutputFile, _
False, _
"C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf", _
"Gujarati")
The language name you pass here must match the script you actually OCR'd.
3. Adapt the values for your own document
Replace the font path and language name with the values for your document. For a different language, point to a font that supports that script and pass the matching language name.
4. Verify the extracted text
Open the generated PDF and copy the text to confirm it now extracts correctly. If it still appears garbled after this change, confirm the supplied font genuinely includes glyphs for your script.
Notes and Limitations
- Not specific to Gujarati: any non-Latin or complex script can show garbled copied text when the PDF font does not cover it. Examples include Devanagari (Hindi, Marathi), Arabic, Thai, and Chinese, Japanese, or Korean text.
- Per-script fonts: supply a font that includes the script you recognized. The Noto font family from Google is a broad option, with per-script fonts such as
Noto Sans Gujarati,Noto Sans Devanagari, andNoto Sans Arabic.

