Spouse we have a DIV that we want to print and its ID is 'printPDF' 
<div id="printPDF"> This area will be print</div>
var style_sheet = 'baseUrl . "/css/style.css"; ?>'; //Css file,Base url
var style_sheet = '';// Style sheet that you want to include
 var printContent = document.getElementById('printPDF').innerHTML;
        var printContent2 = " " + style_sheet + "" + printContent + "";
        var windowUrl = 'about:blank';
        var uniqueName = new Date();
        var windowName = 'Print' + uniqueName.getTime();
        var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');
        printWindow.document.write(printContent2);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();
        printWindow.close();
No comments:
Post a Comment