Skip to content

Stroke color of annotations cannot be correctly set #4447

@cli-lilly

Description

@cli-lilly

dummy.pdf

Description of the bug

When I use annot.set_colors(stroke=(0, 0, 0)) to set annotations' border color to black, the fill color of the annotations are changed to black instead. The border color remains the same as the text color.

How to reproduce the bug

import pymupdf
pdf = pymupdf.open(input_pdf_path)
page = pdf[0]

text_color = (1, 0, 0)
fill_color = (191/255, 1, 1)
border_color = (0, 0, 0)

annot_rect = pymupdf.Rect(90.1, 486.73, 139.26, 499.46)

annot = page.add_freetext_annot(  
    annot_rect,  
    "AETERM",  
    fontname="Arial",  
    fontsize=10,  
    text_color=text_color,
    fill_color=fill_color,   
    border_width=1   
)  

annot.set_colors(stroke=(0, 0, 0))
annot.update()  # Save the annotation to the page
pdf.save(output_pdf_path)

Expected behavior:
The border of the annotation should be black, and the fill color should remains light blue

Actual behavior:
The fill of the annotation is set to black, while the border color is the same as the text color

Image

PyMuPDF version

1.25.4

Operating system

Windows

Python version

3.13

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions