Follow the Steps:
- Create Print Button : Add content Editor web part to your page and paste the following script as Source Text
<>
< type="button" onclick="javascript:void(PrintWebPart())" value="Print Web Part">
< language="JavaScript">
//Controls which Web Part or zone to print
var WebPartElementID = "WebPartWPQ6";
//Function to print Web Part
function PrintWebPart()
{
var bolWebPartFound = false;
if (document.getElementById != null)
{
//Create html to print in new window var PrintingHTML = '\n\n';
//Take data from Head Tag if (document.getElementsByTagName != null)
{
var HeadData= document.getElementsByTagName("HEAD");
if (HeadData.length > 0)
PrintingHTML += HeadData[0].innerHTML;
}
PrintingHTML += '\n\n\n';
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
{
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
}
else
{ bolWebPartFound = false; alert ('Cannot Find Web Part'); } } PrintingHTML += '\n\n'; //Open new window to print if (bolWebPartFound)
{
var PrintingWindow = window.open("","PrintWebPart", "toolbar,width=800,height=600,scrollbars,resizable,menubar"); PrintingWindow.document.open(); PrintingWindow.document.write(PrintingHTML); // Open Print Window PrintingWindow.print(); }}< /script>
- In order to print content from web part you need to connect the desired web part to the print button
- Get the Div Id of web part from the Page Source and assign it to the variable in Button
Well you would like to check this for simpler explanation :
http://www.imakenews.com/mernstmann/e_article000435389.cfm