diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-07-04 12:11:20 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-07-04 12:11:20 +0100 |
commit | ac84904af638b243284e24d5f401c3f1a21cb0ef (patch) | |
tree | 32e9f6b3b0d0ad83cb8f2dd0c41bc5e60b53ed3e /platform/android | |
parent | b33b3b41100f2bb0b63dbf270bdd4401451c081a (diff) | |
download | mupdf-ac84904af638b243284e24d5f401c3f1a21cb0ef.tar.xz |
Update pdf_write_document to support incremental update
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/jni/mupdf.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c index bb827778..889abe07 100644 --- a/platform/android/jni/mupdf.c +++ b/platform/android/jni/mupdf.c @@ -2342,21 +2342,42 @@ JNI_FN(MuPDFCore_saveInternal)(JNIEnv * env, jobject thiz) { char *tmp; fz_write_options opts; - opts.do_ascii = 1; + opts.do_incremental = 1; + opts.do_ascii = 0; opts.do_expand = 0; - opts.do_garbage = 1; + opts.do_garbage = 0; opts.do_linear = 0; tmp = tmp_path(glo->current_path); if (tmp) { - int written; + int written = 0; fz_var(written); fz_try(ctx) { - fz_write_document(glo->doc, tmp, &opts); - written = 1; + FILE *fin = fopen(glo->current_path, "rb"); + FILE *fout = fopen(tmp, "wb"); + char buf[256]; + int n, err = 1; + + if (fin && fout) + { + while ((n = fread(buf, 1, sizeof(buf), fin)) > 0) + fwrite(buf, 1, n, fout); + err = (ferror(fin) || ferror(fout)); + } + + if (fin) + fclose(fin); + if (fout) + fclose(fout); + + if (!err) + { + fz_write_document(glo->doc, tmp, &opts); + written = 1; + } } fz_catch(ctx) { |