Thursday, November 02, 2006

Creating printfriendly list pages

I think a common request is to print listitems, so I searched on the net for a solution and I stumbled upon te following toolbar by James Milne named SPPageToolBar. I placed this webpart in the dispform.aspx page by using the &toolpaneview=2 url hack ;) I stripped the toolbar that it only showed the printfunction and added some classes to not be shown when printed.
See code below:

if (document.location.href.indexOf('PrintPreview') >0) {
 document.write('<style>');

 document.write('.jm-toolbar, .ms-navframe,.ms-bannerframe,.ms-sbtable,.ms-searchform,.ms-sbtopcorner,.ms-sblbcorner,.ms-phnav1wrapper,ms-titleareaframe,.ms-titlearea,.ms-pagetitle,.ms-toolbar,.ms-WPHeader,.ms-titlearealine { display: none; } ');
 document.write('div.ms-titleareaframe { border-top: 0px white solid; } ');
document.write('#onetidinfoblock1, #onetidinfoblock2,.ms-sectionline{display:none;}');
document.write('td.ms-titlearealine{background-image:none;border-style:none;}'); 
document.write('.ms-phnav1wrapper,.ms-phnavtopl1sel,.ms-phnavtopr1sel,.ms-titlearealine{border-style:none;}');
document.write('div.ms-titleareaframe {Border-Top: 2px solid #FFFFFF;Border-bottom: 65px solid #FFFFFF;background-color:#FFFFFF;} ');
document.write('#MSOZoneCell_WebPartWPQ2{valign:bottom;}');

document.write('</style>');
print();
}

2 comments:

Ishai Sagi [SharePoint MVP] said...

I have a better proposal. Take a look at how I did it in wssv3 - you can do the same for list items:

how to add print list option to list

Robin Meuré said...

Is it a printfriendly version of a listitem or the complete list?