How to put checkbox in PDF file

Does anyone have example code for putting flattened checkboxes inside a pdf file?

If so, please help. I couldn't find any code examples on the site.

Thank you.

David

Hi,

Thank you for considering Aspose.

You have two option.

  1. Add checkbox in new Pdf(creating from Scratch). To do that Please refer to the following code:

[ VB.NET ]

Dim pdf1 As Pdf = New Pdf
Dim sec1 As Section = pdf1.Sections.Add()
Dim checkBox As FormField = New FormField
checkBox.FormFieldType = FormFieldType.CheckBox
checkBox.FieldName = "ACombo"
checkBox.CheckBoxIsChecked = True
checkBox.FormWidth = 20
checkBox.FormHeight = 20
checkBox.IsBordered = True
sec1.Paragraphs.Add(checkBox)
pdf1.Save("D:\ASposeTest\CheckBox.Pdf")

NOTE: But in this case you can’t Flatten the checkBox field

2.a) Adding Pdf in existing Pdf. So for that this library won’t work. You need Aspose.Pdf.Kit for that. Please refer to the following code to create a check Box at :

2.b) To Flatten the field you need to use Form Class. Please refer to :

Please See form.FlattenField():

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team

Thanks Adeel.

I wish the PDF class would save a PDF file with a flattened text box...

I tried the .disabled property but that makes it invisible.

Maybe you all should add a .flattened property or .readonly property.

for ASPOSE.pdf.

David

Hi,

I will discuss this issue with the developers and if we have plans to support this, I will let you know. Thanks for patience.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

I have added this task into our plan but I am afraid we can’t support it in short time.

We have supported ReadOnly formfield in hotfix 3.4.5.0.