问题
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.
回答1:
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.
回答2:
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).
来源:https://stackoverflow.com/questions/8990235/c-sharp-to-read-xfa-form-data