-
Notifications
You must be signed in to change notification settings - Fork 674
Closed
Labels
not a bugnot a bug / user error / unable to reproducenot a bug / user error / unable to reproduce
Description
Description of the bug
I have a tagged PDF in which I wanted to change the color of one half of one line of text. Post changing the color using page.insert_text() method, screen reader is not reading the line of text.
Can you help me understand why this had happened and the mechanism to adopt to overcome it?
How to reproduce the bug
import fitz
import json
fitz.TOOLS.set_subset_fontnames(True)
doc=fitz.open("TagTest_tagged.pdf")
with open('color.json', 'r') as file:
data = json.load(file)
try:
page = doc[int(data["page"]-1)]
bg_color=[cv/255 for cv in data["background_color"]]
page.draw_rect(fitz.Rect(data["bbox"]), color=bg_color,fill=bg_color)
position = data["position"]
rect=data["bbox"]
page.add_redact_annot(rect)
page.apply_redactions()
fg_color=[cv/255 for cv in data["foreground_color"]]
page.insert_text(position,text=data["text"],fontsize=data["font_size"],fontname="Times-Roman",color=fg_color)
doc.save("TagTestNew_tagged.pdf")
except Exception as e:
print(e)
finally:
doc.close()
In the saved document, the content that has been inserted using insert text is not readable by screen reader whereas in the input document, the content is readable.
I am providing the input tagged PDF and the json file.
color.json
TagTest_tagged.pdf
May I know the reason why this had happened? If so, how can I resolve this even after re-insertion of text?
PyMuPDF version
1.23.x or earlier
Operating system
Windows
Python version
3.11
Metadata
Metadata
Assignees
Labels
not a bugnot a bug / user error / unable to reproducenot a bug / user error / unable to reproduce