I am displaying few tables using HTML table tag and CSS . I am using Struts 2 and would like to include the "Export to PDF" functionality. Right now its just one page where i have to use this. Later one there will be one or two more page where i have to use this feature. I am Looking for some easy to implement available plugins or jar or anything that can be used to do that.
Asked
Active
Viewed 1,563 times
-2
-
In http://stackoverflow.com/questions/6118635/what-is-the-best-pdf-open-source-library-for-java, people discussed free pdf library for java – Arthur Spirke Sep 03 '13 at 19:17
1 Answers
1
There is a Java API for generating PDF.
Here it is: http://itextpdf.com/download.php
Call it from you Servlet or Struts Action, and use HttpServletRersponse.getOutputStream to direct the PDF document back to the browser.

NickJ
- 9,380
- 9
- 51
- 74
-
But this requires me to give all the inputs from java class itself, like giving table and column and row size and CSS class and all..I was looking for something which can simply ask the user to save the option of whatever is there on that page. for example when we print the page using CTRL P then it ask us to save the document in pdf format. – promil pandey Sep 03 '13 at 20:34
-
I was assuming the contents of your HTML table were generated by the Servlet, in which case it can just as easily put them into a PDF document as well. – NickJ Sep 04 '13 at 08:32