Skip to content

FreeText annotation not showing in chrome browser #2372

Open
@123woscc

Description

@123woscc

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

  • Windows-10-10.0.22000-SP0
  • pypdf 3.17.4
  • pypdf==3.17.4, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=8.4.0

Code + PDF

input.pdf

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)
page = reader.pages[0]
writer = PdfWriter()
writer.add_page(page)

# 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)

# Write the annotated file to disk
with open("output.pdf", "wb") as fp:
    writer.write(fp)

output.pdf

Screenshots

The added comments are not displayed

output.pdf in firefox
image

output.pdf in chrome
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has MCVEA minimal, complete and verifiable example helps a lot to debug / understand feature requestsis-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-annotationEverything about annotating PDF files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions