Why Urdu/Arabic text breaks when you edit a PDF

You opened a PDF to fix a quick typo in an Arabic or Urdu document. You typed the new word, and suddenly the letters are disconnected, reading left-to-right, and the whole paragraph is ruined. Sound familiar?

The core problem

The PDF format is not a word processor document; it is a fixed layout format. It doesn't store "paragraphs of text" like Microsoft Word does. It stores "draw this specific glyph at these exact X and Y coordinates."

Arabic, Persian, and Urdu use complex text shaping. The shape of a letter changes depending on its context (initial, medial, final, or isolated). When a PDF is created, the creator software calculates the exact shape and position of every letter and bakes it into the file.

When you try to edit that PDF later, most PDF editors simply insert the raw Unicode characters you typed. They lack a text shaping engine to convert those raw characters into the correct connected ligatures, and they often assume left-to-right ordering. The result is disconnected, backwards text.

The four ways it goes wrong

"It broke" usually turns out to be one of four distinct failures. Recognising which one you are looking at tells you whether it is fixable:

  1. Letters disconnect. Each character is drawn in its isolated form, so a word becomes a row of separate letters. The editor inserted raw Unicode without running it through a shaping engine.
  2. The word order reverses. The editor treated the text as left-to-right, so the last word of the sentence appears first. This is a missing bidirectional algorithm.
  3. Boxes or blanks appear. The embedded font is subset - PDF creators strip out every glyph the document does not use, to save space. If the original never contained the letter you just typed, that glyph is simply not in the file, and there is nothing to draw.
  4. The font changes mid-line. The editor gave up on the embedded font and fell back to a default one, so your correction is legible but visibly different from the text around it.

The third is the one people find most baffling, because the document clearly displays Urdu already. But a subset font embedded for a certificate may contain only the sixty or so glyphs that certificate used. Type a name it has never seen and the glyph does not exist. A capable editor detects this and embeds the missing glyphs; a careless one writes a character code that maps to nothing, or worse, to an unrelated glyph - which is how a space can come out as a letter.

Why it is harder than it looks

Shaping is not a lookup table. The correct glyph for a letter depends on what surrounds it, and in Nastaliq a whole word may collapse into a single ligature glyph that has no one-to-one relationship with the characters you typed. Going backwards - from glyphs on a page to the text they represent - is lossy, which is why copying Urdu out of a PDF so often produces nonsense even in readers that display it perfectly.

An editor therefore has to do three things at once: work out what the existing glyphs mean, shape your replacement text correctly for the font in use, and write it back at the right positions in the right direction - without disturbing the rest of the page.

How to fix it

To edit these PDFs properly, you need an editor with a built-in complex text layout (CTL) engine that understands right-to-left scripts and Arabic/Nastaliq shaping.

Editrix PDF was built specifically to solve this problem. It recalculates the glyph shaping in real-time as you type, ensuring that your Arabic or Urdu text remains perfectly connected and formatted.

For the step-by-step version, see how to edit Urdu text in a PDF on Android.