From 7b40777c5dcd4797f795ca6d442d9ec2f47b0c92 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Mon, 18 Jul 2016 01:49:58 +0800 Subject: JNI: Add DisplayList.toStructuredText(). --- platform/java/mupdf_native.c | 29 ++++++++++++++++++++++ platform/java/mupdf_native.h | 14 ++++++++--- .../src/com/artifex/mupdf/fitz/DisplayList.java | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) (limited to 'platform') diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 03250605..08643b7c 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -4506,6 +4506,35 @@ FUN(DisplayList_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs, return to_Pixmap_safe_own(ctx, env, pixmap); } +JNIEXPORT jobject JNICALL +FUN(DisplayList_toStructuredText)(JNIEnv *env, jobject self) +{ + fz_context *ctx = get_context(env); + fz_display_list *list = from_DisplayList(env, self); + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; + + if (ctx == NULL || list == NULL) + return NULL; + + fz_var(sheet); + + fz_try(ctx) + { + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page_from_display_list(ctx, list, sheet); + } + fz_always(ctx) + fz_drop_stext_sheet(ctx, sheet); + fz_catch(ctx) + { + jni_rethrow(env, ctx); + return NULL; + } + + return to_StructuredText_safe_own(ctx, env, text); +} + JNIEXPORT jobject JNICALL FUN(DisplayList_search)(JNIEnv *env, jobject self, jstring jneedle) { diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h index 7afcccc0..3e50fc2d 100644 --- a/platform/java/mupdf_native.h +++ b/platform/java/mupdf_native.h @@ -467,6 +467,14 @@ JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_DisplayList_newNative JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DisplayList_toPixmap (JNIEnv *, jobject, jobject, jobject, jboolean); +/* + * Class: com_artifex_mupdf_fitz_DisplayList + * Method: toStructuredText + * Signature: ()Lcom/artifex/mupdf/fitz/StructuredText; + */ +JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DisplayList_toStructuredText + (JNIEnv *, jobject); + /* * Class: com_artifex_mupdf_fitz_DisplayList * Method: search @@ -2232,15 +2240,15 @@ 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 + * Method: getSample * Signature: (III)B */ -JNIEXPORT jbyte JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getSamples__III +JNIEXPORT jbyte JNICALL Java_com_artifex_mupdf_fitz_Pixmap_getSample (JNIEnv *, jobject, jint, jint, jint); /* diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java index 3e822eea..f274ebfa 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java +++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java @@ -22,6 +22,7 @@ public class DisplayList } public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha); + public native StructuredText toStructuredText(); public native Rect[] search(String needle); public native void run(Device dev, Matrix ctm, Rect scissor, Cookie cookie); -- cgit v1.2.3