Check handling of Document.get_toc() when toc item has kind=4.
()
| 104 | new_doc.get_toc() |
| 105 | |
| 106 | def test_2788(): |
| 107 | ''' |
| 108 | Check handling of Document.get_toc() when toc item has kind=4. |
| 109 | ''' |
| 110 | if not hasattr(pymupdf, 'mupdf'): |
| 111 | # Classic implementation does not have fix for this test. |
| 112 | print(f'Not running test_2788 on classic implementation.') |
| 113 | return |
| 114 | path = os.path.abspath(f'{__file__}/../../tests/resources/test_2788.pdf') |
| 115 | document = pymupdf.open(path) |
| 116 | toc0 = [[1, 'page2', 2, {'kind': 4, 'xref': 14, 'page': 1, 'to': pymupdf.Point(100.0, 760.0), 'zoom': 0.0, 'nameddest': 'page.2'}]] |
| 117 | toc1 = document.get_toc(simple=False) |
| 118 | print(f'{toc0=}') |
| 119 | print(f'{toc1=}') |
| 120 | assert toc1 == toc0 |
| 121 | |
| 122 | doc.set_toc(toc0) |
| 123 | toc2 = document.get_toc(simple=False) |
| 124 | print(f'{toc0=}') |
| 125 | print(f'{toc2=}') |
| 126 | assert toc2 == toc0 |
| 127 | |
| 128 | # Also test Page.get_links() bugfix from #2817. |
| 129 | for page in document: |
| 130 | page.get_links() |
| 131 | wt = pymupdf.TOOLS.mupdf_warnings() |
| 132 | assert wt == ( |
| 133 | "syntax error: expected 'obj' keyword (0 3 ?)\n" |
| 134 | "trying to repair broken xref\n" |
| 135 | "repairing PDF document" |
| 136 | ), f'{wt=}' |
| 137 | |
| 138 | |
| 139 | def test_toc_count(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…