Checkbox problem when using FillField()

Hi,

I am interested in buying the Adobe.PDF product for .NET and at the moment i am trying to fill a simple scenario of a PDF document using the FillField() method.

Text-boxes are filled up correctly but check-boxes are not. I tried all these methods but none of them works:

  • form.FillField(“Check_box1”, True)
  • form.FillField(“Check_box1”, “Yes”)
  • form.FillField(“Check_box1”, “On”)

The fields are named as follows:

  • Textbox_1
  • Textbox_2
  • Check_box1
  • Check_box2

Can you please tell me what is wrong and how I can fix this?

NB: Attached please find the PDF document I am using. I am also using the evaluation license and I downloaded the Aspose.Pdf for .NET 7.2.0 (DLLs only).

Thanks
Mark Mizzi

Hi Mark,

Thank you for considering Aspose.Pdf.

I have tested your issue with the Aspose.Pdf for .NET v7.2 using your template file and I am able to check the checkbox fields. Following is my sample code:

//open document
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(@"D:\TestPDFForm.pdf", @"D:\TestPDFForm_output.pdf");

//Check the Checkbox field
pdfForm.FillField("Check_Box1", true);

//save updated PDF
pdfForm.Save();

Please share your sample code with us to show us the issue.

Sorry for the inconvenience,

Hi Nausherwan,

I tried the code as you suggested but still no success. I am using VB.NET 2010.

This is the code I am using:

'Get path of original pdf
Dim sPDFPath = “D:\testFile.pdf”

'Create New PDF Doc Path
Dim snewPDFPath = sPDFPath.Substring(0, sFDFPath.Length - 4) & Guid.NewGuid().ToString() & “.pdf”

'Open PDF document
Dim pdfForm As New Aspose.Pdf.Facades.Form(sPDFPath, snewPDFPath)

pdfForm.FillField(“Check_box1”, True)

'save document
pdfForm.Save()

Thanks
Mark

Hi Mark,

Thank you for the feedback and sample code.

I noticed that there is a small issue in your code. You are using the field name as “Check_box1” instead of “Check_Box1” (B should be in capital) which is causing the problem. Please update your code and it will work fine.

Thank You & Best Regards,

Hi Nausherwan,

Yes it worked fine now. Thought it was due to the evaluation copy I was using.

Thank you for your help.
Mark Mizzi