Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Converting Html to PDF

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
there's a requirement in my project to convert html to .xls and .pdf format. i accomplished the .xls conversion. can anyone help me with converting html to pdf?
in .xls conversion i included two lines of codes in the start of the page.

<%
response.reset();
response.setHeader("Content-type","application/vnd.ms-excel");
response.setHeader("Content-disposition","inline; filename=ExpenseAson.xls");
%>

what code do i add for .pdf conversion...?

thanks in advance....
 
Nitin Menon
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry... 3 lines of code...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't generate PDF from a JSP template. You will have to generate it with a specific PDF generating tool such as FOP or iText and give a link to the binary data in a link to a servlet that can formulate the response correctly.

Remember, JSP is for HTML formatted character data, binary data should be handled by servlets.

Bill
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to clarify, you haven't converted anything to XLS. You have created a page that will be opened by Excel, which happens to be able to make sense of some HTML pages. That's all. Don't be surprised if you make a change to the HTML page and find that Excel does not understand it any longer.

As to PDF, if your pages are XHTML styled with CSS, you may be able to use the FlyingSaucer library to create PDFs from them.
 
Nitin Menon
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
exactly Ulf. sorry for the use of the wrong word. infact, i just want to generate the html result as a pdf file.
 
reply
    Bookmark Topic Watch Topic
  • New Topic