Garbled Text in Searchable PDFs for Non-Latin Scripts

OCR a document with IronOCR, save it as a searchable PDF, and the recognized text can look correct on screen yet turn to nonsense when you copy or extract it. This happens when the PDF's font has no glyphs for the script you recognized, and it is common with non-Latin and complex scripts. The fix is to save the PDF with a font that supports your script; the example below uses Gujarati.

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 resolve this: the font you supply has to cover the script you actually recognized.

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.

Please noteRequires IronOCR version 2026.3.3 or later.

Solution

1. Place a Font That Covers Your Script

Find a font that includes glyphs for your target script, put it on the machine, and note 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 to SaveAsSearchablePdf

When saving the searchable PDF, supply the path to your script-capable font as the CustomFontFile (3rd) argument. The 4th argument is an optional CustomFontName label; if you omit it, IronOCR uses the font file's own name:

ocrResult.SaveAsSearchablePdf(
    strOutputFile,
    false,
    @"C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf",
    "AnekGujarati");
ocrResult.SaveAsSearchablePdf(
    strOutputFile,
    false,
    @"C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf",
    "AnekGujarati");
ocrResult.SaveAsSearchablePdf( _
    strOutputFile, _
    False, _
    "C:\Path\To\AnekGujarati-VariableFont_wdth,wght.ttf", _
    "AnekGujarati")
$vbLabelText   $csharpLabel

The argument that fixes garbled extraction is the font file (3rd parameter): it must contain glyphs for the script you OCR'd. The 4th parameter only names the embedded font and does not affect script mapping. For a different document, point the 3rd parameter to a font that supports that script.

3. Confirm the Text Extracts

Open the generated PDF and copy the recognized text to verify it now extracts correctly. If it still appears garbled, the supplied font almost certainly lacks glyphs for your script; recheck that the font genuinely covers it.

Notes

  • Not specific to Gujarati: any non-Latin or complex script can show garbled copied text when the PDF font does not cover it, including Devanagari (Hindi, Marathi), Arabic, Thai, and Chinese, Japanese, or Korean text.
  • One font per script: supply a font that includes the script you recognized. The Noto family from Google is a broad option, with per-script fonts such as Noto Sans Gujarati, Noto Sans Devanagari, and Noto Sans Arabic.
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 6,125,430 | Version: 2026.7 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package IronOcr
run a sample watch your image become searchable text.