DEV Community

Cover image for Convert Word Documents into Fillable PDFs Using C#
Zahra Sandra Nasaka for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

Convert Word Documents into Fillable PDFs Using C#

TL;DR: Learn to create a fillable PDF from a Word document in C# using the .NET Word Library, enabling form fields, dropdowns, checkboxes, and other interactive elements to collect user input.

Fillable PDFs streamline data collection by allowing users to enter and submit information digitally, eliminating the hassle of paper-based forms. Businesses and professionals can quickly share and process these forms, improving efficiency.

With the Syncfusion .NET Word Library (DocIO), we can easily create, edit, and manipulate Word documents programmatically—without relying on Microsoft Office or interop dependencies. This blog explores how to convert Word documents with form fields into fillable PDFs using the .NET Word Library, enabling seamless digital form creation.

Create a template Word document with form fields

To create a structured Word template for conversion into a fillable PDF, we need to include some essential form fields:

  • Checkboxes – For multiple-choice selections.
  • Dropdowns – To offer predefined choices.
  • Text Fields – To collect user input like name and address.

You can create a template Word document using our .NET Word Library (DocIO) programmatically or design it visually using a Word editor. A Word editor helps format and arrange form fields for a structured layout before converting it into a fillable PDF using DocIO.

Note: For more details, refer to the .NET Word Library getting started documentation.

Getting started

Step 1: ** First, create a new C# .NET Core **Console App in Visual Studio.

Create a new C# .NET Core Console app

Step 2: Then, install the Syncfusion.DocIORenderer.Net.Core NuGet package as a reference to the app from NuGet Gallery. Install the Syncfusion.DocIORenderer.Net.Core NuGet packageStep 3: Now, include the following namespaces in the Program.cs file.

using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;
Enter fullscreen mode Exit fullscreen mode

Now, the project is ready! Let’s write the code to convert a Word document with form fields into a fillable PDF while preserving the form fields as editable using the PreserveFormFields API.

// Open the Word document as a file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath("Template.docx"), FileMode.Open))
{
    // Load an existing Word document.
    using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic))
    {
        // Create an instance of DocIORenderer.
        using (DocIORenderer renderer = new DocIORenderer())
        {
            // Enable preserving form fields as editable in the PDF.
            renderer.Settings.PreserveFormFields = true;

            // Convert the Word document to a PDF.   
            using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
            {
                // Save the PDF document to a file stream. 
                using (FileStream outputStream = new FileStream(Path.GetFullPath("Output.pdf"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                    pdfDocument.Save(outputStream);
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

By executing this code example, we will get the output as shown in the following image.

Fillable PDF generated from a Word document using .NET Word Library


Fillable PDF generated from a Word document using .NET Word Library

.NET Word Library in Fillable PDF


.NET Word Library in Fillable PDF

GitHub reference

You can also find all the examples for creating a fillable PDF from a Word document using our .NET Word Library on this GitHub repository.

Conclusion

Thanks for reading! Syncfusion .NET Word Library offers customizable settings to fine-tune the Word to PDF conversion process, allowing you to optimize performance, enhance accessibility, and preserve document fidelity across platforms. Whether you’re working with Word documents on any .NET platform, the Word to PDF converter simplifies the process for .NET developers.

Take a moment to peruse the Word to PDF conversion documentation, where you can find other options and features, all with code examples.

Are you already a Syncfusion user? You can download the product setup here. If you’re not yet a Syncfusion user, you can download a 30-day free trial.

If you have questions, contact us through our support forum, support portal, or feedback portal. We are always happy to assist you!

Related Blogs

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • --last-failed: Zero in on just the tests that failed in your previous run
  • --only-changed: Test only the spec files you've modified in git
  • --repeat-each: Run tests multiple times to catch flaky behavior before it reaches production
  • --forbid-only: Prevent accidental test.only commits from breaking your CI pipeline
  • --ui --headed --workers 1: Debug visually with browser windows and sequential test execution

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Practical examples included!

Watch Video 📹️

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay