| 35 | text = pymupdf.ConversionTrailer("xml") |
| 36 | |
| 37 | def _test_extract2(): |
| 38 | import sys |
| 39 | import time |
| 40 | path = f'{scriptdir}/../../PyMuPDF-performance/adobe.pdf' |
| 41 | if not os.path.exists(path): |
| 42 | print(f'test_extract2(): not running because does not exist: {path}') |
| 43 | return |
| 44 | doc = pymupdf.open( path) |
| 45 | for opt in ( |
| 46 | 'dict', |
| 47 | 'dict2', |
| 48 | 'text', |
| 49 | 'blocks', |
| 50 | 'words', |
| 51 | 'html', |
| 52 | 'xhtml', |
| 53 | 'xml', |
| 54 | 'json', |
| 55 | 'rawdict', |
| 56 | 'rawjson', |
| 57 | ): |
| 58 | for flags in None, pymupdf.TEXTFLAGS_TEXT: |
| 59 | t0 = time.time() |
| 60 | for page in doc: |
| 61 | page.get_text(opt, flags=flags) |
| 62 | t = time.time() - t0 |
| 63 | print(f't={t:.02f}: opt={opt} flags={flags}') |
| 64 | sys.stdout.flush() |
| 65 | |
| 66 | def _test_extract3(): |
| 67 | import sys |