Trying to open a .pdf file in an iframe

carlg picture carlg · May 1, 2013 · Viewed 7.3k times · Source

I am really having a hard time opening up certain .pdf files within an iframe HTML element. I can open some .pdf files in this iframe, but not all of them. The ones that I cannot open were created by the Crystal Reports engine in Visual Studio 2010.

My source is simple and looks like the following:

<iframe src= "c:\jnk\EULA.pdf">
</iframe>

Is there any characteristic of a .pdf file that could prevent it from being displayed in an iframe? I am using IE8, but get the same results in FF. I also can perfectly display this .pdf file when it is not in an iframe.

Answer

TN888 picture TN888 · May 1, 2013

IFrame isn't correct solution. You can use other solutions :

1 . <embed src="file:///C:\jnk\EULA.pdf" width="500" height="375">

2 . Download this library and use it.

I hope that I helped.

PS Remember that when we use local file, we should write in prefix file:///

Sorry for my English