We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Check box issue

I am evaluating your Pdf.Kit product for a client project. So far, your
product is better able to read and process PDF files than several
competitors we also evaluated, but there remains one issue that perhaps
you could help us with.

We are working with PDF
forms produced by a wide range of sources, and therefore there is little
consistency between them. It appears that different forms expect
different values for check boxes - some show as checked when set to “On”,
others to “Yes”. Some work correctly when using the FillField(string,
bool) overload, some do not.

After reading through your support
forums, it seems this is a common scenario, whereby different forms
contain the expected values for check boxes. It was our hope that the
above-mentioned overload of the FillField method would automatically map
the boolean value to the document-defined checked/unchecked value, but
this does not seem to be the case.

Is there a simple way that we
have overlooked to set a check box to checked or unchecked without having
to parse the form to determine what the expected values are? If not, can you point us in the right direction to parse these values within the Pdf.Kit namespace?

Thanks for your time.

Hi Adam,

Thank you very much for considering Aspose.

I would like to share with you that PDF forms might represent the check box values as “On/Off”, “Yes/No”, or “True/False”. However, while filling value using FillField method, you only need to provide True or False. The other options only cause problem when you fill the data from XML. In that case, you’ll have to take care that how the check box value is presented in a particular file and then input the value accordingly in the XML file. While using FillField method, you shouldn’t have any such problem.

Nevertheless, if you still find any issues then please share a sample PDF file along with the code snippet which you’re using at your end, so we could investigate the issue at our end and guide you accordingly.

We’re sorry for the inconvenience and looking forward to help you out.

Thank you for your response. Further investigation seems to show that
the FillField(string, bool) overload does set the value correctly, but
does not alter the appearance state properly. With the two files we’re
currently testing against, one of them displays the check mark only when
using the bool overload (which sets the value to “On”), while the other
will only display the check mark when using the (string, string)
overload with a value of “Yes”. It seems there may be a discrepancy between the actual value, and the appearance state.

I am not able to find anything within the Pdf.Kit namespace for specifically modifying the appearance state of the check box, though I suspect this should be properly handled by the (String, bool) overload anyway. It looks like it may be a bug, but I’m hesitant to call something a bug until I’m sure I’m not misusing or misunderstanding it!

Let me know if the above information gives you any more insight into our situation, or if you still need the PDF files to look at internally.


Hi Adam,

Thank you very much for sharing the details with us. Actually, we do need the document(s) and code snippet in order to understand and then resolve the issue using your particular scenario. If you do not want to share the documents with public, you can mark the thread as private while making the post. If you think the files contain confidential data, you may try creating similar sample files with dummy data and share those.

I hope you understand. We’re looking forward to help you out.

The files aren’t sensitive in nature - I’ve attached them here. We need our code to be able to programmatically check the check box on both of these forms, preferably using the (string, bool) overload, but without having to specifically set one to “On” and the other to “Yes”, because we’ll be processing many forms, and it would be silly to have to code different “checked” values for each of them, when they are coming from many sources and we don’t have control over the creation process.

There are 3 files for each document, as follows:

First form:

  • NHfWT.pdf - original form, cobbled together with OpenOffice.
  • NHfWT_Manual.pdf - the form, with the check box checked, using Foxit Reader v5.
  • NHfWT_Out.pdf - the form, programmatically checked using the FillField(string, bool) overload. Opening this file in Foxit Reader v5 does NOT show the box checked.
Second form:
  • TestSrc_AcroForm.pdf - original form, unsure of what tool created it.
  • TestSrc_AcroForm_Manual.pdf - the form, with the “Transportation” check box checked, using Foxit Reader v5.
  • TestOut_AcroForm.pdf - the form, programmatically checked using the FillField(string, bool) overload. Opening this file in Foxit Reader v5 DOES show the box checked.
If I instead use FillField(string, “Yes”) to check the box, then the results are reversed - NHfWT.pdf DOES show the box in Foxit Reader, and TestOut_AcroForm.pdf does NOT show it.

Hi Adam,

Thank you very much for sharing the sample PDF files along with the details. We’ll further investigate this issue at our end and update you with the results accordingly.

We’re sorry for the inconvenience.

Hello Shahzad,

I just thought I’d check in and see if you had any insights into our issue. If you need any additional information or clarification, don’t hesitate to contact me. Thanks!

Hi Adam,

I have reproduced this issue at my end and logged it as PDFKITNET-28792 in our issue tracking system. In fact, as I shared earlier, different files represent check box values in different ways – true/false, yes/no or on/off – that’s why Aspose.Pdf.Kit treats the check boxes accordingly. However, I have logged this issue so that our team would be able to investigate if we can check all the values based on only one input i.e. true/false. You’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience. If you have any further questions, please do let us know.