I am trying to convert HTML into a PDF document in Django and haven’t been successful.
I have tried using wkhtmltopdf 0.9.9, however Apache throws an error that wkhtmltopdf cannot connect to server. When I use wkhtmltopdf directly, it runs perfectly fine and converts the HTML into a PDF document.
I have also tried using unoconv, however the rendered PDF file doesn’t have any CSS applied to it. I have also tried using xhtml2pdf. Again I am facing same issue; the rendered PDF file doesn’t have any CSS styling applied. I have spent the better part of today and last night trying to solve this issue and I’m still no closer to solving the problem.
Let me know if you need any more information
Configuring Pisa for Django shouldn’t be too hard.
There are really several examples on the net that show you how to do it and
explain how to link to external resources in your templates:
In your case you should try the link-callback-function mentioned in the first blog post:
For newer Django-Version you probably should use
STATIC_ROOTinstead ofMEDIA_ROOTThen use
fetch resourcesaccordingly in your render-method: