简体   繁体   中英

C# to read XFA form data

I am trying to programmatically read the field values from a Livecycle created form. I tried opening the document using the Acrobat COM component and it seemed to work and with some reflection I managed to get the actual field names, but the value for each field is the hard part, as it seems.

Furthermore, I know believe that I actually need to use a different approach to extract the values, since it is an XFA form PDF.

(Please don't tell me to look into the examples provided in the Adobe PDF SDK, because they are very poor and absolutely useless to my issue - I already read all I could from the Adobe documentation).

Thank you all.

I use iText/iTextSharp when working with both Acrobat and LiveCycle (XFA) forms. You need need to get access to the LiveCycle XML DOM as the starting point:

iTextSharp Example:

string sourcePdf = @"c:\livecycle.pdf";<br>
PdfReader reader = new PdfReader(sourcePdf);<br>
XmlDocument xmlDoc = reader.AcroFields.Xfa.DomDocument;

You'll need to familiarize yourself with the XFA specification to work with the DOM.

Perhaps, you could use a third-party library, such as ABCPdf to extract field values (this is not an advertisement, I used this library in a similar case, though some time ago).

Another opportunity is that if the PDF in question is under your control, you can use the HTTP-post facility of the LifeCycle-generated PDF files (AFAIK, they can send the values of the fields to a pre-configured Web address once the user pushed the Send button).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM