This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting Html to PDF  RSS feed

 
Nitin Menon
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
sorry... 3 lines of code...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!