4

Is there a way to convert XHTML/HTML with CSS to PDF with floating divs?

I have tried pisa/xhtml2pdf in python and dompdf in PHP both are not able to do so.

Is there any way?

GeekTantra
  • 11,580
  • 6
  • 41
  • 55

2 Answers2

4

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.).

Community
  • 1
  • 1
gimel
  • 83,368
  • 10
  • 76
  • 104
0

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

Alvin
  • 2,533
  • 33
  • 45