Forum Samples, Tips and Tricks

Using HTML Tidy to convert HTML to XHTML

If you would like to print web pages and other HTML documents with Prince but find that they are not well-formed XHTML, try using the HTML Tidy utility to convert them to XHTML.

HTML Tidy is a free cross-platform tool (also available as a library) that can be used to tidy up irregular HTML as found on the web into valid HTML or XHTML. This is a handy way of converting old websites into a form that Prince can then print. Here is an example:

$ tidy -asxhtml -doctype loose messy.html > clean.xhtml
$ prince clean.xhtml