summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gardiner <paul.gardiner@artifex.com>2018-07-16 13:33:59 +0100
committerPaul Gardiner <paul.gardiner@artifex.com>2018-07-17 14:57:57 +0100
commit709b4b95e1b30a62511234773fb53f75a40279f3 (patch)
tree8af592f96e85a461470ab94c20a40d20afffb618
parent3d22bf8ba1c824f6722be63d9b5109fce56e076c (diff)
downloadmupdf-709b4b95e1b30a62511234773fb53f75a40279f3.tar.xz
Disallow incremental updating for documents that have hybrid xrefs
Alter pdf_can_be_saved_incrementally to return false when a hybrid xref file has been opened. This doesn't enforce the behaviour, but will ensure it for apps that determine their behaviour via this test function. Once changes have been saved to such a file, it is no longer hybrid and so further saving steps can use incremental updates. This change was made because we were previously unable to sign hybrid xref documents in a way that was satisfactory to Adobe Reader. Adobe Reader reorganises hybrid xref files, thus invalidating any signature.
-rw-r--r--include/mupdf/pdf/document.h1
-rw-r--r--source/pdf/pdf-write.c5
-rw-r--r--source/pdf/pdf-xref.c2
3 files changed, 8 insertions, 0 deletions
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index f73cf5f3..24e3aaed 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -635,6 +635,7 @@ struct pdf_document_s
int *xref_index;
int freeze_updates;
int has_xref_streams;
+ int has_old_style_xrefs;
int rev_page_count;
pdf_rev_page_map *rev_page_map;
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 53a63cfc..26fcd9d1 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -2177,6 +2177,8 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_state
{
fz_rethrow(ctx);
}
+
+ doc->has_old_style_xrefs = 0;
}
static void
@@ -2865,6 +2867,9 @@ int pdf_can_be_saved_incrementally(fz_context *ctx, pdf_document *doc)
return 0;
if (doc->crypt != NULL)
return 0;
+ if (doc->has_xref_streams && doc->has_old_style_xrefs)
+ return 0;
+
return 1;
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index d60eb089..682a3ddb 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -933,6 +933,8 @@ pdf_read_old_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
if (tok != PDF_TOK_OPEN_DICT)
fz_throw(ctx, FZ_ERROR_GENERIC, "expected trailer dictionary");
+ doc->has_old_style_xrefs = 1;
+
return pdf_parse_dict(ctx, doc, file, buf);
}