summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/structured-text.h29
-rw-r--r--include/mupdf/fitz/util.h12
-rw-r--r--platform/android/viewer/jni/mupdf.c6
-rw-r--r--platform/gl/gl-main.c4
-rw-r--r--platform/ios/Classes/MuPageViewNormal.m2
-rw-r--r--platform/ios/Classes/MuPageViewReflow.m2
-rw-r--r--platform/ios/common.m2
-rw-r--r--platform/java/mupdf_native.c10
-rw-r--r--platform/java/mupdf_native.h8
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/DisplayList.java2
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/Page.java2
-rw-r--r--platform/x11/pdfapp.c2
-rw-r--r--source/fitz/stext-device.c103
-rw-r--r--source/fitz/util.c28
-rw-r--r--source/tools/mudraw.c2
-rw-r--r--source/tools/murun.c6
16 files changed, 137 insertions, 83 deletions
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h
index e4199272..a12c3cc9 100644
--- a/include/mupdf/fitz/structured-text.h
+++ b/include/mupdf/fitz/structured-text.h
@@ -28,6 +28,25 @@ typedef struct fz_stext_sheet_s fz_stext_sheet;
typedef struct fz_stext_page_s fz_stext_page;
/*
+ FZ_STEXT_PRESERVE_LIGATURES: If this option is activated ligatures
+ are passed through to the application in their original form. If
+ this option is deactivated ligatures are expanded into their
+ constituent parts, e.g. the ligature ffi is expanded into three
+ separate characters f, f and i.
+
+ FZ_STEXT_PRESERVE_WHITESPACE: If this option is actived whitespace
+ is passed through to the application in its original form. If this
+ option is deactivated any type of horizontal whitespace (including
+ horizontal tabs) will be replaced with space characters of variable
+ width.
+*/
+enum
+{
+ FZ_STEXT_PRESERVE_LIGATURES = 1,
+ FZ_STEXT_PRESERVE_WHITESPACE = 2,
+};
+
+/*
fz_stext_sheet: A text sheet contains a list of distinct text styles
used on a page (or a series of pages).
*/
@@ -280,9 +299,13 @@ char *fz_copy_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect);
page: The text page to which content should be added. This will
usually be a newly created (empty) text page, but it can be one
- containing data already (for example when merging multiple pages, or
- watermarking).
+ containing data already (for example when merging multiple pages,
+ or watermarking).
+
+ options: Mask of heuristic options to activate. If 0 is given the
+ default is to activate both FZ_STEXT_PRESERVE_LIGATURES and
+ FZ_STEXT_PRESERVE_WHITESPACE.
*/
-fz_device *fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page);
+fz_device *fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page, int options);
#endif
diff --git a/include/mupdf/fitz/util.h b/include/mupdf/fitz/util.h
index 9f982699..f8dec50a 100644
--- a/include/mupdf/fitz/util.h
+++ b/include/mupdf/fitz/util.h
@@ -38,9 +38,9 @@ fz_pixmap *fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, const fz_m
/*
fz_new_stext_page_from_page: Extract structured text from a page. The sheet must not be NULL.
*/
-fz_stext_page *fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet);
-fz_stext_page *fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet);
-fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet);
+fz_stext_page *fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet, int options);
+fz_stext_page *fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet, int options);
+fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet, int options);
/*
fz_new_buffer_from_stext_page: Convert structured text into plain text, cropped by the selection rectangle.
@@ -48,9 +48,9 @@ fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_l
otherwise '\n'.
*/
fz_buffer *fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text, const fz_rect *sel, int crlf);
-fz_buffer *fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf);
-fz_buffer *fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_rect *sel, int crlf);
-fz_buffer *fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf);
+fz_buffer *fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf, int options);
+fz_buffer *fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_rect *sel, int crlf, int options);
+fz_buffer *fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf, int options);
/*
fz_search_page: Search for the 'needle' text on the page.
diff --git a/platform/android/viewer/jni/mupdf.c b/platform/android/viewer/jni/mupdf.c
index 83560aad..9eabc243 100644
--- a/platform/android/viewer/jni/mupdf.c
+++ b/platform/android/viewer/jni/mupdf.c
@@ -1266,7 +1266,7 @@ JNI_FN(MuPDFCore_searchPage)(JNIEnv * env, jobject thiz, jstring jtext)
fz_scale(&ctm, zoom, zoom);
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, pc->page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, pc->page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
fz_drop_device(ctx, dev);
@@ -1358,7 +1358,7 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz)
fz_scale(&ctm, zoom, zoom);
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, pc->page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, pc->page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
fz_drop_device(ctx, dev);
@@ -1468,7 +1468,7 @@ JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz)
ctm = fz_identity;
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, pc->page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, pc->page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
fz_drop_device(ctx, dev);
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index ab8641b1..904f3f51 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -355,9 +355,9 @@ static void do_copy_region(fz_rect *screen_sel, int xofs, int yofs)
fz_transform_rect(&page_sel, &page_inv_ctm);
#ifdef _WIN32
- buf = fz_new_buffer_from_page(ctx, page, &page_sel, 1);
+ buf = fz_new_buffer_from_page(ctx, page, &page_sel, 1, 0);
#else
- buf = fz_new_buffer_from_page(ctx, page, &page_sel, 0);
+ buf = fz_new_buffer_from_page(ctx, page, &page_sel, 0, 0);
#endif
fz_write_buffer_rune(ctx, buf, 0);
glfwSetClipboardString(window, (char*)buf->data);
diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m
index c190754a..fb88d8de 100644
--- a/platform/ios/Classes/MuPageViewNormal.m
+++ b/platform/ios/Classes/MuPageViewNormal.m
@@ -77,7 +77,7 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page)
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, page, dev, &fz_identity, NULL);
fz_close_device(ctx, dev);
fz_drop_device(ctx, dev);
diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m
index 2b1cdebf..8356ac6a 100644
--- a/platform/ios/Classes/MuPageViewReflow.m
+++ b/platform/ios/Classes/MuPageViewReflow.m
@@ -25,7 +25,7 @@ NSString *textAsHtml(fz_document *doc, int pageNum)
ctm = fz_identity;
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
page = fz_load_page(ctx, doc, pageNum);
fz_run_page(ctx, page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
diff --git a/platform/ios/common.m b/platform/ios/common.m
index 80c2c738..081e6a6f 100644
--- a/platform/ios/common.m
+++ b/platform/ios/common.m
@@ -23,7 +23,7 @@ int search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie)
fz_rect mediabox;
fz_stext_sheet *sheet = fz_new_stext_sheet(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_device *dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, page, dev, &fz_identity, cookie);
fz_drop_device(ctx, dev);
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 87e57e57..39256043 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -4202,7 +4202,7 @@ FUN(Page_toDisplayList)(JNIEnv *env, jobject self, jboolean no_annotations)
}
JNIEXPORT jobject JNICALL
-FUN(Page_toStructuredText)(JNIEnv *env, jobject self)
+FUN(Page_toStructuredText)(JNIEnv *env, jobject self, jint joptions)
{
fz_context *ctx = get_context(env);
fz_page *page = from_Page(env, self);
@@ -4216,7 +4216,7 @@ FUN(Page_toStructuredText)(JNIEnv *env, jobject self)
fz_try(ctx)
{
sheet = fz_new_stext_sheet(ctx);
- text = fz_new_stext_page_from_page(ctx, page, sheet);
+ text = fz_new_stext_page_from_page(ctx, page, sheet, joptions);
}
fz_always(ctx)
fz_drop_stext_sheet(ctx, sheet);
@@ -4258,7 +4258,7 @@ FUN(Page_textAsHtml)(JNIEnv *env, jobject self)
ctm = fz_identity;
sheet = fz_new_stext_sheet(ctx);
text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
fz_run_page(ctx, page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
@@ -4436,7 +4436,7 @@ FUN(DisplayList_toPixmap)(JNIEnv *env, jobject self, jobject jctm, jobject jcs,
}
JNIEXPORT jobject JNICALL
-FUN(DisplayList_toStructuredText)(JNIEnv *env, jobject self)
+FUN(DisplayList_toStructuredText)(JNIEnv *env, jobject self, jint joptions)
{
fz_context *ctx = get_context(env);
fz_display_list *list = from_DisplayList(env, self);
@@ -4450,7 +4450,7 @@ FUN(DisplayList_toStructuredText)(JNIEnv *env, jobject self)
fz_try(ctx)
{
sheet = fz_new_stext_sheet(ctx);
- text = fz_new_stext_page_from_display_list(ctx, list, sheet);
+ text = fz_new_stext_page_from_display_list(ctx, list, sheet, joptions);
}
fz_always(ctx)
fz_drop_stext_sheet(ctx, sheet);
diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h
index d43f1526..d674c715 100644
--- a/platform/java/mupdf_native.h
+++ b/platform/java/mupdf_native.h
@@ -470,10 +470,10 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DisplayList_toPixmap
/*
* Class: com_artifex_mupdf_fitz_DisplayList
* Method: toStructuredText
- * Signature: ()Lcom/artifex/mupdf/fitz/StructuredText;
+ * Signature: (I)Lcom/artifex/mupdf/fitz/StructuredText;
*/
JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_DisplayList_toStructuredText
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jint);
/*
* Class: com_artifex_mupdf_fitz_DisplayList
@@ -2072,10 +2072,10 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_toDisplayList
/*
* Class: com_artifex_mupdf_fitz_Page
* Method: toStructuredText
- * Signature: ()Lcom/artifex/mupdf/fitz/StructuredText;
+ * Signature: (I)Lcom/artifex/mupdf/fitz/StructuredText;
*/
JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_toStructuredText
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jint);
/*
* Class: com_artifex_mupdf_fitz_Page
diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
index f274ebfa..37a218e7 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
@@ -22,7 +22,7 @@ public class DisplayList
}
public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha);
- public native StructuredText toStructuredText();
+ public native StructuredText toStructuredText(int options);
public native Rect[] search(String needle);
public native void run(Device dev, Matrix ctm, Rect scissor, Cookie cookie);
diff --git a/platform/java/src/com/artifex/mupdf/fitz/Page.java b/platform/java/src/com/artifex/mupdf/fitz/Page.java
index 69a4003e..b42935c5 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/Page.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/Page.java
@@ -33,7 +33,7 @@ public class Page
//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 StructuredText toStructuredText(int options);
public native Rect[] search(String needle);
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index e4b0c13f..e76f9be0 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -865,7 +865,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
if (app->page_list || app->annotations_list)
{
- tdev = fz_new_stext_device(app->ctx, app->page_sheet, app->page_text);
+ tdev = fz_new_stext_device(app->ctx, app->page_sheet, app->page_text, 0);
pdfapp_runpage(app, tdev, &fz_identity, &fz_infinite_rect, &cookie);
fz_close_device(app->ctx, tdev);
fz_drop_device(app->ctx, tdev);
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index 607dcbab..909d0a46 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -30,6 +30,7 @@ struct fz_stext_device_s
span_soup *spans;
fz_stext_span *cur_span;
int lastchar;
+ int options;
};
static fz_rect *
@@ -715,41 +716,68 @@ no_glyph:
static void
fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_stext_style *style, int c, int glyph, fz_matrix *trm, float adv, int wmode)
{
- switch (c)
- {
- case -1: /* ignore when one unicode character maps to multiple glyphs */
- break;
- case 0xFB00: /* ff */
- fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
- break;
- case 0xFB01: /* fi */
- fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'i', -1, trm, 0, wmode);
- break;
- case 0xFB02: /* fl */
- fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'l', -1, trm, 0, wmode);
- break;
- case 0xFB03: /* ffi */
- fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'i', -1, trm, 0, wmode);
- break;
- case 0xFB04: /* ffl */
- fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 'l', -1, trm, 0, wmode);
- break;
- case 0xFB05: /* long st */
- case 0xFB06: /* st */
- fz_add_stext_char_imp(ctx, dev, style, 's', glyph, trm, adv, wmode);
- fz_add_stext_char_imp(ctx, dev, style, 't', -1, trm, 0, wmode);
- break;
- default:
- fz_add_stext_char_imp(ctx, dev, style, c, glyph, trm, adv, wmode);
- break;
- }
+ /* ignore when one unicode character maps to multiple glyphs */
+ if (c == -1)
+ return;
+
+ if (!(dev->options & FZ_STEXT_PRESERVE_LIGATURES))
+ switch (c)
+ {
+ case 0xFB00: /* ff */
+ fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
+ return;
+ case 0xFB01: /* fi */
+ fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'i', -1, trm, 0, wmode);
+ return;
+ case 0xFB02: /* fl */
+ fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'l', -1, trm, 0, wmode);
+ return;
+ case 0xFB03: /* ffi */
+ fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'i', -1, trm, 0, wmode);
+ return;
+ case 0xFB04: /* ffl */
+ fz_add_stext_char_imp(ctx, dev, style, 'f', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'f', -1, trm, 0, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 'l', -1, trm, 0, wmode);
+ return;
+ case 0xFB05: /* long st */
+ case 0xFB06: /* st */
+ fz_add_stext_char_imp(ctx, dev, style, 's', glyph, trm, adv, wmode);
+ fz_add_stext_char_imp(ctx, dev, style, 't', -1, trm, 0, wmode);
+ return;
+ }
+
+ if (!(dev->options & FZ_STEXT_PRESERVE_WHITESPACE))
+ switch (c)
+ {
+ case 0x0009: /* tab */
+ case 0x0020: /* space */
+ case 0x00A0: /* no-break space */
+ case 0x1680: /* ogham space mark */
+ case 0x180E: /* mongolian vowel separator */
+ case 0x2000: /* en quad */
+ case 0x2001: /* em quad */
+ case 0x2002: /* en space */
+ case 0x2003: /* em space */
+ case 0x2004: /* three-per-em space */
+ case 0x2005: /* four-per-em space */
+ case 0x2006: /* six-per-em space */
+ case 0x2007: /* figure space */
+ case 0x2008: /* punctuation space */
+ case 0x2009: /* thin space */
+ case 0x200A: /* hair space */
+ case 0x202F: /* narrow no-break space */
+ case 0x205F: /* medium mathematical space */
+ case 0x3000: /* ideographic spac */
+ fz_add_stext_char_imp(ctx, dev, style, ' ', glyph, trm, adv, wmode);
+ }
+
+ fz_add_stext_char_imp(ctx, dev, style, c, glyph, trm, adv, wmode);
}
static void
@@ -1039,11 +1067,11 @@ fz_stext_drop_device(fz_context *ctx, fz_device *dev)
}
fz_device *
-fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page)
+fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page, int options)
{
fz_stext_device *dev = fz_new_device(ctx, sizeof *dev);
- dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE;
+ dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE | FZ_STEXT_PRESERVE_LIGATURES | FZ_STEXT_PRESERVE_WHITESPACE;
dev->super.close_device = fz_stext_close_device;
dev->super.drop_device = fz_stext_drop_device;
@@ -1061,6 +1089,7 @@ fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page)
dev->spans = NULL;
dev->cur_span = NULL;
dev->lastchar = ' ';
+ dev->options = options ? options : FZ_STEXT_PRESERVE_LIGATURES | FZ_STEXT_PRESERVE_WHITESPACE;
return (fz_device*)dev;
}
diff --git a/source/fitz/util.c b/source/fitz/util.c
index 4c7b3232..6e0982e7 100644
--- a/source/fitz/util.c
+++ b/source/fitz/util.c
@@ -265,7 +265,7 @@ fz_new_pixmap_from_page_number(fz_context *ctx, fz_document *doc, int number, co
}
fz_stext_page *
-fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet)
+fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet, int options)
{
fz_stext_page *text;
fz_device *dev;
@@ -277,7 +277,7 @@ fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_s
text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list, &mediabox));
fz_try(ctx)
{
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, options);
fz_run_display_list(ctx, list, dev, &fz_identity, NULL, NULL);
fz_close_device(ctx, dev);
}
@@ -295,7 +295,7 @@ fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_s
}
fz_stext_page *
-fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet)
+fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet, int options)
{
fz_stext_page *text;
fz_device *dev;
@@ -307,7 +307,7 @@ fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *shee
text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
fz_try(ctx)
{
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, options);
fz_run_page(ctx, page, dev, &fz_identity, NULL);
fz_close_device(ctx, dev);
}
@@ -325,14 +325,14 @@ fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *shee
}
fz_stext_page *
-fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet)
+fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet, int options)
{
fz_page *page;
fz_stext_page *text;
page = fz_load_page(ctx, doc, number);
fz_try(ctx)
- text = fz_new_stext_page_from_page(ctx, page, sheet);
+ text = fz_new_stext_page_from_page(ctx, page, sheet, options);
fz_always(ctx)
fz_drop_page(ctx, page);
fz_catch(ctx)
@@ -350,7 +350,7 @@ fz_search_display_list(fz_context *ctx, fz_display_list *list, const char *needl
sheet = fz_new_stext_sheet(ctx);
fz_try(ctx)
{
- text = fz_new_stext_page_from_display_list(ctx, list, sheet);
+ text = fz_new_stext_page_from_display_list(ctx, list, sheet, 0);
count = fz_search_stext_page(ctx, text, needle, hit_bbox, hit_max);
}
fz_always(ctx)
@@ -371,7 +371,7 @@ fz_search_page(fz_context *ctx, fz_page *page, const char *needle, fz_rect *hit_
sheet = fz_new_stext_sheet(ctx);
fz_try(ctx)
{
- text = fz_new_stext_page_from_page(ctx, page, sheet);
+ text = fz_new_stext_page_from_page(ctx, page, sheet, 0);
count = fz_search_stext_page(ctx, text, needle, hit_bbox, hit_max);
}
fz_always(ctx)
@@ -478,7 +478,7 @@ fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text, const fz_rec
}
fz_buffer *
-fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf)
+fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf, int options)
{
fz_stext_sheet *sheet;
fz_stext_page *text;
@@ -487,7 +487,7 @@ fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz
sheet = fz_new_stext_sheet(ctx);
fz_try(ctx)
{
- text = fz_new_stext_page_from_display_list(ctx, list, sheet);
+ text = fz_new_stext_page_from_display_list(ctx, list, sheet, options);
buf = fz_new_buffer_from_stext_page(ctx, text, sel, crlf);
}
fz_always(ctx)
@@ -499,7 +499,7 @@ fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz
}
fz_buffer *
-fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf)
+fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf, int options)
{
fz_stext_sheet *sheet;
fz_stext_page *text;
@@ -508,7 +508,7 @@ fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int
sheet = fz_new_stext_sheet(ctx);
fz_try(ctx)
{
- text = fz_new_stext_page_from_page(ctx, page, sheet);
+ text = fz_new_stext_page_from_page(ctx, page, sheet, options);
buf = fz_new_buffer_from_stext_page(ctx, text, sel, crlf);
}
fz_always(ctx)
@@ -520,14 +520,14 @@ fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int
}
fz_buffer *
-fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_rect *sel, int crlf)
+fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_rect *sel, int crlf, int options)
{
fz_page *page;
fz_buffer *buf;
page = fz_load_page(ctx, doc, number);
fz_try(ctx)
- buf = fz_new_buffer_from_page(ctx, page, sel, crlf);
+ buf = fz_new_buffer_from_page(ctx, page, sel, crlf, options);
fz_always(ctx)
fz_drop_page(ctx, page);
fz_catch(ctx)
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index e7dc629b..fde776d2 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -626,7 +626,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
else
fz_bound_page(ctx, page, &mediabox);
text = fz_new_stext_page(ctx, &mediabox);
- dev = fz_new_stext_device(ctx, sheet, text);
+ dev = fz_new_stext_device(ctx, sheet, text, 0);
if (lowmemory)
fz_enable_device_hints(ctx, dev, FZ_NO_CACHE);
if (output_format == OUT_HTML)
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 5767d27d..3843ea1f 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1627,6 +1627,7 @@ static void ffi_Page_toStructuredText(js_State *J)
{
fz_context *ctx = js_getcontext(J);
fz_page *page = js_touserdata(J, 0, "fz_page");
+ const char *options = js_tointeger(J, 1);
fz_stext_sheet *sheet = NULL;
fz_stext_page *text;
@@ -1634,7 +1635,7 @@ static void ffi_Page_toStructuredText(js_State *J)
fz_try(ctx) {
sheet = fz_new_stext_sheet(ctx);
- text = fz_new_stext_page_from_page(ctx, page, sheet);
+ text = fz_new_stext_page_from_page(ctx, page, sheet, options);
}
fz_always(ctx)
fz_drop_stext_sheet(ctx, sheet);
@@ -2458,6 +2459,7 @@ static void ffi_DisplayList_toStructuredText(js_State *J)
{
fz_context *ctx = js_getcontext(J);
fz_display_list *list = js_touserdata(J, 0, "fz_display_list");
+ const char *options = js_tointeger(J, 1);
fz_stext_sheet *sheet = NULL;
fz_stext_page *text;
@@ -2465,7 +2467,7 @@ static void ffi_DisplayList_toStructuredText(js_State *J)
fz_try(ctx) {
sheet = fz_new_stext_sheet(ctx);
- text = fz_new_stext_page_from_display_list(ctx, list, sheet);
+ text = fz_new_stext_page_from_display_list(ctx, list, sheet, options);
}
fz_always(ctx)
fz_drop_stext_sheet(ctx, sheet);