1 Reply Latest reply on Nov 24, 2009 5:46 AM by statonk

    cfPDFForm XML Problem


      I've got an XFA form that submits to CF 8.  I read the form into an XML object, resize some images, change a couple of form field values and then try to write the file to a server.  I run into a problem with text data coming from one the fields.  When I try to use this XML object to populate the data when I write the PDF to disk I get an XML parsing error.  I've tried converting the XML Object to a string before saving the PDF to no avail.  I use the same PDF that was received as the source for the one I'm writing so I know it should be able to handle all the form fields.


      I think the problem is caused by CR/LFs in the data.  These are stored in ASCII and then converted into hex in the XML.  The problem is that the Hex representation contains a single pound (#) sign and that may be causing the conversion error.  I've tried escaping all #s in the string version of the XML object and it shows as valid XML.  I've tried it with data that is typed into all the fields and it works.  The first two QA testers both ran into this problem so I need to find a fix.


      Has anyone else run into this problem?


      Thanks in advance,



        • 1. Re: cfPDFForm XML Problem
          statonk Level 1

          Found the problem.  It looks like CFPDFFORM does not handle high-ASCII characters well.  I had to remove them from the fields before trying to populate the form with XML data.  When a user copies in data from a MSWord doc it contains high-ASCII characters.  The PDF and XML Data Object handle these with no problem.  It is only when I tried to populate a PDF on the server with data from a submitted form that the error appeared.


          Here is some of the code I had to use:


          <!--- I found this function online.  Thanks to the gentleman who wrote it --->

          <cffunction name="replaceNonAscii" returntype="string" output="false">

             <cfargument name="argString" type="string" default="" />

             <cfreturn REReplace(arguments.argString,"[^\0-\x80]", "", "all") />



          <!--- Repeat the following call for each pdf form field that accepts user input --->

          variables.xmlFormDoc.datasets.data.form1.ExteriorNotes.xmlText = replaceNonAscii(lrForm.ExteriorNotes);