From e717674eba31ed19ca1078652843a22f24a96180 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Wed, 4 Jul 2018 14:53:38 +0100 Subject: Fix document signing adding unnecessary incremental updates When a document is signed multiple times, an incremental update is needed for each, the multiple updates sometimes written to the file as a single saving operation. Within pdf_sign_signature it is the call to pdf_signature_set_value that marks the current section of the xref to which changes are recorded as "full", so that subsequent changes will trigger the creation of a new section. Within pdf_sign_signature we were creating the signature's appearance stream after the call to pdf_signature_set_value and hence triggering an extra unnecessary setction. This commit moves the pdf_signature_set_value to after the creation of the appearance stream, so that we need only as many new xref sections as there are signings. --- source/pdf/pdf-signature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/pdf') diff --git a/source/pdf/pdf-signature.c b/source/pdf/pdf-signature.c index cfb623d9..aaa2c5e1 100644 --- a/source/pdf/pdf-signature.c +++ b/source/pdf/pdf-signature.c @@ -69,8 +69,6 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, pdf_obj *wobj = ((pdf_annot *)widget)->obj; fz_rect rect = fz_empty_rect; - pdf_signature_set_value(ctx, doc, wobj, signer); - rect = pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME(Rect))); /* Create an appearance stream only if the signature is intended to be visible */ @@ -98,6 +96,8 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, dn_str = fz_string_from_buffer(ctx, fzbuf); pdf_update_signature_appearance(ctx, (pdf_annot *)widget, dn->cn, dn_str, NULL); } + + pdf_signature_set_value(ctx, doc, wobj, signer); } fz_always(ctx) { -- cgit v1.2.3