Skip to content

Instantly share code, notes, and snippets.

Code to Create a Form in Word using C#. Further details are available here: https://kb.aspose.com/words/net/how-to-create-a-form-in-word-using-csharp/
using Aspose.Words;
using Aspose.Words.Fields;
namespace HowToCreateAFormInWordUsingCSharp
{
class Program
{
static void Main(string[] args) // Main function for how to create a form in Word using CSharp
{
//Initialize license
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense("Aspose.Total.lic");
// Create a document
Document docForm = new Document();
// Create a DocumentBuilder object
DocumentBuilder builderForm = new DocumentBuilder(docForm);
// Insert text input
builderForm.InsertTextInput("TextInputControl", TextFormFieldType.Regular, "", "Enter text here", 0);
builderForm.InsertBreak(BreakType.LineBreak);
// Insert checkbox
builderForm.InsertCheckBox("CheckBoxControl", true, true, 0);
// Save the document
docForm.Save("output.docx");
System.Console.WriteLine("Done");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment