Shishant
Shishant

Reputation: 9294

Display PDF file in modal window

Is there any way I can direct display PDF files in modal boxes?

I am using CodeIgniter PHP framework and jQuery as JavaScript framework.


UPDATE: I read on net that this is possible by loading it in iframe, and Adobe PDF will render it, but many seems to oppose, so is there any way I can convert those PDFs to images?

Upvotes: 1

Views: 11416

Answers (3)

Arda Xi
Arda Xi

Reputation: 2666

If you really want to, you can just embed it as a normal object. For example:

<object type="application/pdf" data="embeddedfile.pdf" width="500" height="650">

Upvotes: 1

J&#248;rn Schou-Rode
J&#248;rn Schou-Rode

Reputation: 38346

Short answer: No.

Longer answer: Usually, PDF documents are not rendered by the browser directly, but rather by some specialized PDF reader. As soon as the browser sees a content type of application/pdf, it passes the response along to the reader. Nothing you would do in your HTTP headers, HTML or JavaScript would make it across the gap between the browser and that other program, and the PDF format itself contains no switch to enable any kind of modal user interface.

Update: Rendering the PDF as an image would allow you to display the graphical content of the document in a more modal fashion. You still are not able to block the user from closing the browser, but you would be able to "lock down" anything else on your page while the image is displayed.

Related: How do I convert a PDF document to a preview image in PHP?

Upvotes: 4

rkulla
rkulla

Reputation: 2524

That's a bad idea. Always let the user set their browser to how they want to handle PDF files. So just create a link to the pdf. Modal windows aren't for that purpose anyway.

Upvotes: 0

Related Questions