diff options
-rw-r--r-- | include/mupdf/fitz/structured-text.h | 4 | ||||
-rw-r--r-- | platform/android/viewer/jni/mupdf.c | 10 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 3 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewReflow.m | 3 | ||||
-rw-r--r-- | platform/ios/common.m | 4 | ||||
-rw-r--r-- | platform/x11/pdfapp.c | 3 | ||||
-rw-r--r-- | source/fitz/stext-device.c | 4 | ||||
-rw-r--r-- | source/fitz/util.c | 12 | ||||
-rw-r--r-- | source/tools/mudraw.c | 7 |
9 files changed, 36 insertions, 14 deletions
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h index ffb9f263..e4199272 100644 --- a/include/mupdf/fitz/structured-text.h +++ b/include/mupdf/fitz/structured-text.h @@ -215,8 +215,10 @@ void fz_drop_stext_sheet(fz_context *ctx, fz_stext_sheet *sheet); The text page is filled out by the text device to contain the blocks, lines and spans of text on the page. + + mediabox: optional mediabox information. */ -fz_stext_page *fz_new_stext_page(fz_context *ctx); +fz_stext_page *fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox); void fz_drop_stext_page(fz_context *ctx, fz_stext_page *page); void fz_analyze_text(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page); diff --git a/platform/android/viewer/jni/mupdf.c b/platform/android/viewer/jni/mupdf.c index b70d3f1a..91a002e3 100644 --- a/platform/android/viewer/jni/mupdf.c +++ b/platform/android/viewer/jni/mupdf.c @@ -1251,13 +1251,15 @@ JNI_FN(MuPDFCore_searchPage)(JNIEnv * env, jobject thiz, jstring jtext) fz_try(ctx) { + fz_rect mediabox; + if (glo->hit_bbox == NULL) glo->hit_bbox = fz_malloc_array(ctx, MAX_SEARCH_HITS, sizeof(*glo->hit_bbox)); zoom = glo->resolution / 72; fz_scale(&ctm, zoom, zoom); sheet = fz_new_stext_sheet(ctx); - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); @@ -1342,12 +1344,13 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) fz_try(ctx) { + fz_rect mediabox; int b, l, s, c; zoom = glo->resolution / 72; fz_scale(&ctm, zoom, zoom); sheet = fz_new_stext_sheet(ctx); - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); @@ -1451,11 +1454,12 @@ JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz) fz_try(ctx) { + fz_rect mediabox; int b, l, s, c; ctm = fz_identity; sheet = fz_new_stext_sheet(ctx); - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index b9da24e5..c56ad840 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -72,10 +72,11 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) fz_try(ctx) { + fz_rect mediabox; int b, l, c; sheet = fz_new_stext_sheet(ctx); - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, NULL); fz_drop_device(ctx, dev); diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m index 9378da61..86905b03 100644 --- a/platform/ios/Classes/MuPageViewReflow.m +++ b/platform/ios/Classes/MuPageViewReflow.m @@ -11,6 +11,7 @@ NSString *textAsHtml(fz_document *doc, int pageNum) fz_matrix ctm; fz_buffer *buf = NULL; fz_output *out = NULL; + fz_rect mediabox; fz_var(page); fz_var(sheet); @@ -23,7 +24,7 @@ NSString *textAsHtml(fz_document *doc, int pageNum) { ctm = fz_identity; sheet = fz_new_stext_sheet(ctx); - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); dev = fz_new_stext_device(ctx, sheet, text); page = fz_load_page(ctx, doc, pageNum); fz_run_page(ctx, page, dev, &ctm, NULL); diff --git a/platform/ios/common.m b/platform/ios/common.m index 6ee3653f..80c2c738 100644 --- a/platform/ios/common.m +++ b/platform/ios/common.m @@ -20,9 +20,9 @@ static fz_rect hit_bbox[500]; int search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie) { fz_page *page = fz_load_page(ctx, doc, number); - + fz_rect mediabox; fz_stext_sheet *sheet = fz_new_stext_sheet(ctx); - fz_stext_page *text = fz_new_stext_page(ctx); + fz_stext_page *text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); fz_device *dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, cookie); fz_drop_device(ctx, dev); diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index 431c9994..e3e9ccc5 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -843,6 +843,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai if (loadpage) { + fz_rect mediabox; pdfapp_loadpage(app, searching); /* Zero search hit position */ @@ -850,7 +851,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai /* Extract text */ app->page_sheet = fz_new_stext_sheet(app->ctx); - app->page_text = fz_new_stext_page(app->ctx); + app->page_text = fz_new_stext_page(app->ctx, fz_bound_page(app->ctx, app->page, &mediabox)); if (app->page_list || app->annotations_list) { diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 55f2033b..607dcbab 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -456,10 +456,10 @@ fz_lookup_stext_style(fz_context *ctx, fz_stext_sheet *sheet, fz_text_span *span } fz_stext_page * -fz_new_stext_page(fz_context *ctx) +fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox) { fz_stext_page *page = fz_malloc(ctx, sizeof(*page)); - page->mediabox = fz_empty_rect; + page->mediabox = *mediabox; page->len = 0; page->cap = 0; page->blocks = NULL; diff --git a/source/fitz/util.c b/source/fitz/util.c index cefac962..ff1464fc 100644 --- a/source/fitz/util.c +++ b/source/fitz/util.c @@ -269,8 +269,12 @@ fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_s { fz_stext_page *text; fz_device *dev; + fz_rect mediabox; - text = fz_new_stext_page(ctx); + if (list == NULL) + return NULL; + + text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list, &mediabox)); fz_try(ctx) { dev = fz_new_stext_device(ctx, sheet, text); @@ -295,8 +299,12 @@ fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *shee { fz_stext_page *text; fz_device *dev; + fz_rect *mediabox; + + if (page == NULL) + return NULL; - text = fz_new_stext_page(ctx); + text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); fz_try(ctx) { dev = fz_new_stext_device(ctx, sheet, text); diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 16e12b6b..e7dc629b 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -620,7 +620,12 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in fz_try(ctx) { - text = fz_new_stext_page(ctx); + fz_rect mediabox; + if (list) + fz_bound_display_list(ctx, list, &mediabox); + else + fz_bound_page(ctx, page, &mediabox); + text = fz_new_stext_page(ctx, &mediabox); dev = fz_new_stext_device(ctx, sheet, text); if (lowmemory) fz_enable_device_hints(ctx, dev, FZ_NO_CACHE); |