-->

Alternate method of inserting a .PDF file into HTM

2019-07-12 15:09发布

问题:

Currently I'm using an embed tag with the src directed to the location of the .pdf however the embed tag does not allow for z-index manipulation or other div tags to be placed over it. After extensive searching for a fix to allow for embed tag z-index manipulation I have found that it is adobe that will not allow this to happen with their pdf files.

I need a way to insert (without using embed or iframe tags) a pdf document into an html page and allow other divs to overlap it.

Please Help!

回答1:

The <object> tag, maybe? If that won't do it, Adobe's probably going to win this one.



回答2:

You could drop the Acrobat plugin and use a server side tool to render the PDF to an image. Display that image on your page and overlay it with whatever divs you like.

There are many tools available (free and commercial) that can render PDF to an image. I've used PDFRasterizer.NET for this on a couple of ASP.NET projects.

A component like PDFRasterizer.NET will let you render PDF into images on the fly, streaming it back to the browser directly. On a typical page with text and some images or vector graphics rendering typically takes (much) less than a second. You can save the generated images to disk and use that as a cache to optimize performance. Unless you expect massive traffic there's no real need to process all documents offline.