• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rendering PDF in browser using Flying Saucer

 
Suzi Cooper
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try writing the pdf to the file system? Are you able to get the pdf?

Ananth Chellathurai
 
Suzi Cooper
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to create a PDF locally.But i want it to be rendered to the browser instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic