How to convert any document to HTML5 format programmatically?