We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Syncfusion Feedback


Trusted by the world’s leading companies

Overview

The Syncfusion .NET Word Library (DocIO) enables the creation of fillable forms with both legacy form fields and content controls in C#. It lets users design forms consisting of various elements such as plain text, rich text, pictures, checkboxes, combo boxes, and dropdown lists.


How to fill a form in Word documents in C#

  1. Install NuGet package: Install the Syncfusion.DocIO.Net.Core NuGet package in your project.
  2. Open Word document: Create a FileStream object to represent the input Word document.
  3. Load in .NET Word Library: Create a WordDocument object by passing the FileStream object.
  4. Fill text in plain text content control: Utilize the FindItemByProperty method to retrieve the plain text content control and add the text.
  5. Check the checkbox content control: Retrieve the content control of checkbox type and check it.
  6. Save Word document: Save the WordDocument object to the FileStream object.

Here is an example of how to fill a form in Word document in C# using the Syncfusion .NET Word Library (DocIO).

//Open an existing Word document.
using FileStream inputDocumentStream = new FileStream("Template", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using WordDocument document = new WordDocument(inputDocumentStream, FormatType.Docx);
 
//Find content control by title.
InlineContentControl inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Title", "TitleName") as InlineContentControl;
//Fill text.
WTextRange textrange = inlineContentControl.ParagraphItems[0] as WTextRange;
textrange.Text = "Add content";
 
//Find checkbox content control.
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Type", "CheckBox") as InlineContentControl;
//Check the checkbox
inlineContentControl.ContentControlProperties.IsChecked = true;
 
//Save the Word document.
using FileStream outputDocumentStream = new FileStream("Result.docx", FileMode.Create, FileAccess.ReadWrite);
document.Save(outputDocumentStream, FormatType.Docx);

Form filling

Legacy forms fields

Create and fill out forms with legacy form fields in Word documents such as text, dropdown, and checkbox form fields, and seamlessly extract the filled data from them.

Content controls

Enhance your forms by incorporating content controls such as plain text, rich text, pictures, checkboxes, combo boxes, dropdown lists, and date pickers.

Restrict editing

Protect the content of content controls from being edited by locking their content. You can also prevent a content control from being deleted from the document.

Binding

Bind content controls to an element in the custom XML part embedded in a document.



Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.

Scroll up icon