This tutorial will help you to convert the HTML element in a page to pdf document. I created this tutorial with help of mPrint extension from yiiframework.
Features
- Apply Css
- Select HTML Elements to print
- Hide HTML Elements from print
<?php $this->widget('ext.mPrint.mPrint', array( //the title of the document. Defaults to the HTML title 'title' => 'HTML Element To Pdf', //tooltip message of the print icon. Defaults to 'print' 'tooltip' => 'HTML PDF', //text which will appear beside the print icon. Defaults to NULL 'text' => 'Print Results', 'element' => '#PRINT', //the element to be printed. 'exceptions' => array( //the element/s which will be ignored '.summary', ), 'publishCss' => true, //publish the CSS for the whole page? 'id' => 'PRINT_BUTTON_ID', 'style'=>'float: right; padding: 5px; margin-top: -5px;' )); ?> <div id="PRINT"> <?php echo "<div class='title'><h3 style='color:red;'>PRINT THIS PAGE</h3></div>"; ?> WELCOME HTML ELEMENT TO PDF CONVERTER EXTENSION </div> <div class='summary'>HIDE THIS SUMMARY DIV</div>