views:

323

answers:

6

I have a pdf file that the user has to see and click on the "I agree" button. How do you display a pdf inside a div?

+1  A: 

I don't think you can. You may need to use an Iframe instead.

Diodeus
+1  A: 

We use this on our website

http://issuu.com/smartlook

Its a very customizable to display PDF's directly in your browser. It basically hosts the PDF in a flash object if you are not opposed to that sort of thing.

Here is a sample from our corporate website.

Jason Watts
That's pretty cool.
Diodeus
+1  A: 

You could create an image thumbnail, and link it to the actual pdf as an inline popup using something like http://orangoo.com/labs/GreyBox/

Bala R
+3  A: 

You cannot, and here is the simple answer.

Every media asset poured into the browser is identified by a mime type name. A browser then makes processing determinations upon that mime type name. If it is image/gif or image/jpeg the browser processes the asset as an image. If it is text/css or text/javascript it is processed as a code asset unless the asset is addressed independent of HTML. PDF is identified as application/pdf. When browsers see application/pdf they immediately switch processing to a plugin software capable of processing that media type. If you attempt to push media of type application/pdf into a div the browser will likely throw an error to the user. Typically files of type application/pdf are linked to directly so that the processing software an intercept the request and process the media independent of the browser.

+1  A: 
Nitz
+2  A: 

Yes you can. See the following thread from 2007:

http://www.webdeveloper.com/forum/showthread.php?t=152923

It uses < object >, which can be styled with CSS, and so you can float them, give them borders, etc.

(In the end, I edited my pdf files to remove large borders and converted them to jpg images.)

Ron Knee
Code: <div> <object data="test.pdf" type="application/pdf" width="300" height="200"> alt : <a href="test.pdf">test.pdf</a> </object> </div>
Matthijs Bierman