19 March 2010

PyPoppler, PDF rendering in Pythonic way

PyPoppler viewing Blender Wiki Manual PDF

Poppler Library has been used by Inkscape and GIMP to render PDF document nicely. PyPoppler is a bindings to Python using PyGTK for its user interface. It's analogue to PyWebkitGTK.

In this PDF reader screenshot, pypoppler demonstrate simple page and zoom control. In my test, rendering speed is quite responsive compared to Acrobat for pdf document with light graphics and rich text. But when handling pdf with rich layered graphics (that contain transparency), it starts to choked up though. Also it seems the demo fail to recognize page width & height (clip box?) correctly in some case, that's it drawn a smaller white rectangle like shown in 2nd shot and notice how scrollbars are missing there while inkscape correctly import the page with the same poppler.

Nonetheless this is probably the fastest way to integrate a PDF previewer or reader in your python apps rather than calling acrobat that might not installed, especially if you also using PyGTK. Or it could become a neat internal help/manual viewer (alternative to CHM eh?), hmm.. as long as it searchable :-).