| 137 | |
| 138 | |
| 139 | def 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 | |
| 161 | def test_3347(): |