C# – How to add PDF viewer panel to Sharepoint WebPart

asp.netcpdfsharepointweb-parts

Never worked with Sharepoint, but need to add a WebPart to display a PDF document. How does this work?

There is currently some code to add a ReportViewer (SSRS) WebPart, but I need to replace it to display a PDF file (from disk).

The PDF file is from a local/network path that is not served publicly. I need to get the PDF content streamed in a web part, setting the content-type along the way.

If it helps any, my thoughts are to respond on a different URL (page in the same site), that simply takes some token (get params?) and streams a byte[] and sets the content-type as application/pdf – I could well be completely off the mark. You will need to be quite specific with steps and code/sample/links in the answer.

Best Answer

Add a Page Viewer Web Part to the page and set the URL to the location of the pdf. A side effect of this is the Acrobat tool bar is displayed in the web part. If you want that to go away you have to add #toolbar=0&navpanes=0 to the url. For example:

http://server:port/path/filename.pdf#toolbar=0&navpanes=0

NOTE: The user would have to have Adobe reader plugin installed to view the pdf in the web part.

Related Topic