Easily Create a Fillable Form Using JavaScript Word Processor | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (219)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (917)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (149)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (631)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (595)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Easily Create a Fillable Form Using JavaScript Word Processor

Easily Create a Fillable Form Using JavaScript Word Processor

This blog illustrates how to create and fill a form in a Word document using the Syncfusion JavaScript Word Processor (document editor) component. It is a user interface component that allows you to compose, edit, view, and print Word documents interactively in your web app. It provides all the standard word processing features, including editing text, formatting contents, resizing images and tables, finding and replacing text, creating a table of contents, printing, and more. It requires server-side dependencies to perform some operations.

Note: If you are new to our Word Processor component, it is highly recommended that you follow our Getting Started guide.

Form fields in JavaScript Word Processor

The JavaScript Word Processor component supports legacy form fields like text, checkboxes, and dropdown form fields to create fillable forms in a Word document. These form fields are supported in both DOC and DOCX formats.

The component enables authors to protect their documents with several editing restrictions. One such editing restriction is FormFieldsOnly. It allows users only to fill the form fields in a Word document and prevents all other edits.

Editing Restriction Feature in Form Fields of JavaScript Word Processor
Editing Restriction Feature in Form Fields of JavaScript Word Processor

Note: For more details, refer to the protecting the document in form filling mode documentation.

Create a fillable form in JavaScript Word Processor

The JavaScript Word Processor component comes with an intuitive UI for designing a fillable form in a Word document by inserting legacy form fields, like in Microsoft Word apps. The legacy form fields allow you to design a form with:

  • Text form fields with text type to fill any string value.
  • Text form fields with number type to fill a numeric value.
  • Text form fields with date type to fill a date or time.
  • Checkbox form fields to answer a simple yes-or-no question.
  • Dropdown form fields to choose one value from a list of strings.

The following GIF illustrates how to design a fillable form in the Word Processor component.

Creating a Fillable Form in JavaScript Word Processor
Creating a Fillable Form in JavaScript Word Processor

If you want to prevent the filling of a specific form field, uncheck the Fill-in enabled option for the required form field in the properties dialog. (To do so, double-click on the form field or choose the properties option from the context menu.)

Use the formFieldSettings API to customize the appearance (enable/disable shading, shading and selection of colors) of form fields.

You can automate retrieving and modifying the form field properties in a Word document using the getFormFieldInfo and setFormFieldInfo APIs. For more details, refer to the Form fields in JavaScript Word Processor documentation.

Fill a form in JavaScript Word Processor

Once you create a fillable form and protect it with the editing restriction type FormFieldsOnly, your form is ready for filling.

The Syncfusion Word Processor component provides two form-filling modes:

  • PopUp: Opens a pop-up with an in-place editor to fill the form field when you click on or navigate to a form field. This mode is enabled by default.
  • Inline: This allows users to fill the form fields directly without any pop-up.

The following GIF illustrates how to fill a form in the JavaScript Word Processor component.

Filling a Form in JavaScript Word Processor
Filling a Form in JavaScript Word Processor

Use the resetFormFields API to reset all the form fields in a Word document to their default value.

Export filled form data in JavaScript Word Processor

The Word Processor has an exportFormData API that returns the names and values of all the form fields in a document. You can easily save the exported form data to a database.

Refer to the following code example.

let formFieldDate: FormFieldData[] = documentEditor.exportFormData();

Import form data into a fillable form in JavaScript Word Processor

The component comes with an importFormData API that sets a specified value to the respective form field in a document. You can automatically fill the values from the database into the form fields while opening a document in Word Processor component.

Refer to the following code example.

let textformField: FormFieldData = { fieldName: 'Text1', value: 'Hello World' };
let checkformField: FormFieldData = { fieldName: 'Check1', value: true };
let dropdownformField: FormFieldData = { fieldName: 'Drop1', value: 1 };

//Import form field data
this.container.documentEditor.importFormData([textformField, checkformField, dropdownformField]);

GitHub repository

Refer to the complete working example of Creating a Fillable Form Using Syncfusion JavaScript Word Processor.

Conclusion

Thanks for reading! With the help of the form fields in the JavaScript Word Processor component, you can provide form-filling capability in Word documents to your web app with ease. The Word Processor component is available for JavaScript (ES5 and ES6), Angular, React, Vue, ASP.NET MVC, ASP.NET Core, and Blazor web platforms.

Are you already a Syncfusion user? You can download the product setup. If you are not yet a Syncfusion user, you can download a 30-day free trial.

If you have any questions about these features, please let us know in the comments below. You can also contact us through our support forum, support portal, or feedback portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed