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.
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);
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.
Enhance your forms by incorporating content controls such as plain text, rich text, pictures, checkboxes, combo boxes, dropdown lists, and date pickers.
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.
Bind content controls to an element in the custom XML part embedded in a document.
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.