Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more: , +
I have tried with iframe , embed and object but nothing gives me the output.

What I have tried:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div class="c-modal__dialog" role="document">
    <div class="c-modal__content">
      <div class="c-modal__header c-modal__header--success">
        <h5 class="c-modal__title">Floor Plan</h5>
      </div>
      <div class="c-modal__body">        
        <iframe src="~file:///C:/uploads/d094a66c-c941-4e1a-98ae-f96aca4048ac.pdf" style="width:680px;max-width:680px; height:500px;" frameborder="0"></iframe>
        <embed src="~file:///C:/uploads/d094a66c-c941-4e1a-98ae-f96aca4048ac.pdf" frameborder="0" style="width:100%;height:600px">
        <object type="application/pdf" data="~file:///C:/uploads/d094a66c-c941-4e1a-98ae-f96aca4048ac.pdf" style="width:100%;height:600px">No Support</object>
      </div>
      <div class="c-modal__footer u-text-right">
        <button type="button" class="c-btn c-btn--secondary" modal-close>Close</button>
      </div>
    </div>
  </div>
Posted
Updated 3-Feb-22 21:19pm
Comments
F-ES Sitecore 27-Aug-19 4:05am    
The problem is that it is a local file and these days browsers tend to not like accessing local files for security reasons. Google "show local pdf file iframe" for questions about similar issues, but there is no universal solution that I'm aware of.

If it isn't a local file and the "c:\uploads" path is on the web server then you need to use an http path to the file on the server. If the file is outside of the websites file structure then you'll need some intermediate page on the website that will stream the desired file to the client. If you google "asp.net stream pdf file to client" you'll probably find examples of how to do that.

You can use Google Doc :

HTML
<iframe src="https://docs.google.com/gview?url=https://path.com/yourpdf.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


But your file must be online.
 
Share this answer
 
v3
You can also embed the pdf inside the modal. Like this:
<embed src="sample.pdf" frameborder="0" width="100%" height="400px">
That worked for me
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900