aspose file tools*
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
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...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to generate PDF report using servlets