Aspose.Words Cloud enables you to convert Word documents, including DOC and DOCX, to HTML file format. Word to HTML conversion is helpful in situations where you want to show the contents of a Word document online and make them search engine friendly. The additive advantage is that no special viewer or 3rd party application is needed for viewing HTML files. Aspose.Words Cloud provides the following APIs to convert a Word Document to HTML:
Name | Description |
---|---|
GetDocumentWithFormat | Converts a document in cloud storage to the specified format. |
ConvertDocument | Converts a document on a local drive to the specified format. |
SaveAs | Converts document to destination format with detailed settings and save the result to storage. |
Word to HTML Conversion
Before you call the above APIs, you need to register an account with Aspose Cloud and get your App Key and SID at Cloud Dashboard. As soon as you sign up, a generous Free Trial will be awarded to you so that you can test APIs without any evaluation limitations.
The following cURL example shows how to convert DOCX to HTML:
This code snippet efficiently converts DOCX to HTML files. It will not create any additional images or style sheets. For instance, it converts the image in the DOCX file to the base64 image so that you can get the highest-fidelity output. Following are the screenshots of files:
Input DOCX file
Output HTML file (Google Chrome preview)
You can notice the quality of HTML rendering in the above screenshots.
Word to HTML Conversion with Detailed Settings
PUT /words/{name}/saveAs API lets you convert Microsoft Word document to HTML with details settings. The following cURL example generates a ZIP file as output because we have set ‘ZipOutput’ to ’true’ in HtmlSaveOptions. For a complete list of HtmlSaveOptions, please check the documentation.
The generated ZIP file will include the HTML file and the images as PNG, JPG, etc. instead of converting them to base64 images. Let’s take a look at a comparison screenshot showing the source of HTML files generated by these code snippets.
The marked sections on this image clarify how both approaches work. The left side displays the image tag containing data as base64 image. While the right side, captured from DOCXtoHTML.zip, displays the image as a local PNG file.
HTML to Word Conversion
We have addressed the Word to HTML conversion in detail. Let us check out HTML to Word conversion, which is another worth-mentioning feature of Aspose.Words Cloud. It lets you convert a web-page to DOCX simply by specifying the URL. The cURL example is pretty simple, as under:
The rendering engine is efficient enough to produce WYSIWYG output in the DOCX file. Following is the screengrab of the output DOCX file.
The heading levels, lists, indentation, formatting, everything is in place that speaks volumes about the capabilities of the rendering engine. We hope you would love to use these simple yet powerful features. In case of any queries or concerns, please reach out to us via the Free Support Forum. We will be glad to assist you!