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

Function test_toc_count

tests/test_toc.py:139–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137
138
139def test_toc_count():
140 file_in = os.path.abspath(f'{__file__}/../../tests/resources/test_toc_count.pdf')
141 file_out = os.path.abspath(f'{__file__}/../../tests/test_toc_count_out.pdf')
142
143 def get(doc):
144 outlines = doc.xref_get_key(doc.pdf_catalog(), "Outlines")
145 ret = doc.xref_object(int(outlines[1].split()[0]))
146 return ret
147 print()
148 with pymupdf.open(file_in) as doc:
149 print(f'1: {get(doc)}')
150 toc = doc.get_toc(simple=False)
151 doc.set_toc([])
152 #print(f'2: {get(doc)}')
153 doc.set_toc(toc)
154 print(f'3: {get(doc)}')
155 doc.save(file_out, garbage=4)
156 with pymupdf.open(file_out) as doc:
157 print(f'4: {get(doc)}')
158 pymupdf._log_items_clear()
159
160
161def test_3347():

Callers

nothing calls this directly

Calls 4

get_tocMethod · 0.80
set_tocMethod · 0.80
getFunction · 0.70
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…