Saurabh Dwivedi
Saurabh Dwivedi

Reputation: 39

Opening a local pdf file in iframe with javascript

I am using the below code to open a pdf file but its not working-

<iframe src="file:///C:\Users\Downloads\0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>

For a google doc the below code is working fine, I am not sure what is required to open a locally saved doc.

<iframe src="http://docs.google.com/gview?url=http://webshire-aioopsss.com/pdfs/sample_contract.pdf&embedded=true" style="height:638px;" frameborder="0"></iframe>

Upvotes: 1

Views: 12527

Answers (3)

zeah
zeah

Reputation: 254

You can use var pdf = $('\<\object type="application/pdf">'); pdf.attr('data', "you pdf scr"); append it in your iframe..

Upvotes: 0

SliderBlackrose
SliderBlackrose

Reputation: 121

Most browsers won't let you open a locally stored file from a website for security reasons. Typically I will host the file on an IIS server and then retrieve it from there (which is what you're doing when you're retrieving it from googledoc).

Upvotes: 2

Simon Kraemer
Simon Kraemer

Reputation: 5680

You are using backslashes in your src. Please change them to slashes

<iframe src="file:///C:/Users/Downloads/0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>

Upvotes: 0

Related Questions