my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rendering PDF in browser using Flying Saucer
 
Similar Threads
Create PDF in Landscape using ITextRenderer
flying saucer not converting cellspacing html property properly into pdf
I am trying to generate a PDF file in Hibernate
flying saucer not identifying   of html
How to save a webpage as PDF ?