Free Support Forum - aspose.com

Checkboxes

am a developer currently evaluating aspose.word and I ran across an interesting question. The document I am building is to replace a paper form. The form has several checkboxes. What is the best way to show a checkbox as checked?

In your document the empty checkboxes are just characters of some font, probably Windginds. This font has many nice looking characters including checkboxes both checked and unchecked. If you are to continue this approach, you just need to use Wingdings character 254 - it represents a checked checkbox.
However, if you want to programmatically change the state of the checkboxes, you will probably be better off using checkbox form fields.

To try out form fields, show Forms toolbar in MS Word and insert a checkbox. You can give it a name and later refer to this checkbox by name from the program and get/set its value.

You can use Document.Range.FormFields and retrieve a form field by name.
When you have a FormField object, you can set its Result to 1 or 0 to indicate checkbox on or off.
http://www.aspose.com/Products/Aspose.Word/Api/Aspose.Word.FormField.Result.html

Thanks for your quick response. I used the Document.Range.FormField solution in insert checkboxes into the MS Word document. Everything worked great until I attempted to export the document to PDF. During the export, the checkboxes disappeared. I need a solution that will work for the document export to pdf as well as the display in MSWord.

Note: I used the Document.Range.FormField to populate some text form fields, and they exported to PDF great.

I was looking at the option of inserting the special characters from the wingding character set to give users the checked and unchecked check boxes. Do I need to use the documentbuilder library to insert these into the document? If so, can you point me in the right direction?

----------------
We also would like to export checkboxes to PDF okay. I think I have a solution. I will make sure that Aspose.Word converts checbboxes into appropriate Wingding symbols when exporting to PDF so they will appear as checkboxes. Will include in the next hotfix in a few days.