summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-11-15 16:10:03 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-11-16 12:09:20 +0100
commitfa9cd67527ab9994fec917f0f88fc16abb9926a6 (patch)
tree9f533a52350e32b0d778c158fbb4eafbe0d0d12e /platform
parent5ed7e6c29233874a68733cdf075260fe261caa40 (diff)
downloadmupdf-fa9cd67527ab9994fec917f0f88fc16abb9926a6.tar.xz
pdf: Add 'compressed/raw' flag to pdf_add_stream.
Also expose the argument to JS and JNI.
Diffstat (limited to 'platform')
-rw-r--r--platform/java/mupdf_native.c10
-rw-r--r--platform/java/mupdf_native.h8
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java32
3 files changed, 38 insertions, 12 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 5dec7b05..722444a2 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -6057,10 +6057,11 @@ FUN(PDFDocument_graftObject)(JNIEnv *env, jobject self, jobject jsrc, jobject jo
}
JNIEXPORT jobject JNICALL
-FUN(PDFDocument_addStreamBuffer)(JNIEnv *env, jobject self, jobject jbuf)
+FUN(PDFDocument_addStreamBuffer)(JNIEnv *env, jobject self, jobject jbuf, jobject jobj, jboolean compressed)
{
fz_context *ctx = get_context(env);
pdf_document *pdf = from_PDFDocument(env, self);
+ pdf_obj *obj = from_PDFObject(env, jobj);
fz_buffer *buf = from_Buffer(env, jbuf);
pdf_obj *ind = NULL;
@@ -6068,7 +6069,7 @@ FUN(PDFDocument_addStreamBuffer)(JNIEnv *env, jobject self, jobject jbuf)
if (!jbuf) { jni_throw_arg(env, "buffer must not be null"); return NULL; }
fz_try(ctx)
- ind = pdf_add_stream(ctx, pdf, buf, NULL);
+ ind = pdf_add_stream(ctx, pdf, buf, obj, compressed);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
@@ -6079,10 +6080,11 @@ FUN(PDFDocument_addStreamBuffer)(JNIEnv *env, jobject self, jobject jbuf)
}
JNIEXPORT jobject JNICALL
-FUN(PDFDocument_addStreamString)(JNIEnv *env, jobject self, jstring jbuf)
+FUN(PDFDocument_addStreamString)(JNIEnv *env, jobject self, jstring jbuf, jobject jobj, jboolean compressed)
{
fz_context *ctx = get_context(env);
pdf_document *pdf = from_PDFDocument(env, self);
+ pdf_obj *obj = from_PDFObject(env, jobj);
fz_buffer *buf = NULL;
const char *sbuf = NULL;
unsigned char *data = NULL;
@@ -6104,7 +6106,7 @@ FUN(PDFDocument_addStreamString)(JNIEnv *env, jobject self, jstring jbuf)
memcpy(data, sbuf, len);
buf = fz_new_buffer_from_data(ctx, data, len);
data = NULL;
- ind = pdf_add_stream(ctx, pdf, buf, NULL);
+ ind = pdf_add_stream(ctx, pdf, buf, obj, compressed);
}
fz_always(ctx)
{
diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h
index c572b6bd..3e6c51b3 100644
--- a/platform/java/mupdf_native.h
+++ b/platform/java/mupdf_native.h
@@ -1471,18 +1471,18 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_graftObject
/*
* Class: com_artifex_mupdf_fitz_PDFDocument
* Method: addStreamBuffer
- * Signature: (Lcom/artifex/mupdf/fitz/Buffer;)Lcom/artifex/mupdf/fitz/PDFObject;
+ * Signature: (Lcom/artifex/mupdf/fitz/Buffer;Ljava/lang/Object;Z)Lcom/artifex/mupdf/fitz/PDFObject;
*/
JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addStreamBuffer
- (JNIEnv *, jobject, jobject);
+ (JNIEnv *, jobject, jobject, jobject, jboolean);
/*
* Class: com_artifex_mupdf_fitz_PDFDocument
* Method: addStreamString
- * Signature: (Ljava/lang/String;)Lcom/artifex/mupdf/fitz/PDFObject;
+ * Signature: (Ljava/lang/String;Ljava/lang/Object;Z)Lcom/artifex/mupdf/fitz/PDFObject;
*/
JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addStreamString
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *, jobject, jstring, jobject, jboolean);
/*
* Class: com_artifex_mupdf_fitz_PDFDocument
diff --git a/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java b/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java
index 601919d7..f866cb86 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java
@@ -48,15 +48,39 @@ public class PDFDocument
public native PDFGraftMap newPDFGraftMap();
public native PDFObject graftObject(PDFDocument src, PDFObject obj, PDFGraftMap map);
- private native PDFObject addStreamBuffer(Buffer buf);
- private native PDFObject addStreamString(String str);
+ private native PDFObject addStreamBuffer(Buffer buf, Object obj, boolean compressed);
+ private native PDFObject addStreamString(String str, Object obj, boolean compressed);
+
+ public PDFObject addRawStream(Buffer buf, Object obj) {
+ return addStreamBuffer(buf, obj, true);
+ }
+
+ public PDFObject addStream(Buffer buf, Object obj) {
+ return addStreamBuffer(buf, obj, false);
+ }
+
+ public PDFObject addRawStream(String str, Object obj) {
+ return addStreamString(str, obj, true);
+ }
+
+ public PDFObject addStream(String str, Object obj) {
+ return addStreamString(str, obj, false);
+ }
+
+ public PDFObject addRawStream(Buffer buf) {
+ return addStreamBuffer(buf, null, true);
+ }
public PDFObject addStream(Buffer buf) {
- return addStreamBuffer(buf);
+ return addStreamBuffer(buf, null, false);
+ }
+
+ public PDFObject addRawStream(String str) {
+ return addStreamString(str, null, true);
}
public PDFObject addStream(String str) {
- return addStreamString(str);
+ return addStreamString(str, null, false);
}
private native PDFObject addPageBuffer(Rect mediabox, int rotate, PDFObject resources, Buffer contents);