I assume I need to flatten a XFA form in order to display properly on the UI of an application that uses Nuance's CSDK. When I process it now I get a generic message "Please Wait.... If this message is not eventually replaced..".
Looking for some sample iTextSharp code to do this.
You didn't insert a code sample to show how you are currently flattening the XFA form. I assume your code looks like this:
This code will work when trying to flatten forms based on AcroForm technology, but it can't be used for forms based on the XML Forms Architecture (XFA)!
A dynamic XFA form usually consists of a single page PDF (the one with the "Please wait..." message) that is shown in viewer that do not understand XFA. The actual content of the document is stored as an XML file.
The process of flattening an XFA form to an ordinary PDF requires that you parse the XML and convert the XML syntax into PDF syntax. This can be done using iText's XFA Worker: http://itextpdf.com/product/xfa_worker
Suppose that you have a file in memory (
ms
) that consists of an XFA form that is filled out, then you can use the following code to flatten that form:You can download a zip file containing the DLLs for XFA Worker as well as an example here: http://itextsupport.com/download/xfa-net.zip
However: as too many developers are using the AGPL version of iTextSharp in a commercial context without buying a commercial license, we have decided not to open source XFA Worker. You can get a license key for a trial period, but it is a commercial product built on top of the commercial version of iTextSharp. XFA Worker can only be used in production if you purchase a license from iText Software. This is also true for iTextSharp, but with iTextSharp, there is no license key that prevents the use if you do not buy a commercial license. For iTextSharp, we count on honesty. For XFA Worker, we took some precautions ;-)