/** * Html2Pdf Library - example * * HTML => PDF convertor * distributed under the LGPL License * * isset($_GET['vuehtml']) is not mandatory * it allow to display the result in the HTML format * * @package Html2pdf * @author Laurent MINGUET <*****@*****.**> * @copyright 2016 Laurent MINGUET */ require_once dirname(__FILE__) . '/../vendor/autoload.php'; use Spipu\Html2Pdf\Html2Pdf; use Spipu\Html2Pdf\Html2PdfException; // get the HTML ob_start(); require dirname(__FILE__) . '/res/exemple00.php'; $content = ob_get_clean(); // convert to PDF try { $html2pdf = new Html2Pdf('P', 'A4', 'fr'); $html2pdf->setDefaultFont('Arial'); $html2pdf->writeHTML($content, isset($_GET['vuehtml'])); $html2pdf->Output('exemple00.pdf'); } catch (Html2PdfException $e) { echo $e; exit; }
/** * prepare self::$_subobj (used for create the sub Html2Pdf objects * * @access protected */ protected function _prepareSubObj() { $pdf = null; // create the sub object self::$_subobj = new Html2Pdf($this->_orientation, $this->_format, $this->_langue, $this->_unicode, $this->_encoding, array($this->_defaultLeft, $this->_defaultTop, $this->_defaultRight, $this->_defaultBottom)); // init self::$_subobj->setTestTdInOnePage($this->_testTdInOnepage); self::$_subobj->setTestIsImage($this->_testIsImage); self::$_subobj->setDefaultFont($this->_defaultFont); self::$_subobj->parsingCss->css =& $this->parsingCss->css; self::$_subobj->parsingCss->cssKeys =& $this->parsingCss->cssKeys; self::$_subobj->extensions = $this->extensions; // clone font from the original PDF self::$_subobj->pdf->cloneFontFrom($this->pdf); // remove the link to the parent self::$_subobj->parsingCss->setPdfParent($pdf); }