1

I have jsp with one button download pdf. Here is a table with some welcome phrases and some geter or setter properties

<HTML>
<body>
 <%
        String value = "12324";
        String email = "abc@gmail.com";
        %>
<h3>Welcome to the system. To download this form click on "Download PDF" </h3> 
                     <jsp:useBean id="myBean" scope="session" class="VU.viechelInfoClass" />
                     <jsp:getProperty name="myBean" property="model" />
                     <table border="1" width="20%" height="50" >
                         <thead>
                             <tr>
                                 <th>#</th>
                                 <th>1</th>
                                 <th>2</th>
                                 <th>3</th>
                                 <th>4</th>
                             </tr>
                         </thead>
                         <tbody width="20%" height="50" >
                             <tr>
                                 <td><%= value %> </td>
                                 <td><%= email %></td>
                                 <td> email </td>
                                 <td>name </td>
                                 <td>Address </td>
                             </tr>
                             <tr>
                                 <td> id </td>
                                 <td> Quiz</td>
                                 <td> email </td>
                                 <td>name</td>
                                 <td>Address </td>
                             </tr>
                             
                         </tbody>
                     </table>

    <br>
    <input type="submit" value="Download PDF" />


    </form>
</body>
</HTML>

When download button clicked I got this jsp in pdf format but it is not showing data properly in table? Is this possible? How to do it please? it shows this type of output in pdf :( I want to get whole table properly

Please share some informative tips.

Community
  • 1
  • 1
Fatima Eman
  • 27
  • 1
  • 3
  • 12
  • You are going to need to use a PDF library (like **IText**) to recreate the page yourself if you don't wan't to use the Browser Print Tools. – AxelH Nov 21 '16 at 11:38
  • Possible duplicate of [how to save a jsp page as pdf in java?](http://stackoverflow.com/questions/29386585/how-to-save-a-jsp-page-as-pdf-in-java) or any other page for this [search](http://stackoverflow.com/search?tab=relevance&q=jsp%20page%20pdf) – AxelH Nov 21 '16 at 11:39
  • Possible duplicate of [Is it possible to save HTML page as PDF using JavaScript or jquery?](http://stackoverflow.com/questions/6896592/is-it-possible-to-save-html-page-as-pdf-using-javascript-or-jquery) – Jerry Chin Nov 21 '16 at 11:48

1 Answers1

0

I have used a simple alternative, that is print pdf Code for button is here

<input type="submit" value="Download PDF" name="download" onclick="window.print()" /> 

Now I am able to print it in any format doc, pdf etc and entries will look like as given in jsp table format.

Fatima Eman
  • 27
  • 1
  • 3
  • 12