done undo functions

This commit is contained in:
azeeee05
2026-06-16 10:53:37 +05:30
parent be45b2211b
commit f8fb4feaff
3 changed files with 19 additions and 12 deletions
+3 -2
View File
@@ -362,13 +362,14 @@ def apply_edits_impl(document_id: str, request: EditsRequest):
del op["data"]["imageData"]
edits_json = json.dumps(req_dict)
doc.apply_edits(edits_json)
doc_copy = pdfengine.PdfDocument.load_from_memory(doc_info["bytes_data"])
doc_copy.apply_edits(edits_json)
# Redaction and in-place text rewrites mutate existing objects, which do
# not round-trip cleanly through an incremental save — force a full save.
full_save_types = {"redaction", "replace_text"}
needs_full = any(op.get("type") in full_save_types for op in req_dict.get("operations", []))
new_bytes = doc.save_full() if needs_full else doc.save_incremental()
new_bytes = doc_copy.save_full() if needs_full else doc_copy.save_incremental()
new_doc = pdfengine.PdfDocument.load_from_memory(new_bytes)