Exemplo n.º 1
1
<?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\Html2PdfException;
// get the HTML
ob_start();
require dirname(__FILE__) . '/res/exemple01.php';
$content = ob_get_clean();
// convert to PDF
try {
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('exemple01.pdf');
} catch (Html2PdfException $e) {
    echo $e;
    exit;
}
Exemplo n.º 2
0
 /**
  * test: The image src is unknown
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\ImageException
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('Hello World <img src="' . dirname(__FILE__) . '/res/wrong.png" />');
     $object->Output('test.pdf', 'S');
 }
Exemplo n.º 3
0
 /**
  * test: The image src is unknown
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\ImageException
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('<div style="background-image: url(' . dirname(__FILE__) . '/res/wrong.png)">Hello World</div>');
     $object->Output('test.pdf', 'S');
 }
Exemplo n.º 4
0
 /**
  * test: The HTML tag code provided is invalid
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\HtmlParsingException
  */
 public function testInvalidCode()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('<az1-r_h>Hello</az1-r_h>');
     $object->Output('test.pdf', 'S');
 }
Exemplo n.º 5
0
 /**
  * test: the file extension must be PDF
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\Html2PdfException
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('<p>Hello World</p>');
     $object->Output('test.bad', 'S');
 }
Exemplo n.º 6
0
 /**
  * test
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\HtmlParsingException
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('<g />');
     $object->Output('test.pdf', 'S');
 }
Exemplo n.º 7
0
 /**
  * test: the file extension must be PDF
  *
  * @return void
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('Hello World');
     $result = $object->Output('test.pdf', 'S');
     $this->assertContains('PhpUnit Test', $result);
 }
Exemplo n.º 8
0
 /**
  * test: The image src is unknown
  *
  * @return void
  */
 public function testCase()
 {
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('Hello World <img src="' . dirname(__FILE__) . '/res/logo.png" />');
     $result = $object->Output('test.pdf', 'S');
     $this->assertContains('PhpUnit Test', $result);
 }
Exemplo n.º 9
0
 /**
  * test
  *
  * @return void
  * @expectedException \Spipu\Html2Pdf\Exception\TableException
  */
 public function testCase()
 {
     $sentence = 'Hello World ! ';
     $sentences = '';
     for ($k = 0; $k < 100; $k++) {
         $sentences .= $sentence;
     }
     $object = new Html2Pdf();
     $object->pdf->SetTitle('PhpUnit Test');
     $object->writeHTML('<table><tr><td style="width: 28mm">' . $sentences . '</td></tr></table>');
     $object->Output('test.pdf', 'S');
 }
Exemplo n.º 10
0
    /**
     * test
     *
     * @return void
     * @expectedException \Spipu\Html2Pdf\Exception\HtmlParsingException
     */
    public function testCase()
    {
        $html = '
<page>
    <draw style="width:150mm; height:100mm;">
        <path style="fill:#770000; stroke:#AA0033;" d="n 20mm,40mm a16mm,8mm 0,0,0 16mm,8mm" />
    </draw>
</page>';
        $object = new Html2Pdf();
        $object->pdf->SetTitle('PhpUnit Test');
        $object->writeHTML($html);
        $object->Output('test.pdf', 'S');
    }
Exemplo n.º 11
0
 public function testExtensionTag()
 {
     $tag = Phake::mock('Spipu\\Html2Pdf\\Tag\\TagInterface');
     Phake::when($tag)->getName()->thenReturn('test_tag');
     $extension = Phake::mock('Spipu\\Html2Pdf\\Extension\\ExtensionInterface');
     Phake::when($extension)->getName()->thenReturn('test');
     Phake::when($extension)->getTags()->thenReturn(array($tag));
     $this->html2pdf->addExtension($extension);
     $this->html2pdf->writeHTML('<test_tag/>');
     Phake::verify($tag)->open;
     Phake::verify($tag, Phake::times(2))->close;
     // TODO Html2Pdf should probably call this only one time
 }
Exemplo n.º 12
0
 *
 * 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;
// for display the post information
if (isset($_POST['test'])) {
    echo '<pre>';
    echo htmlentities(print_r($_POST, true));
    echo '</pre>';
    exit;
}
try {
    ob_start();
    require dirname(__FILE__) . '/res/forms.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('forms.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 13
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/exemple02.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(15, 5, 15, 5));
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('exemple02.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 14
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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);
    $html2pdf->Output('exemple11.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 15
0
 * HTML => PDF convertor
 * distributed under the LGPL License
 *
 * @package   Html2pdf
 * @author    Laurent MINGUET <*****@*****.**>
 * @copyright 2016 Laurent MINGUET
 *
 * isset($_GET['vuehtml']) is not mandatory
 * it allow to display the result in the HTML format
 */
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Html2PdfException;
require_once dirname(__FILE__) . '/../vendor/autoload.php';
try {
    // init Html2Pdf
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(0, 0, 0, 0));
    // display the full page
    $html2pdf->pdf->SetDisplayMode('fullpage');
    // get the HTML
    ob_start();
    include dirname(__FILE__) . '/res/about.php';
    $content = ob_get_clean();
    // convert
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    // add the automatic index
    $html2pdf->createIndex('Sommaire', 30, 12, false, true, 2);
    // send the PDF
    $html2pdf->Output('about.pdf');
} catch (Html2PdfException $e) {
    echo $e;
    exit;
Exemplo n.º 16
0
            <g style="fill: #cccccc"><path d="M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"/></g>
            <g style="fill: #cccccc"><path d="M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"/></g>
            <g style="fill: #cccccc"><path d="M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"/></g>
            <g style="fill: #cccccc"><path d="M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"/></g>
            <g style="fill: #cccccc"><path d="M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"/></g>
            <g style="fill: #cccccc"><path d="M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"/></g>
            <g style="fill: #cccccc"><path d="M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"/></g>
            <g style="fill: #cccccc"><path d="M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"/></g>
            <g style="fill: #cccccc"><path d="M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"/></g>
            <g style="fill: #cccccc"><path d="M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"/></g>
            <g style="fill: #cccccc"><path d="M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"/></g>
            <g style="fill: #cccccc"><path d="M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"/></g>
            <g style="fill: #cccccc"><path d="M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"/></g>
            <g style="stroke:#000000"><path d="M-89.25 169L-67.25 173.75"/></g>
            <g style="stroke:#000000"><path d="M-39 331C-39 331 -39.5 327.5 -48.5 338"/></g>
            <g style="stroke:#000000"><path d="M-33.5 336C-33.5 336 -31.5 329.5 -38 334"/></g>
            <g style="stroke:#000000"><path d="M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"/></g>
        </g>
    </draw>
</page>';
// convert to PDF
require_once dirname(__FILE__) . '/../vendor/autoload.php';
try {
    $html2pdf = new Html2Pdf('L', 'A4', 'fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->Output('svg_tiger.pdf');
} catch (Html2PdfException $e) {
    echo $e;
    exit;
}
Exemplo n.º 17
0
/**
 * 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;
}
Exemplo n.º 18
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/groups.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('groups.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 19
0
        intro au chapitre 3
        <bookmark title="Chapitre 3.1" level="1" ></bookmark><h2>Chapitre 3.1</h2>
        <div class="niveau">
            Contenu du chapitre 3.1
        </div>
        <bookmark title="Chapitre 3.2" level="1" ></bookmark><h2>Chapitre 3.2</h2>
        <div class="niveau">
            intro au chapitre 3.2
            <bookmark title="Chapitre 3.2.1" level="2" ></bookmark><h3>Chapitre 3.2.1</h3>
            <div class="niveau">
                Contenu du chapitre 3.2.1
            </div>
            <bookmark title="Chapitre 3.2.2" level="2" ></bookmark><h3>Chapitre 3.2.2</h3>
            <div class="niveau">
                Contenu du chapitre 3.2.2
            </div>
        </div>
    </div>
</page>
<?php 
$content = ob_get_clean();
require_once dirname(__FILE__) . '/../vendor/autoload.php';
try {
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    $html2pdf->createIndex('Sommaire', 25, 12, false, true, 1);
    $html2pdf->Output('bookmark.pdf');
} catch (Html2PdfException $e) {
    echo $e;
    exit;
}
Exemplo n.º 20
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/exemple00.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->setDefaultFont('Arial');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('exemple00.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 21
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/regle.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('L', 'A4', 'fr', true, 'UTF-8', 10);
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('regle.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 22
0
<?php 
session_start();
require_once "../html2pdf/vendor/autoload.php";
// ini_set("session.auto-start", 0);
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Html2Pdf;
try {
    //ob_clean();
    $content = "";
    ob_start();
    include 'carro2_pdf.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    // $content = ob_get_clean();
    $html2pdf->writeHTML($content);
    ob_get_clean();
    $html2pdf->Output();
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 23
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();
}
Exemplo n.º 24
0
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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;
// for display the post information
if (isset($_POST['test'])) {
    echo '<pre>';
    echo htmlentities(print_r($_POST, true));
    echo '</pre>';
    exit;
}
try {
    ob_start();
    require dirname(__FILE__) . '/res/forms.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('forms.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 25
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/qrcode.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('qrcode.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 26
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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 {
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(0, 0, 0, 0));
    $html2pdf->pdf->SetDisplayMode('fullpage');
    ob_start();
    include dirname(__FILE__) . '/res/about.php';
    $content = ob_get_clean();
    $html2pdf->writeHTML($content);
    $html2pdf->createIndex('Sommaire', 30, 12, false, true, 2);
    $html2pdf->Output('about.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 27
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/ticket.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('ticket.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 28
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/bookmark.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0);
    $html2pdf->writeHTML($content);
    $html2pdf->createIndex('Sommaire', 25, 12, false, true, 1);
    $html2pdf->Output('bookmark.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 29
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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/svg.php';
    $content = ob_get_clean();
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('svg.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}
Exemplo n.º 30
0
<?php

/**
 * Html2Pdf Library - example
 *
 * HTML => PDF converter
 * distributed under the LGPL License
 *
 * @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 {
    $html2pdf = new Html2Pdf('P', 'A4', 'fr');
    $content = file_get_contents(K_PATH_MAIN . 'examples/data/utf8test.txt');
    $content = '<page style="font-family: freeserif"><br />' . nl2br($content) . '</page>';
    $html2pdf->pdf->SetDisplayMode('real');
    $html2pdf->writeHTML($content);
    $html2pdf->Output('utf8.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}