pymupdf

How to change the highlight color in pdf using fitz module in python

霸气de小男生 提交于 2021-02-19 03:56:07
问题 Hi I am trying to change the highlight color in a pdf but not able to do so. The default highlight color is yellow but i want to change it Following is my code: import fitz doc = fitz.open(r"path\input.pdf") page=doc[0] text="some text" text_instances = page.searchFor(text) for inst in text_instances: highlight = page.addHighlightAnnot(inst) highlight.setColors(colors='Red') highlight.update() doc.save(r"path\output.pdf") Also how do i search for the entire pdf together and not just one page