Print Html View In Yii

Download Extension

Using the below link download the extension to take the print of html [Take print What you see].

Click here to download http://www.yiiframework.com/extension/mprint

After download, Add the extension into follwoing directory “protected/extension/mPrint/mPrint”

Print Table
I added sample code to print the some view content

<?php
       $this->widget('ext.mPrint.mPrint', array(
            'title' => 'User Result',        //the title of the document. Defaults to the HTML title
            'tooltip' => 'User Result',    //tooltip message of the print icon. Defaults to 'print'
            'text' => 'Print Results', //text which will appear beside the print icon. Defaults to NULL
            'element' => '#resultprint',      //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?
            'id' => 'resultprintid',
            'style'=>'float: right; padding: 5px; margin-top: -5px;'                       
        ));
  ?>
 <div id="resultprint">
<?php
echo"<div class='title'><h3>Yii User Results</h3></div>";
?>
<table>
<tr><th>Name</th></tr>
<tr><td>Yii</td></tr>
<tr><td>Framework</td></tr> 
</table>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *