MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / test_objectstream2

Function test_objectstream2

tests/test_objectstreams.py:26–46  ·  view source on GitHub ↗

Test save option "use_objstms". This option compresses PDF object definitions into a special object type "ObjStm". We test its presence by searching for that /Type.

()

Source from the content-addressed store, hash-verified

24
25
26def test_objectstream2():
27 """Test save option "use_objstms".
28 This option compresses PDF object definitions into a special object type
29 "ObjStm". We test its presence by searching for that /Type.
30 """
31 # make some arbitrary page with content
32 text = "Hello, World! Hallo, Welt!"
33 doc = pymupdf.open()
34 page = doc.new_page()
35 rect = (50, 50, 200, 500)
36
37 page.insert_htmlbox(rect, text) # place into the rectangle
38 _ = doc.write(use_objstms=False)
39
40 found = False
41 for xref in range(1, doc.xref_length()):
42 objstring = doc.xref_object(xref, compressed=True)
43 if "/Type/ObjStm" in objstring:
44 found = True
45 break
46 assert not found, "Unexpected: Object stream found!"
47
48
49def test_objectstream3():

Callers

nothing calls this directly

Calls 5

new_pageMethod · 0.80
insert_htmlboxMethod · 0.80
xref_lengthMethod · 0.80
xref_objectMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…