You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
Description of the bug
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
The text was updated successfully, but these errors were encountered: