none
SharePoint 2013 Blogs - how can you combine filters and print results

    Question

  • Hello: A request came to my attention that instead of creating newsletter (probably distributed as PDF), why not filter on Blog posts based on Categories and Months and print the filtered posts on-the-fly (perhaps either as PDF or through a Printer if accessible). Is this possible? I don't see an option for print let alone an option for Advanced Filtering (with selection of Categories and Months).

    Thanks!


    • Edited by get3rrd0ne Friday, April 21, 2017 3:37 PM
    Thursday, April 20, 2017 7:50 PM

Answers

  • You can add a print button using Content Editor web part on the same page and call default javascript print method

    <a href="javascript:window.print()">Print</a>

    And while taking windows print it will print all header, footer and navigation. To avoid those from printing you need to add print media css which will avoid all this.

    @media print {
       @page 
        {
            size:  auto;   /* auto is the initial value */
            margin: 0mm;  /* this affects the margin in the printer settings */
        }
    
        html
        {
            background-color: #FFFFFF; 
            margin: 0px;  /* this affects the margin on the html before sending to printer */
        }
    
        body
        {
            margin: 10mm 0mm 10mm 0mm; /* margin you want for the content */
        }
        
        #title-row, #sidenavigation, #topnavigation {
    		display: none;
    	}
    }

    And filtering with Categories and Months won`t have option by default as they are redirecting to different pages. I will investigate on this. Let me know if you need further help on Print one.

    • Marked as answer by get3rrd0ne Monday, April 24, 2017 5:37 PM
    Thursday, April 20, 2017 10:56 PM
  • Hi get3rrdOne,

    The “@media print” is one of the CSS at-rules, which is used for printers. Read this article for Media types.

    As Konjeti Venkat mentioned, just add the CSS into a Content Editor web part or a Script Editor web part.

    For example:

    <a href="javascript:window.print()">Print</a>
    
    <style>
    
    @media print {……}
    
    </style>


    Information about how to add CSS and JavaScript to the SharePoint page.

    http://techtrainingnotes.blogspot.sg/2012/05/adding-javascript-and-css-to-sharepoint.html

    Best regards,

    Linda Zhang


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

    • Marked as answer by get3rrd0ne Monday, April 24, 2017 5:38 PM
    Monday, April 24, 2017 7:25 AM
    Moderator

All replies

  • You can add a print button using Content Editor web part on the same page and call default javascript print method

    <a href="javascript:window.print()">Print</a>

    And while taking windows print it will print all header, footer and navigation. To avoid those from printing you need to add print media css which will avoid all this.

    @media print {
       @page 
        {
            size:  auto;   /* auto is the initial value */
            margin: 0mm;  /* this affects the margin in the printer settings */
        }
    
        html
        {
            background-color: #FFFFFF; 
            margin: 0px;  /* this affects the margin on the html before sending to printer */
        }
    
        body
        {
            margin: 10mm 0mm 10mm 0mm; /* margin you want for the content */
        }
        
        #title-row, #sidenavigation, #topnavigation {
    		display: none;
    	}
    }

    And filtering with Categories and Months won`t have option by default as they are redirecting to different pages. I will investigate on this. Let me know if you need further help on Print one.

    • Marked as answer by get3rrd0ne Monday, April 24, 2017 5:37 PM
    Thursday, April 20, 2017 10:56 PM
  • Thanks Konjeti for your quick response...I will try out your suggestion and while waiting, for the second requirement, I wonder if we can use filtering with URL Query string as mentioned in this blog or if you have a better idea.

    Again, thanks for the help!

    Friday, April 21, 2017 3:59 PM
  • Thanks Konjeti - what's a quick way to embed the css code above to the javascript?

    Again, thanks for the help!

    Friday, April 21, 2017 5:49 PM
  • Hi get3rrdOne,

    The “@media print” is one of the CSS at-rules, which is used for printers. Read this article for Media types.

    As Konjeti Venkat mentioned, just add the CSS into a Content Editor web part or a Script Editor web part.

    For example:

    <a href="javascript:window.print()">Print</a>
    
    <style>
    
    @media print {……}
    
    </style>


    Information about how to add CSS and JavaScript to the SharePoint page.

    http://techtrainingnotes.blogspot.sg/2012/05/adding-javascript-and-css-to-sharepoint.html

    Best regards,

    Linda Zhang


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

    • Marked as answer by get3rrd0ne Monday, April 24, 2017 5:38 PM
    Monday, April 24, 2017 7:25 AM
    Moderator
  • Thanks, Linda for your help! It worked..
    • Marked as answer by get3rrd0ne Monday, April 24, 2017 5:37 PM
    • Unmarked as answer by get3rrd0ne Monday, April 24, 2017 5:38 PM
    Monday, April 24, 2017 5:37 PM