开发者

Display PDF file in modal window

Is there any way I can direct disp开发者_如何学Pythonlay 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?


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?


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">


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜