11

How challenging is it to add these two functions to all SharePoint site pages?

  • Have a printer icon that allows user to print the content of the page
  • Have a PDF icon that lets the user export the page as a PDF document

Are there any 3rd party solutions for this?

6 Answers 6

13

We usually use print style sheets (<link rel="stylesheet" href="print.css" type="text/css" media="print" />) to do this.

Check this guide:
http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml

I know Muhimbi has a good third party PDF generator, but I havent tried it.

4
  • Thanks, Anders. In general, is it difficult to print lists in SharePoint 2010, with/without a print CSS?
    – Alex C
    Commented Sep 12, 2011 at 9:15
  • 1
    I can confirm that the Muhimbi PDF Converter for SharePoint is brilliant :-) See this link for HTML to PDF conversion: blog.muhimbi.com/2010/09/…. You can also trigger the process from your own links and even SharePoint Designer and Nintex workflows. Commented Sep 12, 2011 at 10:09
  • Thanks, Muhimbi. Can the PDF conversion tool appear as an icon on the page itself instead in a menu?
    – Alex C
    Commented Sep 12, 2011 at 10:46
  • Generally speaking, I prefer Anders' CSS approach. Most people misuse or don't understand print style sheets, but they make life so much easier with these types of requests. I do have a blog post that covers some of the basic steps: mike-greene.com/2010/04/print-formatting-via-css. The guide Anders posted is good too.
    – webdes03
    Commented Oct 13, 2011 at 3:40
3

It is not a good option if you require generic print functionality but SQL Reporting Services is great for building custom reports and it comes with different built in export functions.

However it requires some extra work eg. you need to build your reports separately, you need to take care of integration etc. so maybe it is overkill for your requirements.

Some additional info:

Overview of Reporting Services and SharePoint Technology Integration

1
  • Thanks, Vedran. We'll be using SSRS with SP, so this is definitely a good, free option.
    – Alex C
    Commented Sep 12, 2011 at 12:38
2

For printing Lists you can use the http://spprintlistbutton.codeplex.com/.

2
  • Welcome to SharePoint Stack Exchange! While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See How to Answer for general guidelines.
    – Alex Angas
    Commented Sep 13, 2011 at 9:53
  • Thanks, user4737 and Alex. The printing utility will come in quite handy for lists :)
    – Alex C
    Commented Sep 13, 2011 at 10:46
1

I did this through a httpmodule that checks for the querystring PrinterFriendly=True and when that is set on any page in SharePoint, it swaps out the masterpage for a printerfriendly one. Here's some of the code:

    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += new EventHandler(PrinterFriendlyMasterPage_PreRequestHandlerExecute);
    }

    void PrinterFriendlyMasterPage_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;
        if (page == null) return;

        // If the request originates from a Publishing Page then we have to
        // change the master page on the current Sharepoint Web instance object
        // (of course we don't want to persist this change since it would
        // change the master page permanently..for all users).

        if (page is PublishingLayoutPage || page is TemplateRedirectionPage)
        {
            HttpContext context = HttpContext.Current;

            if (ShouldOverrideMasterPage(context))
            {
                SPContext.Current.Web.MasterUrl = Utility.GetSetting("PrinterFriendlyMasterPage_MasterPageUrl");
                SPContext.Current.Web.CustomMasterUrl = Utility.GetSetting("PrinterFriendlyMasterPage_MasterPageUrl");
                page.Load += new EventHandler(application_page_Load);
            }
        }
        else
        {
            // Now, if this is a normal wss 3.0 page hook into
            // the PreInit event (just before the ordinary Page event
            // cycle starts.            
            page.PreInit += new EventHandler(PrinterFriendlyMasterPage_PreInit);
        }
    }

    void PrinterFriendlyMasterPage_PreInit(object sender, EventArgs e)
    {
        try
        {
            Page page = sender as Page;
            if (page == null) return;
            if (page.MasterPageFile == null) return;

            HttpContext context = HttpContext.Current;

            if (ShouldOverrideMasterPage(context))
            {
                page.MasterPageFile = Utility.GetSetting("PrinterFriendlyMasterPage_MasterPageUrl");
            }

        }
        catch { }
    }

    private bool ShouldOverrideMasterPage(HttpContext context)
    {
        return GetQueryStringSwitch(context, Utility.GetSetting("PrinterFriendlyMasterPage_QueryString"));
    }

    private bool GetQueryStringSwitch(HttpContext context, string queryString)
    {
        try
        {
            if (!String.IsNullOrEmpty(context.Request.QueryString[queryString]) &&
                Boolean.Parse(context.Request.QueryString[queryString]))
            {
                return true;
            }
        }
        catch { }
        return false;
    }
6
  • 1
    Seems a bit excessive to use an HttpModule for this (especially performance wise) when almost the same can be achieved with a simple css file. What are the advanages for doing this serverside instead of doing it on the client? Commented Sep 12, 2011 at 15:14
  • @steve-lineberry contact me on chat if you need me to merge your two accounts. You have another account with +1000 rep ;) Commented Sep 12, 2011 at 15:16
  • @Anders-Rask, I sent the chat, I think i did it correctly. Let me know if I didn't. Commented Sep 12, 2011 at 18:25
  • I agree the httpmodule might be a little excessive, but I feel like the flexibility is there. I didn't include in my code above, but I had other switches to apply such as whether or not to include the quicklaunch, some other company specific items on the page, etc. Those are things I couldn't do with a plain css file. Commented Sep 12, 2011 at 18:28
  • This is a neat solution, but I think it makes it a lot harder than it needed to be. 95% of what you'd need to change to make a print friendly master page can usually be done with print CSS on the same master page that the site is using by default.
    – webdes03
    Commented Oct 13, 2011 at 3:38
1

The PDF Converter for SharePoint adds a lot of PDF Related functionality to SharePoint, including the PDF button you are after.

It comes with both SharePoint Designer and Nintex workflow activities as well as a host of other PDF related functionality such as PDF Security, Merging and watermarking.

More here.

Note that I worked on this product so the usual disclaimers apply.

1
  • Thanks, Muhimbi. Very nice product and one that's on our eval list for PDF.
    – Alex C
    Commented Oct 12, 2011 at 11:08
1

Check out also Smart Print Pro. It can print lists or list items according to user defined templates and export it to PDF

Check it out - http://www.infowisesolutions.com/product.aspx?id=SmartPrintPro

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.