diff options
Diffstat (limited to 'source/pdf/js')
-rw-r--r-- | source/pdf/js/pdf-js.c | 15 | ||||
-rw-r--r-- | source/pdf/js/pdf-util.js | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/source/pdf/js/pdf-js.c b/source/pdf/js/pdf-js.c index c03429a7..bc9fcae0 100644 --- a/source/pdf/js/pdf-js.c +++ b/source/pdf/js/pdf-js.c @@ -541,6 +541,9 @@ static void declare_dom(pdf_js *js) addmethod(J, "Doc.mailDoc", doc_mailDoc, 6); } js_setregistry(J, "Doc"); + + js_getregistry(J, "Doc"); + js_setglobal(J, "MuPDF_Doc"); /* for pdf-util.js use */ } static void preload_helpers(pdf_js *js) @@ -676,11 +679,19 @@ void pdf_js_execute(pdf_js *js, char *source) { if (js) { - puts(source); if (js_ploadstring(js->imp, "[pdf]", source)) + { + fz_warn(js->ctx, "%s", js_tostring(js->imp, -1)); + js_pop(js->imp, 1); return; + } js_getregistry(js->imp, "Doc"); /* set 'this' to the Doc object */ - js_pcall(js->imp, 0); + if (js_pcall(js->imp, 0)) + { + fz_warn(js->ctx, "%s", js_tostring(js->imp, -1)); + js_pop(js->imp, 1); + return; + } js_pop(js->imp, 1); } } diff --git a/source/pdf/js/pdf-util.js b/source/pdf/js/pdf-util.js index 9a62add0..299f80ac 100644 --- a/source/pdf/js/pdf-util.js +++ b/source/pdf/js/pdf-util.js @@ -819,7 +819,7 @@ function AFSimple_Calculate(op, list) for (i = 0; i < list.length; i++) { - var field = getField(list[i]); + var field = MuPDF_Doc.getField(list[i]); var value = Number(field.value); switch (op) |