Convert HTMLDcoument as PDF not OK for checkbox

Hello support !!

We have created a html template contains and java script function to parser checkbox value Y as checked true.

Using HTMLDocument ConvertTemplate(Url url, TemplateData data, TemplateLoadOptions options) to bind data fields from xml into HTML template and result as HTMLDocument, using ConvertHTML(HTMLDocument document, DocSaveOptions options, string outputPath) to output as PDF file…

In the first test case, we have found the output PDF seems not contain checkbox checked if data field = Y …

We also tried to use ConvertTemplate(Url url, TemplateData data, TemplateLoadOptions options,
string outputPath) to save as html file and load into HTMLDcoument for ConvertHTML(HTMLDocument document, DocSaveOptions options, string outputPath) to output as PDF …

In the second test case we have found the output PDF contain checkbox checked if data field = Y …

We have attached a html template for your reference …

thanks and regards !!

Mason Pai 08-21-2024

@masonpai0212

To address the issue of checkboxes not appearing as checked in the PDF output when using the HTMLDocument conversion, it is important to ensure that the checkbox input elements are correctly set up in your HTML template.

From version 22.11.0 of Aspose, there is enhanced support for binding checkbox states directly through data binding. To ensure that a checkbox is rendered as checked in the output PDF, you need to include the checked attribute in your HTML template. This can be done by adding the attribute without assigning a value, like so:

<input type="checkbox" disabled="disabled" value="{{FD0001}}" checked="checked"/>

In your case, if the data field evaluates to “Y”, you should ensure that the checked attribute is present in the HTML. If you are using a data source to control the checkbox state, you can set it up like this:

var dataSource = "\n checked\n"; // For checked state

To uncheck the checkbox, you would remove the checked attribute:

var dataSource = "\n \n"; // For unchecked state

If you are using an earlier version than 22.11, this functionality may not work as expected, so consider upgrading to the latest version to take advantage of these improvements.

If you continue to experience issues, please ensure that your HTML template is correctly formatted and that the data binding is functioning as intended.

Feel free to reach out if you have further questions or need additional assistance!

Sources:
[1]: Html checkbox data binding
[2]: Html checkbox data binding

htmltemplate01.zip (931 Bytes)

@masonpai0212

Can you please also share how you are binding the XML data with the HTML using the API? Please share XML as well so that we can further proceed with the investigation.

Hello support ,

We knew it would be OK to add “checked” attribute via data binding, but our issue is focus on ConvertHTML(HTMLDocument document, DocSaveOptions options, string outputPath) not OK for checkbox checked attribute if HTMLDocument is coming directly from ConvertTemplate(Url url, TemplateData data, TemplateLoadOptions options) …

datasource01.zip (1.0 KB)

Mason pai 08-21-2024

@masonpai0212

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-5728

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hello support !!

I would like to make sure if the new release 24.8 has solved this issue (
HTMLNET-5728) or not ? if it has not been solved by 24.8 release , how about the schedule for it ?

regards !!

Mason Pai 09-20-2024

@masonpai0212

We are afraid that we cannot really promise for the resolution in 24.8 or any future version. Please note that the issues are resolved on a first come first serve basis in free support model. The resolution time depends upon how many issues are in the queue logged previously as well as the complexity level of the issue. Nevertheless, we have recorded your concerns and as soon as the ticket investigation is complete and we have some information about its ETA, we will share with you. Please spare us some time.

We are sorry for the inconvenience.