We have web application under SharePoint 2010. PDf documents are stored in SharePoint sites. SharePoint site is deployed on the server. Our requirement is when users are going to browse the SharePoint site from their Client machine with the click of Print button on the SharePoint site they should be able to print pdf documents using client machine’s default printer.

We are ready to explore third party dll or solution to achieve the above requirement.

  • Do you need a button code to print (Single or multiple) PDF from your SP site's library? – Hardik Apr 15 '16 at 6:51
  • yes thats correct. – Raj Gangwani Apr 15 '16 at 12:16

You can use below mentioned code to PRINT selected (multiple as well) PDF files from library using local printer.

/// <summary>
/// Used to get selected item on page load.
/// </summary>
protected void getSelectedItem()
        if (Request.QueryString["items"] != null && Request.QueryString["ListID"] != null)
            string listID = Request.QueryString["ListID"];
            string[] items = Request.QueryString["items"].ToString().Split('|');                                    

            listID = listID.Substring(1, listID.Length - 2).ToLower();

            Guid sourceID = new Guid(listID);

            SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)SPContext.Current.Web.Lists[sourceID];

            List<string> fileName = new List<string>();

            for (int i = 1; i < items.Length; i++)
                SPListItem currentListItem = sourceDocLib.GetItemByIdAllFields(int.Parse(items[i]));                        
                string fileURL = siteURL+""+currentListItem.File.ServerRelativeUrl;

            foreach (string filePath in fileName)
                Process proc = new Process();
                proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                proc.StartInfo.Verb = "print";

                proc.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe";
                proc.StartInfo.Arguments = String.Format(@"/p /h {0}", filePath);
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = true;

                proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                if (proc.HasExited == false)
                proc.EnableRaisingEvents = true;

                return true;               
            lblMessage.Text = "Sucessfully print all the files";
    catch (Exception ex)

NOTE :- You can use itextsharp or pdfsharp to do the same but those are external DLLs

  • Is above code works for you? – Hardik Apr 18 '16 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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