【发布时间】:2019-09-06 05:29:58
【问题描述】:
单击表格下方同一页面上的打开 PDF 时,我试图在 iframe 中加载 pdf。 当我使用 target=blank 但未在 iframe 中打开时,此 pdf 在新选项卡上打开。
<c:forEach items="${files}" var="file">
<tr>
<td>${file.name}</td>
<td>${file.createdOn}</td>
<td><a href="http://localhost:8080/dms/getFile?filePath=${file.realPath}" target="search_iframe">Open PDF</a></td>
</tr>
</c:forEach>
</table>
<iframe src="" width="100%" height="100%" name="search_iframe"></iframe>
</body>
【问题讨论】:
-
新标签页打开的pdf实际上是浏览器打开的,所以无法在iframe中显示,如果真的想在iframe中打开pdf,可以使用一些js库渲染pdf文件,比如 pdf.js [mozilla.github.io/pdf.js/]
标签: html spring-boot jstl