diff options
author | Robin Watts <robin.watts@artifex.com> | 2018-03-15 15:51:33 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2018-03-15 15:57:35 +0000 |
commit | a3527d2839a83e7a764e979b696693db53069a75 (patch) | |
tree | 15a197f22fec92a8003b1e140c7b379e7357b0ad /source/pdf | |
parent | 461b81547c1328b819ee626a3f9b55c044b45dcd (diff) | |
download | mupdf-a3527d2839a83e7a764e979b696693db53069a75.tar.xz |
PDF stream filtering; fix pattern/xobject resource handling.
Patterns and XObjects can have their own resource dictionaries.
If they do, use those in preference to the page ones when
filtering.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-clean.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/pdf/pdf-clean.c b/source/pdf/pdf-clean.c index 0c9cb974..eaa4c0e2 100644 --- a/source/pdf/pdf-clean.c +++ b/source/pdf/pdf-clean.c @@ -236,11 +236,15 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page l = pdf_dict_len(ctx, obj); for (i = 0; i < l; i++) { + pdf_obj *pat_res; pdf_obj *pat = pdf_dict_get_val(ctx, obj, i); if (!pat) continue; + pat_res = pdf_dict_get(ctx, pat, PDF_NAME_Resources); + if (pat_res == NULL) + pat_res = resources; if (pdf_to_int(ctx, pdf_dict_get(ctx, pat, PDF_NAME_PatternType)) == 1) - pdf_clean_stream_object(ctx, doc, pat, resources, cookie, 0, text_filter, after_text, proc_arg, sanitize, ascii); + pdf_clean_stream_object(ctx, doc, pat, pat_res, cookie, 0, text_filter, after_text, proc_arg, sanitize, ascii); } } @@ -252,11 +256,15 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page l = pdf_dict_len(ctx, obj); for (i = 0; i < l; i++) { + pdf_obj *xobj_res; pdf_obj *xobj = pdf_dict_get_val(ctx, obj, i); if (!xobj) continue; + xobj_res = pdf_dict_get(ctx, xobj, PDF_NAME_Resources); + if (xobj_res == NULL) + xobj_res = resources; if (pdf_name_eq(ctx, PDF_NAME_Form, pdf_dict_get(ctx, xobj, PDF_NAME_Subtype))) - pdf_clean_stream_object(ctx, doc, xobj, resources, cookie, 1, text_filter, after_text, proc_arg, sanitize, ascii); + pdf_clean_stream_object(ctx, doc, xobj, xobj_res, cookie, 1, text_filter, after_text, proc_arg, sanitize, ascii); } } |