Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"vishal", please check your private messages for an important administrative matter.
 
author & internet detective
Posts: 40795
828
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic