aspose file tools*
The moose likes Other Open Source Projects and the fly likes Rendering PDF in browser using Flying Saucer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Rendering PDF in browser using Flying Saucer" Watch "Rendering PDF in browser using Flying Saucer" New topic
Author

Rendering PDF in browser using Flying Saucer

Suzi Cooper
Ranch Hand

Joined: Jul 23, 2005
Posts: 45
Hi guys,

I am trying to create a pdf(using Flying Saucer) and display it in the browser but i keep getting a blank page. Here's a code snippet :

########

// read XML and convert to pdf
String inputFile = "weather.xml";


ByteArrayOutputStream baos = new ByteArrayOutputStream();

ITextRenderer renderer = new ITextRenderer(900,200);
renderer.setDocument(new File(inputFile));
renderer.layout();
renderer.createPDF(baos);


response.reset();
response.setContentType("application/pdf");
response.setContentLength(baos.size());

ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();

###########

Anyone any ideas ?
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Did you try writing the pdf to the file system? Are you able to get the pdf?

Ananth Chellathurai


Ananth Chellathurai [Walk on software]
Suzi Cooper
Ranch Hand

Joined: Jul 23, 2005
Posts: 45
I am able to create a PDF locally.But i want it to be rendered to the browser instead.
 
 
subject: Rendering PDF in browser using Flying Saucer