A different approach to print whatever is in your screen.
Yii 1.1 or above jQuery
Extract it under your /extensions directory.
Declare the largest element as the 'element', and just add the unneeded DIVs or classes under exceptions.
Edit the mprint.css or/and add css to satisfy your taste.
Debug mode is added so that you can play with the the page that you will be printing.If you enable this feature, you can set the dimensions of the mPrint section (which appears at the bottom of the page) by overriding dbgWidth and dbgHeight, which defaults are set to 100%. Printing will not proceed if debug mode is enabled.
$this->widget('ext.mPrint.mPrint', array( 'title' => 'title', //the title of the document. Defaults to the HTML title 'tooltip' => 'Print', //tooltip message of the print icon. Defaults to 'print' 'text' => 'Print Results', //text which will appear beside the print icon. Defaults to NULL 'element' => '#page', //the element to be printed. 'exceptions' => array( //the element/s which will be ignored '.summary', '.search-form' ), 'publishCss' => true, //publish the CSS for the whole page? 'visible' => Yii::app()->user->checkAccess('print'), //should this be visible to the current user? 'alt' => 'print', //text which will appear if image can't be loaded 'debug' => true, //enable the debugger to see what you will get 'id' => 'print-div' //id of the print link ));
<head>is inside the
fixed the bug 'Missing argument 2 for CClientScript::registerCss()' by replacing registerCss with registerCssFile (thanks to joblo)
modified the property 'exemptions' to 'exceptions' for a more definitive term (thanks Gustavo)
added the property 'publishCss' (bool), which will dictate whether to register the CSS file for the whole page (for the benefit of CTRL+P).
JQuery print code came from: http://www.bennadel.com