diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-12-09 14:32:21 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-12-12 13:40:40 +0100 |
commit | dbdea58a61dace3c36c586e4858e462674590f66 (patch) | |
tree | f0aac41bfdd52e08952be08d2018ecd8bd42275e /source | |
parent | fd8157ead4e10985e1ad1d996e2452bac4dca784 (diff) | |
download | mupdf-dbdea58a61dace3c36c586e4858e462674590f66.tar.xz |
Tweak pdf portfolio: automatically use incremental writing.
Windows cannot remove open files, so we can't save non-incrementally
to the same file name as the open document. Force incremental saves
if the input and output file names are the same.
NOTE: We will also create corrupt files if saving a new document incrementally,
so take care not to turn on incremental saves if we have created a new blank
document.
Diffstat (limited to 'source')
-rw-r--r-- | source/tools/pdfportfolio.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/tools/pdfportfolio.c b/source/tools/pdfportfolio.c index ff119bf8..87662989 100644 --- a/source/tools/pdfportfolio.c +++ b/source/tools/pdfportfolio.c @@ -197,6 +197,7 @@ int pdfportfolio_main(int argc, char **argv) char *infile; int exit_code = 0; int do_save = 0; + int has_old_file = 0; int c; while ((c = fz_getopt(argc, argv, "p:o:O:")) != -1) @@ -230,6 +231,7 @@ int pdfportfolio_main(int argc, char **argv) if (pdf_needs_password(ctx, doc)) if (!pdf_authenticate_password(ctx, doc, password)) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", infile); + has_old_file = 1; } else { @@ -299,6 +301,8 @@ int pdfportfolio_main(int argc, char **argv) { pdf_write_options opts; pdf_parse_write_options(ctx, &opts, outopts); + if (has_old_file && infile == outfile) + opts.do_incremental = 1; pdf_save_document(ctx, doc, outfile, &opts); } |