Skip to content
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

A Bug of Free Text in Annotations #2433

Closed
hachinoone opened this issue Feb 2, 2024 · 3 comments
Closed

A Bug of Free Text in Annotations #2433

hachinoone opened this issue Feb 2, 2024 · 3 comments
Labels
workflow-annotation Everything about annotating PDF files

Comments

@hachinoone
Copy link

The bug is observed in the official document in annotation part. The the font_color is always the same as the border_color, and cannot be changed. As the example shown in the document, the font_color is supposed to be green, but it remains blue, which is the same as border_color.

from pypdf import PdfReader, PdfWriter
from pypdf.annotations import FreeText

# Fill the writer with the pages you want
pdf_path = os.path.join(RESOURCE_ROOT, "crazyones.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("annotated-pdf.pdf", "wb") as fp:
    writer.write(fp)
@stefan6419846
Copy link
Collaborator

Seems to be a duplicate of #2084?

@hachinoone
Copy link
Author

Seems to be a duplicate of #2084?

Thanks. It seems that this issue is not sovled yet. I just want to add some text in PDF without using the border. Are there any other solutions?

@MartinThoma MartinThoma added the workflow-annotation Everything about annotating PDF files label Feb 4, 2024
@MartinThoma
Copy link
Member

As it's a duplicate, I'm closing this one in favor of #2084

@MartinThoma MartinThoma closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-annotation Everything about annotating PDF files
Projects
None yet
Development

No branches or pull requests

3 participants