Example #1
0
<?php

/**
 * 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\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
    ob_start();
    include dirname(__FILE__) . '/res/exemple11.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->setTestTdInOnePage(false);
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('exemple11.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Example #2
0
 /**
  * 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);
 }