Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to generate PDF report using servlets

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to generate reports using JSP/Servlets. I can generate an HTML report, but this report is not good for printing as the formatting changes from browser to browser depending upon the settings of the browser(like font, size). I have heard that it is possible to generate PDF documents from the servlets/java classes dynamically.
I would be happy if some one could help me out.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Harpreet,
there is this open source API, you might want to check it out.
Java-PDF API
Let me just warn you that the Javadocs are not descriptive enough.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to look at the Apache FOP project.
Kyle
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want an alternative to HTML reports, then you could also try outputing to Word/Excel. This can be simply achieved by setting the response content type in your servlet ...

response.setContentType("application/vnd.ms-excel"); // for Excel
or
response.setContentType("application/msword"); // for word documents.

Have a look here (this is where I got the idea)
http://pdf.coreservlets.com/
(Chapter 11)
good luck...
 
reply
    Bookmark Topic Watch Topic
  • New Topic