0

I am trying to load pdf in iframe when clicked on Open PDF on this same page below the table. This pdf is opening on the new tab when I use target=blank but is not opening in iframe.

<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>
Amit Kumar Lal
  • 5,537
  • 3
  • 19
  • 37
vivek sharma
  • 19
  • 1
  • 1
  • 8
  • The pdf opened in new tab actually is opened by browser, so it can't be shown in iframe, if you really want to open pdf in iframe, you can use some js library to render pdf file, like pdf.js [https://mozilla.github.io/pdf.js/] – Peter-Yu Sep 06 '19 at 05:37
  • please read these links which already discusses on this topic: https://stackoverflow.com/questions/19654577/html-embedded-pdf-iframe https://stackoverflow.com/questions/12974115/how-to-open-a-pdf-file-in-an-iframe – Suriyakanth Sep 06 '19 at 05:46

1 Answers1

0

I am using bootstrap 4 for my one of the theme and I open modal on button click and in that modal I put the iframe for open my PFD. you may also try this once. if you are not using bootstrap you can create your own customize modal.

<a href="javascript:void(0);" data-toggle="modal" data-target="#staffInformationForCBSE">

<div class="modal fade" id="staffInformationForCBSE">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title text_orange">Staff Information for CBSE</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body">
                <iframe class="pdf_documents" src="documents/StaffInfoForCBSE.pdf"></iframe>
            </div>
        </div>
    </div>
</div>
KuldipKoradia
  • 3,005
  • 7
  • 20