Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to generate PDF report using servlets

 
Harpreet Hira
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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.
 
Nitin Shivaram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • 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.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to look at the Apache FOP project.
Kyle
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic