From dbdea58a61dace3c36c586e4858e462674590f66 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 9 Dec 2016 14:32:21 +0100 Subject: 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. --- source/tools/pdfportfolio.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/tools/pdfportfolio.c') 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); } -- cgit v1.2.3