[poppler] poppler/qt4/src: poppler-page.cc, 1.5, 1.6 poppler-qt4.h,
1.8, 1.9
Albert Astals Cid
aacid at freedesktop.org
Fri Nov 25 14:52:58 PST 2005
Update of /cvs/poppler/poppler/qt4/src
In directory gabe:/tmp/cvs-serv4688/qt4/src
Modified Files:
poppler-page.cc poppler-qt4.h
Log Message:
patch from kebekus to add to the qt4 binding the same functions we added to the qt3 one
Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- poppler-page.cc 30 Oct 2005 20:29:05 -0000 1.5
+++ poppler-page.cc 25 Nov 2005 22:52:56 -0000 1.6
@@ -78,14 +78,19 @@
void Page::renderToPixmap(QPixmap *pixmap) const
{
+ renderToPixmap(pixmap, 72.0, 72.0);
+}
+
+void Page::renderToPixmap(QPixmap *pixmap, double xres, double yres) const
+{
QPainter* painter = new QPainter(pixmap);
painter->setRenderHint(QPainter::Antialiasing);
ArthurOutputDev output_dev(painter);
output_dev.startDoc(m_page->parentDoc->m_doc->doc.getXRef ());
m_page->parentDoc->m_doc->doc.displayPageSlice(&output_dev,
m_page->index + 1,
- 72,
- 72,
+ xres,
+ yres,
0,
false,
true,
@@ -130,6 +135,41 @@
return result;
}
+QList<TextBox*> Page::textList() const
+{
+ TextOutputDev *output_dev;
+
+ QList<TextBox*> output_list;
+
+ output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse);
+
+ m_page->parentDoc->m_doc->doc.displayPageSlice(output_dev, m_page->index + 1, 72, 72,
+ 0, false, false, false, -1, -1, -1, -1);
+
+ TextWordList *word_list = output_dev->makeWordList();
+
+ if (!word_list) {
+ delete output_dev;
+ return output_list;
+ }
+
+ for (int i = 0; i < word_list->getLength(); i++) {
+ TextWord *word = word_list->get(i);
+ QString string = QString::fromUtf8(word->getText()->getCString());
+ double xMin, yMin, xMax, yMax;
+ word->getBBox(&xMin, &yMin, &xMax, &yMax);
+
+ TextBox* text_box = new TextBox(string, QRectF(xMin, yMin, xMax, yMax));
+
+ output_list.append(text_box);
+ }
+
+ delete word_list;
+ delete output_dev;
+
+ return output_list;
+}
+
QSizeF Page::pageSizeF() const
{
::Page *p;
Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- poppler-qt4.h 6 Aug 2005 02:15:58 -0000 1.8
+++ poppler-qt4.h 25 Nov 2005 22:52:56 -0000 1.9
@@ -35,6 +35,19 @@
class PageData;
+ class TextBox {
+ public:
+ TextBox(const QString& text, const QRectF &bBox) :
+ m_text(text), m_bBox(bBox) {};
+
+ QString text() const { return m_text; };
+ QRectF boundingBox() const { return m_bBox; };
+
+ private:
+ QString m_text;
+ QRectF m_bBox;
+ };
+
/**
Container class for information about a font within a PDF
@@ -128,6 +141,13 @@
page->renderToPixmap(myPixmap);
\endcode
*/
+ void renderToPixmap(QPixmap *q, double xres, double yres) const;
+
+ /**
+ * This is a convenience function that is equivalent to
+ * renderToPixmap() with xres and yres set to 72.0. We keep it
+ * only for binary compatibility
+ **/
void renderToPixmap(QPixmap *q) const;
/**
@@ -138,6 +158,8 @@
**/
QString text(const QRectF &rect) const;
+ QList<TextBox*> textList() const;
+
/**
The dimensions of the page, in points.
*/
More information about the poppler
mailing list