[EMAIL PROTECTED] wrote:
Hi,

I'm trying to load an existing Pdf document (with PdfReader), change a few of the AcroFields, flatening the results and displaying the new pdf file on screen. I have been able to read the original Pdf successfully, been able to change the fields succesfully and flaten its results. But now I need to display the new file on screen instead of save it on disc (with the stamper.close()).

In other words: you have been able to save
the PDF on the server side, but now you want
to send the PDF to the browser (which is not
the same as 'display the new file on screen')

How do I do that?

Write the PDF to memory instead of to a file.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfStamper copy = new PdfStamper(reader, baos);
After closing the stamper do this:

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());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();

I looked at some example on-line, but I found pieces, but can't put them together.

It's quite easy.
br,
Bruno


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to