summaryrefslogtreecommitdiff
path: root/source/tools/murun.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-07-06 14:20:26 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-08-10 12:09:10 +0200
commit0abcccc4aab4d893ac2a0ef116ff1f0c006fbc30 (patch)
tree8fe312208afaf28e2d759f4a1c53ec4ef131124f /source/tools/murun.c
parent6f8cb5606e426084160eaec82e9c11966e7fb5f4 (diff)
downloadmupdf-0abcccc4aab4d893ac2a0ef116ff1f0c006fbc30.tar.xz
Rejig pdf_update_page and pdf_update_annot.
The intent is for a user to iterate over the annotations on a page calling pdf_update_annot for each one. If this function returns true, then the annotation has changed since the last time it was called, and the user needs to re-render. pdf_update_page is a simple loop over the annotations on a page, for use if you only care about page level granularity. Users should no longer look at or change the pdf_annot.has_new_ap field.
Diffstat (limited to 'source/tools/murun.c')
-rw-r--r--source/tools/murun.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index c6ad673f..02144df4 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -4040,6 +4040,18 @@ static void ffi_PDFPage_deleteAnnotation(js_State *J)
rethrow(J);
}
+static void ffi_PDFPage_update(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ pdf_page *page = js_touserdata(J, 0, "pdf_page");
+ int changed = 0;
+ fz_try(ctx)
+ changed = pdf_update_page(ctx, page);
+ fz_catch(ctx)
+ rethrow(J);
+ js_pushboolean(J, changed);
+}
+
static void ffi_PDFAnnotation_getType(js_State *J)
{
fz_context *ctx = js_getcontext(J);
@@ -4435,6 +4447,18 @@ static void ffi_PDFAnnotation_updateAppearance(js_State *J)
rethrow(J);
}
+static void ffi_PDFAnnotation_update(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ pdf_annot *annot = js_touserdata(J, 0, "pdf_annot");
+ int changed = 0;
+ fz_try(ctx)
+ changed = pdf_update_annot(ctx, annot);
+ fz_catch(ctx)
+ rethrow(J);
+ js_pushboolean(J, changed);
+}
+
#endif /* FZ_ENABLE_PDF */
int murun_main(int argc, char **argv)
@@ -4737,6 +4761,7 @@ int murun_main(int argc, char **argv)
{
jsB_propfun(J, "PDFPage.createAnnotation", ffi_PDFPage_createAnnotation, 1);
jsB_propfun(J, "PDFPage.deleteAnnotation", ffi_PDFPage_deleteAnnotation, 1);
+ jsB_propfun(J, "PDFPage.update", ffi_PDFPage_update, 0);
}
js_setregistry(J, "pdf_page");
@@ -4765,6 +4790,7 @@ int murun_main(int argc, char **argv)
jsB_propfun(J, "PDFAnnotation.getModificationDate", ffi_PDFAnnotation_getModificationDate, 0);
jsB_propfun(J, "PDFAnnotation.setModificationDate", ffi_PDFAnnotation_setModificationDate, 0);
jsB_propfun(J, "PDFAnnotation.updateAppearance", ffi_PDFAnnotation_updateAppearance, 0);
+ jsB_propfun(J, "PDFAnnotation.update", ffi_PDFAnnotation_update, 0);
}
js_setregistry(J, "pdf_annot");