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.
()
| 2 | |
| 3 | |
| 4 | def 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 | |
| 26 | def test_objectstream2(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…