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

Function test_objectstream1

tests/test_objectstreams.py:4–23  ·  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

2
3
4def test_objectstream1():
5 """Test save option "use_objstms".
6 This option compresses PDF object definitions into a special object type
7 "ObjStm". We test its presence by searching for that /Type.
8 """
9 # make some arbitrary page with content
10 text = "Hello, World! Hallo, Welt!"
11 doc = pymupdf.open()
12 page = doc.new_page()
13 rect = (50, 50, 200, 500)
14
15 page.insert_htmlbox(rect, text) # place into the rectangle
16 _ = doc.write(use_objstms=True)
17 found = False
18 for xref in range(1, doc.xref_length()):
19 objstring = doc.xref_object(xref, compressed=True)
20 if "/Type/ObjStm" in objstring:
21 found = True
22 break
23 assert found, "No object stream found"
24
25
26def test_objectstream2():

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…