赞
踩
import fitz doc = fitz.open(r"d:/test.pdf") page=doc[0] #按照指定的位置设置颜色 highlight = page.add_highlight_annot((10, 500,60, 520)) highlight.set_colors(stroke=[1, 0.8, 0.8]) # light red color (r, g, b) highlight.update() text="2022 年是党的二十大召开之年,是实施“十四五”规划" #按照查找的文本设置颜色 text_instances = page.search_for(text,quads=True) for inst in text_instances: highlight = page.add_highlight_annot(inst) highlight.update() doc.save(r"d:/test.pdf",incremental=True,encryption=0)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。