the code is:
public class PrintProtocolUsePdfAction
extends org.apache.struts.action.Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.setHeader("Cache-Control", "max-age=30");
response.setHeader("Content-Type", "application/pdf");
PdfReader reader = new PdfReader("D:\\Tomcat 4.1\\webapps\\tms\\docs\\protocol1.pdf");
PdfStamper stamp = new PdfStamper(reader,new FileOutputStream("D:\\Tomcat 4.1\\webapps\\tms\\docs\\obj.pdf"));//(1)
// PdfStamper stamp = new PdfStamper(reader,baos);//(2)
AcroFields aform = stamp.getAcroFields();
aform.setField("text1", "hello,iText");
stamp.setFormFlattening(true);
ServletOutputStream out= response.getOutputStream();
baos.flush();
baos.writeTo(out);
stamp.close();
out.flush();
baos.reset();
return null
}
}
notes: (1)write to file,and it is ok! (2)write to browser,then it doesn't work.why? thanks again.
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions