0

I want to open a pdf file on my html document, but the file won't open. Chrome said

Failed to load PDF document.

Please help.

the pdf and the html are on the same location on the localhost of my computer.

<!DOCTYPE html>
<html>
    <body>
        <embed src="1.pdf" width="500" height="375" type='application/pdf'>
    </body>
</html>
Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
knowmeifyou
  • 217
  • 7
  • 17

2 Answers2

0

below code are working for PDF in chrome browser

<object data="Certification-Study-Guide-MCD-v2.2.pdf" type="application/pdf">
   <embed src="Certification-Study-Guide-MCD-v2.2.pdf" type="application/pdf" />
</object>

<iframe id="iframepdf" src="Certification-Study-Guide-MCD-v2.2.pdf"></iframe>
Dhaval Patel
  • 1,076
  • 6
  • 19
0

After Struggling with this problem i came to solution, By Referring this Link Here. Hope this help someone.

JS:

var file = b64toBlob(pdfBase64, 'application/pdf');//pdfBase64 without content type 
var fileURL = URL.createObjectURL(file);

HTML

//Added dynamically by Jquery in my case
<iframe src="'+fileURL +'" style="width:600px; height:500px;" frameborder="0"></iframe>