# View and render documents with GroupDocs.Viewer Render Word, Excel, PDF and 170+ other formats to HTML, PDF or PNG from GroupDocs.Total for .NET, with runnable C# examples and downloadable input and output files. GroupDocs.Viewer renders a document into something a browser can display — HTML, PDF, or one image per page — without Microsoft Office or any other external software. It is the API to reach for when you want to *show* a document rather than change it. Every example below opens `contract.docx` and is ready to copy into a console app once you have [installed the package]({{< ref "/total/net/getting-started/installation.md" >}}). ## Render a document to HTML Rendering to HTML gives you one `.html` file per page. `ForEmbeddedResources` inlines images, fonts and stylesheets into each page, so a page is self-contained and needs no companion files. {{< tabs "viewer-render-to-html" >}} {{< tab "C#" >}} ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using (Viewer viewer = new Viewer("contract.docx")) { // {0} is replaced with the page number, so page 1 becomes page_1.html HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources( "viewer-render-to-html/page_{0}.html"); viewer.View(viewOptions); } ``` {{< /tab >}} {{< tab "contract.docx" >}} {{< tab-text >}} `contract.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/total/net/_sample_files/contract.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "viewer-render-to-html.zip" >}} ```text viewer-render-to-html/page_1.html (147 KB) viewer-render-to-html/page_2.html (74 KB) viewer-render-to-html/page_3.html (828 bytes) ``` [Download full output](https://docs.groupdocs.com/total/net/_output_files/developer-guide/viewer/ViewerRenderToHtml/viewer-render-to-html.zip) {{< /tab >}} {{< /tabs >}} To keep resources as separate files next to the HTML instead of inlining them, use `HtmlViewOptions.ForExternalResources` — useful when several pages share the same images and you want them cached once. ## Render a document to PDF Rendering to PDF produces a single file, which is the usual choice for printing or archiving. {{< tabs "viewer-render-to-pdf" >}} {{< tab "C#" >}} ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using (Viewer viewer = new Viewer("contract.docx")) { PdfViewOptions viewOptions = new PdfViewOptions("viewer-render-to-pdf.pdf"); viewer.View(viewOptions); } ``` {{< /tab >}} {{< tab "contract.docx" >}} {{< tab-text >}} `contract.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/total/net/_sample_files/contract.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "viewer-render-to-pdf.pdf" >}} ```text Binary file (PDF, 127 KB) ``` [Download full output](https://docs.groupdocs.com/total/net/_output_files/developer-guide/viewer/ViewerRenderToPdf/viewer-render-to-pdf.pdf) {{< /tab >}} {{< /tabs >}} ## Render a document to PNG Rendering to images gives you one PNG per page — the right output for thumbnails and previews. `PngViewOptions` also accepts a width and height if you need a fixed size. {{< tabs "viewer-render-to-png" >}} {{< tab "C#" >}} ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using (Viewer viewer = new Viewer("contract.docx")) { PngViewOptions viewOptions = new PngViewOptions( "viewer-render-to-png/page_{0}.png"); // Render only the first two pages viewer.View(viewOptions, 1, 2); } ``` {{< /tab >}} {{< tab "contract.docx" >}} {{< tab-text >}} `contract.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/total/net/_sample_files/contract.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "viewer-render-to-png.zip" >}} ```text viewer-render-to-png/page_1.png (68 KB) viewer-render-to-png/page_2.png (67 KB) ``` [Download full output](https://docs.groupdocs.com/total/net/_output_files/developer-guide/viewer/ViewerRenderToPng/viewer-render-to-png.zip) {{< /tab >}} {{< /tabs >}} ## Read document information Before rendering you often want to know what you are dealing with — how many pages, what format, whether it is encrypted. `GetViewInfo` answers that without rendering anything. {{< tabs "viewer-document-info" >}} {{< tab "C#" >}} ```csharp using System; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using GroupDocs.Viewer.Results; using (Viewer viewer = new Viewer("contract.docx")) { ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions); Console.WriteLine("File type: " + viewInfo.FileType); Console.WriteLine("Pages: " + viewInfo.Pages.Count); foreach (Page page in viewInfo.Pages) { Console.WriteLine("Page " + page.Number + ": " + page.Width + "x" + page.Height); } } ``` {{< /tab >}} {{< tab "contract.docx" >}} {{< tab-text >}} `contract.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/total/net/_sample_files/contract.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "viewer-document-info.txt" >}} ```text File type: Microsoft Word Open XML Document (.docx) Pages: 3 Page 1: 612x792 Page 2: 612x792 Page 3: 612x792 ``` [Download full output](https://docs.groupdocs.com/total/net/_output_files/developer-guide/viewer/ViewerDocumentInfo/viewer-document-info.txt) {{< /tab >}} {{< /tabs >}} ## Learn more The examples above cover the common cases. GroupDocs.Viewer also renders archives, CAD drawings, email messages, Outlook data files and Visio diagrams, caches rendered output, and processes attachments. * [GroupDocs.Viewer for .NET documentation](https://docs.groupdocs.com/viewer/net/) — the full product guide * [Supported file formats](https://docs.groupdocs.com/viewer/net/supported-document-formats/) * [API reference](https://reference.groupdocs.com/viewer/net/)