Last active
June 7, 2022 19:10
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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