This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to generate PDF report using servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to generate PDF report using servlets" Watch "How to generate PDF report using servlets" New topic

How to generate PDF report using servlets

Harpreet Hira
Ranch Hand

Joined: Sep 27, 2001
Posts: 72
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

Joined: Jan 17, 2001
Posts: 71
there is this open source API, you might want to check it out.
Let me just warn you that the Javadocs are not descriptive enough.

Nitin S<br />Sun Certified Java Programmer for the Java 2 platform.<br />Tekmetrics Certified Java Programmer For the Java 2 Platform.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
You might want to look at the Apache FOP project.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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/"); // for Excel
response.setContentType("application/msword"); // for word documents.

Have a look here (this is where I got the idea)
(Chapter 11)
good luck...
I agree. Here's the link:
subject: How to generate PDF report using servlets
It's not a secret anymore!