diff options
author | Robin Watts <robin.watts@artifex.com> | 2014-06-05 15:03:14 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-02-25 19:12:01 +0000 |
commit | d4b742ab61f32abd7b49bb507e69c8d43f400bbc (patch) | |
tree | 79db1c94a940cf668b24e9c2a2be506a2dd9aa06 /source/pdf/pdf-clean.c | |
parent | 63c811b5ff2a50c5b1739526cc9e3112d3cda151 (diff) | |
download | mupdf-d4b742ab61f32abd7b49bb507e69c8d43f400bbc.tar.xz |
Add post processing option to page operator cleaning.
In order to be able to watermark etc, we want the ability to
add more operators/resources after page cleaning.
Add a post processing hook to enable this to be done more
easily.
Diffstat (limited to 'source/pdf/pdf-clean.c')
-rw-r--r-- | source/pdf/pdf-clean.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/pdf/pdf-clean.c b/source/pdf/pdf-clean.c index 89926832..b88bbb71 100644 --- a/source/pdf/pdf-clean.c +++ b/source/pdf/pdf-clean.c @@ -117,7 +117,7 @@ pdf_clean_type3(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_obj *orig_ } } -void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_cookie *cookie) +void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_cookie *cookie, pdf_page_contents_process_fn *proc_fn, void *proc_arg) { pdf_process process, process2; fz_buffer *buffer = fz_new_buffer(ctx, 1024); @@ -166,7 +166,6 @@ void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, num = pdf_to_num(ctx, contents); pdf_dict_dels(ctx, contents, "Filter"); } - pdf_update_stream(ctx, doc, num, buffer); /* Now deal with resources. The spec allows for Type3 fonts and form * XObjects to omit a resource dictionary and look in the parent. @@ -260,6 +259,10 @@ void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, /* Properties - no cleaning possible. */ + if (proc_fn) + (*proc_fn)(proc_arg, buffer, res); + + pdf_update_stream(ctx, doc, num, buffer); pdf_drop_obj(ctx, page->resources); ref = pdf_new_ref(ctx, doc, res); page->resources = pdf_keep_obj(ctx, ref); |