summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-08-31 15:09:10 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-09-05 12:52:06 +0200
commite8df80eb54d51c9339f7e150e266f21b34945ba0 (patch)
treefb0a24c300525d8530be8ab5ec8b7a3a22bcf56e
parent4a70c5f9441153e8860c31f958e0987a2d46085d (diff)
downloadmupdf-e8df80eb54d51c9339f7e150e266f21b34945ba0.tar.xz
Add fz_new_stext_page_from_annot utility function.
-rw-r--r--include/mupdf/fitz/util.h1
-rw-r--r--source/fitz/util.c31
2 files changed, 32 insertions, 0 deletions
diff --git a/include/mupdf/fitz/util.h b/include/mupdf/fitz/util.h
index 1335cf86..87595017 100644
--- a/include/mupdf/fitz/util.h
+++ b/include/mupdf/fitz/util.h
@@ -41,6 +41,7 @@ fz_pixmap *fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, fz_matrix
fz_stext_page *fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, const fz_stext_options *options);
fz_stext_page *fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_stext_options *options);
fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, const fz_stext_options *options);
+fz_stext_page *fz_new_stext_page_from_annot(fz_context *ctx, fz_annot *annot, const fz_stext_options *options);
/*
fz_new_buffer_from_stext_page: Convert structured text into plain text.
diff --git a/source/fitz/util.c b/source/fitz/util.c
index 8f0d9f62..fcf6ca00 100644
--- a/source/fitz/util.c
+++ b/source/fitz/util.c
@@ -339,6 +339,37 @@ fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number
return text;
}
+fz_stext_page *
+fz_new_stext_page_from_annot(fz_context *ctx, fz_annot *annot, const fz_stext_options *options)
+{
+ fz_stext_page *text;
+ fz_device *dev = NULL;
+
+ fz_var(dev);
+
+ if (annot == NULL)
+ return NULL;
+
+ text = fz_new_stext_page(ctx, fz_bound_annot(ctx, annot));
+ fz_try(ctx)
+ {
+ dev = fz_new_stext_device(ctx, text, options);
+ fz_run_annot(ctx, annot, dev, fz_identity, NULL);
+ fz_close_device(ctx, dev);
+ }
+ fz_always(ctx)
+ {
+ fz_drop_device(ctx, dev);
+ }
+ fz_catch(ctx)
+ {
+ fz_drop_stext_page(ctx, text);
+ fz_rethrow(ctx);
+ }
+
+ return text;
+}
+
int
fz_search_display_list(fz_context *ctx, fz_display_list *list, const char *needle, fz_quad *hit_bbox, int hit_max)
{