开发者

Free PDF viewers in ASP.net

开发者 https://www.devze.com 2022-12-23 00:26 出处:网络
I have many PDF documents in binary format which is in the SQL Server 2008 database. I have a gridview in my ASP.net page. When a user clicks on any ID column of the record I need to open the pdf in t

I have many PDF documents in binary format which is in the SQL Server 2008 database. I have a gridview in my ASP.net page. When a user clicks on any ID column of the record I need to open the pdf in the browser.

Are there any fre开发者_如何学运维e PDF viewer controls out there? How can I convert the binary PDF file and display as PDF in the browser.

Thanks


Just return the data to the client with a Content-Type of application/pdf. The client will open it in Adobe Reader or whatever PDF viewer is installed.


If you want a consistent experience without wondering how the user's browser will choose to handle the file (i.e. display it inline, launch Acrobat, or try to save it, etc)...

Google has made its own web-based PDF viewer available for free for embedding. You might use the iframe version in your website.

(This is a sample I created using their web viewer. They make available zoom, thumbnail and page controls - enough to get around the documents easily)

You will have to make an ASP.NET page that delivers the PDF binary stream, then give Google's viewer the URL of that page.

To stream a PDF through an ASPX page you'll want to Google and search for articles like these :

  • http://support.microsoft.com/default.aspx?scid=kb;en-us;307603
  • http://support.microsoft.com/default.aspx?scid=kb;en-us;326502
  • etc.

Basically it's about HTTP and manipulating the MIME type, page headers, etc and writing binary data to the Response stream using available ASP.NET mechanisms.

It might be worthwhile to post a separate question specifically about streaming PDF data through an ASPX page because the current question can be construed as a two-part question or being more oriented toward PDF viewers.


When using modern Webbrowser (with HTML5 Canvas support) you can try PDFJS library (https://mozilla.github.io/pdf.js/)

0

精彩评论

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

关注公众号