Populate PDF form fields using Aspose.PDF for .NET - Calculated field in pdf form not working

Hi just updated to the latest version and found out that calculated field in a PDF form doesn’t really work. Form can be obtained from https://www.dol.gov/sites/dolgov/files/WHD/legacy/files/wh347.pdf. For example, using Aspose PDF form API, I define “2” for field “ST11” and hope calculated field “totalHoursST1” will calculate, but it doesn’t. Could you advise? Thanks.

@jasonfeng

Would you kindly share the sample code snippet that you are using at your end to fill the fields. We will test the scenario in our environment and address it accordingly.

Hi, thanks for the prompt reply. Below is my code as well as my xml data used for import.

var xmlFile = @“c:\input.xml”;
var fsXml = new FileStream(xmlFile, FileMode.Open, FileAccess.Read, FileShare.Read);

var f = @“c:\result.pdf”;
var doc = new Document(f);
doc.Form.AutoRecalculate = false;

var form = new Form();
form.BindPdf(doc);
form.ImportXml(fsXml);
fsXml.Close();

doc.Form.AutoRecalculate = true;

form.Save(f);
form.Dispose();

xml data.zip (263 Bytes)

I just sent my updated xml data file xml data2.zip (285 Bytes)
to include one more data field. Please use this instead for two more questions,

  1. Year is not displayed correctly after importing. Even my data for “weekEnding” field is 4/12/2020, it shows as “4/12/3920”. This question has been asked before by somebody else. Not sure why there is still no fix.

  2. The xml file format in my upload is the format that Aspose PDF ImportXml can understand. However, the xml file generated by exporting form data from Acrobat or Foxit both is below format, which looks cleaner, but it is won’t be imported using Aspose ImportXml

<?xml version="1.0" encoding="UTF-8"?> 04/12/2020 8 8

Sorry, the xml format used by Acrobat in my previous reply is like below,

<?xml version="1.0" encoding="UTF-8"?>
<fields xmlns:xfdf="http://ns.adobe.com/xfdf-transition/">
   <weekEnding>04/12/2020</weekEnding>
   <ST11>2</ST11>
   <ST12>3</ST12>
</fields>

Sorry, one more update of the xml file xml data3.zip (394 Bytes)

I added two names in the xml data file. As you noticed, after calling ImportXml, the first name’s orientation is rotated, but not the second name. Inspecting the form field in design mode with Acrobat, I don’t see field “nameAddrSSN1” defined with orientation 90. Is the rotation cased by ImportXml?

Opening the file with Chrome or Edge or FoxIt will show the first name rotated 90 degree. Only Acrobat displays it correctly.

Thanks.

@jasonfeng

We have tested the scenario in our environment with Aspose.PDF for .NET 20.6. We were able to reproduce the issues that you have mentioned and created ticket for them in our issue tracking system as PDFNET-48468. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks Asad. Just want to make sure, are all issues that I reported included in your future fix?

  1. Form field auto calculation doesn’t work.
  2. Wrong year displayed even though the data imported is correct.
  3. Some fields rotate 90 degree after xml import.
  4. Not sure this is an issue or not. The xml format required by Aspose ImportXML doesn’t match “standard format” by Acrobat or other PDF vendors. You can verify it by using exporting feature with Acrobat or Foxit, which doesn’t match xml file exported by using Aspose ExportXML method.

@jasonfeng

Yes, we have mentioned all anomalies in the logged ticket and all of them will be investigated. We will also investigate about the exported XML.