2
0

utf8.php 893 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Html2Pdf Library - example
  4. *
  5. * HTML => PDF converter
  6. * distributed under the OSL-3.0 License
  7. *
  8. * @package Html2pdf
  9. * @author Laurent MINGUET <webmaster@html2pdf.fr>
  10. * @copyright 2023 Laurent MINGUET
  11. */
  12. require_once dirname(__FILE__).'/../vendor/autoload.php';
  13. use Spipu\Html2Pdf\Html2Pdf;
  14. use Spipu\Html2Pdf\Exception\Html2PdfException;
  15. use Spipu\Html2Pdf\Exception\ExceptionFormatter;
  16. try {
  17. $html2pdf = new Html2Pdf('P', 'A4', 'fr');
  18. $content = file_get_contents(K_PATH_MAIN.'examples/data/utf8test.txt');
  19. $content = '<page style="font-family: freeserif"><br />'.nl2br($content).'</page>';
  20. $html2pdf->pdf->SetDisplayMode('real');
  21. $html2pdf->writeHTML($content);
  22. $html2pdf->output('utf8.pdf');
  23. } catch (Html2PdfException $e) {
  24. $html2pdf->clean();
  25. $formatter = new ExceptionFormatter($e);
  26. echo $formatter->getHtmlMessage();
  27. }