Skip to content

Instantly share code, notes, and snippets.

Code to Make a Fillable Form in Word using Java. Refer to this link for more information: https://kb.aspose.com/words/java/how-to-make-a-fillable-form-in-word-using-java/
import com.aspose.words.BreakType;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.License;
import com.aspose.words.TextFormFieldType;
public class MakeAFillableFormInWord {
public static void main(String[] args) throws Exception {//main function for how to make a fillable form in Word using Java
// Load license
License lic = new License();
lic.setLicense("Aspose.Total.lic");
// Create a document
Document formDoc = new Document();
// Create a DocumentBuilder object
DocumentBuilder formBuilder = new DocumentBuilder(formDoc);
// Insert text input
formBuilder.insertTextInput("TxtInputControl", TextFormFieldType.REGULAR, "", "The Text Input Control", 0);
formBuilder.insertBreak(BreakType.LINE_BREAK);
// Insert checkbox
formBuilder.insertCheckBox("CheckBoxControl", true, true, 0);
// Save the document
formDoc.save("outputJava.docx");
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment