-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeText annotation not showing in chrome browser #2372
Comments
I can confirm that I see the annotation in Evince, but not in the Google Chrome viewer (also with a different |
Thanks for sharing! |
This might be related to #2332. Did this work correctly in PyPDF2? |
You should try to append the page :
is it better ? |
Using append causes the same problems: from pypdf import PdfReader, PdfWriter
from pypdf.annotations import FreeText
# Fill the writer with the pages you want
pdf_path = 'input.pdf'
reader = PdfReader(pdf_path)
writer = PdfWriter()
writer.append(reader, [0])
# Create the annotation and add it
annotation = FreeText(
text="Hello World\nThis is the second line!",
rect=(50, 550, 200, 650),
font="Arial",
bold=True,
italic=True,
font_size="20pt",
font_color="00ff00",
border_color="0000ff",
background_color="cdcdcd",
)
writer.add_annotation(page_number=0, annotation=annotation)
writer.create_viewer_preferences()
# Write the annotated file to disk
with open("output.pdf", "wb") as fp:
writer.write(fp) |
@stefan6419846 It was also broken in PyPDF2: from PyPDF2 import PdfReader, PdfWriter
from PyPDF2.generic import AnnotationBuilder
# Fill the writer with the pages you want
pdf_path = 'input.pdf'
reader = PdfReader(pdf_path)
page = reader.pages[0]
writer = PdfWriter()
writer.add_page(page)
# Create the annotation and add it
annotation = AnnotationBuilder.free_text(
text="Hello World\nThis is the second line!",
rect=(50, 550, 200, 650),
font="Arial",
bold=True,
italic=True,
font_size="20pt",
font_color="00ff00",
border_color="0000ff",
background_color="cdcdcd",
)
writer.add_annotation(page_number=0, annotation=annotation)
# Write the annotated file to disk
with open("output-pypdf2.pdf", "wb") as fp:
writer.write(fp) |
I am experiencing the same issue. |
I've found the problem : the annotation is missing the ["/AP"]["/N"] entry. under analysis to produce the form |
@pubpub-zz would there be any update on this? |
Hey, also encountered this problem today, hoping for a fix. |
We need to build a Content stream looking for all options. fpf2 may help to do so. I have currently little time to work on this.Feel free to propose PR. |
Still happening in 2025... |
Constantly pinging "Me too" comments in this issue will not help getting it solved - this is still a FOSS project with its development mostly happening in our free time. Being such, you are of course always invited to analyze this further and propose a corresponding PR to fix this. |
I added a FreeText annotation to a PDF, but noticed that it's not shown in some PDF viewers.
The input PDF seems not to matter.
Environment
Code + PDF
input.pdf
output.pdf
Screenshots
The added comments are not displayed
output.pdf in firefox
output.pdf in chrome
The text was updated successfully, but these errors were encountered: