diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-03-03 13:05:35 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-03-14 17:08:28 +0100 |
commit | db8c7b6020199465ff395cff8ccd6c6f4be22d5a (patch) | |
tree | b33a93eb8d82141c6691d23c4411dd1e30efdc77 /source/tools | |
parent | 27d73f2043e72dc146f543bbc871dbf820f9900e (diff) | |
download | mupdf-db8c7b6020199465ff395cff8ccd6c6f4be22d5a.tar.xz |
js: Add obj.writeStream and writeRawStream to update stream contents.
Diffstat (limited to 'source/tools')
-rw-r--r-- | source/tools/murun.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c index 9eef2d02..194bc6c2 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -2527,6 +2527,32 @@ static void ffi_PDFObject_readStream(js_State *J) ffi_pushbuffer(J, buf); } +static void ffi_PDFObject_writeStream(js_State *J) +{ + fz_context *ctx = js_getcontext(J); + pdf_obj *obj = js_touserdata(J, 0, "pdf_obj"); + fz_buffer *buf = ffi_tobuffer(J, 1); + fz_try(ctx) + pdf_update_stream(ctx, pdf_get_bound_document(ctx, obj), obj, buf, 0); + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + rethrow(J); +} + +static void ffi_PDFObject_writeRawStream(js_State *J) +{ + fz_context *ctx = js_getcontext(J); + pdf_obj *obj = js_touserdata(J, 0, "pdf_obj"); + fz_buffer *buf = ffi_tobuffer(J, 1); + fz_try(ctx) + pdf_update_stream(ctx, pdf_get_bound_document(ctx, obj), obj, buf, 1); + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + rethrow(J); +} + static void ffi_PDFObject_readRawStream(js_State *J) { fz_context *ctx = js_getcontext(J); @@ -2838,6 +2864,8 @@ int murun_main(int argc, char **argv) jsB_propfun(J, "PDFObject.isStream", ffi_PDFObject_isStream, 0); jsB_propfun(J, "PDFObject.readStream", ffi_PDFObject_readStream, 0); jsB_propfun(J, "PDFObject.readRawStream", ffi_PDFObject_readRawStream, 0); + jsB_propfun(J, "PDFObject.writeStream", ffi_PDFObject_writeStream, 1); + jsB_propfun(J, "PDFObject.writeRawStream", ffi_PDFObject_writeRawStream, 1); jsB_propfun(J, "PDFObject.forEach", ffi_PDFObject_forEach, 1); } js_setregistry(J, "pdf_obj"); |