• Post Reply Bookmark Topic Watch Topic
  • New Topic

is it possible to convert reports in jsp to pdf format?

 
vishal shiramshetty
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

I have reports in JAVA SERVER PAGES which i want to convert into pdf format with or with out using third party tools is it possible???

can any one please give me a solution 4 it...

waiting for your replies
[ July 09, 2008: Message edited by: Bear Bibeault ]
 
Gopal krushna Das
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yap it's possible.First of all ypu just do a .csv file and store it.
Then write your code
response.setContentType("text/csv");
response.setHeader("Content-Disposition","filename=\"test.csv\"");
like this in your jsp page....

If you are using any javascript then in onClick function you can write your code like this
jsp page with a button, the javascript onClick() for this button is:
if(flag=="CSV")
{
var fileName = "/eriapps/frameset.do?action=CsvErricsson";
var win1 = window.open(fileName,"_blank",'resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no'); } fileName points to a servlet, SO the servlet class has the following code: theResponse.setContentType("text/csv"); theResponse.setHeader("Content-Disposition","filename=\"test.csv\""); It is a sample example.You can cahnge it as your required file name and all. Thanks Gopal Das
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vishal", please check your private messages for an important administrative matter.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35719
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CSV is easier because it is plain text. You need a library to write out anything in PDF. Some, such as iText, are free.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to avoid 3rd party libraries? Face it, no Java web app of any size is getting done without using a number of other libraries these days.

There's a library called Flying saucer that can convert XHTML + CSS to PDF. So if you generate the HTML page, you could capture the output and generate a PDF from it, assuming that you're generating valid XHTML and are styling the page with CSS (which you should be doing anyway).

A servlet filter that taps into the OutputStream (obtainable from the HttpServletResponse object) would be a good place to put this code.
[ July 09, 2008: Message edited by: Ulf Dittmer ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!