Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3967452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:43:17+00:00 2026-05-20T03:43:17+00:00

Never worked with Sharepoint, but need to add a WebPart to display a PDF

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:43:17+00:00Added an answer on May 20, 2026 at 3:43 am

    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 :

    enter image description here

    Here is a simple code for the httphandler :

    public class TestPdfHandler : IHttpHandler
    {
        #region IHttpHandler Membres
    
        public bool IsReusable
        {
            get { return true; }
        }
    
        public void ProcessRequest(HttpContext context)
        {
            string fileName = context.Request["pdfname"];
    
            byte[] buffer = null;
            buffer = File.ReadAllBytes("d:\\" + fileName +".pdf");
            context.Response.Clear();
            context.Response.ContentType = "application/pdf";
    
            context.Response.OutputStream.Write(buffer, 0, buffer.Length);
            context.Response.End();
        }
    
        #endregion
    }
    

    In the web.config, you add the httphandler :

     <add verb="*" path="pdf.axd" type="test.TestPdfHandler, pdfhandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=98df27cf3a770eaa"/>
    

    In the WebPart, you set the src property:

    enter image description here

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never worked with web services and rails, and obviously this is something
I might be an exception here but I have never worked on a team
Never worked with mootools and have this code. Instead on just injecting the content
I never worked with ajax. I need to know if it is possible to
I never worked with Silverlight before, but I have the requirement to build a
So I've never worked with stored procedures and have not a whole lot of
I've never worked on a professional project with a team, as I'm still in
I’ve never worked on software where I needed to use design patterns. According to
I'm doing a personal organizer for learning purposes, and i've never worked with XML
A project I'm working on supposed to authenticate users agains AD. I've never worked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.