# View MS Word DOCX and PDF Documents using a .NET C# Document Viewer for ASP.NET Core and ASP.NET

> Learn how to view MS Word DOCX and PDF documents using a .NET C# Document Viewer for ASP.NET Core and ASP.NET. This article shows how to integrate the TX Text Control Document Viewer into your ASP.NET Core and ASP.NET applications.

- **Author:** Bjoern Meyer
- **Published:** 2024-08-08
- **Modified:** 2025-11-16
- **Description:** Learn how to view MS Word DOCX and PDF documents using a .NET C# Document Viewer for ASP.NET Core and ASP.NET. This article shows how to integrate the TX Text Control Document Viewer into your ASP.NET Core and ASP.NET applications.
- **4 min read** (775 words)
- **Tags:**
  - ASP.NET
  - ASP.NET Core
  - Document Viewer
- **Web URL:** https://www.textcontrol.com/blog/2024/08/08/view-ms-word-docx-and-pdf-documents-using-a-net-csharp-document-viewer-for-aspnet-core-and-aspnet/
- **LLMs URL:** https://www.textcontrol.com/blog/2024/08/08/view-ms-word-docx-and-pdf-documents-using-a-net-csharp-document-viewer-for-aspnet-core-and-aspnet/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2024/08/08/view-ms-word-docx-and-pdf-documents-using-a-net-csharp-document-viewer-for-aspnet-core-and-aspnet/llms-full.txt

---

In addition to a powerful Document Editor, TX Text Control provides a Document Viewer for viewing documents in a variety of formats, including Office Open XML, DOCX, DOC, RTF, and PDF.

![ASP.NET C# Document Viewer](https://s1-www.textcontrol.com/assets/dist/blog/2024/08/08/b/assets/viewer.webp "ASP.NET C# Document Viewer")

Viewing documents in web applications is a very typical use case. Consider an invoice portal where invoices are previewed and offered for download, or documents that should be reviewed by other users to add annotations. Electronic signatures, where documents are displayed and users can sign the document, is a very common and popular use case.

TX Text Control provides a fully-featured Document Viewer that can be used in any web application. The viewer is customizable and can be integrated into any web application without any dependencies to MS Word or Acrobat Reader.

### Typical Viewer Tasks

The Document Viewer is a fully-featured viewer that can be used to display documents in various formats. The following tasks are typical for a viewer:

- View documents in a variety of formats, including DOCX, DOC, RTF, and PDF
- Print documents
- Fill out form fields
- Sign documents (electronically and digitally)
- Add annotations
- Review track changes

The above tasks are typical features of the Document Viewer and can be implemented with little code, providing a complete UI and workflow for these tasks. The viewer can be customized in many ways to fit into any web application.

### Tutorial

The following tutorial shows how to create a .NET 6 ASP.NET Core web application that uses the DocumentViewer component.

> **Getting Started Video**
> 
> Prefer a video tutorial? This complete tutorial is available as a video tutorial that also shows how to load documents.
> 
> [How to use the Document Viewer in ASP.NET Core C# ](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-document-viewer-in-asp-net-core-csharp/llms-full.txt)

### Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0).

1. In Visual Studio 2022, create a new project by choosing *Create a new project*.
2. Select *ASP.NET Core Web App (Model-View-Controller)* as the project template and confirm with *Next*.
3. Choose a name for your project and confirm with *Next*.
4. In the next dialog, choose *.NET 8 (Long Term Support)* as the *Framework* and confirm with *Create*.
    
    ![Creating the .NET 6 project](https://s1-www.textcontrol.com/assets/dist/blog/2024/08/08/b/assets/visualstudio1.webp "Creating the .NET 6 project")

#### Adding the NuGet Packages

5. In the *Solution Explorer*, select your created project and choose *Manage NuGet Packages...* from the *Project* main menu.
    
    Select *Text Control Offline Packages* from the *Package source* drop-down.
    
    > **Package Source**
    > 
    > Select either **Text Control Offline Packages** or **nuget.org** as the *Package source*. Packages in the official *Text Control* NuGet profile are frequently updated.
    > 
    > In case you are using a **Trial Access Token**, please choose *nuget.org*.
    
    *Install* the latest versions of the following packages:
    
    
    - *TXTextControl.Web.DocumentViewer*
    - *TXTextControl.TextControl.ASP.SDK*
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2024/08/08/b/assets/visualstudio2.webp "ASP.NET Core Web Application")
6. Switch the package source to *nuget.org* and choose *Installed* to check for available updates. Update the installed packages to the most current version.
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2024/08/08/b/assets/updates.webp "ASP.NET Core Web Application")

#### Adding the Control to the View

7. Find the *Index.cshtml* file in the *Views -> Home* folder. Replace the complete content with the following code:
    
    ```
    @using TXTextControl.Web.MVC.DocumentViewer
    @using System.Text
            
    <div style="width: 800px; height: 600px;">
        
    @Html.TXTextControl().DocumentViewer(settings => {
        settings.DocumentData = Convert.ToBase64String(
            Encoding.ASCII.GetBytes("<strong>Sample Content</strong>"));
        settings.Dock = DocumentViewerSettings.DockStyle.Fill;
    }).Render()
        
    </div>
    
    <script>
    
        var jsonAnnotations = '[[{"pen":{"type":"comment","objectWidth":32,"objectHeight":32},"user":"Unknown User","location":{"x":127,"y":50},"time":1658908087097,"comments":[{"comment":"Welcome to Text Control","user":"Unknown User","date":1658908100339,"id":"c8d818ce-ff1e-4c0c-b78c-6ba95a98dede","status":"none"}],"id":"feed80ff-1c94-4abf-9838-3e833faa4092","status":"Accepted"}]]';
    
        window.addEventListener("documentViewerLoaded", function () {
            TXDocumentViewer.annotations.showToolbar(true);
            TXDocumentViewer.annotations.load(jsonAnnotations);
        });
    
    </script>
    ```
    
    This code adds the DocumentViewer to the view and loads a simple HTML string.

### Conclusion

TX Text Control is a highly versatile document viewer designed for seamless integration into any web application. This powerful tool is fully customizable, allowing developers to customize how it works and looks to meet specific needs. One of its main advantages is that it works independently, i.e. it does not require any external dependencies such as MS Word or Acrobat Reader. This flexibility allows for a smoother and more efficient deployment across a wide variety of web environments.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [High-Performance Text Replacement in Large DOCX Files using C# .NET](https://www.textcontrol.com/blog/2025/07/30/high-performance-text-replacement-in-large-docx-files-using-csharp-dotnet/llms.txt)
- [Document Viewer 33.2.1 Released: New Event and Bug Fixes](https://www.textcontrol.com/blog/2025/07/30/document-viewer-33-2-1-released-new-event-and-bug-fixes/llms.txt)
- [Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor and Viewer](https://www.textcontrol.com/blog/2025/03/26/building-an-asp-net-core-backend-for-the-document-editor-and-viewer/llms.txt)
- [TX Text Control Document Editor and Viewer for Blazor Released](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-document-editor-and-viewer-for-blazor-released/llms.txt)
- [Getting Started: Document Viewer for Blazor in ASP.NET Core](https://www.textcontrol.com/blog/2025/03/25/getting-started-document-viewer-for-blazor-in-asp-net-core/llms.txt)
- [Announcing Our Work on a Blazor Component for Document Editing and Viewing](https://www.textcontrol.com/blog/2025/01/24/announcing-our-work-on-a-blazor-component-for-document-editing-and-viewing/llms.txt)
- [Preparing Documents for E-Signing for Multiple Signers in .NET C#](https://www.textcontrol.com/blog/2024/11/13/preparing-documents-for-e-signing-for-multiple-signers-in-net-c-sharp/llms.txt)
- [ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View](https://www.textcontrol.com/blog/2024/11/08/asp-net-core-use-the-document-editor-and-viewer-in-the-same-razor-view/llms.txt)
- [Optimizing Digital Signature Workflows: Starting with MS Word DOCX Files Instead of PDFs in C#](https://www.textcontrol.com/blog/2024/09/27/optimizing-digital-signature-workflows-starting-with-ms-word-docx-files-instead-of-pdfs-in-csharp/llms.txt)
- [Document Viewer: Setting the Rendering Mode](https://www.textcontrol.com/blog/2024/08/22/document-viewer-setting-the-rendering-mode/llms.txt)
- [Getting Started Video Tutorial: How to Add Electronic and Digital Signatures to PDF Documents in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-add-electronic-and-digital-signatures-to-pdf-documents-in-asp-net-core-csharp/llms.txt)
- [Getting Started Video Tutorial: How to use the Document Viewer in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/08/05/getting-started-video-tutorial-how-to-use-the-document-viewer-in-asp-net-core-csharp/llms.txt)
- [Transforming Financial Documents into Smart and Secure Forms in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/05/01/transforming-financial-documents-into-smart-and-secure-forms-in-asp-net-core-c-sharp/llms.txt)
- [Document Viewer: Long Polling Support for Loading Documents](https://www.textcontrol.com/blog/2024/04/25/document-viewer-long-polling-support-for-loading-documents/llms.txt)
- [Adding and Sharing Annotations across Document Types using the Document Viewer in ASP.NET Core C#](https://www.textcontrol.com/blog/2024/04/19/adding-and-sharing-annotations-across-document-types-using-the-document-viewer-in-asp-net-core-c-sharp/llms.txt)
- [Adding a Security Middleware to ASP.NET Core Web Applications to Protect TX Text Control Document Editor and Document Viewer Endpoints](https://www.textcontrol.com/blog/2024/03/18/adding-a-security-middleware-to-asp-net-core-web-applications-to-protect-tx-text-control-document-editor-and-document-viewer-endpoints/llms.txt)
- [Building an ASP.NET Core Backend Application to Host the Document Editor and Document Viewer](https://www.textcontrol.com/blog/2024/03/14/building-an-asp-net-core-backend-application-to-host-the-document-editor-and-document-viewer/llms.txt)
- [Signature Soft Pad Customization](https://www.textcontrol.com/blog/2023/11/20/signature-soft-pad-customization/llms.txt)
- [Securing the Signature Endpoint with Custom ActionFilterAttributes](https://www.textcontrol.com/blog/2023/07/25/securing-the-signature-endpoint-with-custom-actionfilterattributes/llms.txt)
- [Common Web API Methods for Handling E-Signature Workflows in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/07/20/common-web-api-methods-for-handling-esignature-workflows-in-aspnet-core-csharp/llms.txt)
- [Use PDF.js to Render PDF Documents within the Document Viewer](https://www.textcontrol.com/blog/2023/03/18/use-pdfjs-to-render-pdf-documents-within-the-document-viewer/llms.txt)
- [Document Viewer 31.2.2 RC1 Released with New Features](https://www.textcontrol.com/blog/2023/03/17/document-viewer-3122-rc1-released-with-new-features/llms.txt)
- [Feature Announcement: Enabling External PDF Renderer PDF.js in TX Text Control DocumentViewer](https://www.textcontrol.com/blog/2023/01/20/documentviewer-enabling-external-pdf-renderer-pdfjs/llms.txt)
- [Document Viewer: SignatureSettings Explained](https://www.textcontrol.com/blog/2022/09/16/document-viewer-signaturesettings-explained/llms.txt)
- [Getting Started: Document Viewer with ASP.NET Core](https://www.textcontrol.com/blog/2022/09/01/getting-started-document-viewer-with-aspnet-core/llms.txt)
