# Spaces missing after extracting text with Page.get\_text()

**URL:** <https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308>\
**Category:** PyMuPDF\
**Tags:** text\
**Created:** [February 24, 2026, 4:16pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308 "2026-02-24T16:16:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdelaney](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rdelaney](https://forum.mupdf.com/u/rdelaney)\
**Post date:** [February 24, 2026, 4:16pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/1 "2026-02-24T16:16:41Z")

</div>

Hello,

I am experience an issue where some spaces between words appear to missing after extracting text using PyMuPDF’s `Page.get_text()` method.

Here is the PDF in question: [https://export.arxiv.org/pdf/2601.05047v3](https://export.arxiv.org/pdf/2601.05047v3)

The code I am using to observe this behavior is as follow:

```auto
    input_pdf = Path("./documents/2601.05047v3.pdf")

    doc = pymupdf.open(input_pdf)
    page = doc.load_page(0)
    page_dict = page.get_text("dict")
    blocks = page_dict.get("blocks", [])
    text_blocks = [block for block in blocks if block.get("type") == 0]

    for block in text_blocks:
        lines = block.get("lines", [])
        for line in lines:
            spans = line.get("spans", [])

            for span in spans:
                print(span.get("text"))

```

Below are some instances from the first page of this document where I am seeing missing spaces:

- “​for 10X memory capacity with​​HBM-like bandwidth; Processing-Near-Memory and​”
- “. Rather than a single dense​​feedforward block, MoE uses tens to hundreds​”
- “. Reasoning is a think-before-act​​technique to improve quality. An extra “thinking”​"
- “. LLMs have evolved from text to image,​​audio, and video generation. Larger data types​”
- “​A context window refers to the amount​​of information the LLM model can look at when​”

I am using `pymupdf` v1.27.1.

Any assistance would be greatly appreciated!

---

<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:** [February 24, 2026, 5:02pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/2 "2026-02-24T17:02:14Z")

</div>

Interesting I can replicate if I import pymupdf.layout & pymupdf4llm - and only when I use `pymupdf4llm.to_text` can you confirm if you are importing these?

---

<div class="post-metadata">

**Author:** ![rdelaney](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rdelaney](https://forum.mupdf.com/u/rdelaney)\
**Post date:** [February 24, 2026, 5:21pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/3 "2026-02-24T17:21:19Z")

</div>

Hi @Jamie_Lemon, thank you for the quick response. I am not importing either of those. Nor are they installed in my environment. I’m only installing `pymupdf`.

---

<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:** [February 24, 2026, 6:02pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/4 "2026-02-24T18:02:08Z")

</div>

Very strange - I cannot replicate this when I only use `import pymupdf`. Please see my attached developer experience video. There is something odd about those spaces though - they look larger than regular spaces.

@HaraldLieder Please let us know your thoughts when you have time!

---

<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:** [February 24, 2026, 9:20pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/5 "2026-02-24T21:20:07Z")

</div>

This PDF awkwardly uses certain space suppression techniques via so-called “ActualText” (to prevent certain things from happening when copy-pasting of extracting).  
So if you use our flag bit that ignores ActualText, the space will re-appear, like so:  
`text = page.get_text(flags=pymupdf.TEXT_IGNORE_ACTUALTEXT)`.

---

<div class="post-metadata">

**Author:** ![rdelaney](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rdelaney](https://forum.mupdf.com/u/rdelaney)\
**Post date:** [February 25, 2026, 12:30am UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/6 "2026-02-25T00:30:26Z")

</div>

Wow, excellent! Confirming that using that flag bit does now include the expected spaces in the extracted text. As @Jamie_Lemon pointed out, they do appear oddly larger than a normal space, but this is definitely more satisfactory than omitting the spaces.

Thank you @Jamie_Lemon and @HaraldLieder for your assistance!

---

<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:** [February 25, 2026, 10:13am UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/7 "2026-02-25T10:13:34Z")

</div>

The reason for those “oddly larger” spaces is that the PDF author encoded them like that … for reasons only he / she can know. The native PDF text (i.e. _ **including** _ “ActualText” particles) contains

`10X memory capacity with&#x200b;&#x200b;HBM-like bandwidth`

The Unicode `&#x200b;` is called **“Zero‑Width Space”**. It occupies no room and is normally used to indicate “if needed, insert a line break here”. Why we have two of them in a row remains the author’s secret. As per the specifications this **_never makes sense._**

If you use the recommended flag bit, ActualText is ignored and this Unicode is replaced by 1 space … thus leading to the result.

---

<div class="post-metadata">

**Author:** ![rdelaney](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rdelaney](https://forum.mupdf.com/u/rdelaney)\
**Post date:** [February 25, 2026, 2:09pm UTC](https://forum.mupdf.com/t/spaces-missing-after-extracting-text-with-page-get-text/308/8 "2026-02-25T14:09:32Z")

</div>

Thank you for the context, that is very helpful!
