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.
You should combine Matt’s solution and a HttpHandler :
The HttpHandler will get the PDF file from your local/network path and get it to your client.
The Page Viewer Web Part (or an iframe inserted with a content webpart) will integrate the PDF on your page :
Here is a simple code for the httphandler :
In the web.config, you add the httphandler :
In the WebPart, you set the src property:
The difficulty would be if you want to load different PDF depending on a parameter passed on the URL.
If so you would need to create your own webpart that simply take the QueryString parameter on the current request and write an iframe elt with the src attribute containing the parameter.