# Any idea what is wrong with this PDF?

**URL:** <https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47>\
**Category:** PyMuPDF\
**Created:** [July 9, 2025, 1:01pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47 "2025-07-09T13:01:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamie\_Lemon](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/jamie_lemon/32/5_2.png) [@Jamie\_Lemon](https://forum.mupdf.com/u/Jamie_Lemon)\
**Post date:** [July 9, 2025, 1:01pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/1 "2025-07-09T13:01:39Z")

</div>

It produces garbled text when text is extracted. e.g.

```auto
import pymupdf

doc = pymupdf.open("anon-test.pdf")
page = doc[0]
text = page.get_text()
print(text)

```

I think this is a PDF problem! How can we check?

[anon-test.pdf](https://forum.mupdf.com/uploads/short-url/xVrA8XdQymVb9uTPahSOyvgaWwp.pdf) (90.4 KB)

---

<div class="post-metadata">

**Author:** ![HaraldLieder](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/haraldlieder/32/14_2.png) [@HaraldLieder](https://forum.mupdf.com/u/HaraldLieder)\
**Post date:** [July 9, 2025, 3:03pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/2 "2025-07-09T15:03:53Z")

</div>

The fonts in this PDF are missing back-translation information [visible glyph] ==\> Unicode.  
The default flags for text extraction try to circumvent this by returning glyph numbers whenever the Invalid Unicode character � is returned.

Often helps, but sometimes only increases confusion - like here.  
Try using `page.get_text(flags=0)` to confirm that you normally would see � characters.

In any case, there is no way to improve this situation - except using OCR of course.

---

<div class="post-metadata">

**Author:** ![Jamie\_Lemon](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/jamie_lemon/32/5_2.png) [@Jamie\_Lemon](https://forum.mupdf.com/u/Jamie_Lemon)\
**Post date:** [July 9, 2025, 3:05pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/3 "2025-07-09T15:05:30Z")

</div>

How can you detect this? Is there a PyMuPDF command which you can run which gives you this info? Something like “validate PDF” or whatever. 🙂

---

<div class="post-metadata">

**Author:** ![HaraldLieder](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/haraldlieder/32/14_2.png) [@HaraldLieder](https://forum.mupdf.com/u/HaraldLieder)\
**Post date:** [July 9, 2025, 3:13pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/4 "2025-07-09T15:13:13Z")

</div>

Unfortunately, the missing information may not be “universal” in the sense “not there for anything”: It may be just one font out of many on the page with the problem, or even worse: just 1 or a handful of glyphs out of many okay ones are missing this.

I am considering changing the default flags to not trying this auto-replacement. So the situation becomes detectable. I have done that in PyMuPDF4LLM - probably should do it in general.

---

<div class="post-metadata">

**Author:** ![Jamie\_Lemon](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/jamie_lemon/32/5_2.png) [@Jamie\_Lemon](https://forum.mupdf.com/u/Jamie_Lemon)\
**Post date:** [July 9, 2025, 3:23pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/5 "2025-07-09T15:23:18Z")

</div>

Hmmm, when I check it in Adobe Acrobat I get this weird font name:  
 ![Screenshot 2025-07-09 at 16.20.21](https://canada1.discourse-cdn.com/flex004/uploads/mupdf/original/1X/af693cb2a6054a8c3d3382a3f325f37dbb185c83.png)

Also if I select, copy and paste the text from Adobe ( or Preview ) then I also get garbage.

So it seems this is just a badly made PDF, right? ( or deliberately “bad” to prevent easy text copying )

---

<div class="post-metadata">

**Author:** ![HaraldLieder](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/haraldlieder/32/14_2.png) [@HaraldLieder](https://forum.mupdf.com/u/HaraldLieder)\
**Post date:** [July 9, 2025, 3:29pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/6 "2025-07-09T15:29:51Z")

</div>

Exactly the right check. If any time a PDF viewer can successfully copy/paste where we return rubbish, then - and only then - **_we_** have a problem.

---

<div class="post-metadata">

**Author:** ![Jamie\_Lemon](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.mupdf.com/jamie_lemon/32/5_2.png) [@Jamie\_Lemon](https://forum.mupdf.com/u/Jamie_Lemon)\
**Post date:** [July 9, 2025, 3:44pm UTC](https://forum.mupdf.com/t/any-idea-what-is-wrong-with-this-pdf/47/7 "2025-07-09T15:44:50Z")

</div>

Thanks — Got it! 👍
