WeasyPrint converts HTML including images to PDF, it's cross platform but Windows requires a decent amount of massaging to persuade it to work.
To install Pango and Cairo download the all in one bundle of the GTK+ stack and extract the archive to C:\GTK.
You'll need to add the GTK bin folder to your system path so the various libraries can be found when requested by WeasyPrint, to do that go to the 'System' in the Control Panel, then open 'Advanced System Settings' then 'Environment Variables' and edit the System variable called Path by adding ;c:\gtk to the end of the current value.
With that out of the way, we need to install a few Python libraries that WeasyPrint uses to interface with the GTK stack. The easiest way is from precompiled binaries, so head over to Christoph Gohkle's Python Packages and download and install Py2Cairo, PyGObject and PyGTK for your version of Python (I've tested with 32bit 2.7). You'll also need to install the lxml package he provides.
Now you should be able to just pip install WeasyPrint
I still have this issue. I have followed instructions here and from the linked SO page.
Everything installed fine, just cannot import weasyprint without getting the dreaded dlopen() error :/
I'm thinking its something to do with my path, but everything there seems fine too. GTK+2/bin is on the path, as instructed.
EDIT 1:
Very strange. I can
import cairo
no problem. But usingctypes.util
doesn't find it. Hmmm.In the end I commented out the
dlopen()
function, and replaced it withimport cairo
. Now, upon tryingimport weasyprint
I get a different error:But properties.py is right there... Definitely something wrong with the path.Still investigating. I'm new to all this, but it turns out debugging is fun!
EDIT 2:
Now, without having touched anything, a new errror:
Investigating.