diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Annotation.java | 3 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Buffer.java | 39 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/DisplayList.java | 7 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Document.java | 8 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/DocumentWriter.java | 27 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Image.java | 1 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/PDFDocument.java | 57 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/PDFObject.java | 155 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Page.java | 5 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Path.java | 1 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/Pixmap.java | 9 | ||||
-rw-r--r-- | platform/java/com/artifex/mupdf/fitz/StructuredText.java | 21 | ||||
-rw-r--r-- | platform/java/mupdf_native.c | 2439 | ||||
-rw-r--r-- | platform/java/mupdf_native.h | 875 |
14 files changed, 3645 insertions, 2 deletions
diff --git a/platform/java/com/artifex/mupdf/fitz/Annotation.java b/platform/java/com/artifex/mupdf/fitz/Annotation.java index 5f652246..855ff5a1 100644 --- a/platform/java/com/artifex/mupdf/fitz/Annotation.java +++ b/platform/java/com/artifex/mupdf/fitz/Annotation.java @@ -16,6 +16,9 @@ public class Annotation } public native void run(Device dev, Matrix ctm, Cookie cookie); + public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha); + public native Rect getBounds(); + public native DisplayList toDisplayList(); private native long advance(); } diff --git a/platform/java/com/artifex/mupdf/fitz/Buffer.java b/platform/java/com/artifex/mupdf/fitz/Buffer.java new file mode 100644 index 00000000..7f23b062 --- /dev/null +++ b/platform/java/com/artifex/mupdf/fitz/Buffer.java @@ -0,0 +1,39 @@ +package com.artifex.mupdf.fitz; + +public class Buffer +{ + static { + Context.init(); + } + + public static final int DEFAULT_BUFFER_SIZE = 1024; + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNativeBuffer(int n); + + public Buffer(int n) { + pointer = newNativeBuffer(n); + } + + public Buffer() { + pointer = newNativeBuffer(DEFAULT_BUFFER_SIZE); + } + + public native int getLength(); + public native void writeByte(byte b); + public native void writeBytes(byte[] bs); + public native void writeBuffer(Buffer buf); + public native void writeRune(int rune); + public native void writeLine(String line); + public native void writeLines(String... lines); + + public native void save(String filename); +} diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/com/artifex/mupdf/fitz/DisplayList.java index 1933f9ae..3e822eea 100644 --- a/platform/java/com/artifex/mupdf/fitz/DisplayList.java +++ b/platform/java/com/artifex/mupdf/fitz/DisplayList.java @@ -17,6 +17,13 @@ public class DisplayList pointer = newNative(); } + private DisplayList(long p) { + pointer = p; + } + + public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha); + public native Rect[] search(String needle); + public native void run(Device dev, Matrix ctm, Rect scissor, Cookie cookie); public void run(Device dev, Matrix ctm, Cookie cookie) { diff --git a/platform/java/com/artifex/mupdf/fitz/Document.java b/platform/java/com/artifex/mupdf/fitz/Document.java index 22d2f9bf..89e3013b 100644 --- a/platform/java/com/artifex/mupdf/fitz/Document.java +++ b/platform/java/com/artifex/mupdf/fitz/Document.java @@ -32,6 +32,10 @@ public class Document pointer = newNativeWithBuffer(buffer, magic); } + private Document(long p) { + pointer = p; + } + public native boolean needsPassword(); public native boolean authenticatePassword(String password); @@ -39,6 +43,10 @@ public class Document public native Page loadPage(int number); public native Outline loadOutline(); public native String getMetaData(String key); + public native boolean isReflowable(); + public native void layout(float width, float height, float em); public native boolean isUnencryptedPDF(); + + public native PDFDocument toPDFDocument(); } diff --git a/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java b/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java new file mode 100644 index 00000000..dce9d73d --- /dev/null +++ b/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java @@ -0,0 +1,27 @@ +package com.artifex.mupdf.fitz; + +public class DocumentWriter +{ + static { + Context.init(); + } + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNativeDocumentWriter(String filename, String format, String options); + + public DocumentWriter(String filename, String format, String options) { + pointer = newNativeDocumentWriter(filename, format, options); + } + + public native Device beingPage(Rect mediabox); + public native void endPage(Device device); + public native void close(); +} diff --git a/platform/java/com/artifex/mupdf/fitz/Image.java b/platform/java/com/artifex/mupdf/fitz/Image.java index a9eb2ffa..4d2f7eb5 100644 --- a/platform/java/com/artifex/mupdf/fitz/Image.java +++ b/platform/java/com/artifex/mupdf/fitz/Image.java @@ -31,6 +31,7 @@ public class Image public native int getXResolution(); public native int getYResolution(); + public native ColorSpace getColorSpace(); public native int getNumberOfComponents(); public native int getBitsPerComponent(); public native boolean getImageMask(); diff --git a/platform/java/com/artifex/mupdf/fitz/PDFDocument.java b/platform/java/com/artifex/mupdf/fitz/PDFDocument.java new file mode 100644 index 00000000..58a3e3a6 --- /dev/null +++ b/platform/java/com/artifex/mupdf/fitz/PDFDocument.java @@ -0,0 +1,57 @@ +package com.artifex.mupdf.fitz; + +public class PDFDocument +{ + static { + Context.init(); + } + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private PDFDocument(long p) { + pointer = p; + } + + public native Document toDocument(); + + public native int countPages(); + public native PDFObject findPage(int at); + + public native PDFObject getTrailer(); + public native int countObjects(); + + public native PDFObject newNull(); + public native PDFObject newBoolean(boolean b); + public native PDFObject newInteger(int i); + public native PDFObject newReal(float f); + public native PDFObject newString(String s); + public native PDFObject newName(String name); + public native PDFObject newIndirect(int num, int gen); + public native PDFObject newArray(); + public native PDFObject newDictionary(); + + public native PDFObject addObject(PDFObject obj); + public native PDFObject createObject(); + public native void deleteObject(int i); + + public native PDFObject addStream(Buffer buf); + + public native PDFObject addPage(Rect mediabox, int rotate, PDFObject resources, Buffer contents); + public native void insertPage(int at, PDFObject page); + public native void deletePage(int at); + public native PDFObject addImage(Image image); + public native PDFObject addSimpleFont(Font font); + public native PDFObject addFont(Font font); + public native void save(String filename, String options); + + public void deleteObject(PDFObject obj) { + deleteObject(obj.toIndirect()); + } +} diff --git a/platform/java/com/artifex/mupdf/fitz/PDFObject.java b/platform/java/com/artifex/mupdf/fitz/PDFObject.java new file mode 100644 index 00000000..f2e926f2 --- /dev/null +++ b/platform/java/com/artifex/mupdf/fitz/PDFObject.java @@ -0,0 +1,155 @@ +package com.artifex.mupdf.fitz; + +public class PDFObject +{ + static { + Context.init(); + } + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private PDFObject(long p) { + pointer = p; + } + + public native boolean isIndirect(); + public native boolean isNull(); + public native boolean isBoolean(); + public native boolean isInteger(); + public native boolean isReal(); + public native boolean isNumber(); + public native boolean isString(); + public native boolean isName(); + public native boolean isArray(); + public native boolean isDictionary(); + public native boolean isStream(); + + public native boolean toBoolean(); + public native int toInteger(); + public native float toFloat(); + public native byte[] toByteString(); + public native int toIndirect(); + public native String toString(boolean tight); + + public String toString() { + return toString(false); + } + + public native PDFObject resolve(); + + public native byte[] readStream(); + public native byte[] readRawStream(); + + public native PDFObject getArray(int index); + public native PDFObject getDictionary(String name); + + public PDFObject get(int index) { + return getArray(index); + } + + public PDFObject get(String name) { + return getDictionary(name); + } + + public native void putArrayBoolean(int index, boolean b); + public native void putArrayInteger(int index, int i); + public native void putArrayFloat(int index, float f); + public native void putArrayString(int index, String str); + public native void putArrayPDFObject(int index, PDFObject obj); + + public native void putDictionaryStringBoolean(String name, boolean b); + public native void putDictionaryStringInteger(String name, int i); + public native void putDictionaryStringFloat(String name, float f); + public native void putDictionaryStringString(String name, String str); + public native void putDictionaryStringPDFObject(String name, PDFObject obj); + + public native void putDictionaryPDFObjectBoolean(PDFObject name, boolean b); + public native void putDictionaryPDFObjectInteger(PDFObject name, int i); + public native void putDictionaryPDFObjectFloat(PDFObject name, float f); + public native void putDictionaryPDFObjectString(PDFObject name, String str); + public native void putDictionaryPDFObjectPDFObject(PDFObject name, PDFObject obj); + + + public void put(int index, boolean b) { + putArrayBoolean(index, b); + } + + public void put(int index, int i) { + putArrayInteger(index, i); + } + + public void put(int index, float f) { + putArrayFloat(index, f); + } + + public void put(int index, String s) { + putArrayString(index, s); + } + + public void put(int index, PDFObject obj) { + putArrayPDFObject(index, obj); + } + + public void put(String name, boolean b) { + putDictionaryStringBoolean(name, b); + } + + public void put(String name, int i) { + putDictionaryStringInteger(name, i); + } + + public void put(String name, float f) { + putDictionaryStringFloat(name, f); + } + + public void put(String name, String str) { + putDictionaryStringString(name, str); + } + + public void put(String name, PDFObject obj) { + putDictionaryStringPDFObject(name, obj); + } + + public void put(PDFObject name, boolean b) { + putDictionaryPDFObjectBoolean(name, b); + } + + public void put(PDFObject name, int i) { + putDictionaryPDFObjectInteger(name, i); + } + + public void put(PDFObject name, float f) { + putDictionaryPDFObjectFloat(name, f); + } + + public void put(PDFObject name, String str) { + putDictionaryPDFObjectString(name, str); + } + + public void put(PDFObject name, PDFObject obj) { + putDictionaryPDFObjectPDFObject(name, obj); + } + + public native void deleteArray(int index); + public native void deleteDictionaryString(String name); + public native void deleteDictionaryPDFObject(PDFObject name); + + public void delete(int index) { + deleteArray(index); + } + + public void delete(String name) { + deleteDictionaryString(name); + } + + public void delete(PDFObject name) { + deleteDictionaryPDFObject(name); + } +} diff --git a/platform/java/com/artifex/mupdf/fitz/Page.java b/platform/java/com/artifex/mupdf/fitz/Page.java index 71f39857..64fe4030 100644 --- a/platform/java/com/artifex/mupdf/fitz/Page.java +++ b/platform/java/com/artifex/mupdf/fitz/Page.java @@ -35,4 +35,9 @@ public class Page // FIXME: Later. Much later. //fz_transition *fz_page_presentation(fz_document *doc, fz_page *page, float *duration); + + public native DisplayList toDisplayList(boolean no_annotations); + public native StructuredText toStructuredText(); + + public native Rect[] search(String needle); } diff --git a/platform/java/com/artifex/mupdf/fitz/Path.java b/platform/java/com/artifex/mupdf/fitz/Path.java index fa925bab..455dce69 100644 --- a/platform/java/com/artifex/mupdf/fitz/Path.java +++ b/platform/java/com/artifex/mupdf/fitz/Path.java @@ -33,6 +33,7 @@ public class Path implements PathWalker public native void curveTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey); public native void curveToV(float cx, float cy, float ex, float ey); public native void curveToY(float cx, float cy, float ex, float ey); + public native void rect(int x1, int y1, int x2, int y2); public native void closePath(); public void moveTo(Point xy) { diff --git a/platform/java/com/artifex/mupdf/fitz/Pixmap.java b/platform/java/com/artifex/mupdf/fitz/Pixmap.java index ac14e95c..52432fea 100644 --- a/platform/java/com/artifex/mupdf/fitz/Pixmap.java +++ b/platform/java/com/artifex/mupdf/fitz/Pixmap.java @@ -55,12 +55,21 @@ public class Pixmap public native boolean getAlpha(); public native ColorSpace getColorSpace(); public native byte[] getSamples(); + public native byte getSamples(int x, int y, int n); public native int[] getPixels(); /* only valid for RGBA or BGRA pixmaps */ + public native int getXResolution(); + public native int getYResolution(); public void clear(int value) { clearWithValue(value); } + public Rect getBounds() { + int x = getX(); + int y = getY(); + return new Rect(x, y, x + getWidth(), y+ getHeight()); + } + public String toString() { return "Pixmap(w=" + getWidth() + " h=" + getHeight() + diff --git a/platform/java/com/artifex/mupdf/fitz/StructuredText.java b/platform/java/com/artifex/mupdf/fitz/StructuredText.java new file mode 100644 index 00000000..0f3549d5 --- /dev/null +++ b/platform/java/com/artifex/mupdf/fitz/StructuredText.java @@ -0,0 +1,21 @@ +package com.artifex.mupdf.fitz; + +public class StructuredText +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private StructuredText(long p) { + pointer = p; + } + + public native Rect[] search(String needle); + public native Rect[] highlight(Rect rect); + public native String copy(Rect rect); +} diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 9b910d22..ef9a04b8 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -50,11 +50,13 @@ static inline jlong jlong_cast(const void *p) /* All the cached classes/mids/fids we need. */ static jclass cls_Annot; +static jclass cls_Buffer; static jclass cls_ColorSpace; static jclass cls_Cookie; static jclass cls_Device; static jclass cls_DisplayList; static jclass cls_Document; +static jclass cls_DocumentWriter; static jclass cls_Exception; static jclass cls_Font; static jclass cls_Image; @@ -67,21 +69,26 @@ static jclass cls_Outline; static jclass cls_Page; static jclass cls_Path; static jclass cls_PathWalker; +static jclass cls_PDFDocument; +static jclass cls_PDFObject; static jclass cls_Pixmap; static jclass cls_Point; static jclass cls_Rect; static jclass cls_Shade; static jclass cls_StrokeState; +static jclass cls_StructuredText; static jclass cls_Text; static jclass cls_TextWalker; static jclass cls_TryLaterException; static jfieldID fid_Annot_pointer; +static jfieldID fid_Buffer_pointer; static jfieldID fid_ColorSpace_pointer; static jfieldID fid_Cookie_pointer; static jfieldID fid_Device_pointer; static jfieldID fid_DisplayList_pointer; static jfieldID fid_Document_pointer; +static jfieldID fid_DocumentWriter_pointer; static jfieldID fid_Font_pointer; static jfieldID fid_Image_pointer; static jfieldID fid_Link_pointer; @@ -97,6 +104,8 @@ static jfieldID fid_Outline_pointer; static jfieldID fid_Page_nativeAnnots; static jfieldID fid_Page_pointer; static jfieldID fid_Path_pointer; +static jfieldID fid_PDFDocument_pointer; +static jfieldID fid_PDFObject_pointer; static jfieldID fid_Pixmap_pointer; static jfieldID fid_Rect_x0; static jfieldID fid_Rect_x1; @@ -104,6 +113,7 @@ static jfieldID fid_Rect_y0; static jfieldID fid_Rect_y1; static jfieldID fid_Shade_pointer; static jfieldID fid_StrokeState_pointer; +static jfieldID fid_StructuredText_pointer; static jfieldID fid_Text_pointer; static jmethodID mid_Annot_init; @@ -126,9 +136,12 @@ static jmethodID mid_Device_fillPath; static jmethodID mid_Device_fillShade; static jmethodID mid_Device_fillText; static jmethodID mid_Device_ignoreText; +static jmethodID mid_Device_init; static jmethodID mid_Device_popClip; static jmethodID mid_Device_strokePath; static jmethodID mid_Device_strokeText; +static jmethodID mid_DisplayList_init; +static jmethodID mid_Document_init; static jmethodID mid_Font_init; static jmethodID mid_Image_init; static jmethodID mid_Matrix_init; @@ -140,11 +153,14 @@ static jmethodID mid_PathWalker_curveTo; static jmethodID mid_PathWalker_lineTo; static jmethodID mid_PathWalker_moveTo; static jmethodID mid_Path_init; +static jmethodID mid_PDFDocument_init; +static jmethodID mid_PDFObject_init; static jmethodID mid_Pixmap_init; static jmethodID mid_Point_init; static jmethodID mid_Rect_init; static jmethodID mid_Shade_init; static jmethodID mid_StrokeState_init; +static jmethodID mid_StructuredText_init; static jmethodID mid_Text_init; static jmethodID mid_TextWalker_showGlyph; @@ -291,6 +307,9 @@ static int find_fids(JNIEnv *env) fid_Annot_pointer = get_field(&err, env, "pointer", "J"); mid_Annot_init = get_method(&err, env, "<init>", "(J)V"); + cls_Buffer = get_class(&err, env, PKG"Buffer"); + fid_Buffer_pointer = get_field(&err, env, "pointer", "J"); + cls_ColorSpace = get_class(&err, env, PKG"ColorSpace"); fid_ColorSpace_pointer = get_field(&err, env, "pointer", "J"); mid_ColorSpace_init = get_method(&err, env, "<init>", "(J)V"); @@ -301,6 +320,7 @@ static int find_fids(JNIEnv *env) cls_Device = get_class(&err, env, PKG"Device"); fid_Device_pointer = get_field(&err, env, "pointer", "J"); + mid_Device_init = get_method(&err, env, "<init>", "(J)V"); mid_Device_fillPath = get_method(&err, env, "fillPath", "(L"PKG"Path;ZL"PKG"Matrix;L"PKG"ColorSpace;[FF)V"); mid_Device_strokePath = get_method(&err, env, "strokePath", "(L"PKG"Path;L"PKG"StrokeState;L"PKG"Matrix;L"PKG"ColorSpace;[FF)V"); mid_Device_clipPath = get_method(&err, env, "clipPath", "(L"PKG"Path;ZL"PKG"Matrix;)V"); @@ -328,9 +348,14 @@ static int find_fids(JNIEnv *env) cls_DisplayList = get_class(&err, env, PKG"DisplayList"); fid_DisplayList_pointer = get_field(&err, env, "pointer", "J"); + mid_DisplayList_init = get_method(&err, env, "<init>", "(J)V"); cls_Document = get_class(&err, env, PKG"Document"); fid_Document_pointer = get_field(&err, env, "pointer", "J"); + mid_Document_init = get_method(&err, env, "<init>", "(J)V"); + + cls_DocumentWriter = get_class(&err, env, PKG"DocumentWriter"); + fid_DocumentWriter_pointer = get_field(&err, env, "pointer", "J"); cls_Font = get_class(&err, env, PKG"Font"); fid_Font_pointer = get_field(&err, env, "pointer", "J"); @@ -365,6 +390,14 @@ static int find_fids(JNIEnv *env) fid_Path_pointer = get_field(&err, env, "pointer", "J"); mid_Path_init = get_method(&err, env, "<init>", "(J)V"); + cls_PDFDocument = get_class(&err, env, PKG"PDFDocument"); + fid_PDFDocument_pointer = get_field(&err, env, "pointer", "J"); + mid_PDFDocument_init = get_method(&err, env, "<init>", "(J)V"); + + cls_PDFObject = get_class(&err, env, PKG"PDFObject"); + fid_PDFObject_pointer = get_field(&err, env, "pointer", "J"); + mid_PDFObject_init = get_method(&err, env, "<init>", "(J)V"); + cls_Pixmap = get_class(&err, env, PKG"Pixmap"); fid_Pixmap_pointer = get_field(&err, env, "pointer", "J"); mid_Pixmap_init = get_method(&err, env, "<init>", "(J)V"); @@ -393,6 +426,10 @@ static int find_fids(JNIEnv *env) fid_StrokeState_pointer = get_field(&err, env, "pointer", "J"); mid_StrokeState_init = get_method(&err, env, "<init>", "(J)V"); + cls_StructuredText = get_class(&err, env, PKG"StructuredText"); + fid_StructuredText_pointer = get_field(&err, env, "pointer", "J"); + mid_StructuredText_init = get_method(&err, env, "<init>", "(J)V"); + cls_Text = get_class(&err, env, PKG"Text"); fid_Text_pointer = get_field(&err, env, "pointer", "J"); mid_Text_init = get_method(&err, env, "<init>", "(J)V"); @@ -434,6 +471,8 @@ static void lose_fids(JNIEnv *env) (*env)->DeleteGlobalRef(env, cls_Page); (*env)->DeleteGlobalRef(env, cls_Path); (*env)->DeleteGlobalRef(env, cls_PathWalker); + (*env)->DeleteGlobalRef(env, cls_PDFDocument); + (*env)->DeleteGlobalRef(env, cls_PDFObject); (*env)->DeleteGlobalRef(env, cls_Pixmap); (*env)->DeleteGlobalRef(env, cls_Point); (*env)->DeleteGlobalRef(env, cls_Rect); @@ -679,6 +718,42 @@ static inline jobject to_ColorSpace(fz_context *ctx, JNIEnv *env, fz_colorspace return jobj; } +/* take ownership and don't throw fitz exceptions */ +static inline jobject to_Device_safe_own(fz_context *ctx, JNIEnv *env, fz_device *device) +{ + jobject jdev; + + if (ctx == NULL || device == NULL) + return NULL; + + jdev = (*env)->NewObject(env, cls_DisplayList, mid_Device_init, jlong_cast(device)); + if (jdev == NULL) + { + fz_drop_device(ctx, device); + return NULL; + } + + return jdev; +} + +/* take ownership and don't throw fitz exceptions */ +static inline jobject to_DisplayList_safe_own(fz_context *ctx, JNIEnv *env, fz_display_list *list) +{ + jobject jlist; + + if (ctx == NULL || list == NULL) + return NULL; + + jlist = (*env)->NewObject(env, cls_DisplayList, mid_DisplayList_init, jlong_cast(list)); + if (jlist == NULL) + { + fz_drop_display_list(ctx, list); + return NULL; + } + + return jlist; +} + /* don't throw fitz exceptions */ static inline jobject to_Font_safe(fz_context *ctx, JNIEnv *env, fz_font *font) { @@ -762,6 +837,69 @@ static inline jobject to_Path(fz_context *ctx, JNIEnv *env, const fz_path *path) return jobj; } +/* don't throw fitz exceptions */ +static inline jobject to_Document_safe(fz_context *ctx, JNIEnv *env, fz_document *doc) +{ + jobject jdoc; + + if (ctx == NULL || doc == NULL) + return NULL; + + jdoc = (*env)->NewObject(env, cls_Document, mid_Document_init, jlong_cast(doc)); + if (jdoc != NULL) + fz_keep_document(ctx, doc); + + return jdoc; +} + +/* don't throw fitz exceptions */ +static inline jobject to_PDFDocument_safe(fz_context *ctx, JNIEnv *env, pdf_document *pdf) +{ + jobject jpdf; + + if (ctx == NULL || pdf == NULL) + return NULL; + + jpdf = (*env)->NewObject(env, cls_PDFDocument, mid_PDFDocument_init, jlong_cast(pdf)); + if (jpdf != NULL) + fz_keep_document(ctx, (fz_document *) pdf); + + return jpdf; +} + +/* don't throw fitz exceptions */ +static inline jobject to_PDFObject_safe(fz_context *ctx, JNIEnv *env, jobject pdf, pdf_obj *obj) +{ + jobject jobj; + + if (ctx == NULL || obj == NULL) + return NULL; + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), pdf); + if (jobj != NULL) + pdf_keep_obj(ctx, obj); + + return jobj; +} + +/* take ownership and don't throw fitz exceptions */ +static inline jobject to_PDFObject_safe_own(fz_context *ctx, JNIEnv *env, jobject pdf, pdf_obj *obj) +{ + jobject jobj; + + if (ctx == NULL || obj == NULL) + return NULL; + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), pdf); + if (jobj == NULL) + { + pdf_drop_obj(ctx, obj); + return NULL; + } + + return jobj; +} + /* take ownership and don't throw fitz exceptions */ static inline jobject to_Pixmap_safe_own(fz_context *ctx, JNIEnv *env, fz_pixmap *pixmap) { @@ -812,6 +950,24 @@ static inline jobject to_StrokeState(fz_context *ctx, JNIEnv *env, const fz_stro return jobj; } +/* take ownership and don't throw fitz exceptions */ +static inline jobject to_StructuredText_safe_own(fz_context *ctx, JNIEnv *env, fz_stext_page *text) +{ + jobject jtext; + + if (ctx == NULL || text == NULL) + return NULL; + + jtext = (*env)->NewObject(env, cls_StructuredText, mid_StructuredText_init, jlong_cast(text)); + if (jtext == NULL) + { + fz_drop_stext_page(ctx, text); + return NULL; + } + + return jtext; +} + static inline jobject to_Text(fz_context *ctx, JNIEnv *env, const fz_text *text) { jobject jobj; @@ -886,6 +1042,13 @@ static inline fz_annot *from_Annotation(JNIEnv *env, jobject jobj) return CAST(fz_annot *, (*env)->GetLongField(env, jobj, fid_Annot_pointer)); } +static inline fz_buffer *from_Buffer(JNIEnv *env, jobject jobj) +{ + if (jobj == NULL) + return NULL; + return CAST(fz_buffer *, (*env)->GetLongField(env, jobj, fid_Buffer_pointer)); +} + static inline fz_cookie *from_Cookie(JNIEnv *env, jobject jobj) { if (jobj == NULL) @@ -921,6 +1084,27 @@ static inline fz_document *from_Document(JNIEnv *env, jobject jobj) return CAST(fz_document *, (*env)->GetLongField(env, jobj, fid_Document_pointer)); } +static inline fz_document_writer *from_DocumentWriter(JNIEnv *env, jobject jobj) +{ + if (jobj == NULL) + return NULL; + return CAST(fz_document_writer *, (*env)->GetLongField(env, jobj, fid_DocumentWriter_pointer)); +} + +static inline pdf_document *from_PDFDocument(JNIEnv *env, jobject jobj) +{ + if (jobj == NULL) + return NULL; + return CAST(pdf_document *, (*env)->GetLongField(env, jobj, fid_PDFDocument_pointer)); +} + +static inline pdf_obj *from_PDFObject(JNIEnv *env, jobject jobj) +{ + if (jobj == NULL) + return NULL; + return CAST(pdf_obj *, (*env)->GetLongField(env, jobj, fid_PDFObject_pointer)); +} + static inline fz_font *from_Font(JNIEnv *env, jobject jobj) { if (jobj == NULL) @@ -984,6 +1168,13 @@ static inline fz_stroke_state *from_StrokeState(JNIEnv *env, jobject jobj) return CAST(fz_stroke_state *, (*env)->GetLongField(env, jobj, fid_StrokeState_pointer)); } +static inline fz_stext_page *from_StructuredText(JNIEnv *env, jobject jobj) +{ + if (jobj == NULL) + return NULL; + return CAST(fz_stext_page *, (*env)->GetLongField(env, jobj, fid_StructuredText_pointer)); +} + static inline fz_text *from_Text(JNIEnv *env, jobject jobj) { if (jobj == NULL) @@ -2466,6 +2657,34 @@ FUN(Pixmap_getSamples)(JNIEnv *env, jobject self) return arr; } +JNIEXPORT jbyte JNICALL +FUN(Pixmap_getSample)(JNIEnv *env, jobject self, jint x, jint y, jint k) +{ + fz_context *ctx = get_context(env); + fz_pixmap *pixmap = from_Pixmap(env, self); + + if (ctx == NULL || pixmap == NULL) + return 0; + + if (x < 0 || x >= pixmap->w) + { + jni_throw(env, FZ_ERROR_GENERIC, "X out of range"); + return 0; + } + if (y < 0 || y >= pixmap->h) + { + jni_throw(env, FZ_ERROR_GENERIC, "Y out of range"); + return 0; + } + if (k < 0 || k >= pixmap->n) + { + jni_throw(env, FZ_ERROR_GENERIC, "K out of range"); + return 0; + } + + return pixmap->samples[(x + y * pixmap->w) * pixmap->n + k]; +} + JNIEXPORT jintArray JNICALL FUN(Pixmap_getPixels)(JNIEnv *env, jobject self) { @@ -2498,6 +2717,30 @@ FUN(Pixmap_getPixels)(JNIEnv *env, jobject self) return arr; } +JNIEXPORT jint JNICALL +FUN(Pixmap_getXResolution)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_pixmap *pixmap = from_Pixmap(env, self); + + if (ctx == NULL || pixmap == NULL) + return 0; + + return pixmap->xres; +} + +JNIEXPORT jint JNICALL +FUN(Pixmap_getYResolution)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_pixmap *pixmap = from_Pixmap(env, self); + + if (ctx == NULL || pixmap == NULL) + return 0; + + return pixmap->yres; +} + /* Path Interface */ JNIEXPORT void JNICALL @@ -2623,6 +2866,21 @@ FUN(Path_curveToY)(JNIEnv *env, jobject self, jfloat cx, jfloat cy, jfloat ex, j } JNIEXPORT void JNICALL +FUN(Path_rect)(JNIEnv *env, jobject self, jint x1, jint y1, jint x2, jint y2) +{ + fz_context *ctx = get_context(env); + fz_path *path = from_Path(env, self); + + if (ctx == NULL || path == NULL) + return; + + fz_try(ctx) + fz_rectto(ctx, path, x1, y1, x2, y2); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL FUN(Path_closePath)(JNIEnv *env, jobject self) { fz_context *ctx = get_context(env); @@ -3134,6 +3392,24 @@ FUN(Image_getNumberOfComponents)(JNIEnv *env, jobject self) return image ? image->n : 0; } +JNIEXPORT jobject JNICALL +FUN(Image_getColorSpace)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_image *image = from_Image(env, self); + jobject jcs = NULL; + + if (ctx == NULL || image == NULL) + return NULL; + + fz_try (ctx) + jcs = to_ColorSpace(ctx, env, image->colorspace); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return jcs; +} + JNIEXPORT jint JNICALL FUN(Image_getBitsPerComponent)(JNIEnv *env, jobject self) { @@ -3272,6 +3548,63 @@ FUN(Annotation_advance)(JNIEnv *env, jobject self) return jlong_cast(annot); } +JNIEXPORT jobject JNICALL +FUN(Annotation_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs, jboolean alpha) +{ + fz_context *ctx = get_context(env); + fz_annot *annot = from_Annotation(env, self); + fz_matrix ctm = from_Matrix(env, jctm); + fz_colorspace *cs = from_ColorSpace(env, jcs); + fz_pixmap *pixmap = NULL; + + if (ctx == NULL || cs == NULL) + return NULL; + + fz_try(ctx) + pixmap = fz_new_pixmap_from_annot(ctx, annot, &ctm, cs, alpha); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_Pixmap_safe_own(ctx, env, pixmap); +} + +JNIEXPORT jobject JNICALL +FUN(Annotation_getBounds)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_annot *annot = from_Annotation(env, self); + jobject jrect = NULL; + fz_rect rect; + + if (ctx == NULL || annot == NULL) + return NULL; + + fz_try(ctx) + jrect = to_Rect(ctx, env, fz_bound_annot(ctx, annot, &rect)); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return jrect; +} + +JNIEXPORT jobject JNICALL +FUN(Annotation_toDisplayList)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_annot *annot = from_Annotation(env, self); + fz_display_list *list = NULL; + + if (ctx == NULL || annot == NULL) + return NULL; + + fz_try(ctx) + list = fz_new_display_list_from_annot(ctx, annot); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_DisplayList_safe_own(ctx, env, list); +} + /* Link interface */ JNIEXPORT void JNICALL @@ -3398,6 +3731,39 @@ FUN(Document_countPages)(JNIEnv *env, jobject self) return count; } +JNIEXPORT jboolean JNICALL +FUN(Document_isReflowable)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_document *doc = from_Document(env, self); + int is_reflowable = 0; + + if (ctx == NULL || doc == NULL) + return 0; + + fz_try(ctx) + is_reflowable = fz_is_document_reflowable(ctx, doc); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return is_reflowable; +} + +JNIEXPORT void JNICALL +FUN(Document_layout)(JNIEnv *env, jobject self, jfloat w, jfloat h, jfloat em) +{ + fz_context *ctx = get_context(env); + fz_document *doc = from_Document(env, self); + + if (ctx == NULL || doc == NULL) + return; + + fz_try(ctx) + fz_layout_document(ctx, doc, w, h, em); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + JNIEXPORT jobject JNICALL FUN(Document_loadPage)(JNIEnv *env, jobject self, jint number) { @@ -3483,6 +3849,24 @@ FUN(Document_loadOutline)(JNIEnv *env, jobject self) return to_Outline_safe_own(ctx, env, outline); } +JNIEXPORT jobject JNICALL +FUN(Document_toPDFDocument)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_document *doc = from_Document(env, self); + pdf_document *pdf = NULL; + + if (ctx == NULL || doc == NULL) + return NULL; + + fz_try(ctx) + pdf = pdf_specifics(ctx, doc); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFDocument_safe(ctx, env, pdf); +} + /* Page interface */ JNIEXPORT void JNICALL @@ -3636,10 +4020,108 @@ FUN(Page_getAnnotations)(JNIEnv *env, jobject self) fz_throw(ctx, FZ_ERROR_GENERIC, "getAnnotations failed (4)"); } fz_catch(ctx) + jni_rethrow(env, ctx); + + return jannots; +} + +JNIEXPORT jobject JNICALL +FUN(Page_search)(JNIEnv *env, jobject self, jstring jneedle) +{ + fz_context *ctx = get_context(env); + fz_page *page = from_Page(env, self); + fz_rect hits[256] = { 0 }; + const char *needle = NULL; + jobject jhits = NULL; + int n = 0; + int i; + + if (ctx == NULL || page == NULL || jneedle == NULL) + return NULL; + + needle = (*env)->GetStringUTFChars(env, jneedle, NULL); + if (needle == NULL) + return NULL; + + fz_try(ctx) + n = fz_search_page(ctx, page, needle, hits, nelem(hits)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jneedle, needle); + fz_catch(ctx) { jni_rethrow(env, ctx); + return NULL; } - return jannots; + + jhits = (*env)->NewObjectArray(env, n, cls_Rect, NULL); + if (jhits == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "search failed"); + return NULL; + } + + fz_try(ctx) + { + for (i = 0; i < n; i++) + { + jobject jhit = to_Rect(ctx, env, &hits[i]); + (*env)->SetObjectArrayElement(env, jhits, i, jhit); + } + } + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return jhits; +} + +JNIEXPORT jobject JNICALL +FUN(Page_toDisplayList)(JNIEnv *env, jobject self, jboolean no_annotations) +{ + fz_context *ctx = get_context(env); + fz_page *page = from_Page(env, self); + fz_display_list *list = NULL; + + if (ctx == NULL || page == NULL) + return NULL; + + fz_try(ctx) + if (no_annotations) + list = fz_new_display_list_from_page_contents(ctx, page); + else + list = fz_new_display_list_from_page(ctx, page); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_DisplayList_safe_own(ctx, env, list); +} + +JNIEXPORT jobject JNICALL +FUN(Page_toStructuredText)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_page *page = from_Page(env, self); + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; + + if (ctx == NULL || page == NULL) + return NULL; + + fz_var(sheet); + + fz_try(ctx) + { + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page_from_page(ctx, page, sheet); + } + fz_always(ctx) + fz_drop_stext_sheet(ctx, sheet); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_StructuredText_safe_own(ctx, env, text); } /* Cookie interface */ @@ -3691,6 +4173,7 @@ JNIEXPORT jlong JNICALL FUN(DisplayList_newNative)(JNIEnv *env, jobject self) { fz_context *ctx = get_context(env); + fz_display_list *list = NULL; if (ctx == NULL) @@ -3746,3 +4229,1957 @@ FUN(DisplayList_finalize)(JNIEnv *env, jobject self) fz_drop_display_list(ctx, list); } + +JNIEXPORT jobject JNICALL +FUN(DisplayList_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs, jboolean alpha) +{ + fz_context *ctx = get_context(env); + fz_display_list *list = from_DisplayList(env, self); + fz_matrix ctm = from_Matrix(env, jctm); + fz_colorspace *cs = from_ColorSpace(env, jcs); + fz_pixmap *pixmap = NULL; + + if (ctx == NULL || list == NULL || cs == NULL) + return NULL; + + fz_try(ctx) + pixmap = fz_new_pixmap_from_display_list(ctx, list, &ctm, cs, alpha); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_Pixmap_safe_own(ctx, env, pixmap); +} + +JNIEXPORT jobject JNICALL +FUN(DisplayList_search)(JNIEnv *env, jobject self, jstring jneedle) +{ + fz_context *ctx = get_context(env); + fz_display_list *list = from_DisplayList(env, self); + fz_rect hits[256] = { 0 }; + const char *needle = NULL; + jobject jhits = NULL; + int n = 0; + int i; + + if (ctx == NULL || list == NULL || jneedle == NULL) + return NULL; + + needle = (*env)->GetStringUTFChars(env, jneedle, NULL); + if (needle == NULL) + return NULL; + + fz_try(ctx) + n = fz_search_display_list(ctx, list, needle, hits, nelem(hits)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jneedle, needle); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jhits = (*env)->NewObjectArray(env, n, cls_Rect, NULL); + if (jhits == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "search failed"); + return NULL; + } + + fz_try(ctx) + { + for (i = 0; i < n; i++) + { + jobject jhit = to_Rect(ctx, env, &hits[i]); + (*env)->SetObjectArrayElement(env, jhits, i, jhit); + } + } + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return jhits; +} + +/* Buffer interface */ + +JNIEXPORT void JNICALL +FUN(Buffer_finalize)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + + if (ctx == NULL || buf == NULL) + return; + + fz_drop_buffer(ctx, buf); +} + +JNIEXPORT jlong JNICALL +FUN(Buffer_newNativeBuffer)(JNIEnv *env, jobject self, jint n) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = NULL; + + if (ctx == NULL) + return 0; + + fz_try(ctx) + buf = fz_new_buffer(ctx, n); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return jlong_cast(buf); +} + +JNIEXPORT jint JNICALL +FUN(Buffer_getLength)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + + if (ctx == NULL || buf == NULL) + return 0; + + return buf->len; +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeByte)(JNIEnv *env, jobject self, jbyte b) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + + if (ctx == NULL || buf == NULL) + return; + + fz_try(ctx) + fz_write_buffer_byte(ctx, buf, b); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeBytes)(JNIEnv *env, jobject self, jobject jbs) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + jbyte *bs = NULL; + int n = 0; + + if (ctx == NULL || buf == NULL || jbs == NULL) + return; + + n = (*env)->GetArrayLength(env, jbs); + bs = (*env)->GetByteArrayElements(env, jbs, NULL); + + fz_try(ctx) + fz_write_buffer(ctx, buf, bs, n); + fz_always(ctx) + (*env)->ReleaseByteArrayElements(env, jbs, bs, JNI_ABORT); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeBuffer)(JNIEnv *env, jobject self, jobject jbuf) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + fz_buffer *cat = from_Buffer(env, jbuf); + + if (ctx == NULL || buf == NULL || cat == NULL) + return; + + fz_try(ctx) + fz_append_buffer(ctx, buf, cat); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeRune)(JNIEnv *env, jobject self, jint rune) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + + if (ctx == NULL || buf == NULL) + return; + + fz_try(ctx) + fz_write_buffer_rune(ctx, buf, rune); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeLine)(JNIEnv *env, jobject self, jstring jline) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + const char *line = NULL; + + if (ctx == NULL || buf == NULL || jline == NULL) + return; + + line = (*env)->GetStringUTFChars(env, jline, NULL); + if (line == NULL) + return; + + fz_try(ctx) + { + fz_write_buffer(ctx, buf, line, strlen(line)); + fz_write_buffer_byte(ctx, buf, '\n'); + } + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jline, line); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(Buffer_writeLines)(JNIEnv *env, jobject self, jobject jlines) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + int i = 0; + int n = 0; + + if (ctx == NULL || buf == NULL || jlines == NULL) + return; + + n = (*env)->GetArrayLength(env, jlines); + + for (i = 0; i < n; ++i) + { + jobject jline = (*env)->GetObjectArrayElement(env, jlines, i); + const char *line = NULL; + + if (jline == NULL) + continue; + + line = (*env)->GetStringUTFChars(env, jline, NULL); + if (line == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "writeLines failed"); + return; + } + + fz_try(ctx) + { + fz_write_buffer(ctx, buf, line, strlen(line)); + fz_write_buffer_byte(ctx, buf, '\n'); + } + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jline, line); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return; + } + } +} + +JNIEXPORT void JNICALL +FUN(Buffer_save)(JNIEnv *env, jobject self, jstring jfilename) +{ + fz_context *ctx = get_context(env); + fz_buffer *buf = from_Buffer(env, self); + const char *filename = NULL; + + if (ctx == NULL || buf == NULL || jfilename == NULL) + return; + + filename = (*env)->GetStringUTFChars(env, jfilename, NULL); + if (filename == NULL) + return; + + fz_try(ctx) + fz_save_buffer(ctx, buf, filename); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jfilename, filename); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +/* DocumentWriter interface */ + +JNIEXPORT void JNICALL +FUN(DocumentWriter_finalize)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_document_writer *wri = from_DocumentWriter(env, self); + + if (ctx == NULL || wri == NULL) + return; + + fz_drop_document_writer(ctx, wri); +} + +JNIEXPORT jlong JNICALL +FUN(DocumentWriter_newNativeDocumentWriter)(JNIEnv *env, jobject self, jstring jfilename, jstring jformat, jstring joptions) +{ + fz_context *ctx = get_context(env); + fz_document_writer *wri = from_DocumentWriter(env, self); + const char *filename = NULL; + const char *format = NULL; + const char *options = NULL; + + if (ctx == NULL || wri == NULL || jfilename == NULL) + return 0; + + filename = (*env)->GetStringUTFChars(env, jfilename, NULL); + if (filename == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "DocumentWriter constructor failed (1)"); + return 0; + } + if (jformat != NULL) + { + format = (*env)->GetStringUTFChars(env, jformat, NULL); + if (format == NULL) + { + (*env)->ReleaseStringUTFChars(env, jfilename, filename); + jni_throw(env, FZ_ERROR_GENERIC, "DocumentWriter constructor failed (2)"); + return 0; + } + } + if (joptions != NULL) + { + options = (*env)->GetStringUTFChars(env, joptions, NULL); + if (options == NULL) + { + if (format != NULL) + (*env)->ReleaseStringUTFChars(env, jformat, format); + (*env)->ReleaseStringUTFChars(env, jfilename, filename); + jni_throw(env, FZ_ERROR_GENERIC, "DocumentWriter constructor failed (3)"); + return 0; + } + } + + fz_try(ctx) + wri = fz_new_document_writer(ctx, filename, format, options); + fz_always(ctx) + { + if (options != NULL) + (*env)->ReleaseStringUTFChars(env, joptions, options); + if (format != NULL) + (*env)->ReleaseStringUTFChars(env, jformat, format); + (*env)->ReleaseStringUTFChars(env, jfilename, filename); + } + fz_catch(ctx) + jni_rethrow(env, ctx); + + return jlong_cast(wri); +} + +JNIEXPORT jobject JNICALL +FUN(DocumentWriter_beginPage)(JNIEnv *env, jobject self, jobject jmediabox) +{ + fz_context *ctx = get_context(env); + fz_document_writer *wri = from_DocumentWriter(env, self); + fz_rect mediabox = from_Rect(env, jmediabox); + fz_device *device = NULL; + + if (ctx == NULL || wri == NULL) + return NULL; + + fz_try(ctx) + device = fz_begin_page(ctx, wri, &mediabox); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_Device_safe_own(ctx, env, device); +} + +JNIEXPORT void JNICALL +FUN(DocumentWriter_endPage)(JNIEnv *env, jobject self, jobject jdev) +{ + fz_context *ctx = get_context(env); + fz_document_writer *wri = from_DocumentWriter(env, self); + fz_device *device = from_Device(env, jdev); + + if (ctx == NULL || wri == NULL || device == NULL) + return; + + fz_try(ctx) + fz_end_page(ctx, wri, device); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(DocumentWriter_close)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_document_writer *wri = from_DocumentWriter(env, self); + + if (ctx == NULL || wri == NULL) + return; + + fz_try(ctx) + fz_close_document_writer(ctx, wri); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +/* StructuredText interface */ + +JNIEXPORT void JNICALL +FUN(StructuredText_finalize)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_stext_page *text = from_StructuredText(env, self); + + if (ctx == NULL || text == NULL) + return; + + fz_drop_stext_page(ctx, text); +} + +JNIEXPORT jobject JNICALL +FUN(StructuredText_search)(JNIEnv *env, jobject self, jstring jneedle) +{ + fz_context *ctx = get_context(env); + fz_stext_page *text = from_StructuredText(env, self); + fz_rect hits[256] = { 0 }; + const char *needle = NULL; + jobject jhits = NULL; + int n = 0; + int i; + + if (ctx == NULL || text == NULL || jneedle == NULL) + return NULL; + + needle = (*env)->GetStringUTFChars(env, jneedle, NULL); + if (needle == NULL) + return NULL; + + fz_try(ctx) + n = fz_search_stext_page(ctx, text, needle, hits, nelem(hits)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jneedle, needle); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jhits = (*env)->NewObjectArray(env, n, cls_Rect, NULL); + if (jhits == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "search failed"); + + fz_try(ctx) + { + for (i = 0; i < n; i++) + { + jobject jhit = to_Rect(ctx, env, &hits[i]); + (*env)->SetObjectArrayElement(env, jhits, i, jhit); + } + } + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return jhits; +} + +JNIEXPORT jobject JNICALL +FUN(StructuredText_highlight)(JNIEnv *env, jobject self, jobject jrect) +{ + fz_context *ctx = get_context(env); + fz_stext_page *text = from_StructuredText(env, self); + fz_rect rect = from_Rect(env, jrect); + fz_rect hits[256] = { 0 }; + jobject jhits = NULL; + int n = 0; + int i; + + if (ctx == NULL || text == NULL) + return NULL; + + fz_try(ctx) + n = fz_highlight_selection(ctx, text, rect, hits, nelem(hits)); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jhits = (*env)->NewObjectArray(env, n, cls_Rect, NULL); + if (jhits == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "search failed (1)"); + + fz_try(ctx) + { + for (i = 0; i < n; i++) + { + jobject jhit = to_Rect(ctx, env, &hits[i]); + (*env)->SetObjectArrayElement(env, jhits, i, jhit); + } + } + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return jhits; +} + +JNIEXPORT jobject JNICALL +FUN(StructuredText_copy)(JNIEnv *env, jobject self, jobject jrect) +{ + fz_context *ctx = get_context(env); + fz_stext_page *text = from_StructuredText(env, self); + fz_rect rect = from_Rect(env, jrect); + jobject jstring = NULL; + char *s = NULL; + + if (ctx == NULL || text == NULL) + return NULL; + + fz_var(s); + + fz_try(ctx) + s = fz_copy_selection(ctx, text, rect); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jstring = (*env)->NewStringUTF(env, s); + fz_free(ctx, s); + + return jstring; +} + +/* PDFDocument interface */ + +JNIEXPORT void JNICALL +FUN(PDFDocument_finalize)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + + if (ctx == NULL || pdf == NULL) + return; + + fz_drop_document(ctx, (fz_document *) pdf); +} + +JNIEXPORT jint JNICALL +FUN(PDFDocument_countObjects)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + int count = 0; + + if (ctx == NULL || pdf == NULL) + return 0; + + fz_try(ctx) + count = pdf_xref_len(ctx, pdf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return count; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newNull)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_null(ctx, pdf); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newBoolean)(JNIEnv *env, jobject self, jboolean b) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_bool(ctx, pdf, b); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newInteger)(JNIEnv *env, jobject self, jint i) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_int(ctx, pdf, i); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newReal)(JNIEnv *env, jobject self, jfloat f) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_real(ctx, pdf, f); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newString)(JNIEnv *env, jobject self, jstring jstring) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + const char *s = NULL; + + if (ctx == NULL || pdf == NULL || jstring == NULL) + return NULL; + + s = (*env)->GetStringUTFChars(env, jstring, NULL); + if (s == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_string(ctx, pdf, s, strlen(s)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jstring, s); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newName)(JNIEnv *env, jobject self, jstring jname) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + const char *name = NULL; + + if (ctx == NULL || pdf == NULL || jname == NULL) + return NULL; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_name(ctx, pdf, name); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newIndirect)(JNIEnv *env, jobject self, jint num, jint gen) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_indirect(ctx, pdf, num, gen); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newArray)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_array(ctx, pdf, 0); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_newDictionary)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + jobject jobj = NULL; + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_new_dict(ctx, pdf, 0); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(obj), self); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_toDocument)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + + if (ctx == NULL || pdf == NULL) + return NULL; + + return to_Document_safe(ctx, env, (fz_document *) pdf); +} + +JNIEXPORT jint JNICALL +FUN(PDFDocument_countPages)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + int count = 0; + + if (ctx == NULL || pdf == NULL) + return 0; + + fz_try(ctx) + count = pdf_count_pages(ctx, pdf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return count; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_findPage)(JNIEnv *env, jobject self, jint at) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_lookup_page_obj(ctx, pdf, at); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe(ctx, env, self, obj); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_getTrailer)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + pdf_obj *obj = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_trailer(ctx, pdf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe(ctx, env, self, obj); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addObject)(JNIEnv *env, jobject self, jobject jobj) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + pdf_obj *obj = from_PDFObject(env, jobj); + + if (ctx == NULL || pdf == NULL || obj == NULL) + return NULL; + + fz_try(ctx) + obj = pdf_add_object_drop(ctx, pdf, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_createObject)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_new_indirect(ctx, pdf, pdf_create_object(ctx, pdf), 0); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT void JNICALL +FUN(PDFDocument_deleteObject)(JNIEnv *env, jobject self, jint num) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + + if (ctx == NULL || pdf == NULL) + return; + + fz_try(ctx) + pdf_delete_object(ctx, pdf, num); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addStream)(JNIEnv *env, jobject self, jobject jbuf) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + fz_buffer *buf = from_Buffer(env, jbuf); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL || buf == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_add_stream(ctx, pdf, buf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addPage)(JNIEnv *env, jobject self, jobject jmediabox, jint rotate, jobject jresources, jobject jcontents) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + fz_rect mediabox = from_Rect(env, jmediabox); + pdf_obj *resources = from_PDFObject(env, jresources); + fz_buffer *contents = from_Buffer(env, jcontents); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL || resources == NULL || contents == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_add_page(ctx, pdf, &mediabox, rotate, resources, contents); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT void JNICALL +FUN(PDFDocument_insertPage)(JNIEnv *env, jobject self, jint at, jobject jpage) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + pdf_obj *page = from_PDFObject(env, jpage); + + if (ctx == NULL || pdf == NULL || page == NULL) + return; + + fz_try(ctx) + pdf_insert_page(ctx, pdf, at, page); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFDocument_deletePage)(JNIEnv *env, jobject self, jint at) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + + if (ctx == NULL || pdf == NULL) + return; + + fz_try(ctx) + pdf_delete_page(ctx, pdf, at); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addImage)(JNIEnv *env, jobject self, jobject jimage) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + fz_image *image = from_Image(env, jimage); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL || image == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_add_image(ctx, pdf, image, 0); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addFont)(JNIEnv *env, jobject self, jobject jfont) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + fz_font *font = from_Font(env, jfont); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL || font == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_add_cid_font(ctx, pdf, font); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT jobject JNICALL +FUN(PDFDocument_addSimpleFont)(JNIEnv *env, jobject self, jobject jfont) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + fz_font *font = from_Font(env, jfont); + pdf_obj *ind = NULL; + + if (ctx == NULL || pdf == NULL || font == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_add_simple_font(ctx, pdf, font); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe_own(ctx, env, self, ind); +} + +JNIEXPORT void JNICALL +FUN(PDFDocument_save)(JNIEnv *env, jobject self, jstring jfilename, jstring joptions) +{ + fz_context *ctx = get_context(env); + pdf_document *pdf = from_PDFDocument(env, self); + const char *filename = NULL; + const char *options = NULL; + pdf_write_options pwo = { 0 }; + + if (ctx == NULL || pdf == NULL || jfilename == NULL) + return; + + filename = (*env)->GetStringUTFChars(env, jfilename, NULL); + if (filename == NULL) + return; + + if (joptions != NULL) + { + options = (*env)->GetStringUTFChars(env, joptions, NULL); + if (options == NULL) + return; + } + + fz_try(ctx) + { + pdf_parse_write_options(ctx, &pwo, options); + pdf_save_document(ctx, pdf, filename, &pwo); + } + fz_always(ctx) + { + if (options != NULL) + (*env)->ReleaseStringUTFChars(env, joptions, options); + (*env)->ReleaseStringUTFChars(env, jfilename, filename); + } + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +/* PDFObject interface */ + +JNIEXPORT void JNICALL +FUN(PDFObject_finalize)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + + if (ctx == NULL || obj == NULL) + return; + + pdf_drop_obj(ctx, obj); +} + +JNIEXPORT jint JNICALL +FUN(PDFObject_toIndirect)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int num = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + num = pdf_to_num(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return num; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isIndirect)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_indirect(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isNull)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_null(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isBoolean)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_bool(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isInteger)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_int(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isReal)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_real(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isNumber)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_number(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isString)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_string(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isName)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_name(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isArray)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_array(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isDictionary)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_dict(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_isStream)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_is_stream(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jbyteArray JNICALL +FUN(PDFObject_readStream)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + pdf_document *pdf = NULL; + fz_buffer *buf = NULL; + jbyteArray arr = NULL; + + if (ctx == NULL || obj == NULL) + return NULL; + + fz_var(buf); + + fz_try(ctx) + { + if (!pdf_is_stream(ctx, obj)) + fz_throw(ctx, FZ_ERROR_GENERIC, "not a stream"); + pdf = pdf_get_indirect_document(ctx, obj); + buf = pdf_load_stream(ctx, pdf, pdf_to_num(ctx, obj)); + + arr = (*env)->NewByteArray(env, buf->len); + if (arr == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "JNI creation of byteArray failed"); + + (*env)->SetByteArrayRegion(env, arr, 0, buf->len, (signed char *) &buf->data[0]); + } + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return arr; +} + +JNIEXPORT jbyteArray JNICALL +FUN(PDFObject_readRawStream)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + pdf_document *pdf = NULL; + fz_buffer *buf = NULL; + jbyteArray arr = NULL; + + if (ctx == NULL || obj == NULL) + return NULL; + + fz_var(buf); + + fz_try(ctx) + { + if (!pdf_is_stream(ctx, obj)) + fz_throw(ctx, FZ_ERROR_GENERIC, "not a stream"); + pdf = pdf_get_indirect_document(ctx, obj); + buf = pdf_load_raw_stream(ctx, pdf, pdf_to_num(ctx, obj)); + + arr = (*env)->NewByteArray(env, buf->len); + if (arr == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "JNI creation of byteArray failed"); + + (*env)->SetByteArrayRegion(env, arr, 0, buf->len, (signed char *) &buf->data[0]); + } + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return arr; +} + +JNIEXPORT jobject JNICALL +FUN(PDFObject_resolve)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + pdf_obj *ind = NULL; + jobject jobj = NULL; + + if (ctx == NULL || obj == NULL) + return NULL; + + fz_try(ctx) + ind = pdf_resolve_indirect(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + jobj = (*env)->NewObject(env, cls_PDFObject, mid_PDFObject_init, jlong_cast(ind), self); + if (jobj != NULL) + pdf_keep_obj(ctx, ind); + + return jobj; +} + +JNIEXPORT jobject JNICALL +FUN(PDFObject_getArray)(JNIEnv *env, jobject self, jint index) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + pdf_obj *val = NULL; + + if (ctx == NULL || obj == NULL) + return NULL; + + fz_try(ctx) + val = pdf_array_get(ctx, obj, index); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe(ctx, env, self, val); +} + +JNIEXPORT jobject JNICALL +FUN(PDFObject_getDictionary)(JNIEnv *env, jobject self, jstring jname) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + const char *name = NULL; + pdf_obj *val = NULL; + + if (ctx == NULL || obj == NULL || jname == NULL) + return NULL; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + return NULL; + + fz_try(ctx) + val = pdf_dict_gets(ctx, obj, name); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return to_PDFObject_safe(ctx, env, self, val); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putArrayBoolean)(JNIEnv *env, jobject self, jint index, jboolean b) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + pdf_document *pdf = arr ? pdf_get_bound_document(ctx, arr) : NULL; + + if (ctx == NULL || arr == NULL || pdf == NULL) + return; + + fz_try(ctx) + if (index == pdf_array_len(ctx, arr)) + pdf_array_push(ctx, arr, pdf_new_bool(ctx, pdf, b)); + else + pdf_array_put(ctx, arr, index, pdf_new_bool(ctx, pdf, b)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putArrayInteger)(JNIEnv *env, jobject self, jint index, jint i) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + pdf_document *pdf = arr ? pdf_get_bound_document(ctx, arr) : NULL; + + if (ctx == NULL || arr == NULL || pdf == NULL) + return; + + fz_try(ctx) + if (index == pdf_array_len(ctx, arr)) + pdf_array_push(ctx, arr, pdf_new_int(ctx, pdf, i)); + else + pdf_array_put(ctx, arr, index, pdf_new_int(ctx, pdf, i)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putArrayFloat)(JNIEnv *env, jobject self, jint index, jfloat f) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + pdf_document *pdf = arr ? pdf_get_bound_document(ctx, arr) : NULL; + + if (ctx == NULL || arr == NULL || pdf == NULL) + return; + + fz_try(ctx) + if (index == pdf_array_len(ctx, arr)) + pdf_array_push(ctx, arr, pdf_new_real(ctx, pdf, f)); + else + pdf_array_put(ctx, arr, index, pdf_new_real(ctx, pdf, f)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putArrayString)(JNIEnv *env, jobject self, jint index, jstring jstr) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + pdf_document *pdf = arr ? pdf_get_bound_document(ctx, arr) : NULL; + const char *str = NULL; + + if (ctx == NULL || arr == NULL || pdf == NULL || jstr == NULL) + return; + + str = (*env)->GetStringUTFChars(env, jstr, NULL); + if (str == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + if (index == pdf_array_len(ctx, arr)) + pdf_array_push(ctx, arr, pdf_new_string(ctx, pdf, str, strlen(str))); + else + pdf_array_put(ctx, arr, index, pdf_new_string(ctx, pdf, str, strlen(str))); + fz_always(ctx) + if (str != NULL) + (*env)->ReleaseStringUTFChars(env, jstr, str); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putArrayPDFObject)(JNIEnv *env, jobject self, jint index, jobject jobj) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + pdf_obj *obj = from_PDFObject(env, jobj); + + if (ctx == NULL || arr == NULL || obj == NULL) + return; + + fz_try(ctx) + if (index == pdf_array_len(ctx, arr)) + pdf_array_push(ctx, arr, obj); + else + pdf_array_put(ctx, arr, index, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryStringBoolean)(JNIEnv *env, jobject self, jstring jname, jboolean b) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + const char *name = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, pdf_new_name(ctx, pdf, name), pdf_new_bool(ctx, pdf, b)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryStringInteger)(JNIEnv *env, jobject self, jstring jname, jint i) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + const char *name = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, pdf_new_name(ctx, pdf, name), pdf_new_int(ctx, pdf, i)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryStringFloat)(JNIEnv *env, jobject self, jstring jname, jfloat f) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + const char *name = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, pdf_new_name(ctx, pdf, name), pdf_new_real(ctx, pdf, f)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryStringString)(JNIEnv *env, jobject self, jstring jname, jstring jstr) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + const char *name = NULL; + const char *str = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL || jstr == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + str = (*env)->GetStringUTFChars(env, jstr, NULL); + if (str == NULL) + { + (*env)->ReleaseStringUTFChars(env, jname, name); + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, pdf_new_name(ctx, pdf, name), pdf_new_string(ctx, pdf, str, strlen(str))); + fz_always(ctx) + { + (*env)->ReleaseStringUTFChars(env, jstr, str); + (*env)->ReleaseStringUTFChars(env, jname, name); + } + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryStringPDFObject)(JNIEnv *env, jobject self, jstring jname, jobject jobj) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + pdf_obj *obj = from_PDFObject(env, jobj); + const char *name = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL || obj == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, pdf_new_name(ctx, pdf, name), obj); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryPDFObjectBoolean)(JNIEnv *env, jobject self, jobject jname, jboolean b) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + pdf_obj *name = from_PDFObject(env, jname); + + if (ctx == NULL || dict == NULL || pdf == NULL || name == NULL) + return; + + fz_try(ctx) + pdf_dict_put(ctx, dict, name, pdf_new_bool(ctx, pdf, b)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryPDFObjectInteger)(JNIEnv *env, jobject self, jobject jname, jint i) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + pdf_obj *name = from_PDFObject(env, jname); + + if (ctx == NULL || dict == NULL || pdf == NULL || name == NULL) + return; + + fz_try(ctx) + pdf_dict_put(ctx, dict, name, pdf_new_int(ctx, pdf, i)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryPDFObjectFloat)(JNIEnv *env, jobject self, jobject jname, jfloat f) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + pdf_obj *name = from_PDFObject(env, jname); + + if (ctx == NULL || dict == NULL || pdf == NULL || name == NULL) + return; + + fz_try(ctx) + pdf_dict_put(ctx, dict, name, pdf_new_real(ctx, pdf, f)); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryPDFObjectString)(JNIEnv *env, jobject self, jobject jname, jstring jstr) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + pdf_obj *name = from_PDFObject(env, jname); + const char *str = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || name == NULL || jstr == NULL) + return; + + str = (*env)->GetStringUTFChars(env, jstr, NULL); + if (str == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "put failed"); + return; + } + + fz_try(ctx) + pdf_dict_put(ctx, dict, name, pdf_new_string(ctx, pdf, str, strlen(str))); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jstr, str); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_putDictionaryPDFObjectPDFObject)(JNIEnv *env, jobject self, jobject jname, jobject jobj) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_obj *name = from_PDFObject(env, jname); + pdf_obj *obj = from_PDFObject(env, jobj); + + if (ctx == NULL || dict == NULL || name == NULL || obj == NULL) + return; + + fz_try(ctx) + pdf_dict_put(ctx, dict, name, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_deleteArray)(JNIEnv *env, jobject self, jint index) +{ + fz_context *ctx = get_context(env); + pdf_obj *arr = from_PDFObject(env, self); + + if (ctx == NULL || arr == NULL) + return; + + fz_try(ctx) + pdf_array_delete(ctx, arr, index); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_deleteDictionaryString)(JNIEnv *env, jobject self, jstring jname) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_document *pdf = dict ? pdf_get_bound_document(ctx, dict) : NULL; + const char *name = NULL; + + if (ctx == NULL || dict == NULL || pdf == NULL || jname == NULL) + return; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + if (name == NULL) + { + jni_throw(env, FZ_ERROR_GENERIC, "delete failed"); + return; + } + + fz_try(ctx) + pdf_dict_del(ctx, dict, pdf_new_name(ctx, pdf, name)); + fz_always(ctx) + (*env)->ReleaseStringUTFChars(env, jname, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT void JNICALL +FUN(PDFObject_deleteDictionaryPDFObject)(JNIEnv *env, jobject self, jobject jname) +{ + fz_context *ctx = get_context(env); + pdf_obj *dict = from_PDFObject(env, self); + pdf_obj *name = from_PDFObject(env, jname); + + if (ctx == NULL || dict == NULL || name == NULL) + return; + + fz_try(ctx) + pdf_dict_del(ctx, dict, name); + fz_catch(ctx) + jni_rethrow(env, ctx); +} + +JNIEXPORT jboolean JNICALL +FUN(PDFObject_toBoolean)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int b = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + b = pdf_to_bool(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return b; +} + +JNIEXPORT jint JNICALL +FUN(PDFObject_toInteger)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + int i = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + i = pdf_to_int(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return i; +} + +JNIEXPORT jfloat JNICALL +FUN(PDFObject_toFloat)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + float f = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + f = pdf_to_real(ctx, obj); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return f; +} + +JNIEXPORT jobject JNICALL +FUN(PDFObject_toByteString)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + signed char *bs = NULL; + const char *str = NULL; + jobject jbs = NULL; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + if (pdf_is_name(ctx, obj)) + str = pdf_to_name(ctx, obj); + else + str = pdf_to_str_buf(ctx, obj); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + jbs = (*env)->NewByteArray(env, strlen(str) + 1); + bs = (*env)->GetByteArrayElements(env, jbs, NULL); + + memcpy(bs, str, strlen(str) + 1); + + (*env)->ReleaseByteArrayElements(env, jbs, bs, 0); + + return jbs; +} + +JNIEXPORT jstring JNICALL +FUN(PDFObject_toString)(JNIEnv *env, jobject self, jboolean tight) +{ + fz_context *ctx = get_context(env); + pdf_obj *obj = from_PDFObject(env, self); + jstring string = NULL; + char *s = NULL; + int n = 0; + + if (ctx == NULL || obj == NULL) + return 0; + + fz_try(ctx) + { + n = pdf_sprint_obj(ctx, NULL, 0, obj, tight); + s = fz_malloc(ctx, n + 1); + pdf_sprint_obj(ctx, s, n + 1, obj, tight); + string = (*env)->NewStringUTF(env, s); + } + fz_always(ctx) + fz_free(ctx, s); + fz_catch(ctx) + jni_rethrow(env, ctx); + + return string; +} diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h index 08d389a1..e56e43af 100644 --- a/platform/java/mupdf_native.h +++ b/platform/java/mupdf_native.h @@ -25,6 +25,30 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Annotation_run /* * Class: com_artifex_mupdf_fitz_Annotation + * Method: toPixmap + * Signature: (Lcom/artifex/mupdf/fitz/Matrix;Lcom/artifex/mupdf/fitz/ColorSpace;Z)Lcom/artifex/mupdf/fitz/Pixmap; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Annotation_toPixmap + (JNIEnv *, jobject, jobject, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_Annotation + * Method: getBounds + * Signature: ()Lcom/artifex/mupdf/fitz/Rect; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Annotation_getBounds + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Annotation + * Method: toDisplayList + * Signature: ()Lcom/artifex/mupdf/fitz/DisplayList; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Annotation_toDisplayList + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Annotation * Method: advance * Signature: ()J */ @@ -35,6 +59,99 @@ JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_Annotation_advance } #endif #endif +/* Header for class com_artifex_mupdf_fitz_Buffer */ + +#ifndef _Included_com_artifex_mupdf_fitz_Buffer +#define _Included_com_artifex_mupdf_fitz_Buffer +#ifdef __cplusplus +extern "C" { +#endif +#undef com_artifex_mupdf_fitz_Buffer_DEFAULT_BUFFER_SIZE +#define com_artifex_mupdf_fitz_Buffer_DEFAULT_BUFFER_SIZE 1024L +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: finalize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_finalize + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: newNativeBuffer + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_Buffer_newNativeBuffer + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: getLength + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_Buffer_getLength + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeByte + * Signature: (B)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeByte + (JNIEnv *, jobject, jbyte); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeBytes + * Signature: ([B)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeBytes + (JNIEnv *, jobject, jbyteArray); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeBuffer + * Signature: (Lcom/artifex/mupdf/fitz/Buffer;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeBuffer + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeRune + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeRune + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeLine + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeLine + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: writeLines + * Signature: ([Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_writeLines + (JNIEnv *, jobject, jobjectArray); + +/* + * Class: com_artifex_mupdf_fitz_Buffer + * Method: save + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Buffer_save + (JNIEnv *, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif /* Header for class com_artifex_mupdf_fitz_ColorSpace */ #ifndef _Included_com_artifex_mupdf_fitz_ColorSpace @@ -288,6 +405,22 @@ JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_DisplayList_newNative /* * Class: com_artifex_mupdf_fitz_DisplayList + * Method: toPixmap + * Signature: (Lcom/artifex/mupdf/fitz/Matrix;Lcom/artifex/mupdf/fitz/ColorSpace;Z)Lcom/artifex/mupdf/fitz/Pixmap; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DisplayList_toPixmap + (JNIEnv *, jobject, jobject, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_DisplayList + * Method: search + * Signature: (Ljava/lang/String;)[Lcom/artifex/mupdf/fitz/Rect; + */ +JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_DisplayList_search + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_DisplayList * Method: run * Signature: (Lcom/artifex/mupdf/fitz/Device;Lcom/artifex/mupdf/fitz/Matrix;Lcom/artifex/mupdf/fitz/Rect;Lcom/artifex/mupdf/fitz/Cookie;)V */ @@ -462,12 +595,87 @@ JNIEXPORT jstring JNICALL Java_com_artifex_mupdf_fitz_Document_getMetaData /* * Class: com_artifex_mupdf_fitz_Document + * Method: isReflowable + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_Document_isReflowable + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Document + * Method: layout + * Signature: (FFF)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Document_layout + (JNIEnv *, jobject, jfloat, jfloat, jfloat); + +/* + * Class: com_artifex_mupdf_fitz_Document * Method: isUnencryptedPDF * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_Document_isUnencryptedPDF (JNIEnv *, jobject); +/* + * Class: com_artifex_mupdf_fitz_Document + * Method: toPDFDocument + * Signature: ()Lcom/artifex/mupdf/fitz/PDFDocument; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Document_toPDFDocument + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class com_artifex_mupdf_fitz_DocumentWriter */ + +#ifndef _Included_com_artifex_mupdf_fitz_DocumentWriter +#define _Included_com_artifex_mupdf_fitz_DocumentWriter +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_artifex_mupdf_fitz_DocumentWriter + * Method: finalize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_DocumentWriter_finalize + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_DocumentWriter + * Method: newNativeDocumentWriter + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_DocumentWriter_newNativeDocumentWriter + (JNIEnv *, jobject, jstring, jstring, jstring); + +/* + * Class: com_artifex_mupdf_fitz_DocumentWriter + * Method: beingPage + * Signature: (Lcom/artifex/mupdf/fitz/Rect;)Lcom/artifex/mupdf/fitz/Device; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DocumentWriter_beingPage + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_DocumentWriter + * Method: endPage + * Signature: (Lcom/artifex/mupdf/fitz/Device;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_DocumentWriter_endPage + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_DocumentWriter + * Method: close + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_DocumentWriter_close + (JNIEnv *, jobject); + #ifdef __cplusplus } #endif @@ -671,6 +879,14 @@ JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_Image_getYResolution /* * Class: com_artifex_mupdf_fitz_Image + * Method: getColorSpace + * Signature: ()Lcom/artifex/mupdf/fitz/ColorSpace; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Image_getColorSpace + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Image * Method: getNumberOfComponents * Signature: ()I */ @@ -1029,6 +1245,564 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Outline_finalize } #endif #endif +/* Header for class com_artifex_mupdf_fitz_PDFDocument */ + +#ifndef _Included_com_artifex_mupdf_fitz_PDFDocument +#define _Included_com_artifex_mupdf_fitz_PDFDocument +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: finalize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_finalize + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: toDocument + * Signature: ()Lcom/artifex/mupdf/fitz/Document; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_toDocument + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: countPages + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_countPages + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: findPage + * Signature: (I)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_findPage + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: getTrailer + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_getTrailer + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: countObjects + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_countObjects + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newNull + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newNull + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newBoolean + * Signature: (Z)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newBoolean + (JNIEnv *, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newInteger + * Signature: (I)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newInteger + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newReal + * Signature: (F)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newReal + (JNIEnv *, jobject, jfloat); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newString + * Signature: (Ljava/lang/String;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newString + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newName + * Signature: (Ljava/lang/String;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newName + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newIndirect + * Signature: (II)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newIndirect + (JNIEnv *, jobject, jint, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newArray + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newArray + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: newDictionary + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_newDictionary + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addObject + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addObject + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: createObject + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_createObject + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: deleteObject + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_deleteObject + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addStream + * Signature: (Lcom/artifex/mupdf/fitz/Buffer;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addStream + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addPage + * Signature: (Lcom/artifex/mupdf/fitz/Rect;ILcom/artifex/mupdf/fitz/PDFObject;Lcom/artifex/mupdf/fitz/Buffer;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addPage + (JNIEnv *, jobject, jobject, jint, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: insertPage + * Signature: (ILcom/artifex/mupdf/fitz/PDFObject;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_insertPage + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: deletePage + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_deletePage + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addImage + * Signature: (Lcom/artifex/mupdf/fitz/Image;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addImage + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addSimpleFont + * Signature: (Lcom/artifex/mupdf/fitz/Font;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addSimpleFont + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: addFont + * Signature: (Lcom/artifex/mupdf/fitz/Font;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addFont + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFDocument + * Method: save + * Signature: (Ljava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_save + (JNIEnv *, jobject, jstring, jstring); + +#ifdef __cplusplus +} +#endif +#endif +/* Header for class com_artifex_mupdf_fitz_PDFObject */ + +#ifndef _Included_com_artifex_mupdf_fitz_PDFObject +#define _Included_com_artifex_mupdf_fitz_PDFObject +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: finalize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_finalize + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isIndirect + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isIndirect + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isNull + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isNull + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isBoolean + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isBoolean + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isInteger + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isInteger + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isReal + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isReal + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isNumber + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isNumber + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isString + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isString + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isName + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isName + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isArray + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isArray + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isDictionary + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isDictionary + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: isStream + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_isStream + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toBoolean + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toBoolean + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toInteger + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toInteger + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toFloat + * Signature: ()F + */ +JNIEXPORT jfloat JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toFloat + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toByteString + * Signature: ()[B + */ +JNIEXPORT jbyteArray JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toByteString + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toIndirect + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toIndirect + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: toString + * Signature: (Z)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_artifex_mupdf_fitz_PDFObject_toString + (JNIEnv *, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: resolve + * Signature: ()Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFObject_resolve + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: readStream + * Signature: ()[B + */ +JNIEXPORT jbyteArray JNICALL Java_com_artifex_mupdf_fitz_PDFObject_readStream + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: readRawStream + * Signature: ()[B + */ +JNIEXPORT jbyteArray JNICALL Java_com_artifex_mupdf_fitz_PDFObject_readRawStream + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: getArray + * Signature: (I)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFObject_getArray + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: getDictionary + * Signature: (Ljava/lang/String;)Lcom/artifex/mupdf/fitz/PDFObject; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFObject_getDictionary + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putArrayBoolean + * Signature: (IZ)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putArrayBoolean + (JNIEnv *, jobject, jint, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putArrayInteger + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putArrayInteger + (JNIEnv *, jobject, jint, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putArrayFloat + * Signature: (IF)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putArrayFloat + (JNIEnv *, jobject, jint, jfloat); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putArrayString + * Signature: (ILjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putArrayString + (JNIEnv *, jobject, jint, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putArrayPDFObject + * Signature: (ILcom/artifex/mupdf/fitz/PDFObject;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putArrayPDFObject + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryStringBoolean + * Signature: (Ljava/lang/String;Z)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryStringBoolean + (JNIEnv *, jobject, jstring, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryStringInteger + * Signature: (Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryStringInteger + (JNIEnv *, jobject, jstring, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryStringFloat + * Signature: (Ljava/lang/String;F)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryStringFloat + (JNIEnv *, jobject, jstring, jfloat); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryStringString + * Signature: (Ljava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryStringString + (JNIEnv *, jobject, jstring, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryStringPDFObject + * Signature: (Ljava/lang/String;Lcom/artifex/mupdf/fitz/PDFObject;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryStringPDFObject + (JNIEnv *, jobject, jstring, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryPDFObjectBoolean + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;Z)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryPDFObjectBoolean + (JNIEnv *, jobject, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryPDFObjectInteger + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryPDFObjectInteger + (JNIEnv *, jobject, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryPDFObjectFloat + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;F)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryPDFObjectFloat + (JNIEnv *, jobject, jobject, jfloat); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryPDFObjectString + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryPDFObjectString + (JNIEnv *, jobject, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: putDictionaryPDFObjectPDFObject + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;Lcom/artifex/mupdf/fitz/PDFObject;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_putDictionaryPDFObjectPDFObject + (JNIEnv *, jobject, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: deleteArray + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_deleteArray + (JNIEnv *, jobject, jint); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: deleteDictionaryString + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_deleteDictionaryString + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_PDFObject + * Method: deleteDictionaryPDFObject + * Signature: (Lcom/artifex/mupdf/fitz/PDFObject;)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFObject_deleteDictionaryPDFObject + (JNIEnv *, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif /* Header for class com_artifex_mupdf_fitz_Page */ #ifndef _Included_com_artifex_mupdf_fitz_Page @@ -1092,6 +1866,30 @@ JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_Page_getAnnotations JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_Page_getLinks (JNIEnv *, jobject); +/* + * Class: com_artifex_mupdf_fitz_Page + * Method: toDisplayList + * Signature: (Z)Lcom/artifex/mupdf/fitz/DisplayList; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_toDisplayList + (JNIEnv *, jobject, jboolean); + +/* + * Class: com_artifex_mupdf_fitz_Page + * Method: toStructuredText + * Signature: ()Lcom/artifex/mupdf/fitz/StructuredText; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_toStructuredText + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Page + * Method: search + * Signature: (Ljava/lang/String;)[Lcom/artifex/mupdf/fitz/Rect; + */ +JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_Page_search + (JNIEnv *, jobject, jstring); + #ifdef __cplusplus } #endif @@ -1177,6 +1975,14 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Path_curveToY /* * Class: com_artifex_mupdf_fitz_Path + * Method: rect + * Signature: (IIII)V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Path_rect + (JNIEnv *, jobject, jint, jint, jint, jint); + +/* + * Class: com_artifex_mupdf_fitz_Path * Method: closePath * Signature: ()V */ @@ -1338,17 +2144,41 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getColorSpace * Method: getSamples * Signature: ()[B */ -JNIEXPORT jbyteArray JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getSamples +JNIEXPORT jbyteArray JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getSamples__ (JNIEnv *, jobject); /* * Class: com_artifex_mupdf_fitz_Pixmap + * Method: getSamples + * Signature: (III)B + */ +JNIEXPORT jbyte JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getSamples__III + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_artifex_mupdf_fitz_Pixmap * Method: getPixels * Signature: ()[I */ JNIEXPORT jintArray JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getPixels (JNIEnv *, jobject); +/* + * Class: com_artifex_mupdf_fitz_Pixmap + * Method: getXResolution + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getXResolution + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_Pixmap + * Method: getYResolution + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getYResolution + (JNIEnv *, jobject); + #ifdef __cplusplus } #endif @@ -1520,6 +2350,49 @@ JNIEXPORT jfloatArray JNICALL Java_com_artifex_mupdf_fitz_StrokeState_getDashes } #endif #endif +/* Header for class com_artifex_mupdf_fitz_StructuredText */ + +#ifndef _Included_com_artifex_mupdf_fitz_StructuredText +#define _Included_com_artifex_mupdf_fitz_StructuredText +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_artifex_mupdf_fitz_StructuredText + * Method: finalize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_StructuredText_finalize + (JNIEnv *, jobject); + +/* + * Class: com_artifex_mupdf_fitz_StructuredText + * Method: search + * Signature: (Ljava/lang/String;)[Lcom/artifex/mupdf/fitz/Rect; + */ +JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_StructuredText_search + (JNIEnv *, jobject, jstring); + +/* + * Class: com_artifex_mupdf_fitz_StructuredText + * Method: highlight + * Signature: (Lcom/artifex/mupdf/fitz/Rect;)[Lcom/artifex/mupdf/fitz/Rect; + */ +JNIEXPORT jobjectArray JNICALL Java_com_artifex_mupdf_fitz_StructuredText_highlight + (JNIEnv *, jobject, jobject); + +/* + * Class: com_artifex_mupdf_fitz_StructuredText + * Method: copy + * Signature: (Lcom/artifex/mupdf/fitz/Rect;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_artifex_mupdf_fitz_StructuredText_copy + (JNIEnv *, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif /* Header for class com_artifex_mupdf_fitz_Text */ #ifndef _Included_com_artifex_mupdf_fitz_Text |