# Render to HTML Render files to HTML with GroupDocs.Viewer for Python. Easily convert documents like Word to clean HTML. When rendering to HTML, GroupDocs.Viewer renders each page of the source document as a separate HTML document. GroupDocs.Viewer for Python provides two options to manage CSS, fonts, images, and other resources: 1. HTML with external resources stores page resources as separate files. This allows reusing common resources and results in reducing page size and loading speed. 2. HTML with embedded resources integrates page resources into HTML. This makes each document page self-sufficient but results in increasing page size and loading speed. To render files to HTML, follow these steps: 1. Create an instance of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) class. Specify the source document path as a constructor parameter. 2. Instantiate the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) object. Specify a path to save the rendered pages. 3. Call the [View.view()](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method of the [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/) object. Specify the [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/) object as the parameter. ## Rendering to HTML with external resources The following code snippet shows how to render a .docx document to HTML with external resources: {{< tabs "example1">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions def render_to_html_external(): # Create an HTML file for each page. # Specify the HTML file names and location of external resources. # {0} and {1} are replaced with the current page number and resource name, respectively. with Viewer("sample.docx") as viewer: html_options = HtmlViewOptions.for_external_resources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") viewer.view(html_options) if __name__ == "__main__": render_to_html_external() ``` {{< /tab >}} {{< tab "sample.docx" >}} {{< tab-text >}} `sample.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/developer-guide/rendering-documents/rendering-to-html/sample.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ## Rendering to HTML with embedded resources The following code snippet shows how to render a .docx document to HTML with embedded resources: {{< tabs "example2">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions def render_to_html_embedded(): # Create an HTML file for each page. # {0} is replaced with the current page number in the file name. with Viewer("sample.docx") as viewer: html_options = HtmlViewOptions.for_embedded_resources("page_{0}.html") viewer.view(html_options) print(f"\nSource document rendered successfully.") if __name__ == "__main__": render_to_html_embedded() ``` {{< /tab >}} {{< tab "sample.docx" >}} {{< tab-text >}} `sample.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/developer-guide/rendering-documents/rendering-to-html/sample.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} For details, please refer to the following pages: