diff --git glib/poppler-page.cc glib/poppler-page.cc index 9850d44..3bad937 100644 --- glib/poppler-page.cc +++ glib/poppler-page.cc @@ -853,9 +853,19 @@ poppler_page_get_text (PopplerPage *page) } /** - * poppler_page_find_text: + * poppler_page_find_text_full: + * + * Find a string. If is true, starts looking at the + * top of the page; else if is true, starts looking + * immediately after the last find result; else starts looking at + * ,. If is true, stops looking at the + * bottom of the page; else if is true, stops looking + * just before the last find result; else stops looking at + * ,. + * * @page: a #PopplerPage * @text: the text to search for (UTF-8 encoded) + * @case_sensitive: gboolean to turn case sensitive search on/off * * A #GList of rectangles for each occurance of the text on the page. * The coordinates are in PDF points. @@ -863,8 +873,14 @@ poppler_page_get_text (PopplerPage *page) * Return value: (element-type PopplerRectangle) (transfer full): a #GList of #PopplerRectangle, **/ GList * -poppler_page_find_text (PopplerPage *page, - const char *text) +poppler_page_find_text_full (PopplerPage *page, + const char *text, + gboolean start_at_top, + gboolean stop_at_bottom, + gboolean start_at_last, + gboolean stop_at_last, + gboolean case_sensitive, + gboolean backward) { PopplerRectangle *match; GList *matches; @@ -887,9 +903,9 @@ poppler_page_find_text (PopplerPage *page, yMin = 0; while (text_dev->findText (ucs4, ucs4_len, - gFalse, gTrue, // startAtTop, stopAtBottom - gFalse, gFalse, // startAtLast, stopAtLast - gFalse, gFalse, // caseSensitive, backwards + start_at_top, stop_at_bottom, + start_at_last, stop_at_last, + case_sensitive, backward, &xMin, &yMin, &xMax, &yMax)) { match = poppler_rectangle_new (); @@ -905,6 +921,29 @@ poppler_page_find_text (PopplerPage *page, return g_list_reverse (matches); } +/** + * poppler_page_find_text: + * @page: a #PopplerPage + * @text: the text to search for (UTF-8 encoded) + * + * A #GList of rectangles for each occurance of the text on the page. + * The coordinates are in PDF points. + * + * Return value: (element-type PopplerRectangle) (transfer full): a #GList of #PopplerRectangle, + **/ +GList * +poppler_page_find_text (PopplerPage *page, + const char *text) +{ + return poppler_page_find_text_full (page, text, + FALSE, // start_at_top + TRUE, // stop_at_bottom + FALSE, // start_at_last + FALSE, // stop_at_last + FALSE, // case_sensitive + FALSE); // backward +} + static CairoImageOutputDev * poppler_page_get_image_output_dev (PopplerPage *page, GBool (*imgDrawDeviceCbk)(int img_id, void *data), diff --git glib/poppler-page.h glib/poppler-page.h index c151cdc..67493c1 100644 --- glib/poppler-page.h +++ glib/poppler-page.h @@ -60,7 +60,15 @@ PopplerPageTransition *poppler_page_get_transition (PopplerPage *pa gboolean poppler_page_get_thumbnail_size (PopplerPage *page, int *width, int *height); -GList *poppler_page_find_text (PopplerPage *page, +GList *poppler_page_find_text_full (PopplerPage *page, + const char *text, + gboolean startAtTop, + gboolean stopAtBottom, + gboolean startAtLast, + gboolean stopAtLast, + gboolean caseSensitive, + gboolean backward); +GList *poppler_page_find_text (PopplerPage *page, const char *text); void poppler_page_render_to_ps (PopplerPage *page, PopplerPSFile *ps_file);