Skip to content

Commit

Permalink
docs/samples/code-printer.py: fixed to work with latest MuPDF.
Browse files Browse the repository at this point in the history
Specifying complement of a bitmask goes wrong if a new enum value is added to
MuPDF, so we now simply use `pymupdf.TEXTFLAGS_SEARCH`.
  • Loading branch information
julian-smith-artifex-com committed Oct 8, 2024
1 parent 83ac662 commit a73711a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/samples/code-printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a73711a

Please sign in to comment.