diff --git a/docs/samples/code-printer.py b/docs/samples/code-printer.py index 5a456ffbe..c66243cdb 100644 --- a/docs/samples/code-printer.py +++ b/docs/samples/code-printer.py @@ -227,9 +227,11 @@ def code_printer(outfile): pages = [doc[i] for i in new_range] # these are the TOC pages within main PDF for item in TOC: # search for TOC item text to get its rectangle for page in pages: - rl = page.search_for(item[1], flags=~(pymupdf.TEXT_PRESERVE_LIGATURES | pymupdf.TEXT_PRESERVE_SPANS)) + rl = page.search_for(item[1], flags=pymupdf.TEXTFLAGS_SEARCH) if rl != []: # this text must be on next page break + else: + assert 0, f'Cannot find {item[1]=} in {len(pages)=}.' rect = rl[0] # rectangle of TOC item text link = { # make a link from it "kind": pymupdf.LINK_GOTO,