问题
We are Not able to Save the POST data contents from an XFDF form. The POST event is triggered using a button inside the PDF.
We are using Java + SPRING on server side.
EXCEPTION:
java.io.IOException: Expected > for tag: <{1}/> near line 1, column 13
Observed the same error in itext demo page too! Here it is: http://itextpdf.com:8180/book/xfdf
Please help us finding the solution.
[MORE DETAILS]
The error is reproducible in the iText demo page itself. Url:http://itextpdf.com:8180/book/xfdf We can notice it in the ajax response part after submitting the form.
By the way, here is the input, ouput and source code in our app.
HTTP POST INPUT DATA:
%FDF-1.2
1 0 obj
<</FDF<</F<</Type/Filespec/F(http///localhost/8081/triplefin/document/download/4)/UF(http///localhost/8081/triplefin/document/download/4)>>/Fields[<</T(pat_name)/V(sample)>><</T(member_number)>><</T(p_add)>><</T(p_city)>><</T(p_state)>><</T(p_zip)>><</T(pat_phone)>><</T(pat_dob)>><</T(doc_name)/V(provider1)>><</T(doc_add)/V(7/15 krishna nagar)>><</T(doc_city)/V(coimbatore)>><</T(doc_state)/V(641041)>><</T(doc_zip)>><</T(doc_phone)/V(1232131)>><</T(doc_fax)/V(023423423)>><</T(specialty)>><</T(npi_number)>><</T(drug)>><</T(drug_dosage)>><</T(rx_direction)>><</T(Diagnosis)>><</T(pat_start_date)>><</T(alternatives_used)>><</T(non_formulary_reason)>><</T(addi_treatment)>><</T(doc_signature)>><</T(doc_sig_date)>>]>>>>
endobj
trailer
<</Root 1 0 R>>
%%EO
DETAILED EXCEPTION MESSAGE:
java.io.IOException: Expected > for tag: <{1}/> near line 1, column 13
at com.itextpdf.text.xml.simpleparser.SimpleXMLParser.throwException(SimpleXMLParser.java:594)
at com.itextpdf.text.xml.simpleparser.SimpleXMLParser.go(SimpleXMLParser.java:353)
at com.itextpdf.text.xml.simpleparser.SimpleXMLParser.parse(SimpleXMLParser.java:607)
at com.itextpdf.text.xml.simpleparser.SimpleXMLParser.parse(SimpleXMLParser.java:682)
at com.itextpdf.text.xml.simpleparser.SimpleXMLParser.parse(SimpleXMLParser.java:648)
at com.itextpdf.text.pdf.XfdfReader.<init>(XfdfReader.java:113)
SOURCE CODE:
public void savePostDataToPdf(String pdfFileAbsolutePathString, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
XfdfReader xfdfReaderObject = new XfdfReader(request.getInputStream()); //ERROR IS HERE!
}
回答1:
The problem is you're posting FDF data but using the XFDF reader. FDF and XFDF are different formats, and the XFDF reader is treating it as an XML string and throwing an error about unclosed tags.
If you're just providing FDF files, you'd want something like:
FdfReader fdfReaderObject = new FdfReader(request.getInputStream());
来源:https://stackoverflow.com/questions/20986163/not-able-to-save-the-post-data-contents-of-an-xfdf-form