From caafb37ddf3d58f4d37d8c7b535021ff18d57861 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 13 Jul 2016 19:36:39 +0100 Subject: Bug 696699: Fix Text extraction mediabox information. Since the removal of the begin_page device function, structured text extraction has been unable to correctly establish the mediabox for extracted pages. Update the fz_new_stext_page call to take this mediabox information. This is an API change, but hopefully most people are calling fz_new_stext_page_from_page or fz_new_stext_page_from_display_list which are updated here to cope. Update all the apps/tools to behave properly. --- platform/ios/Classes/MuPageViewNormal.m | 3 ++- platform/ios/Classes/MuPageViewReflow.m | 3 ++- platform/ios/common.m | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'platform/ios') 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); -- cgit v1.2.3