summaryrefslogtreecommitdiff
path: root/source/tools/pdfclean.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-04-27 14:14:52 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-04-27 17:01:06 +0200
commit4355fda4abe7e7022e3e258c276ccba9e4713d91 (patch)
tree7a21c614bad51f8157c56db60d658f77ad6273b6 /source/tools/pdfclean.c
parenta1c86cfcea30b18734488935c636a5d7198b3983 (diff)
downloadmupdf-4355fda4abe7e7022e3e258c276ccba9e4713d91.tar.xz
Tweak pdf-write option handling.
The handling of not-decompressing images/fonts was geared towards pdfclean usage; but now that we can create new PDF files, it makes more sense to ask for images and fonts to be compressed, rather than asking for them not to be decompressed with quirky interaction with the 'expand' and 'deflate' flags. If -f or -i are set, we will never decompress images, and we will compress them if they are uncompressed. If -d is set, we will first decompress all streams (module -f or -i). If -z is set, we will then compress all uncompressed streams.
Diffstat (limited to 'source/tools/pdfclean.c')
-rw-r--r--source/tools/pdfclean.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/tools/pdfclean.c b/source/tools/pdfclean.c
index f703b155..22937186 100644
--- a/source/tools/pdfclean.c
+++ b/source/tools/pdfclean.c
@@ -19,13 +19,13 @@ static void usage(void)
"\t-g\tgarbage collect unused objects\n"
"\t-gg\tin addition to -g compact xref table\n"
"\t-ggg\tin addition to -gg merge duplicate objects\n"
- "\t-s\tclean content streams\n"
- "\t-d\tdecompress all streams\n"
"\t-l\tlinearize PDF\n"
- "\t-i\ttoggle decompression of image streams\n"
- "\t-f\ttoggle decompression of font streams\n"
"\t-a\tascii hex encode binary streams\n"
+ "\t-d\tdecompress streams\n"
"\t-z\tdeflate uncompressed streams\n"
+ "\t-f\tcompress font streams\n"
+ "\t-i\tcompress image streams\n"
+ "\t-s\tclean content streams\n"
"\tpages\tcomma separated list of page numbers and ranges\n"
);
exit(1);
@@ -49,18 +49,22 @@ int pdfclean_main(int argc, char **argv)
switch (c)
{
case 'p': password = fz_optarg; break;
- case 'g': opts.do_garbage ++; break;
- case 'd': opts.do_expand ^= PDF_EXPAND_ALL; break;
- case 'f': opts.do_expand ^= PDF_EXPAND_FONTS; break;
- case 'i': opts.do_expand ^= PDF_EXPAND_IMAGES; break;
- case 'l': opts.do_linear ++; break;
- case 'a': opts.do_ascii ++; break;
- case 'z': opts.do_deflate ++; break;
- case 's': opts.do_clean ++; break;
+
+ case 'd': opts.do_decompress += 1; break;
+ case 'z': opts.do_compress += 1; break;
+ case 'f': opts.do_compress_fonts += 1; break;
+ case 'i': opts.do_compress_images += 1; break;
+ case 'a': opts.do_ascii += 1; break;
+ case 'g': opts.do_garbage += 1; break;
+ case 'l': opts.do_linear += 1; break;
+ case 's': opts.do_clean += 1; break;
default: usage(); break;
}
}
+ if ((opts.do_ascii || opts.do_decompress) && !opts.do_compress)
+ opts.do_pretty = 1;
+
if (argc - fz_optind < 1)
usage();