Skip to content

Formulae incorrectly rendered as black boxes #5001

@lucabaldini

Description

@lucabaldini

Description of the bug

I am posting this after pisa-conf/easely#66

[Some context: we are developing a small framework that supports the display of conference posters on screen, and in the process we routinely convert poster files from pdf to png.]

Basically PyMuPDF is not rendering the formulae in one of the posters for a conference we support, specifically
https://indico.global/event/14708/contributions/146662/attachments/69943/135661/PO_102.pdf
For this particular file the two equations in the bottom left box appear as black boxes.

How to reproduce the bug

This is the relevant code snippet

def run_pymupdf(input_file_path: PathLike, output_file_path: PathLike,
                target_width: int, page_number: int = 0) -> pathlib.Path:
    """Convert a .pdf file to a .png file using pymupdf under the hood.

    Arguments
    ---------
    input_file_path : PathLike
        The path to the input pdf file.

    output_file_path : PathLike
        The path to the output rasterized (png) file.

    target_width : int
        The target width for the output png file in pixels.

    page_number : int, optional
        The page number to convert (0-indexed).

    Returns
    -------
    pathlib.Path
        The path to the output rasterized (png) file.
    """
    # Open the PDF document and get the first page.
    with fitz.open(input_file_path) as document:
        page = document[page_number]
        # Calculate the zoom factor to achieve the target width.
        page_width = page.rect.width
        zoom_factor = target_width / page_width
        # Render the page as a pixmap with the specified zoom factor.
        pixmap = page.get_pixmap(matrix=fitz.Matrix(zoom_factor, zoom_factor))
        pixmap.save(output_file_path)
    return output_file_path

Link to the actual file: https://github.com/pisa-conf/easely/blob/main/src/easely/pdf.py

PyMuPDF version

1.27.2.3

Operating system

Linux

Python version

3.13

Metadata

Metadata

Assignees

Labels

fix developedrelease schedule to be determinedupstream bugbug outside this package

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions