This section will be printed

Consider this white area is the section we want to print, not the whole page

Just assign id attribute to this section like in this example its id="masterContent"

 <div id="masterContent"> 
in head section
  1. Include JQuery library as
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    or include your local copy
  2. Include printPreview library as
    <script type="text/javascript" src="js/printPreview.js"></script>
  3. write one more script tag without src attribute for our JQuery section to initiate our Plugin as below
    <script type="text/javascript">
            $(function(){
                $("#btnPrint").printPreview({
                    obj2print:'#masterContent',
                    width:'810'
                    
                    /*optional properties with default values*/
                    //obj2print:'body',     /*if not provided full page will be printed*/
                    //style:'',             /*if you want to override or add more css assign here e.g: "<style>#masterContent:background:red;</style>"*/
                    //width: '670',         /*if width is not provided it will be 670 (default print paper width)*/
                    //height:screen.height, /*if not provided its height will be equal to screen height*/
                    //top:0,                /*if not provided its top position will be zero*/
                    //left:'center',        /*if not provided it will be at center, you can provide any number e.g. 300,120,200*/
                    //resizable : 'yes',    /*yes or no default is yes, * do not work in some browsers*/
                    //scrollbars:'yes',     /*yes or no default is yes, * do not work in some browsers*/
                    //status:'no',          /*yes or no default is yes, * do not work in some browsers*/
                    //title:'Print Preview' /*title of print preview popup window*/
                    
                });
            });
        </script>

Note: Note 2 things

  1. CSS is same here in this page
  2. althought the "print Preview" button resides within the target object which we are printing, but this will not be displayed in print/preview.