summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_write.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/pdf/pdf_write.c b/pdf/pdf_write.c
index 8334e92a..566b9c0e 100644
--- a/pdf/pdf_write.c
+++ b/pdf/pdf_write.c
@@ -1514,6 +1514,34 @@ static void expandstream(pdf_document *xref, pdf_write_options *opts, pdf_obj *o
pdf_drop_obj(obj);
}
+static int is_image_filter(char *s)
+{
+ if ( !strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF") ||
+ !strcmp(s, "DCTDecode") || !strcmp(s, "DCT") ||
+ !strcmp(s, "RunLengthDecode") || !strcmp(s, "RL") ||
+ !strcmp(s, "JBIG2Decode") ||
+ !strcmp(s, "JPXDecode"))
+ return 1;
+ return 0;
+}
+
+static int filter_implies_image(pdf_document *xref, pdf_obj *o)
+{
+ if (!o)
+ return 0;
+ if (pdf_is_name(o))
+ return is_image_filter(pdf_to_name(o));
+ if (pdf_is_array(o))
+ {
+ int i, len;
+ len = pdf_array_len(o);
+ for (i = 0; i < len; i++)
+ if (is_image_filter(pdf_to_name(pdf_array_get(o, i))))
+ return 1;
+ }
+ return 0;
+}
+
static void writeobject(pdf_document *xref, pdf_write_options *opts, int num, int gen)
{
pdf_obj *obj;
@@ -1576,6 +1604,10 @@ static void writeobject(pdf_document *xref, pdf_write_options *opts, int num, in
dontexpand = !(opts->do_expand & fz_expand_fonts);
if (o = pdf_dict_gets(obj, "Subtype"), !strcmp(pdf_to_name(o), "CIDFontType0C"))
dontexpand = !(opts->do_expand & fz_expand_fonts);
+ if (o = pdf_dict_gets(obj, "Filter"), filter_implies_image(xref, o))
+ dontexpand = !(opts->do_expand & fz_expand_images);
+ if (pdf_dict_gets(obj, "Width") != NULL && pdf_dict_gets(obj, "Height") != NULL)
+ dontexpand = !(opts->do_expand & fz_expand_images);
}
if (opts->do_expand && !dontexpand && !pdf_is_jpx_image(ctx, obj))
expandstream(xref, opts, obj, num, gen);