Skip to content

Annotations: raise a clear error for a negative or non-finite border_width - #2133

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:annotation-border-width-finite
Nov 9, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:annotation-border-width-finite

Conversation

@RavSinghChandan

Copy link
Copy Markdown

pdf.link(10, 10, 20, 5, url, border_width=float("nan")) wrote /Border [0 0 nan] into the annotation, and inf or a negative width went through the same way. The same applies to the other annotation methods that take a border_width, such as ink_annotation() and free_text_annotation().

The annotation now raises ValueError: Annotation border width must be zero or a positive number: ..., next to the check on its position and size from #2126. Added test_annotation_invalid_border_width (fails on master).

  • A unit test is covering the code added / modified by this PR
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

@RavSinghChandan
RavSinghChandan force-pushed the annotation-border-width-finite branch from d94de3d to a13b6ba Compare November 9, 2026 13:22
@RavSinghChandan
RavSinghChandan force-pushed the annotation-border-width-finite branch from a13b6ba to a26aace Compare November 9, 2026 14:49
@andersonhc
andersonhc merged commit f05e469 into py-pdf:master Nov 9, 2026
39 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants