I'm thinking of adding a print button to my list ribbon , the minute I click on this button a print dialog appears showing the list of the available printers on my computer. so this printdialog i was intending to do it in my custom element of the button :

<CustomAction Id="Ribbon.Library.PROGED"
    <CommandUIDefinition Location="Ribbon.Library.Groups._children">
      <Group Id="Ribbon.Library.PRO"
        <Controls Id="Ribbon.Library.PRO.Controls">
          <Button Id="Ribbon.Library.PRO.PrintAllFiles"
                  LabelText="Print All Files"
    <CommandUIDefinition Location="Ribbon.Library.Scaling._children">
      <MaxSize Id="Ribbon.Library.PROGED.Scaling.MaxSize"
               Size="LargeLarge" />
    <CommandUIHandler Command="PrintAllFiles"
                     CommandAction="javascript:function CallDETCustomDialog('PrintAllFiles',dialogResult, returnValue)
                                  var options = {
                                  url: '{SiteUrl}' + '/_layouts/YBBEST/TitleRename.aspx?List={ListId}&amp;ID={ItemId}',
                                  title: 'Rename title',
                                  allowMaximize: false,
                                  showClose: true,
                                  width: 500,
                                  height: 300,
                                  dialogReturnValueCallback: CallDETCustomDialog };



It's just I didn't know how to translate this .net regular printing dialog to javascript SP.UI printing dialog:

    public void printall(object sender, System.EventArgs e)
        PrintDialog pd  = new PrintDialog();
        pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
  • I'm not sure if I understand the question. Are you looking for CommandAction="javascript: window.print()" or is that what you already have?
    – eirikb
    Oct 22, 2012 at 9:56
  • no that will print the current window , instead I want to print a selected file when I'm having a collection of printers, so I need a printdialog as the same of .net to choose my printer, i just didn't know how to call it in sharepoint
    – Glolita
    Oct 22, 2012 at 10:06
  • As far as I know you can only show the print dialog that the browser support. But if you want to force a print dialog you could always add a JavaScript to AdditionalPageHead and have this check for something in the URL onload (querystring like ?output=print or a hash #print, and if this is given trigger window.print. Example with jQuery: $(function(){window.location.hash.match(/print/) && window.print()})
    – eirikb
    Oct 22, 2012 at 10:09
  • What you're trying to do is not possible in Javascript, as it only has access to the browser capabilities, and cannot access system resources like printers. Instead, you could add a Silverlight control to your page that handles the print functionality, and pass the file contents to it.
    – Mihai
    Oct 24, 2012 at 13:52

1 Answer 1


I think if you isolate the issue away from SharePoint and post on StackOverflow you'll get a bigger response. If I'm right in thinking you want to print a selection using javascript - I can propose a 'dirty' way of achieving this - simply construct a page from the selection by writing the selection to a fully constructed html page (so just the selected div, for example, inside body tags inside html tags) and print that whole page.

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.