pythonpdfpymupdf

Keywords being highlighted in wrong color using PyMuPDF


I'm doing some basic keyword highlighting, but I'm running into a strange issue. When I enter a stroke color with floating point RGB values (as shown below), the highlights come out in multiple different colors. In this case, I want the highlights to be orange. Some words are orange while others are more red. Any idea what's going on here? If I change the the RGB values to integers, the highlight colors are all the same. Please let me know if there's any additional code you need to see.

annot = page.add_highlight_annot(word)
annot.set_colors(stroke=(1, 0.5, 0))
annot.update()

With floating point - (1, 0.5, 0)

With integers - (1, 1, 0)


Solution

  • Here is an image where all words are highlighted. Neighbouring words show a small color overlap, that is significantly darker than the rest. enter image description here