Commit d3d12235 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-04-04 Kristian Høgsberg <krh@redhat.com>

        * configure.ac: Add checks for mkstemp() and mkstemps().

        * glib/poppler-page.cc (poppler_page_find_text): Reverse
        y-coordinates so we return PDF style coordinates.

        From Maro Pesenti Gritti <mpgritti@gmail.com>:

        * configure.ac, poppler/Makefile.am: Check for fontconfig when
        we're building the splash backend.

        * glib/poppler-page.cc (poppler_page_get_text): New function to
        select text on page.
parent 2cb9d706
2005-04-04 Kristian Høgsberg <krh@redhat.com>
* configure.ac: Add checks for mkstemp() and mkstemps().
* glib/poppler-page.cc (poppler_page_find_text): Reverse
y-coordinates so we return PDF style coordinates.
From Maro Pesenti Gritti <mpgritti@gmail.com>:
* configure.ac, poppler/Makefile.am: Check for fontconfig when
we're building the splash backend.
* glib/poppler-page.cc (poppler_page_get_text): New function to
select text on page.
2005-04-04 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-page.cc (poppler_page_find_text): Reverse list of
......
......@@ -67,7 +67,7 @@ if test $ac_cv_func_gethostbyname = no; then
fi
dnl ##### Checks for library functions.
AC_CHECK_FUNCS(popen)
AC_CHECK_FUNCS(popen mkstemp mkstemps)
dnl ##### Back to C for the library tests.
AC_LANG_C
......@@ -138,6 +138,9 @@ AC_ARG_ENABLE(splash-output,
AC_HELP_STRING([--disable-splash-output],
[Don't build the Splash graphics backend.]),,
enable_splash_output="yes")
if test x$enable_splash_output = xyes; then
PKG_CHECK_MODULES(SPLASH, fontconfig)
fi
AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes)
AC_ARG_ENABLE(cairo-output,
......
......@@ -245,6 +245,46 @@ poppler_page_get_thumbnail_size (PopplerPage *page,
return retval;
}
/**
* poppler_page_get_text:
* @page: a #PopplerPage
* @rect: the rectangle including the text
*
* Retrieves the contents of the specified rectangle as text
*
* Return value: a pointer to the contents of the rectangle
* as a string
**/
char *
poppler_page_get_text (PopplerPage *page,
PopplerRectangle *rect)
{
TextOutputDev *output_dev;
PDFDoc *doc;
GooString *sel_text = new GooString;
PopplerRectangle text_dev_rect;
double height, y1, y2;
char *result;
g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE);
g_return_val_if_fail (rect != NULL, NULL);
output_dev = new TextOutputDev (NULL, gTrue, gFalse, gFalse);
doc = page->document->doc;
height = page->page->getHeight ();
page->page->display(output_dev, 72, 72, 0, gTrue, NULL, doc->getCatalog());
y1 = height - rect->y2;
y2 = height - rect->y1;
sel_text = output_dev->getText (rect->x1, y1, rect->x2, y2);
result = sel_text->getCString ();
delete output_dev;
return result ? g_strdup (result) : NULL;
}
/**
* poppler_page_find_text:
* @page: a #PopplerPage
......@@ -266,6 +306,7 @@ poppler_page_find_text (PopplerPage *page,
double xMin, yMin, xMax, yMax;
gunichar *ucs4;
glong ucs4_len;
double height;
g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE);
g_return_val_if_fail (text != NULL, FALSE);
......@@ -275,7 +316,8 @@ poppler_page_find_text (PopplerPage *page,
output_dev = new TextOutputDev (NULL, gTrue, gFalse, gFalse);
doc = page->document->doc;
page->page->display(output_dev, 72, 72, 0, gTrue, NULL, doc->getCatalog());
height = page->page->getHeight ();
page->page->display (output_dev, 72, 72, 0, gTrue, NULL, doc->getCatalog());
matches = NULL;
while (output_dev->findText (ucs4, ucs4_len,
......@@ -285,9 +327,9 @@ poppler_page_find_text (PopplerPage *page,
{
match = g_new (PopplerRectangle, 1);
match->x1 = xMin;
match->y1 = yMin;
match->y1 = height - yMax;
match->x2 = xMax;
match->y2 = yMax;
match->y2 = height - yMin;
matches = g_list_prepend (matches, match);
}
......
......@@ -60,6 +60,9 @@ typedef struct
gdouble y2;
} PopplerRectangle;
char *poppler_page_get_text (PopplerPage *page,
PopplerRectangle *rect);
/* Mapping between areas on the current page and PopplerActions */
typedef struct
{
......
......@@ -6,7 +6,11 @@ splash_sources = \
splash_headers = \
SplashOutputDev.h
splash_includes = \
$(SPLASH_CFLAGS)
splash_libs = \
$(SPLASH_LIBS) \
$(top_builddir)/splash/libsplash.la
endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment