Question

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

Was it helpful?

Solution 3

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

OTHER TIPS

You can try the phpword library.

The major features include:

Major Features

-Insert and format document sections -Insert and format Text elements -Insert Text breaks -Insert Page breaks -Insert and format Images and binary OLE-Objects -Insert and format watermarks (new) -Insert Header / Footer -Insert and format Tables -Insert native Titles and Table-of-contents -Insert and format List elements -Insert and format hyperlinks -Very simple template system (new)

Since it support format Images and binary objects, it means you can also transfer your html chart to word document.

Here is the detailed documentation on how to use the library.

Hope this can solve your issue. Good luck!

quick search on google gave me this http://www.phpdocx.com/ Never used it so I don't know how well it works. In the docs you can read that it is able to embed image tags in the final doc file. http://www.phpdocx.com/documentation/html-to-word-PHP

I don't know if phpdocx can deal with html5 canvas element but if not you could always convert the canvas element to simple image tags with the help of the toDataURL function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top