Quick Start Guide

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

This quick start guide shows you how to get started with GroupDocs.Viewer for .NET. You will create a .NET console application, install the GroupDocs.Viewer NuGet package, and render a DOCX document to HTML, PDF, and PNG using C#.

GroupDocs.Viewer is a .NET document rendering library that supports 190+ file formats and renders supported documents to HTML, PDF, PNG, or JPG without requiring Microsoft Office or other third-party applications.

Prerequisites

To proceed, make sure you have:

  1. Your environment meets the System Requirements.
  2. The .NET SDK is installed.
  3. Optionally, you have a Temporary License to evaluate all GroupDocs.Viewer features without evaluation limitations.

Create a .NET Application and Install GroupDocs.Viewer

Create a new .NET console application and add the GroupDocs.Viewer NuGet package.

Starting with version 26.8, GroupDocs.Viewer uses TFM-split packaging. Install a single package, and NuGet automatically restores the runtime package that matches your project’s target framework. See Installation for details.

Create a console app

dotnet new console -n DemoApp -o demo-app
cd demo-app

Install the GroupDocs.Viewer package

Install GroupDocs.Viewer:

dotnet add package GroupDocs.Viewer

After the installation completes, your project file contains a package reference similar to the following:

<PackageReference Include="GroupDocs.Viewer" Version="26.10.0" />

Example 1: Render a DOCX Document to HTML

The following example renders a Microsoft Word document to HTML with embedded resources.

You can download the complete example project here.

using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;

// Get the absolute path to the license file
string licensePath = Path.GetFullPath("./GroupDocs.Viewer.lic");

if (File.Exists(licensePath))
{
    // Apply the license
    License license = new License();
    license.SetLicense(licensePath);
}

// Load the DOCX document
using (Viewer viewer = new Viewer("./sample.docx"))
{
    // Configure HTML view options
    HtmlViewOptions htmlOptions =
        HtmlViewOptions.ForEmbeddedResources("render_docx_to_html/page_{0}.html");

    // Render the DOCX document to HTML
    viewer.View(htmlOptions);
}

sample.docx is the source document used in this example. Click here to download it.

render_docx_to_html/page_1.html (228 KB)
render_docx_to_html/page_2.html (110 KB)
render_docx_to_html/page_3.html (142 KB)
render_docx_to_html/page_4.html (885 KB)
render_docx_to_html/page_5.html (86 KB)

Download the complete output

Your project directory should look similar to the following:

📂 demo-app
 ├──DemoApp.csproj
 ├──Program.cs
 ├──sample.docx
 └──GroupDocs.Viewer.lic (optional)

Run the application

dotnet run

How the code works

  • new Viewer("./sample.docx"): loads the DOCX document.
  • HtmlViewOptions.ForEmbeddedResources("render_docx_to_html/page_{0}.html"): configures HTML output with embedded resources.
  • viewer.View(htmlOptions): renders the document and saves the output HTML files page_1.html, page_2.html, etc.

Example 2: Render a DOCX Document to PDF

The following example renders the same DOCX document to a single PDF file.

You can download the complete example project here.

using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;

// Get the absolute path to the license file
string licensePath = Path.GetFullPath("./GroupDocs.Viewer.lic");

if (File.Exists(licensePath))
{
    // Apply the license
    License license = new License();
    license.SetLicense(licensePath);
}

// Load the DOCX document
using (Viewer viewer = new Viewer("./sample.docx"))
{
    // Configure PDF view options
    PdfViewOptions pdfOptions =
        new PdfViewOptions("render_docx_to_pdf/output.pdf");

    // Render the DOCX document to PDF
    viewer.View(pdfOptions);
}

sample.docx is the source document used in this example. Click here to download it.

Binary file (PDF, 719 KB)

Download full output

Your folder tree should look similar to the following directory structure:

📂 demo-app
 ├──DemoApp.csproj
 ├──Program.cs
 ├──sample.docx
 └──GroupDocs.Viewer.lic (optional)

Run the application

dotnet run

How the code works

  • new Viewer("./sample.docx"): loads the DOCX document.
  • new PdfViewOptions("render_docx_to_pdf/output.pdf"): configures PDF output.
  • viewer.View(pdfOptions): renders the document and saves the result as a PDF file.

Example 3: Render a DOCX Document to PNG

The following example renders each page of a DOCX document as a separate PNG image.

You can download the complete example project here.

using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;

// Get the absolute path to the license file
string licensePath = Path.GetFullPath("./GroupDocs.Viewer.lic");

if (File.Exists(licensePath))
{
    // Apply the license
    License license = new License();
    license.SetLicense(licensePath);
}

// Load the DOCX document
using (Viewer viewer = new Viewer("./sample.docx"))
{
    // Configure PNG view options
    PngViewOptions pngOptions =
        new PngViewOptions("render_docx_to_png/output_{0}.png");

    // Render the DOCX document to PNG
    viewer.View(pngOptions);
}

sample.docx is the source document used in this example. Click here to download it.

render_docx_to_png/output_1.png (206 KB)
render_docx_to_png/output_2.png (59 KB)
render_docx_to_png/output_3.png (44 KB)
render_docx_to_png/output_4.png (309 KB)
render_docx_to_png/output_5.png (35 KB)

Download the complete output

Your project directory should look similar to the following:

📂 demo-app
 ├──DemoApp.csproj
 ├──Program.cs
 ├──sample.docx
 └──GroupDocs.Viewer.lic (optional)

Run the application

dotnet run

How the code works

  • new Viewer("./sample.docx"): loads the DOCX document.
  • new PngViewOptions("render_docx_to_png/output_{0}.png"): configures PNG output and specifies the output file name pattern.
  • viewer.View(pngOptions): renders each document page and saves it as a separate PNG image output_1.png, output_2.png, etc.

Next Steps

You have now created a .NET application that renders a DOCX document to HTML, PDF, and PNG.

Explore the following topics to learn more about GroupDocs.Viewer: