• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Rendering PDF in browser using Flying Saucer

 
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 ?
 
Ranch Hand
Posts: 349
Hibernate Eclipse IDE 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.
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!