MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_3887

Function test_3887

tests/test_font.py:212–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210
211
212def test_3887():
213 print(f'{pymupdf.version=}')
214 path = os.path.normpath(f'{__file__}/../../tests/resources/test_3887.pdf')
215
216 path2 = os.path.normpath(f'{__file__}/../../tests/resources/test_3887.pdf.ez.pdf')
217 with pymupdf.open(path) as document:
218 document.subset_fonts(fallback=False)
219 document.ez_save(path2)
220
221 with pymupdf.open(path2) as document:
222 text = f"\u0391\u3001\u0392\u3001\u0393\u3001\u0394\u3001\u0395\u3001\u0396\u3001\u0397\u3001\u0398\u3001\u0399\u3001\u039a\u3001\u039b\u3001\u039c\u3001\u039d\u3001\u039e\u3001\u039f\u3001\u03a0\u3001\u03a1\u3001\u03a3\u3001\u03a4\u3001\u03a5\u3001\u03a6\u3001\u03a7\u3001\u03a8\u3001\u03a9\u3002\u03b1\u3001\u03b2\u3001\u03b3\u3001\u03b4\u3001\u03b5\u3001\u03b6\u3001\u03b7\u3001\u03b8\u3001\u03b9\u3001\u03ba\u3001\u03bb\u3001\u03bc\u3001\u03bd\u3001\u03be\u3001\u03bf\u3001\u03c0\u3001\u03c1\u3001\u03c2\u3001\u03c4\u3001\u03c5\u3001\u03c6\u3001\u03c7\u3001\u03c8\u3001\u03c9\u3002"
223 page = document[0]
224 chars = [c for b in page.get_text("rawdict",flags=0)["blocks"] for l in b["lines"] for s in l["spans"] for c in s["chars"]]
225 output = [c["c"] for c in chars]
226 print(f'text:\n {text}')
227 print(f'output:\n {output}')
228 pixmap = page.get_pixmap()
229 path_pixmap = f'{path}.0.png'
230 pixmap.save(path_pixmap)
231 print(f'Have saved to: {path_pixmap=}')
232 assert set(output)==set(text)
233
234
235def test_4457():

Callers

nothing calls this directly

Calls 5

subset_fontsMethod · 0.80
ez_saveMethod · 0.80
get_textMethod · 0.45
get_pixmapMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…