Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something wrong after extracting fonts from pdf #3246

Closed
khaled-hammoud opened this issue Mar 8, 2024 · 1 comment
Closed

Something wrong after extracting fonts from pdf #3246

khaled-hammoud opened this issue Mar 8, 2024 · 1 comment
Labels
not a bug not a bug / user error / unable to reproduce

Comments

@khaled-hammoud
Copy link

Description of the bug

import fitz

with fitz.open('muster.pdf') as doc:
    for font in doc.get_page_fonts(0, full=True):
        name, ext, _, content = doc.extract_font(font[0])
        with open(name + "." + ext, "wb") as outfile:
            outfile.write(content)

I am using this code to extracts the fonts from a pdf file, they are extracted and saved as expected but when I use any online font viewer to open this saved font, it says: "TypeError: Cannot read properties of undefined (reading 'glyphIndexMap')"

I tried 2 common online viewer, opentype.js.org and glyphrstudio.com but the give the same error.
Is there something wrong or did I forget something to do?

How to reproduce the bug

This is the sample file, and the code is written above:

muster.pdf

PyMuPDF version

1.23.26

Operating system

Windows

Python version

3.9

@JorjMcKie
Copy link
Collaborator

This is not a bug.
The PDF creator is responsible for providing the font ... and nothing forcing him to supply fonts that represent valid font files upon extraction.
In your case, the embedded fonts are indeed not extractable as valid font files.

@JorjMcKie JorjMcKie added the not a bug not a bug / user error / unable to reproduce label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants