diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-04-12 19:42:19 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-04-26 10:54:48 +0100 |
commit | f4a365df3f7709192ec6052832e857d2832ae47f (patch) | |
tree | 407bbbb259c173ed9d89c0064610b442bfc84e12 /source/pdf | |
parent | 4584bb1fbd3208e516a6f17b36c3b861903529f7 (diff) | |
download | mupdf-f4a365df3f7709192ec6052832e857d2832ae47f.tar.xz |
Update mutool clean sanitize to clean annotations too.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-clean.c | 21 | ||||
-rw-r--r-- | source/pdf/pdf-interpret.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-write.c | 7 |
3 files changed, 29 insertions, 1 deletions
diff --git a/source/pdf/pdf-clean.c b/source/pdf/pdf-clean.c index 2c8ade73..ecadc7f2 100644 --- a/source/pdf/pdf-clean.c +++ b/source/pdf/pdf-clean.c @@ -287,3 +287,24 @@ void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_rethrow_message(ctx, "Failed while cleaning page"); } } + +void pdf_clean_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_cookie *cookie, pdf_page_contents_process_fn *proc_fn, void *proc_arg, int ascii) +{ + pdf_obj *ap; + int i, n; + + ap = pdf_dict_get(ctx, annot->obj, PDF_NAME_AP); + if (ap == NULL) + return; + + n = pdf_dict_len(ctx, ap); + for (i = 0; i < n; i++) + { + pdf_obj *v = pdf_dict_get_val(ctx, ap, i); + + if (v == NULL) + continue; + + pdf_clean_stream_object(ctx, doc, v, NULL, cookie, 1, 1); + } +} diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index 3a386614..cff3f197 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -1258,7 +1258,7 @@ pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_p proc->op_cm(ctx, proc, annot->matrix.a, annot->matrix.b, annot->matrix.c, annot->matrix.d, annot->matrix.e, annot->matrix.f); - proc->op_Do_form(ctx, proc, "Annot", annot->ap, page->resources); + proc->op_Do_form(ctx, proc, NULL, annot->ap, page->resources); proc->op_Q(ctx, proc); } } diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 388a5820..8e686218 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2656,8 +2656,15 @@ static void sanitize(fz_context *ctx, pdf_document *doc, int ascii) for (i = 0; i < n; i++) { + pdf_annot *annot; pdf_page *page = pdf_load_page(ctx, doc, i); pdf_clean_page_contents(ctx, doc, page, NULL, NULL, NULL, ascii); + + for (annot = pdf_first_annot(ctx, page); annot != NULL; annot = pdf_next_annot(ctx, annot)) + { + pdf_clean_annot_contents(ctx, doc, annot, NULL, NULL, NULL, ascii); + } + fz_drop_page(ctx, &page->super); } } |