Skip to content

EPUB: blank page before and after the cover since MuPDF 1.28.6 (PyMuPDF 2.x) #5246

Open

Description

@Jamalofski

Description of the bug

Laying out an EPUB and converting it to PDF adds an empty page before and an empty page after the cover image with PyMuPDF 2.1 (MuPDF 1.28.6). PyMuPDF 1.28.2 (MuPDF 1.28.2) and 1.27.2.3 (MuPDF 1.27.2) give the cover on page 1 and no empty page. We also see it with 2.0 on Linux.

Project Gutenberg #4650 (Candide, EPUB 2 with images): 66 pages with 1.27.2.3 and 1.28.2, 68 pages with 2.1. Pages 1 and 3 have no text and no image, page 2 holds the cover.

How to reproduce the bug

EPUB: https://www.gutenberg.org/ebooks/4650.epub.images

import pymupdf

book = pymupdf.open("4650.epub")
book.layout(width=595, height=842, fontsize=11)
pdf = pymupdf.open("pdf", book.convert_to_pdf())
print(pymupdf.VersionFitz, pdf.page_count)
for page in list(pdf)[:4]:
    print(page.number + 1, len(page.get_text().strip()), len(page.get_images()))

1.28.2: 1.28.2 66, page 1 has the cover image.
2.1: 1.28.6 68, pages 1 and 3 empty, cover on page 2.

PyMuPDF version

2.1

Operating system

Windows (also Linux)

Python version

3.14

Activity

  1. JorjMcKie commented on Nov 4, 2026

    @JorjMcKie
    Collaborator

    This report should actually be targeted directly to MuPDF's issue system https://bugs.ghostscript.com/enter_bug.cgi because pymupdf cannot do anything about the problem.
    You could easily argue that the MuPDF viewer displays these 2 empty pages with its current version (confirmed), while older versions do not misbehave.

  2. Jamalofski commented on Nov 4, 2026

    @Jamalofski
    Author

    Thanks, filed upstream as https://bugs.ghostscript.com/show_bug.cgi?id=709957.
    It comes from MuPDF commit 9da4f600b5 (Bug 709663): an image taller than the page is now scaled to the full page height and ignores the body margin, so it no longer fits and gets pushed to the next page. A three-line HTML file with body { margin: 0.5em } reproduces it.
    Fine to close here.

  3. JorjMcKie commented on Nov 4, 2026

    @JorjMcKie
    Collaborator

    We usually, in an effort to maintain a complete test suite, we also test MuPDF fixes when created in response to a PyMuPDF issue ... like yours.
    I think I will create a test script that does the following:

    import pymupdf
    image_counts = (1, 0, 0)  # image counts expected on pages 1, 2, 3
    doc = pymupdf.open("input.epub")
    for page in doc[:3]:
        assert len(page.get_image_info()) == image_counts[page.number]

    Before putting it in our test suite, the respective fix of 709957 must be part of the MuPDF version that becomes part of PyMuPDF.
    Only once this PyMuPDF version becomes available on PyPI, the issue will be closed here.

  4. self-assigned this
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

upstream bugbug outside this package

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions