Search code examples
javascriptphphtmlcanvasdoc

Converting HTML + Javascript to Word/OpenOffice document programatically


How can I convert a whole HTML page with JS-drawn canvases to an editable format on a server?

My web app generates pages with some basic HTML + CSS and with Flot charts (which basically draw on canvas HTML tag with JavaScript). I can convert them to PDF with wkhtmltopdf and it works great, but I am having problems finding a way to convert them to a format which would be recognized by MS Word, OpenOffice Writer and/or LibreOffice Writer.

P.S.: I have seen this question, but it applies to raw HTML only (without JS).


Solution

  • Thanks to all for the answers! In the end I made it work with PhantomJS (custom script converts JS generated parts to images) and Pandoc (which converts the resulting HTML to DOCX).