Printing just the Web part and not the entire SharePoint page I observed stored times infopath Webbased form not print full form contents. it's only print firstpage of the form remaining pages print blank E. G if my Webbased form has 4 pages if I print this form browser based file \ Print \ button, it print only first page remaining 2, 3, 4, pages print blank but here it print header and footer, But I does not print full webpart contents.
So I decided to work on this topic
Insert a Content Editor Web part and edit the source code. Add the following to it:
<Input type = "button" onclick = "javascript: void (printwebpart ()" value = "Print Web Part">
<Script language = "JavaScript">
// Controls which Web part or zone to print
VaR webpartelementid = "<webpartelementid> ";
// Function to print Web Part
Function printwebpart ()
{
VaR bolwebpartfound = false;
If (document. getelementbyid! = NULL)
{
// Create HTML to print in new window
VaR printinghtml = '<HTML> \ 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 VaR webpartdata = Document. getelementbyid (webpartelementid );
If (webpartdata! = NULL)
{
Printinghtml + = webpartdata. innerhtml;
Bolwebpartfound = true;
}
Else
{
Bolwebpartfound = false;
Alert ('could not find Web part ');
}
}
Printinghtml + = '\ n </body> \ n // Open new window to print
If (bolwebpartfound)
{
VaR printingwindow = Window. Open ("", "printwebpart", "toolbar, width = 800, Height = 600, scrollbars, resizable, menubar ");
Printingmediaworkflow Doc ument. open ();
Printingmediaworkflow Doc ument. Write (printinghtml );
// Open print window
Printingwindow. Print ();
}
}
</SCRIPT>
Once you have done the above, you need to find the Web Part ID of the Web part you want to print when this button is clicked.
To do that, you view the source of the page and look for the Web Part title corresponding to the Web part. It looks something like this:
<Div webpartid = "0e77b913-99e6-402c-8558-cdd5a2100eb2" haspers = "false" id ="Webpartctl00_m_g_0e77b913_99e6_402c_8558_cdd5a2100eb2"Width =" 100% "class =" MS-wpbody "allowdelete =" false "style =" ">
The ID that you're interested in to replace <webpartelementid> In the Javascript above is highlighted.
Once it's all there, click on the button and a window will pop open that contains only the contents of the web part. Feel free to print.