Checkbox in Aspose.Pdf

Received : 2007/12/03 13:15:15
Message : Is there the capability to add checkboxes? I see radio buttons, but no checkbox.


This message was posted using Aspose.Live 2 Forum

Hi,

Thank you for considering Aspose.

Checkbox is supported. Unlike Radiobutton there is as such no direct class for checkboxes. Hence for that you need to create new FormField and set it’s type to checkbox. Please refer to the following code and URL to get more details on FormFields.

http://www.aspose.com/Wiki/default.aspx/Aspose.Pdf/ManipulatingFormFields.html

[C#]

Pdf pdf1 = new Pdf();

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.FormField checkBox = new Aspose.Pdf.FormField();

checkBox.FormFieldType = FormFieldType.CheckBox;

checkBox.FieldName = "Checkbox1";

checkBox.CheckBoxIsChecked = true;

checkBox.FormHeight = 20;

checkBox.FormWidth = 20;

sec1.Paragraphs.Add(checkBox);

//Set Font Map for better performance

pdf1.IsTruetypeFontMapCached = true;

pdf1.TruetypeFontMapPath = System.IO.Path.GetTempPath();

//Save the Pdf

pdf1.Save("D:/AsposeTest/RadioChek.pdf");

Thanks.