【发布时间】:2012-03-28 19:39:27
【问题描述】:
我的问题非常简单,我只需要一个技巧来解决它
我的项目文件夹中有 5 个 pdf 文件,例如 file1.pdf、file2.pdf、file3.pdf、file4.pdf 和 file5.pdf。我在 5 行中显示这些 pdf 文件,并且在每一行中,我在 index.jsp 中给出了两个按钮,即 VIEW 和 PRINT。
如果单击 VIEW 按钮,那么我想查看相应的 pdf 文件,如果单击 PRINT 按钮,那么相应的 pdf 文件将被发送到打印屏幕。我有很多 pdf 文件,所以我没有在 index.jsp 中写这些 pdf 文件名,而是创建了一个表 pdf_file 并有一列 pdf_file_name。
当在该行中单击该按钮(查看或打印)时,我如何查看和打印相应的 pdf 文件?
<%
ps=('select distinct pdf_file_name from pdf_file');
//ResultSet rs=ps.executeQuery();
.............
%>
<table>
<tr>
<td>
PDF FILE NAMES click on a respective pdf file to view or print
</td>
</tr>
<tr><td>
<a href='<%=pdf_file_name%>'><%=pdf_file_name%></a>
<input type="button" value="View">// button to view that respective pdf file
<input type="button" value="Print">// button to print that respective pdf file
</td>
</tr>
</table>
【问题讨论】:
-
有用的问题,所以+1。但是你已经尝试过了。
-
我尝试在按钮中使用
window.print(); by onclick event,但 index.jsp 正在进入打印屏幕,但我希望file1.pdf进入打印屏幕 -
参考这个链接,你可能会得到一些帮助stackoverflow.com/questions/687675/…
-
是的,它对我有所帮助,但我的问题略有不同,所以我的问题有什么解决方案吗?如何通过单击按钮查看/打印 pdf 文件?
标签: javascript html jsp printing