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

Function test_objectstream3

tests/test_objectstreams.py:49–72  ·  view source on GitHub ↗

Test ez_save(). Should automatically use object streams

()

Source from the content-addressed store, hash-verified

47
48
49def test_objectstream3():
50 """Test ez_save().
51 Should automatically use object streams
52 """
53 import io
54
55 fp = io.BytesIO()
56
57 # make some arbitrary page with content
58 text = "Hello, World! Hallo, Welt!"
59 doc = pymupdf.open()
60 page = doc.new_page()
61 rect = (50, 50, 200, 500)
62
63 page.insert_htmlbox(rect, text) # place into the rectangle
64
65 doc.ez_save(fp) # save PDF to memory
66 found = False
67 for xref in range(1, doc.xref_length()):
68 objstring = doc.xref_object(xref, compressed=True)
69 if "/Type/ObjStm" in objstring:
70 found = True
71 break
72 assert found, "No object stream found!"

Callers

nothing calls this directly

Calls 5

new_pageMethod · 0.80
insert_htmlboxMethod · 0.80
ez_saveMethod · 0.80
xref_lengthMethod · 0.80
xref_objectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…