Free Support Forum - aspose.com

How to check a checkmark to true or false

I am trying to find a way to check a checkmark (true or false) to an existing checkmark in a PDF document.


I know how to do it to a text field but haven’t got it to work with a checkmark.

Thanks for your help…Keith

Hi Keith,


Thanks for your inquiry. Please check following code snippet. You can change check box style with Style property. Hopefully it will serve the purpose.


//open document
Document pdf = new Document(“input.pdf”);
//change check box style of existing field
(pdf.Form[“cb1”] as CheckboxField).Style = BoxStyle.Check;
//get a field
CheckboxField field = pdf.Form[“cb1”] as CheckboxField;
//modify field value
field.Checked = true;
//save updated document
pdf.Save(“output.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,

How would that be coded in VB?


Thanks…Keith
Hi Keith,

Please check following code snippet.

Dim pdf As New Document("input.pdf")
'change check box style of existing field
TryCast(pdf.Form("cb1"), CheckboxField).Style = BoxStyle.Check
'get a field
Dim Field As CheckboxField = TryCast(pdf.Form("cb1"), CheckboxField)
'modify field value
Field.Checked = True
'save updated document
pdf.Save(myDir + "output.pdf")

Please feel free to contact us for any further assistance.

Best Regards,