Is there a way to convert XHTML/HTML with CSS to PDF with floating divs?
I have tried pisa/开发者_JAVA技巧xhtml2pdf in python and dompdf in PHP both are not able to do so.
Is there any way?
See html-tables-to-pdf-in-php-neither-dompdf-nor-html2ps-pdf-are-working.
A possible path is to use some Layout (Rendering) Engine, such as Webkit or Gecko.
The rendered HTML page can then be saved as PDF. An example of a tool that uses this method is the wkhtmltopdf
project.
(I know, this is not related to Python
or PHP
- you can still drive the tool from a script.).
Found a blog post that does this very thing
http://web.archive.org/web/20130525082452/http://notes.alexdong.com/xhtml-to-pdf-using-pyqt4-webkit-and-headless
got it working rather quickly using the more mature pyqt4 module
精彩评论