Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a current tutorial or howto document for using the xhtml2pdf python module?

I can't seem to find a working tutorial or howto document for this module. Does one exist somewhere?


The "To be completed" section here: https://github.com/chrisglass/xhtml2pdf/blob/master/doc/usage.rst

is buggy, and doesn't seem to contain working code. After corrections, this code sequence:

from xhtml2pdf import pisa as pisa
filename = u'test.pdf'
pdf = pisa.CreatePDF("Hello <strong>World</strong>",file(filename, "wb"))
pisa.startViewer(filename)

produces an empty test.pdf file (well, not exactly empty, it's a pdf file without content)

like image 631
blueberryfields Avatar asked Jan 30 '26 20:01

blueberryfields


1 Answers

Since it is heavily ReportLab based you may find their tutorials useful.

(I don't use either package).

like image 125
msw Avatar answered Feb 01 '26 09:02

msw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!