This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to generate PDF report using servlets" Watch "How to generate PDF report using servlets" New topic
Author

How to generate PDF report using servlets

Harpreet Hira
Ranch Hand

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

Joined: Jan 17, 2001
Posts: 71
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.


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

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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Anonymous
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/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...
 
Don't get me started about those stupid light bulbs.
 
subject: How to generate PDF report using servlets
 
Similar Threads
Generating PDF and RTF file from jsp
Problem in generating pdf Jasper report from large amount of data
Problem in Printing Large Number Of Records in JasperReports
Problem while generating PDF report from Servlet
Generating PDF from Servlets