How to print a part of SharePoint, instead of the entire page Printing just the Web part and not the entire SharePoint page

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.