On Wed, 8 Nov 2006, Ute Hoffmann wrote:

Hallo,
is there someone around who has solved this problem:
- I use WebPdfReports
- I need to have it use the right header for Download of the generated pdf-Files for InternetExplorer 6.x, which throws an exception with the default implementation (under ssl, but I suspect the ssl does not make the difference).

So I would like to pass my headers via appendToResponse.

If I put it into the page I generate the pdf from under append to response and a var, which is set to true while the pdf generation takes place, it seems the header are not set or overwritten.

If I try to use pdfPage.appendToResonse I end up with "no instance available" in place of the pdf.

Can someone please advice?

There might be a better way, but here's what I use (I don;t specifically use WebPdfReports, so you'll have to work that out).

private static String ERROR_MSG = "<html><head><title>Oops</title></head><body><div align=\"center\">There was an error creating your report. Please try again later.</div></body></html>";


    public WOResponse getResponse() {
        WOResponse aResponse;
        byte[] pdf;

        aResponse = new WOResponse() {
            // IE 6 requires that the response be cache-able so that it can
            // pass the content to another program.  override WO's default
            // cache-preventing behaviour here and set headers below.
            public void disableClientCaching() {
                /* do nothing */;
            }
            public boolean _isClientCachingEnabled() {
                return true;
            }
        };
        pdf = null;
        try {
            pdf = getReport();
        } catch (Exception e) {
            System.err.println("Exception generating PDF: " + e);
            e.printStackTrace(System.err);
        }

        if (pdf != null) {
            aResponse.setContent(new NSData(pdf));
            aResponse.setHeader("application/pdf", "Content-Type");
            aResponse.setHeader("attachment; filename=\"rpt-" + (reportNo++) + ".pdf\"", 
"Content-Disposition");
            aResponse.setHeader("public", "Cache-Control");
            aResponse.setHeader("cache", "Pragma");
            aResponse.setHeader(Integer.toString(pdf.length), "Content-Length");
            aResponse.setHeader("Report PDF", "Content-Description");
        } else {
            aResponse.setContent(ERROR_MSG);
            aResponse.setHeader("text/html", "content-type");
        }

        return aResponse;
    }

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to