Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
* SVG import: `opacity`, `fill-opacity` and `stroke-opacity` accept percentages (`50%`), and an out-of-range `opacity` is clamped to 0-1 like the other two instead of raising `ValueError` - thanks to @RavSinghChandan
* css `rgb()` colors accept percentages, as in `rgb(100%, 0%, 50%)` (clamped to 0%-100%), in SVG import and `FPDF.write_html()` instead of raising `ValueError` - thanks to @RavSinghChandan
* hex color strings, such as in `set_fill_color("#...")`, must contain only hexadecimal digits: `"#1 2345"` and `"#+12345"` were silently read as `#012345`, and `"#xyz"` raised an unclear `invalid literal for int()` error; all now raise `ValueError: ... could not be interpreted as a RGB(A) hex string` - thanks to @RavSinghChandan
* `FPDF.ink_annotation()` computes the horizontal position of the annotation rectangle (`/Rect`) from the x coordinates of the path instead of the y coordinates, so the rectangle encloses the drawn path; it could previously lie outside the page - thanks to @RavSinghChandan
* `FPDF.embed_file()` accepts empty byte content and rejects simultaneous path and byte sources even when the bytes are empty.
* `set_text_color()`, `set_fill_color()` and `set_draw_color()` report a component outside 0-255 as given: `set_text_color(300)` now raises `ValueError: color component 300 not in range [0, 255]` instead of `1.1764705882352942 not in range [0.0, 1.0]` - thanks to @RavSinghChandan
* An internal link with an index that `FPDF.add_link()` did not return now raises a clear `ValueError`, like a link without a page number, instead of a bare `AssertionError` (or a `KeyError` with `python -O`) - thanks to @RavSinghChandan
Expand Down
2 changes: 1 addition & 1 deletion fpdf/fpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3536,7 +3536,7 @@ def ink_annotation(
y_max = max(ink_list[1::2])
annotation = AnnotationDict(
"Ink",
x=y_min,
x=x_min,
y=y_max,
width=x_max - x_min,
height=y_max - y_min,
Expand Down
Binary file modified test/encryption/encryption_aes256.pdf
Binary file not shown.
Binary file modified test/ink_annotation.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions test/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ def test_ink_annotation(tmp_path):
assert_pdf_equal(pdf, HERE / "ink_annotation.pdf", tmp_path)


def test_ink_annotation_rect_encloses_the_path():
pdf = FPDF(unit="pt")
pdf.add_page()
annotation = pdf.ink_annotation([(100, 50), (200, 150)])
# page height is 841.89pt: y=150 and y=50 become 691.89 and 791.89
assert annotation.rect == "[100 691.89 200 791.89]"


def test_free_text_annotation_all_parameters(tmp_path):
pdf = FPDF()
pdf.add_page()
Expand Down
Loading