Print specific webpart of a page in SharePoint.

I create a page that conatins two webparts side by side. One is an Anvanced Search Box and the other a DWP that shows the data from a Custom SharePoint List. I'm tryin to create a Print button to print only one of the webparts, as you can imagine, I'm interested
in printing the Search Box. I have tried several methods and so far no luck.
Method 1. Both webpart print
<input onclick="window.print();return false;" type="button" value=" Print this page "/>
Method 2. The same both WP print. I'm inserting the right ID
var WebPartElementID = "XXXXXX-XXXXX";
//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<HEAD>
<meta name="WebPartPageExpansion" content="full" />\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</HEAD>\n<BODY>\n';
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
else
bolWebPartFound = false;
alert ('Cannot Find Web Part');
PrintingHTML += '\n</BODY>\n</HTML>';
//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();
Method 3. I found this proposed solution in this forum (Here). This method doesn't work for me at all.
function PrintPreview(){
var sURL=document.location.href;
if (sURL.indexOf('?') >0) { sURL=document.location+"&PrintPreview";}
else { sURL=document.location+"?PrintPreview";} window.open(sURL); }
// If we are in Print Preview Mode then Hide a bunch of styles.
if (document.location.href.indexOf('PrintPreview') >0) { document.write('<style>');
document.write('.pa-printicon, .jm-toolbar, .ms-navframe,.ms-bannerframe,.ms-sbtable,.ms-searchform,.ms-sbtopcorner,.ms-sblbcornerumb,.ms-globalbreadcrumb,.ms-pagetitleareaframe table { display: none; } ');
document.write('div.ms-titleareaframe { border-top: 0px white solid; } ');
document.write('</style>'); print(); }
EM

Hi emfuentes27,
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<HEAD>\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</HEAD>\n<BODY>\n';
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
else
bolWebPartFound = false;
alert ('Cannot Find Web Part');
PrintingHTML += '\n</BODY>\n</HTML>';
//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>
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%"
allowDelete="false" >
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
Thanks,
Jack
Jack Gao
TechNet Community Support

Similar Messages

  • How do I add multiple audio webparts to a page in SharePoint 2013?

    I need to add multiple media player webparts with audio files to a page in SharePoint 2013 so users can click the play button, listen to the file, then vote for the audio they like best. The problem is I can only get one audio to play at a time, and only
    in certain browsers. I can get them to work intermittently in a Chrome browser, but not IE 10. When I publish the page and click the play arrow, it played the first time. Then I added two more audio player webparts to the page, and linked them to different
    audio files (m4a and mpg). Now only one audio player will work, not the other 2.

    Hi
    Have you used this codeplex webpart
    https://mpwp.codeplex.com/
    Amit Kotha

  • 404 error while adding custom webpart to the page

    I have my solution working in development environment. I deployed the wsp in prod env. While adding one specific webpart to the page leads to 404 error page.
    Thanks in advance.

    Hi,
    boreal123's reply makes sense.
    I would say that somewhere in your specific method call a web service, but it cannot find. You can check the related code snippet.
    I suggest that you can try to store the url in a webpart property so that it can be modified easily.
    Best Regards
    Guangchao chen
    TechNet Community Support

  • How can i print specific pages against searched word or name (in one print command) from 1000 pages

    how can i print specific pages against searched word or name (in one print command) from 1000 pages

    Thanks, Alex!
    ok, I try first approach in print4.vi, but Labview return an error (view jpg); if I cut From, To controls, the VI print all pages. The same things happen also if I trasform I32 in Variant.
    I don't try second approach, because at this time I have only one report
    I try also with VB macro: this is better (print3.vi) but.....if I use:
    Sub Print_Pages_From_To()
    ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="2", To:="3"
    End Sub
    is ok; print the pages selected; if I use:
    Sub PrintPages()
    ActiveDocument.ActiveWindow.PrintOut  Pages:="2-3"  
    End Sub
    printer print all pages.
    what do you think?
    regards,
    Italo
    Attachments:
    print Problem.jpg ‏39 KB
    print4.vi ‏19 KB
    print3.vi ‏19 KB

  • How to print specific page in smartform !

    Hello Friends,
                  I like to print specific page in smartform. for Ex. page 4. But when I give page no. 4, the print preview not showing the exact page.
    Thank you for your time.
    Senthil

    Hi Senthil,
    chk this link you get a brief idea abt Smartforms.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCRSF/BCSRVSCRSF.pdf
    Reward points if you find this helpful
    Regards,
    Harini

  • How to redirect a sub domain to a specific page in Sharepoint Online

    Hi, 
      My Organisation has a O365 account, and hoisted the public website on it, now user requests to have a friendly url for a specific page on the public website.  I've added a sub domain on O365.  but i cant find ways to redirect this domain
    to the page.  How can i do so? 

    Hi,
    If you need to redirect the sub domain to a specific page in SharePoint Online, you need to rename the Public Website with the sub domain.
    Then configure the friendly URL for the page in the Public Website.
    http://office.microsoft.com/en-001/office365-sharepoint-online-enterprise-help/upgrade-your-public-website-HA102801184.aspx?CTT=5&origin=HA102828142#_Step_5_%E2%80%93
    Or you can use the managed metadata navigation for the Public Web site and configure the friendly URL for the page.
    http://jeffkelly.com/2014/05/office-365-public-website-what-no-managed-metadata-mms-navigation/
    In the meanwhile, you can post your question to the forum for Office 365: http://community.office365.com/en-us/f/default.aspx.
    More experts will assist you, then you will get more information relation to SharePoint Online.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Printing specific pages in a PDF

    What is the java code to create a print button to print specific pages in a multiple page PDF file? Help please!

    For more information on the print method, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.511.html
    Note the nStart and nEnd parameters in particular.

  • How to print specific pages out of a book file

    I've searched around but I cannot find any way of printing specific pages out of a book file. Has anyone got any ideas? I have a 100 page book file with 20 files, and doing print outs of sections is a nightmare. I want to be able to print page 5 out of file A and page 6 out of file B together so I can duplex them. I've tried scripting this but I can't seem to set the page range of the print preferences of the book file.

    [Jongware] wrote:
    I don't think it's possible to set the page range of a Book.printPreferences
    Theoretically it ought to be possible. Can't test for myself now; what does happen when you set the pageRange to overlapping sub-files?
    I've just tried it with CS3. It might have been implemented in later versions.
    In the print Book dialogue the page range field is disabled. You cannot enter anything there.
    If you try to do it with a script it says that printPreferences is read only.

  • Java print service + print specific page

    is there anybody know how to print specific page to the printer in java?
    i am using below code. it able to print any txt file from page 1 to n. it just cannot work on printing on specific page??
    code
    String fileName = "NORMAL.txt";
         DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
         FileInputStream pclStream = new FileInputStream(fileName);
         PrintRequestAttributeSet attributes2 = new HashPrintRequestAttributeSet();
         //attributes2.add(new Copies(1));
         Doc doc = new SimpleDoc(pclStream, flavor, null );
         PrintService[] services = PrintServiceLookup.lookupPrintServices( null, attributes2);
         PrintService service = ServiceUI.printDialog(null,50,50,services,services[0],null, attributes2 );
         if(service != null) {
         DocPrintJob dpj = service.createPrintJob();
         dpj.print(doc,attributes2);

    See it!!!
    bye bye
    import javax.print.DocFlavor;
    import java.io.FileInputStream;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.print.SimpleDoc;
    import javax.print.PrintService;
    import javax.print.ServiceUI;
    import javax.print.Doc;
    import javax.print.PrintServiceLookup;
    import javax.print.DocPrintJob;
    import java.io.File;
    import java.awt.GraphicsConfiguration;
    import java.awt.Rectangle;
    import java.awt.GraphicsEnvironment;
    import java.awt.GraphicsDevice;
    public class Untitled1 {
    public Untitled1() {
    try {
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    String fileName = "NORMAL.txt";
    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
    FileInputStream pclStream = new FileInputStream(fileName);
    PrintRequestAttributeSet attributes2 = new HashPrintRequestAttributeSet();
    Doc doc = new SimpleDoc(pclStream, flavor, null );
    PrintService[] services = PrintServiceLookup.lookupPrintServices( flavor, attributes2);
    PrintService service = ServiceUI.printDialog(gc,50,50,services,services[0],flavor, attributes2 );
    if(service != null) {
    DocPrintJob dpj = service.createPrintJob();
    dpj.print(doc,attributes2);
    catch (Exception err) {
    public static void main(String[] args) {
    Untitled1 untitled11 = new Untitled1();
    }

  • How to print specific pages of a pdf from a vb 2013 program using a print dialog

    Hi.  I am using the acrobat sdk to display pdfs from within a vb 2013 program, because the pdfs are large and we have developed indexes on certain columns.  The indexes are stored in SQL tables.  My program has a search window which allows the user to search for a value and displays all the pages on which this value appears in the indexed column in a listbox.  By double-clicking on the desired value in the listbox, the user can go to the selected page and column.  However, the user also needs to be able to highlight one or more of the pages in the listbox and print these pages.  I could do this silently using AcroExchAVDoc.PrintPages, but the user also needs to have a print dialog displayed in order to possibly select a watermark to be printed on the pages.  I also need to default the orientation of the pages depending on the document.
    I have reviewed the sdk documentation and also searched in Google and on this site but have not found a way to do this.  Does anyone have a suggestion?  Thanks for any help you can provide.
    Mary

    Hi.
    I did try using the printParams feature and it worked, but since I need to be able to print sets of non-consecutive pages,  I end up having to bring up the print dialogue multiple times and have the user set watermarks each time. 
    I decided to just create a new pdf in a temp directory containing the selected pages and open this document in a new window.  This works well and allows them to use the print button on the window to print, bringing up the print dialogue just once.  However, since I need to open the document in a way that shows the print button, I am using OpenInWindowEx, with AV_DOC_VIEW, and the option PDUseBookmarks or PDUseThumbs, rather than PDUseNone.  This displays a toolbar which also includes icons for creating a new pdf, deleting pages, etc.  I do not really want to include these icons on the toolbar.  Is there a way to remove unwanted icons from the toolbar, or make them invisible?
    Hope this makes sense.  Thanks for your help.
    Mary

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • I need to print the footer in all pages except last page.

    Hi,
    I'm working on PO RTF template. I got one probelm, I need to print the footer in all pages except last page.
    Can someone help me in this.
    Thanks in advance.
    Venki.

    This question has been answered already multiple times - please search the forum before posting a question - in case you did and you didn't find it - we added a feature
    in 5.6.2 to solve this problem - It is described in the user guide in the RTF template section search for start@last-page:
    Last Page Support
    XML Publisher now has the ability to show content only on the last page. This is useful for documents such as checks, invoices or purchase orders where you want want content such as the check or a summary in a specific place only on the last page.
    The basic command is:
    <?start@last-page:body?>
    <?end body?>
    http://forums.oracle.com/forums/search.jspa?threadID=&q=%40last-page&objID=f245&dateRange=last90days&userID=&numResults=15&rankBy=9
    Any content above or below these two tags will only appear on the last page of the document.
    Hope that helps,
    Klaus

  • How to show property bag values of site collection in web part on landing page in sharepoint online?

    How to show property bag values of site collection in web part on landing page in sharepoint online - office 365?

    You can use JavaScript Client object model to read the property bag values. Example:
    function getWebProperty() {
    var ctx = new SP.ClientContext.get_current();
    var web = ctx.get_site().get_rootWeb();
    this.props =  web.get_allProperties();
    ctx.load(web);
    ctx.load(this.props); //need to load the properties explicitly
    ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
    function gotProperty() {
        var myPropBag = this.props;
        alert(myPropBag.get_fieldValues()["allowdesigner"]); //returns the value of the key allowdesigner
    function failedGettingProperty(args, sender)
         //handle errors here
    Source:
    http://sharepoint.stackexchange.com/questions/37198/grab-a-specific-property-bag-using-ecma-script
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • How do you link to a specific location in another page?

    I'm working in Dreamweaver CS4.  I'm trying to create a link to go to a specific location on another page in my website.  Any advice?

    All the information I have seen about Named Anchors deals with information that is contained on the same page.  I am looking to go to a specific location on a different page.  Is this possible using Named Anchors?  If so, how?
    Sure it is.
    Place a named anchor on your destination page near the bottom of your page for this test.  And name your anchor  1.
    On the parent page, your link will look like this:
    <a href="some_page.html#1">this is a link to named  anchor 1</a>
    Save both pages and test in browser.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • How to place a WebPart in Publishing Page Content

    Hi,
    when you use a publishing page you are able through the ribbon to add existing webparts into the content of the publishing page.
    I would like to add programmatically a webpart into the content of the publishing page. I couldnt find anyting to that question on the web.
    Can someone help?
    regards
    yavuz
    Regards
    Yavuz
    www.ybog.net | Field notes on software development and technology

    Try below:
    http://sharepoint2010mind.blogspot.in/2012/06/add-webpart-programmatically-publishing.html
    http://sharepoint.stackexchange.com/questions/86026/add-programmatically-custom-web-part-to-page-without-web-part-zone
    PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(web);
    string pageName = "NewPage.aspx";
    PageLayout[] pageLayouts = pWeb.GetAvailablePageLayouts();
    PageLayout newPage = pageLayouts[0]; //Body only type of page layout
    PublishingPageCollection pages = pWeb.GetPublishingPages();
    PublishingPage nPage = pages.Add(pageName, newPage);
    nPage.Update();using (SPSite site = new SPSite("http://win2008/sites/publishing"))
    SPWeb web = site.RootWeb;
    SPFile page = web.GetFile("Pages/Lipsum.aspx");
    page.CheckOut();
    using (SPLimitedWebPartManager wpmgr = page.GetLimitedWebPartManager(PersonalizationScope.Shared))
    Guid storageKey = Guid.NewGuid();
    string wpId = String.Format("g_{0}", storageKey.ToString().Replace('-', '_'));
    XmlElement p = new XmlDocument().CreateElement("p");
    p.InnerText = "Hello World";
    ContentEditorWebPart cewp = new ContentEditorWebPart
    Content = p,
    ID = wpId
    wpmgr.AddWebPart(cewp, "wpz", 0);
    string marker = String.Format(CultureInfo.InvariantCulture, "<div class=\"ms-rtestate-read ms-rte-wpbox\" contentEditable=\"false\"><div class=\"ms-rtestate-read {0}\" id=\"div_{0}\"></div><div style='display:none' id=\"vid_{0}\"></div></div>", new object[] { storageKey.ToString("D") });
    SPListItem item = page.Item;
    string content = item["PublishingPageContent"] as string;
    item["PublishingPageContent"] = content.Replace("|", marker);
    item.Update();
    page.CheckIn(String.Empty);
    http://sharepoint.stackexchange.com/questions/86026/add-programmatically-custom-web-part-to-page-without-web-part-zone
    http://www.zeemanj.net/?p=291

Maybe you are looking for

  • Forms Flicker in Forms 9i

    Forms Flicker Forms 9.0.2.11.0 Our application currently runs forms 6i using Jinitiator. We are in the process of upgrading our environment to 9i, database and forms. Because of the problems with downloading jinitiator to our user base we are looking

  • Best way to accept a date from a user

    Hi Guys, Whats the best way to get a date from a user and add it in an insert record to access. I have a form that adds a record and it works well enough as long as the data added is in the correct format. Untill now ive just had a text box with an e

  • Migration from Sp2 to Sp3

    I upgraded weblogic sp2 to Weblogic sp3 in Solaris environment.When i restart the server, all the components are getting deployed and the server listens to the correct port but immediately the shutdown begin and the server undeploys all the component

  • Who shall create a specific Security Domain compliant to GP 2.1?

    Particularly, in case of the delegated management, the GP card specification 2.1.1 decribes as follows: "Security Domains authorized by the Card Issuer to perform Card Content changes shall request the OPEN to load, install, extradite, and delete app

  • How to find the Different entries of the characters.

    HI Gurus, i have two characters in the Cube, for these two characters text is same for some records and different for some records. My requirement i need to find out the records whose text values are different for these two characters. I need to find