按钮单击时,以PDF格式下载jsp表

时间:2016-11-21 11:30:45

标签: java jsp pdf

我有一个按钮下载pdf的jsp。 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>

点击下载按钮后,我得到了pdf格式的jsp,但它没有在表格中正确显示数据?这可能吗?怎么办呢? it shows this type of output in pdf :( I want to get whole table properly

请分享一些信息性提示。

1 个答案:

答案 0 :(得分:0)

我使用了一个简单的替代方案,即print pdf 按钮的代码在这里

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

现在我能够以任何格式doc,pdf等打印它,条目看起来像jsp表格式。