php - XAMPP iframe not working inside localhost
I am trying to use an iframe to embed a pdf into a webpage. for some reason the pdf wont display (appears blank) and i'm prompted to download the file. This happens when i run the code from localhost server. however if i run the code outside localhost the iframe displays the pdf doc as it should. i have also tried using<embed>
,<object>
and pdf.js they all gave the same outcome.
PHP FILE
echo'<div class="main_content_view">
<iframe src="pdf/pdf1.pdf" id="pdf_content"
width="700px" height="800px">
</iframe>
</div>
';
i've also tried adding$cfg['AllowThirdPartyFraming'] = true;
to the config.inc.php and it still didnt work. Any ideas on how i could get the pdf to display in localhost as it does when i right click and open the php directly with a browser?
Answer
Solution:
The thing is probably that a simple iFrame does not support viewing a PDF file. And afaik PDF.js is only for Firefox browser but I am not entirely sure about that. What you can try is PDFObject. This lets you dynamically embed your PDF in HTML documents using JS.