Created
August 5, 2020 11:58
-
-
Save aspose-com-gists/24247a0021776683e8ccd22ddb0ea53c to your computer and use it in GitHub Desktop.
Make Fillable Form in Word
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
// Initialize new Word document | |
Aspose.Words.Document doc = new Aspose.Words.Document(); | |
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); | |
// Insert Text Form Field | |
Aspose.Words.Fields.FormField text = builder.InsertTextInput("TextInput", Aspose.Words.Fields.TextFormFieldType.Regular, "", "Hello", 0); | |
// Add line break | |
builder.InsertBreak(Aspose.Words.BreakType.LineBreak); | |
// Insert Checkbox Form Field | |
Aspose.Words.Fields.FormField checkbox = builder.InsertCheckBox("CheckBox", true, true, 0); | |
checkbox.Checked = true; | |
builder.InsertBreak(Aspose.Words.BreakType.LineBreak); | |
string[] items = { "One", "Two", "Three" }; | |
// Insert Combobox Form Field | |
Aspose.Words.Fields.FormField combo = builder.InsertComboBox("DropDown", items, 0); | |
//builder.InsertBreak(Aspose.Words.BreakType.LineBreak); | |
dataDir = dataDir + "InsertFormFields.docx"; | |
doc.Save(dataDir); |
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
// Load source DOCX file | |
Aspose.Words.Document doc = new Aspose.Words.Document(dataDir + "InsertFormFields.docx"); | |
// Load form fields of the word file | |
Aspose.Words.Fields.FormFieldCollection documentFormFields = doc.Range.FormFields; | |
// Access the checkbox | |
Aspose.Words.Fields.FormField checkbox = documentFormFields["CheckBox"]; | |
//Delete or remove checkbox | |
checkbox.Remove(); | |
// Save updated DOCX file | |
doc.Save(dataDir + "DeleteField.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment