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

Free Support Forum - aspose.com

Import XFDF into PDF in C# using Aspose.PDF - Checkboxes are being set

Hello,


We are using Aspose to convert XFDF file to PDF file. In the XFDF file, we are setting a value of 1 or 0 to indicate the check box selection (1 = checked, 0 = unchecked) for the check box fields; this is causing an issue while converting the PDF file from the XFDF as the Aspose is treating 1 or 0 as a value and checking (selecting) all the check boxes (including unchecked ones) in the PDF after conversion.

The default values in XFDF for check boxes are On and Off for check and un-check respectively, is it possible to configure Aspose to accept 1 or 0 instead of On or Off?

I appreciate your help on this.

Hi Balaji,


Thanks for using our API’s.

Aspose.Pdf for Java provides the feature to set value for Form fields inside PDF document and you can explicitly set the value for PDF form field. However your problem appears to be related to XFA to Standard AcroForm conversion. Can you please share the resource file, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Here are the details of the issue we are facing:


1. Edit the Full time (and Part time) check box fields to set a value of 1 if checked (or selected) - as shown in screen shot 1 of the EFormPDF.doc
2. Create a javascript to set one of the check box values to 0 if the other is selected. - as shown in screen shot 2 of the EFormPDF.doc
3. The PDF is filled and submitted with only one check box selected, but the resulted PDF has all the check boxes selected - as shown in screen shot 3 of the EFormPDF.doc
4. The content of XFDF file was attached as text file for your reference.

Please let us know if you need more details.

Please find the attached fillable PDF form.

We changed the check boxes (full and part time) value to set to 1 when checked/selected. The check box javascript sets the unchecked field value to 0.
Also the submit button’s javascript was modified to replace the check box “off” values (if any) with 0.

Once this fillable form is filled and submitted, the XFDF is generated as we expect - i.e., 0 for unchecked and 1 for checked. But the PDF has all the check boxes checked as you can find in the 3rd screen shot of the EFormPDF.doc.

Hi Balaji,


Thanks for sharing the details and resource files.

I am able to understand the issue while looking over shared resources. However can you please share the code snippet which can be used to fill data inside SB146-eform.pdf file, so that we can test the scenario in our environment. We are sorry for your inconvenience.
Hello,

We are invoking the below code to convert XFDF to PDF (SB146-eform.pdf).

Method Argument's details:
inputPdf - points to a read only PDF file (SB146.pdf); I've attached this read only file.
outputPdf - is the output location of the SB146-eform.pdf file to be created in.
xfdf - is the java.io.File object representing the xfdf file.

public void covertToPDF(String inputPdf ,String outputPdf,File xfdf) {
try{
Form form = new Form (inputPdf, outputPdf);
FileInputStream xfdfInputStream = new FileInputStream(xfdf);
form.importXfdf(xfdfInputStream);
xfdfInputStream.close();
form.save();
}catch(Exception e){
logger.info("covertToPDF");
logger.info("covertToPDF"+e.getMessage());
e.printStackTrace();
}
}

FYI: The web user fills the fillable SB146-eform.pdf online and submits the same.

Hi Balaji,


Thanks for sharing the details and resource files.

I
have tested the scenario and I am able to reproduce the same problem that when importing XFDF values to PDF form, all the check-boxes in side PDF are being set. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWJAVA-35040. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>

We apologize for your inconvenience.