Choose one: - the field names are not correct - it's a Designer created form and you are using an old iText version - none of the above
Paulo > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Oliver Schoenwald > Sent: Friday, June 29, 2007 1:45 PM > To: iText-questions@lists.sourceforge.net > Subject: [iText-questions] Fill PDF-Document Formfields > during Download byServlet > > Hello, > > I'm pretty new to this mailing list. So far I couldn't find a similar > question in the last postings, so if I happen to ask > something that has > been discussed before, please route me to that thread. > > I want to write a Java-Servlet using itext, which will open a certain > PDF-document with prepared form-fields (for adress, date, some other > textual content, empty by default) when called by the client. The > servlet should take some data from our database and fill the > form-fields > of the PDF-document before giving it to the response of the request. > > In my current approach I tried to use PDFReader and > PDFStamper to open > the PDF-document and to fill the relevant fields with > setField(). Then I > would send he Output of PdfStamper into the response-stream. However, > the Client only gets the empty document, no filled fields. What am I > doing wrong? > > Here is the java method that I use to open the document, fill > its fields > and deliver the filled-out document to the user: > > --- snip --- > public void fillAndDeliver(HttpServletResponse response, > String pdfdoc, > String address, String content) { > > PdfReader reader = new PdfReader(pdfdoc); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > > // Fill the Fields > PdfStamper stamp = new PdfStamper(reader, baos); > AcroFields form = stamp.getAcroFields(); > form.setField("address", address); > form.setField("content", content); > stamp.close(); > > // setting some response headers > response.setHeader("Expires", "0"); > response.setHeader("Cache-Control", "must-revalidate, > post-check=0, pre-check=0"); > response.setHeader("Pragma", "public"); > response.setContentType("application/pdf"); > response.setContentLength(baos.size()); > > // write ByteArrayOutputStream to the ServletOutputStream > ServletOutputStream out = response.getOutputStream(); > baos.writeTo(out); > out.flush(); > > return; > } > --- snip! --- > > Thank you in advance, > > Oliver Schönwald > > -- > Oliver Schönwald, Diplom-Informatiker > > FernUniversität Hagen > Zentrum für IT und Medien (ZMI) - Competence Center > Anwendungsentwicklung > Universitätsstr.21/AVZ - 58084 Hagen - Deutschland > fon: +49 2331 987 1721 - email: [EMAIL PROTECTED] > > Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/