By Date: <-- -->
By Thread: <-- -->

Regenerate a PDF file form ServletInputStream.



AnhTuan Nguyen wrote:

The PDF form is submitted to Tomcat server with PDF format, and i used the ServletInputStream (javax.servlet. to gererate the PDF file from PDF client. This is my code:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintFDF(request, response, "POST");
}

I assume that this is a typo. Either you should call makePdf, or the name of the method below should be PrintPDF.

public void makePdf(HttpServletRequest request, HttpServletResponse response, String methodGetPost)
throws ServletException, IOException {
try {
File tempFile = new File("c:\\test.pdf");
FileOutputStream fout = new FileOutputStream(tempFile);
BufferedInputStream bin = new BufferedInputStream(request.getInputStream());
BufferedOutputStream bout = new BufferedOutputStream(fout);
byte[] buf = new byte[8 * 1024];
int len;
while ((len = bin.read(buf)) > -1) {
bout.write(buf, 0, len);
}
bout.close();
bin.close();
} catch (Exception e2) { }
}
The result file (test.pdf) is different with the original file in size and version.

If I understand well, the end user has a file, for instance form.pdf. He may or may not fill in fields. Then he clicks on a button that submits form.pdf as PDF.

Why do you think the file that is received on the server side
should have the same size??? That's an incorrect assumption.

I think you will even see file differences that depend on the
version of Adobe Reader that was used to submit the PDF.
br,
Bruno


------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions (at) lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions