Strange problem, I use the following method to stream a pdf to a browser

 private void streamToDownload(HttpServletResponse response,
ByteArrayOutputStream baos, String contentType,
            String downloadFileName) throws ServletException
    {
        try
        {
                ServletOutputStream servletOutputStream =
response.getOutputStream();
            byte[] bytes = baos.toByteArray();
            servletOutputStream.write(bytes, 0, bytes.length);
            response.setContentType(contentType);
            response.setHeader("content-disposition", "attachment;
filename=" + downloadFileName);
            response.setContentLength(bytes.length);
            servletOutputStream.flush();
            servletOutputStream.close();
        }
        catch (IOException e)
        {
            throw new ServletException(e);
        }
    }


It works fine, the user is prompted to save or open the file in the default
application.

However; this is the weird part, as soon as an image is added to the PDF, or
another PDF is used as a background for the PDF created with iText, the pdf
opens in the browser, not at all the behaviour I want.

Is there something about images or PDFs that "over rides" the content
dispostion?  That doesn't make sense, but if I had an explantion for this
behaviour I wouldn't be posting here right?

Thanks for any help

-- 
View this message in context: 
http://www.nabble.com/Streaming-PDF-from-servlet-problem-tf4759225.html#a13610196
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to