How to set checkbox values in PDF Viewer

Hi,

I'm using the pdfviewer.importformfields method on the pdf viewer control for a form-filling mechanism. This works for text-based fields - I give it a JSON that has the field values for every field ID, and the importformfields method sets the values in the respective fields. However, I would like to set some of the checkbox values using this method, but it does not seem to working. The checkboxes don't seem to have a true/false values but rather seem to have a bunch of different values, which I'm not able to understand. Please see screenshot attached for some of the values I was able to infer on checkbox fields using the exportformfields method.

Basically, I'm trying to set the value of some checkbox fields using ImportFormFields but it is not working. Would be great if you can assist.

Thanks.

10 Replies

SD Saurabh D May 4, 2020 11:00 PM UTC

Hi,

After looking into this further, it looks like the JSON supplied to the ImportFormFields method needs to substitute special characters with their hexadecimal representation. For e.g. I can see that the date 01/01/2020 is stored as 01_x0031_01_x0031_2020 (where the slash "/" is replaced by _x0031_). This approach clearly has downsides, since I will have to find/replace all special characters with their hex equivalents. Is there an easier approach to this?

Thanks.


AA Akshaya Arivoli Syncfusion Team May 5, 2020 12:44 PM UTC

Hi Saurabh , 

Thank you for contacting Syncfusion support. 

We can reproduce the reported behavior with the provided details. We will analyze further on it and update you with more details on May 7th. 2020 . Meanwhile can you please share us the PDF document and the screenshot which you are using. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 



AA Akshaya Arivoli Syncfusion Team May 7, 2020 04:49 PM UTC

Hi Saurabh ,  

Please find the details of your query from the below, 

Query 
Response 
Can we able to change the check box exported status ON/OFF to true/false. 
We have checked the possibilities to changing the check box status in Json export, but the ON/OFF is preserved in the PDF document itself. We can export the current form data into JSON file format. So that we could not change the check box export status to True/False.  

Can we able to remove the Unicode character on the exported data. 
For removing the Unicode character on exported data, it will affect the XML document. Because XML document will not support the whitespace character, so that we encode form fields name into Unicode characters while exporting to JSON data. 


Regards, 
Akshaya 



SD Saurabh D May 7, 2020 10:01 PM UTC

Hi,

Thanks for responding. Understood about the encoding - I wrote a function to find/replace any non-alphanumeric characters with their hex equivalents. It works so okay on that front.

Regarding the checkboxes, it's not a question of changing from On/Off. What I'm seeing is that the JSON contains different values for checkboxes (not just on/off). For e.g., I'm attaching a sample application that I'm working with. You can follow these steps:
a. Run the application
b. Once the form loads, check some of the checkboxes - I have attached screenshots showing which ones I tested with.
c. Click the [Save] button - this will call exportJSON and export the fields to JSON file in AppData folder.

If you check the values that are being set for these checkboxes, some have value of "M" and others have value of "_x0023_20FLR_x0023_20".

What I'm trying to do is to basically create a JSON file with the field values from the database and fill the form using importFormFields. It works for text fields but is being thrown off because of the variations in checkbox values.

Thanks.

Attachment: Gender_Checkbox_bf17e8a2.zip


SD Saurabh D May 7, 2020 10:03 PM UTC

Reattaching the project.

Attachment: EJ2PdfViewer_ef097790.zip


AA Akshaya Arivoli Syncfusion Team May 8, 2020 01:06 PM UTC

Hi Saurabh , 

We can reproduce the reported behavior with the provided sample. We will analyze further on it and update you with more details on May 12th, 2020 

Regards, 
Akshaya  



SM Selvakumar Murugan Syncfusion Team May 12, 2020 03:02 PM UTC

Hi Saurabh,

Sorry for Inconvenience Caused.

We have facing some complexity while validating the reported issue. Currently we are validating this issue with high priority and we will update more details about this issue on May 14th 2020.

Regards,
Selvakumar 



SM Selvakumar Murugan Syncfusion Team May 18, 2020 05:08 PM UTC

Hi Saurabh,

On our further analysis , while exporting  form fields we have added the details like field name and field value. We have adding the check box values ,if it is checked we added the checked value like (Male-M or Female-F) or else we have add the value is “OFF” and it is our default behaviour. So only we can able to import this data. 
We have get the values from field dictionary “V” and “AS” entry. The dictionary itself the value is “M”,  and also we get the value of "#20FLR#20" for the form field Part1 Unit[0]checkbox. 

Please refer the below screen shot for more reference.  
 
 
  
Regards,
Selvakumar



SD Saurabh D May 24, 2020 02:51 AM UTC

Hi Selvakumar,

Thanks for the reply - I'm still not clear on what the solution is here. Are you saying that it is not possible to set the value of checkbox fields during the importformfields method?


AA Akshaya Arivoli Syncfusion Team May 25, 2020 10:05 AM UTC

Hi Saurabh, 

As mentioned earlier ,if the checkbox is checked we have added the checked value like (Male-M or Female-F) or else we have add the value is “OFF” based on the value preserved in the from field dictionary in the PDF document structure and it is our default behavior. So, it is not possible to set the check box value while importing the form fields, the check box value will be preserved as in the PDF document itself 

Regards, 
Akshaya 


Loader.
Up arrow icon