Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding box for java #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions platform/java/jni/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ FUN(Page_getBoundsNative)(JNIEnv *env, jobject self, jint box)
return to_Rect_safe(ctx, env, rect);
}

JNIEXPORT jobject JNICALL
FUN(Page_getBBox)(JNIEnv *env, jobject self)
{
fz_context *ctx = get_context(env);
fz_page *page = from_Page(env, self);
fz_rect bbox = fz_empty_rect;
fz_device *dev = NULL;

if (!ctx || !page) return NULL;

fz_try(ctx)
{
dev = fz_new_bbox_device(ctx, &bbox);
fz_run_page(ctx, page, dev, fz_identity, NULL);
fz_close_device(ctx, dev);
}
fz_always(ctx)
{
fz_drop_device(ctx, dev);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}

return to_Rect_safe(ctx, env, bbox);
}

JNIEXPORT void JNICALL
FUN(Page_run)(JNIEnv *env, jobject self, jobject jdev, jobject jctm, jobject jcookie)
{
Expand Down
3 changes: 3 additions & 0 deletions platform/java/src/com/artifex/mupdf/fitz/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public Rect getBounds() {
return getBoundsNative(Page.CROP_BOX);
}

// compute the bounding box of all objects on a page.
public native Rect getBBox();

public native void run(Device dev, Matrix ctm, Cookie cookie);
public native void runPageContents(Device dev, Matrix ctm, Cookie cookie);
public native void runPageAnnots(Device dev, Matrix ctm, Cookie cookie);
Expand Down