Hi,
I had the same problem:
For me it worked to change the name of the servlet (let's say report to
report.pdf)
For outputting I use the function:
public void renderFO( Document doc, HttpServletResponse
response,HttpServletRequest request ) throws Exception {
// Create the PDF.
ByteArrayOutputStream out = new ByteArrayOutputStream();
MessageHandler.setOutputMethod( MessageHandler.NONE );
Driver driver = new Driver();
driver.setRenderer( Driver.RENDER_PDF );
driver.addElementMapping(
"org.apache.fop.fo.StandardElementMapping");
driver.addElementMapping( "org.apache.fop.svg.SVGElementMapping" );
try {
driver.setOutputStream( out );
driver.render( doc );
}
catch ( Exception ex ) {
cat.error(ex);
}
finally {
try {
out.close();
}
catch ( IOException e ) {
}
}
byte[] content = out.toByteArray();
response.setContentLength( content.length );
response.setContentType( "application/pdf" );
response.addHeader( "Content-Disposition",
"inline;filename=report.pdf" );
response.getOutputStream().write( content );
response.getOutputStream().flush();
}
Just try, for me it works
Jens
"Rajagopal. V" schrieb:
> Hi
> Im using a JSP to generate this PDF. I am able to open
> other "Static" pdfs.
> This is what i do, i create a bytearrayoutputstream
> which will hold the output of the render and then use
> a
>
> pageContext.getOut().print(<bytearrayoutputstreamobject>);
>
> and this results in printing binary content on the
> screen.. I assume this is bcoz IE doesnt recognize the
> content type and print jst prints it on the screen,
> whereas Netscape understands the Content Type and
> displays it as a PDF.
> I tried to create a servlet which will generate the
> PDF(using streams to generate the output) and it works
> in IE and Netscape.
>
> Now, is it not possible to render a PDF using
> JSP(especially on IE)?? IS there a way?
>
> Thanks
> Raj
>
> --- Amit <[EMAIL PROTECTED]> wrote:
> > Can you open other pdf files (via a link in a html
> > page) in IE?
> >
> >
> > "Rajagopal. V" wrote:
> >
> > > Hi All
> > > I have an XML file which i combine with a XSL to
> > > generate the FO file and render it. It works fine
> > with
> > > Netscape but im having a tough time with IE. It is
> > > displaying garbage on teh screen. All i get is
> > binary
> > > characters for the PDF File. I have IE 5.5 Sp1.
> > and i
> > > tried all the workarounds. These are the ones I
> > tried
> > > 1) Changed the name of the file to be .pdf so that
> > IE
> > > will look at the extension and treat it as PDF
> > >
> > > 2) Bloated the file size to be more than 8k so
> > that
> > > there is no buffer problem with IE
> > >
> > > 3) Downloaded the Fo file generated and ran the fo
> > > command line and it generates the PDF properly(as
> > an
> > > application). So there is nothing wrong with the
> > FO.
> > >
> > > IS there any other way to get a PDF on IE? Im not
> > sure
> > > why im getting binary content all over the screen?
> > >
> > > Please HElpppppp...
> > >
> > > TIA
> > > Raj
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Make a great connection at Yahoo! Personals.
> > > http://personals.yahoo.com
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, email:
> > [EMAIL PROTECTED]
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, email:
> > [EMAIL PROTECTED]
> >
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]