# Converting MS Word DOCX Documents to PDF in C#

> Use TX Text Control to programmatically convert MS Word DOC and DOCX documents to PDF. This article outlines the requirements and explains the simple steps you need to take to successfully convert Office documents to Adobe PDF.

- **Author:** Bjoern Meyer
- **Published:** 2023-10-16
- **Modified:** 2026-07-17
- **Description:** Use TX Text Control to programmatically convert MS Word DOC and DOCX documents to PDF. This article outlines the requirements and explains the simple steps you need to take to successfully convert Office documents to Adobe PDF.
- **3 min read** (515 words)
- **Tags:**
  - ASP.NET
  - Windows Forms
  - PDF
  - DOCX
  - MS Word
- **Web URL:** https://www.textcontrol.com/blog/2023/10/16/converting-ms-word-docx-documents-to-pdf-in-csharp/
- **LLMs URL:** https://www.textcontrol.com/blog/2023/10/16/converting-ms-word-docx-documents-to-pdf-in-csharp/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2023/10/16/converting-ms-word-docx-documents-to-pdf-in-csharp/llms-full.txt

---

If you need to programmatically convert an MS Word document in RTF, DOC or DOCX formats to PDF, TX Text Control provides an easy-to-use library to accomplish this task. Using advanced document processing technology, you can use a highly reliable C# API to create PDFs from MS Word documents without using printer drivers.

The following tutorial shows how to create a simple .NET 6 C# Console App to convert MS Word documents to PDF that uses the ServerTextControl class.

### 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).

> ### Prerequisites
> 
>  The following tutorial requires a trial version of TX Text Control .NET Server.
> 
> - [Download Trial Version](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/)

1. In Visual Studio 2022, create a new project by choosing *Create a new project*.
2. Select *Console App* 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 6 (Long-term support)* as the *Framework* and confirm with *Create*.

#### Adding the NuGet Package

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.
    
    *Install* the latest versions of the following package:
    
    
    - *TXTextControl.TextControl.ASP.SDK*
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2023/10/16/a/assets/visualstudio1.webp "ASP.NET Core Web Application")

#### Adding Documents

6. In the *Solution Explorer*, select your created project and choose *New Folder* from the *Project* main menu and name it *Documents*.
7. Select the newly created folder and choose *Add Existing Item...* from the *Project* main menu. Select any MS Word document from your local machine and click the *Add* button to confirm.
8. Select the newly created file and set the *Copy to Output Directory* property to *true*.

#### Adding the Code

9. Open the *Program.cs* file and replace the code with the following code:
    
     ```
    using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
    {
        tx.Create();
    
        // load DOC or RTF file
        //tx.Load("mydocument.doc", TXTextControl.StreamType.MSWord);
        //tx.Load("mydocument.rtf", TXTextControl.StreamType.RichTextFormat);
    
        // load DOCX file
        tx.Load("Documents/mydocument.docx", TXTextControl.StreamType.WordprocessingML);
    
        // optionally set the save settings
        TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings()
        {
            Author = "Text Control",
            CreationDate = DateTime.Now,
            CreatorApplication = "TX Text Control Sample Application",
            DocumentAccessPermissions = TXTextControl.DocumentAccessPermissions.AllowAll
        };
    
        // save as PDF
        tx.Save("mydocument.pdf", TXTextControl.StreamType.AdobePDF, saveSettings);
    
        Console.WriteLine("Document has been converted!");
    }
    ```

Compile and start the application. The converted PDF document will be saved in the root folder of your project.

#### Different Ways to Generate PDFs

TX Text Control .NET allows developers to programmatically create PDF files using C# in a variety of ways, including creating documents from scratch, merging data into predefined templates, and converting documents such as HTML to PDF.

> ### Learn More
> 
>  TX Text Control allows developers to create PDF files programmatically using C#. This article shows various ways to create Adobe PDF documents.
> 
>  [Creating PDF Files using TX Text Control .NET in C#](https://www.textcontrol.com/blog/2022/05/24/creating-pdf-files-using-tx-text-control-dotnet/llms-full.txt)

---

## 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

- [AI Natural Language Document Generation with MCP and TX Text Control .NET](https://www.textcontrol.com/blog/2026/07/16/ai-natural-language-document-generation-with-mcp-server-and-tx-text-control-dotnet/llms.txt)
- [Programmatically Fill, Flatten, and Export DOCX Form Templates to PDF in C# .NET](https://www.textcontrol.com/blog/2026/04/10/programmatically-fill-flatten-and-export-docx-form-templates-to-pdf-in-csharp-dotnet/llms.txt)
- [From DOCX to Long-Term Archiving: Generating PDF/A from Office Documents in .NET C#](https://www.textcontrol.com/blog/2025/09/04/from-docx-to-long-term-archiving-generating-pdfa-from-office-documents-in-dotnet-csharp/llms.txt)
- [PDF Conversion in .NET: Convert DOCX, HTML and more with C#](https://www.textcontrol.com/blog/2025/08/05/pdf-conversion-in-dotnet-convert-docx-html-and-more-with-csharp/llms.txt)
- [Convert MS Word DOCX to PDF including Text Reflow using .NET C# on Linux](https://www.textcontrol.com/blog/2025/06/10/convert-ms-word-docx-to-pdf-including-text-reflow-using-dotnet-csharp-on-linux/llms.txt)
- [Use MailMerge in .NET on Linux to Generate Pixel-Perfect PDFs from DOCX Templates](https://www.textcontrol.com/blog/2025/05/27/use-mailmerge-in-dotnet-on-linux-to-generate-pixel-perfect-pdfs-from-docx-templates/llms.txt)
- [How to Import and Read Form Fields from DOCX Documents in .NET on Linux](https://www.textcontrol.com/blog/2025/05/19/how-to-import-and-read-form-fields-from-docx-documents-in-net-on-linux/llms.txt)
- [How to Programmatically Create MS Word DOCX Documents with .NET C# on Linux](https://www.textcontrol.com/blog/2025/04/10/how-to-programmatically-create-ms-word-docx-documents-with-dotnet-csharp-on-linux/llms.txt)
- [Edit MS Word DOCX Files in .NET C# and ASP.NET Core](https://www.textcontrol.com/blog/2025/01/24/edit-ms-word-docx-files-in-net-c-sharp-and-asp-net-core/llms.txt)
- [Create Word Document with .NET C#](https://www.textcontrol.com/blog/2024/10/25/create-word-document-with-net-c-sharp/llms.txt)
- [Sign Documents with a Self-Signed Digital ID From Adobe Acrobat Reader in .NET C#](https://www.textcontrol.com/blog/2024/08/12/sign-documents-with-a-self-signed-digital-id-from-adobe-acrobat-reader-in-net-c-sharp/llms.txt)
- [Generating MS Word DOCX and PDF Documents with ASP.NET Core C#](https://www.textcontrol.com/blog/2024/04/05/generating-ms-word-docx-and-pdf-documents-with-asp-net-core-c-sharp/llms.txt)
- [Generate PDF Documents from MS Word DOCX Templates in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/10/20/generate-pdf-documents-from-ms-word-docx-templates-in-aspnet-core-csharp/llms.txt)
- [Display PDF Documents in Windows Forms using the Document Viewer and Embedded Kestrel in C#](https://www.textcontrol.com/blog/2023/10/13/display-pdf-documents-in-windows-forms-using-the-document-viewer-and-embedded-kestrel-in-csharp/llms.txt)
- [Extract Text and Data from PDF Documents in C#](https://www.textcontrol.com/blog/2022/06/16/extract-text-and-data-from-pdf-documents-in-csharp/llms.txt)
- [Creating PDF Files using TX Text Control .NET in C#](https://www.textcontrol.com/blog/2022/05/24/creating-pdf-files-using-tx-text-control-dotnet/llms.txt)
- [Generating Interactive PDF Forms by Injecting JavaScript](https://www.textcontrol.com/blog/2022/03/31/generating-interactive-pdf-forms-by-injecting-javascript/llms.txt)
- [Form Field Handling in PDF Documents](https://www.textcontrol.com/blog/2022/01/03/form-field-handling-in-pdf-documents/llms.txt)
- [Creating PDF Documents from MS Word DOCX in C#](https://www.textcontrol.com/blog/2021/02/26/creating-pdf-documents-from-ms-word-docx-in-csharp/llms.txt)
- [Creating ZUGFeRD Compliant PDF Invoices in C#](https://www.textcontrol.com/blog/2021/02/03/creating-zugferd-compliant-pdf-invoices-in-csharp/llms.txt)
- [X19 Sneak Peek: Processing AcroForm Fields in Adobe PDF Documents](https://www.textcontrol.com/blog/2020/10/29/sneak-peek-processing-acroform-fields-from-adobe-pdf-documents/llms.txt)
- [Which MS Word Fields Are Supported and How to Handle Them?](https://www.textcontrol.com/blog/2020/05/13/which-msword-fields-are-supported/llms.txt)
- [Create and Modify Adobe PDF Documents within your .NET Application](https://www.textcontrol.com/blog/2019/05/27/create-and-modify-adobe-pdf-documents/llms.txt)
- [How to create Adobe PDF files in .NET](https://www.textcontrol.com/blog/2018/08/11/how-to-create-pdf-files-in-net/llms.txt)
- [Sneak Peek X15: MS Word Compatible Document Protection and Editable Regions](https://www.textcontrol.com/blog/2017/11/16/ms-word-compatible-editable-regions/llms.txt)
