Complete V2 acceptance checklist

This commit is contained in:
2026-06-30 20:12:49 +08:00
parent b7be31bed9
commit 272dd08262
4 changed files with 213 additions and 25 deletions
+4 -17
View File
@@ -792,6 +792,8 @@ class PdfDocument:
elif annot_type in {"line", "ink", "underline", "strikeout", "highlight"}:
annot.set_colors(stroke=stroke_color)
annot.set_border(width=max(0, float(border_width)))
elif annot_type == "text":
annot.set_colors(stroke=stroke_color)
elif annot_type == "freetext":
annot.set_colors(stroke=stroke_color)
else:
@@ -962,30 +964,15 @@ class PdfDocument:
target = Path(path)
target.parent.mkdir(parents=True, exist_ok=True)
original_path = self.path
can_incremental = (
original_path
and target.resolve() == original_path.resolve()
and self._doc.name
and Path(self._doc.name).resolve() == target.resolve()
)
if can_incremental:
self._doc.saveIncr()
self._doc.close()
self.path = target
self._doc = fitz.open(target)
self.mark_saved()
return
with NamedTemporaryFile(delete=False, suffix=".pdf", dir=target.parent) as tmp:
temp_path = Path(tmp.name)
try:
self._doc.save(temp_path, garbage=4, deflate=True)
temp_path.replace(target)
self.path = target
if self._doc:
self._doc.close()
temp_path.replace(target)
self.path = target
self._doc = fitz.open(target)
self.mark_saved()
finally: