none
How to print content of a CEWP, without printing the rest of the page? RRS feed

  • Question

  • Hi there

    How to print just the content of a CEWP, without printing the rest of the page?

    Thanks.

    Tuesday, January 10, 2017 9:08 PM

All replies

  • Hi Ran,

    You can use the below JavaScript function to print  just the contents of the web part.  Replace the "IdOfTheContentToPrint" with Id of the div in the CEWP 

    function printSpecificContent(){
        windowToPrint = window.open(null, 'Print_Page', 'scrollbars=yes');        
        windowToPrint.document.write(jQuery('#IdOfTheContentToPrint').html());
        windowToPrint.document.close();
        windowToPrint.print();
    };
    Please remember to click Mark as Answer on the answer if it helps you


    Tuesday, January 10, 2017 9:17 PM
  • Hi Giridharan

    Code did work - however on the last page this always shows a strange image as follows:

    Any thoughts?

    Thanks so much.

    Friday, January 13, 2017 9:59 PM
  • Hi,

    The solution provided by Giridharan_G should work.

    Have you reference the jQuery library and replace the id(#IdOfTheContentToPrint)?

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 16, 2017 1:49 AM
  • Yup, I did that exactly as told.

    Not sure what this strange image is doing on the last page.

    Any help will be appreciated!

    Thanks.

    Tuesday, January 17, 2017 12:38 AM
  • Hi,

     

    Did the image belongs to source page? Try to check the IdOfTheContentToPrint is correct.

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, January 17, 2017 1:41 AM
  • Nope, the image has nothing to do with the source page - I wonder where does it come from.

    The image name comes up as "spimn.png" if this can help debug.

    Still trying to fix this!

    Thanks.


    • Edited by ran009 Tuesday, January 17, 2017 7:59 PM
    Tuesday, January 17, 2017 7:58 PM
  • Hi,

     

    Try to check the image by developer tool,( it’s coming from CSS/Link from source page).

     

    You could check below link for more details.

    https://msdn.microsoft.com/en-us/library/gg589500(v=vs.85).aspx

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, January 18, 2017 1:32 AM
  • Hi Lee

    "spimn.png" is standard SharePoint image - what I do not understand why it shows up in Printouts - the list item/CEWP has no relevance to it.

    Thanks.

    Wednesday, January 18, 2017 9:14 PM
  • Hi,

    Try to search the spimn.png to check if it’s include in current page, I think it should be there.

    Then, check whether it’s contained by the content you plan to print.

    What’s the source of your CEWP? I could try to research in my local.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, January 19, 2017 8:05 AM
  • spimn.png is not mentioned anywhere in the page - I wonder why this is showing.

    Thanks.

    Tuesday, January 24, 2017 10:38 PM
  • Hi,

     

    Could you test this with new page/other kind of pages(publishing page/web part page/wiki page).

     

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 6, 2017 8:25 AM