Add freehand ink annotation tool

This commit is contained in:
2026-06-29 16:37:26 +08:00
parent 1c1f491de5
commit c770dd5498
6 changed files with 102 additions and 4 deletions
+12
View File
@@ -248,6 +248,18 @@ class PdfDocument:
annot.update()
self.mark_changed()
def add_ink(self, page_index: int, points: list[tuple[float, float]]) -> None:
if len(points) < 2:
return
self.snapshot()
page = self._page(page_index)
stroke = [(float(x), float(y)) for x, y in points]
annot = page.add_ink_annot([stroke])
annot.set_colors(stroke=(0.05, 0.05, 0.05))
annot.set_border(width=2)
annot.update()
self.mark_changed()
def add_cover_area(self, page_index: int) -> None:
self.snapshot()
page = self._page(page_index)