SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to print everything in a newform.aspx/editform.aspx modal dialog. I was considering creating a Web Part or a bit of JavaScript that was nothing more than a print button that specified the current window but I wasn't sure if that would work...

share|improve this question
up vote 3 down vote accepted

You can create a Custom Action which will add a print button to your Newform.aspx and EditForm.aspx forms, and in the Command you can define a javascript to print current window. See sample below:

Example for NewForm.aspx

  Description="Print me"
  Title="Show Me"
    <CommandUIExtension xmlns="">
      <!-- Define the (UI) button to be used for this custom action -->
        <CommandUIDefinition Location="CommandUI.Ribbon.ListForm.New.Page.Edit.Controls._children">

          LabelText="Print me"
          Description="Print me description"

        <!-- Define the action expected on the Print button click -->
        <CommandUIHandler Command="PrintPage" CommandAction="javascript: window.print()" />
share|improve this answer
I like this idea much better than my original! I was mostly worried that I wouldn't be able to print JUST the modal window (ignoring the parent window). – James Grizzle Jun 26 '12 at 17:28
Parent window in this case would be EditForm.aspx or NewForm.aspx (Modal Dialog), so I don't see a problem here. Also this fulfils your requirement? – Falak Mahmood Jun 26 '12 at 17:33
For what it's worth, if you don't want to bother with Visual Studio, this also works via SharePoint Designer. Open the site, navigate to the details page of the appropriate list, highlight the custom actions area, use the New Custom Action button that is in the main ribbon at top left, then, copy the above CommandAction javascript and paste it into the 'Navigate to URL' field. – bkwdesign Jun 26 '12 at 17:46
That can also be done with SP Designer but creating a custom action in Feature within a WSP is scalable solution especially if you have different Farms (Development, Test, Production). You WSP may contains all your resources including Features, site definitions, assemblies, Web Part packages, class resources etc etc, and also can be deploy to the entire farm in one go, with Features can be activated to sites as per Users likings. – Falak Mahmood Jun 26 '12 at 18:15
I attempted to try the solution using SP Designer as you instructed by placing CommandAction="javascript: window.print()" in the Navigate to URL field but i get an error Could not save List change to server. 'javascript' is an unexpected token, Expecting white space Line 1, position 545? ideas? – user13177 Nov 24 '12 at 0:10

Better CommandAction approach here, because it gets all dialog content w/o the underlying page.

Weakness, doesn't honor InfoPath Page breaks.

                      var patt = /.+_FormControl.+__ViewContainer/gi;
                      var alldivs = document.getElementsByTagName('div');
                      var printpageHTML = '';
                      for(var i=0; i&lt;alldivs.length; i++){
                          printpageHTML = '&lt;HTML&gt;&lt;HEAD&gt;\n' +
                                          document.getElementsByTagName('HEAD')[0].innerHTML +
                                          '&lt;/HEAD&gt;\n&lt;BODY&gt;\n' + 
                                          alldivs[i].innerHTML.replace('inline-block','block') + 
                      var printWindow ='','printWindow');
share|improve this answer

Add this in the SPD 2010 navigate to URL: javascript:window.print() and then add your icon

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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