[poppler] poppler/qt4/src: .cvsignore, 1.1, 1.2 Doxyfile, 1.2, 1.3 Mainpage.dox, NONE, 1.1 poppler-page.cc, 1.7, 1.8 poppler-qt4.h, 1.11, 1.12

Albert Astals Cid aacid at freedesktop.org
Sat Dec 3 13:35:49 PST 2005


Update of /cvs/poppler/poppler/qt4/src
In directory gabe:/tmp/cvs-serv569/qt4/src

Modified Files:
	.cvsignore Doxyfile poppler-page.cc poppler-qt4.h 
Added Files:
	Mainpage.dox 
Log Message:
More docs for the Qt4 frontend, patch by Stefan Kebekus


Index: .cvsignore
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- .cvsignore	28 Jun 2005 10:59:15 -0000	1.1
+++ .cvsignore	3 Dec 2005 21:35:46 -0000	1.2
@@ -4,4 +4,5 @@
 *.lo
 Makefile
 Makefile.in
-
+APIDOCS-html
+APIDOCS-latex

Index: Doxyfile
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/Doxyfile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Doxyfile	6 Aug 2005 02:07:55 -0000	1.2
+++ Doxyfile	3 Dec 2005 21:35:46 -0000	1.3
@@ -606,7 +606,7 @@
 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
 # put in front of it. If left blank `html' will be used as the default path.
 
-HTML_OUTPUT            = html
+HTML_OUTPUT            = APIDOCS-html
 
 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
 # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
@@ -718,7 +718,7 @@
 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
 # put in front of it. If left blank `latex' will be used as the default path.
 
-LATEX_OUTPUT           = latex
+LATEX_OUTPUT           = APIDOCS-latex
 
 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
 # invoked. If left blank `latex' will be used as the default command name.

--- NEW FILE: Mainpage.dox ---
/**
@mainpage The Poppler Qt4 interface library

The Poppler Qt4 interface library, libpoppler-qt4, is library that
allows Qt4 programmers to easily load and render PDF files. The
Poppler Qt4 interface library uses poppler internally to do its job,
but the Qt4 programmer will never have to worry about poppler
internals.


@section help Current Status

At the time this document was written (December '05) the Poppler Qt4
interface library was still somewhat experimental. From the two
rendering engines offered by the library, only the splash engine works
well and has been tested.


@section refimpl Example Programs

Examples programs can be found in the qt4/test directory. The poppler
Qt4 interface library is also used in the development version of KDE's
document viewer kviewshell. The source files for kviewshell's PDF
plugin can be found on the subversion server of the KDE project, under
<a
href="http://websvn.kde.org/trunk/KDE/kdegraphics/kviewshell/plugins/pdf">this
URL</a>.


@section req How to use the Poppler Qt4 interface library in three easy steps

Programmer who would like to use the Poppler Qt4 interface library
simply need to add the following two lines to their C++ source files:

@code
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
@endcode

The #define statement is required at the moment. You indicate that you
think you know what you are doing.

A PDF document can then be loaded as follows.
@code
QString filename;

Poppler::Document* document = Poppler::Document::load(filename.ascii());
if (!document || document->isLocked()) {

  ... error message ....

  delete document;
  return;
}
@endcode

Pages can be rendered to QPixmaps with the following commands.

@code
// Paranoid safety check
if (document == 0) {
  ... error message ...
  return;
}

// Access page of the PDF file
Poppler::Page* pdfPage = document->page(pageNumber);  // Document starts at page 0
if (pdfPage == 0) {
  ... error message ...
  return;
}

// Generate a QPixmap of the rendered page
QPixmap* pixmap = pdfPage->splashRenderToPixmap(0, 0, 0, 0, xres, yres );
if (pixmap == 0) {
  ... error message ...
  return;
}

... use pixmap ...

delete pixmap;
@endcode

Finally, don't forget to destroy the document.

@code
delete document;
@endcode
 */


Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- poppler-page.cc	28 Nov 2005 22:50:19 -0000	1.7
+++ poppler-page.cc	3 Dec 2005 21:35:46 -0000	1.8
@@ -51,13 +51,7 @@
   delete m_page;
 }
 
-
-void Page::splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h) const
-{
-  splashRenderToPixmap(q, x, y, w, h, 72.0, 72.0);
-}
-
-void Page::splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const
+QPixmap *Page::splashRenderToPixmap(int x, int y, int w, int h, double xres, double yres) const
 {
   SplashColor white;
   white[0] = 255;
@@ -83,27 +77,23 @@
   //  QImage *img = new QImage( (uchar*)color_ptr, bw, bh, QImage::Format_RGB32 );
   // --------
 
-  QImage * img = new QImage( bw, bh, QImage::Format_RGB32 );
+  QImage img( bw, bh, QImage::Format_RGB32 );
   SplashColorPtr pixel = new Guchar[4];
   for (int i = 0; i < bw; i++) {
     for (int j = 0; j < bh; j++) {
       output_dev->getBitmap()->getPixel(i, j, pixel);
-      img->setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
+      img.setPixel( i, j, qRgb( pixel[0], pixel[1], pixel[2] ) );
     }
   }
   delete[] pixel;
  
   // Turn the QImage into a QPixmap
-  *q = new QPixmap(QPixmap::fromImage(*img));
+  QPixmap* out = new QPixmap(QPixmap::fromImage(img));
 
   // Delete temporary buffers
-  delete img;
   delete output_dev;
-}
 
-void Page::renderToPixmap(QPixmap *pixmap) const
-{
-  renderToPixmap(pixmap, 72.0, 72.0);
+  return out;
 }
 
 void Page::renderToPixmap(QPixmap *pixmap, double xres, double yres) const

Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- poppler-qt4.h	28 Nov 2005 22:50:19 -0000	1.11
+++ poppler-qt4.h	3 Dec 2005 21:35:46 -0000	1.12
@@ -124,16 +124,46 @@
 	~Page();
 
 	/**
-	 *  Render the page to a pixmap using the Splash renderer
-	 */
-	void splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const;
-	
-	/**
-	 * This is a convenience function that is equivalent to
-	 * splashRenderToPixmap() with xres and yres set to 72.0. We keep it
-	 * only for binary compatibility
+	   Render the page to a QPixmap using the Splash renderer
+	 
+	   This method can be used to render the page to a QPixmap. It
+	   uses the "Splash" rendering engine that is included in the
+	   Poppler distribution. This method is reasonably well-tested
+	   and has produced good output so far. This method is used as
+	   follows.
+
+ at code
+Poppler::Page* pdfPage;
+
+// Generate a QPixmap of the rendered page
+QPixmap* pixmap = pdfPage->splashRenderToPixmap(0, 0, 0, 0, xres, yres );
+if (pixmap == 0) {
+  ... error message ...
+  return;
+}
+
+... use pixmap ...
+
+delete pixmap;
+ at endcode
+
+	   @param x UNUSED
+
+	   @param y UNUSED
+
+	   @param w UNUSED
+
+	   @param h UNUSED
+
+	   @param xres horizontal resolution of the graphics device,
+	   in dots per inch
+
+	   @param yres vertical resolution of the graphics device,
+	   in dots per inch
+
+	   @returns pointer to a QPixmap, or NULL on failure. The pixmap returned must be deleted.
 	 */
-	void splashRenderToPixmap(QPixmap **q, int x, int y, int w, int h) const;
+	QPixmap *splashRenderToPixmap(int x, int y, int w, int h, double xres=72.0, double yres=72.0) const;
 	
 	/**
 	   Render the page to a pixmap using the Arthur (Qt4) renderer
@@ -148,14 +178,7 @@
 	   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;
+        void renderToPixmap(QPixmap *q, double xres=72.0, double yres=72.0) const;
 
 	/**
 	   Returns the text that is inside a specified rectangle



More information about the poppler mailing list