pdf.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. error_reporting(E_ERROR);
  3. require_once 'dompdf/autoload.inc.php';
  4. use Dompdf\Dompdf;
  5. /*define('DB_ENGINE', 'mysql');
  6. define('DB_HOST', 'localhost');
  7. define('DB_PORT', 3306);
  8. define('DB_USER', 'erp.koos-weber.hu');
  9. define('DB_PW', 'Riobi4ee');
  10. define('DB_DBNAME', 'erp_koos_weber_hu');*/
  11. define('DB_ENGINE','mysql');
  12. define('DB_HOST','localhost');
  13. define('DB_PORT',3306);
  14. define('DB_USER','rockhu');
  15. define('DB_PW','coo4hu2N');
  16. define('DB_DBNAME','rockhu');
  17. $conn = new mysqli(DB_HOST,DB_USER,DB_PW,DB_DBNAME);
  18. $conn->query("SET NAMES utf8");
  19. // instantiate and use the dompdf class
  20. $dompdf = new Dompdf();
  21. $options = $dompdf->getOptions();
  22. $dompdf->set_option('defaultFont', 'DejaVu Sans');
  23. //$options->setChroot('');
  24. $dompdf->setOptions($options);
  25. $html = file_get_contents($_REQUEST['fname']);
  26. //$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
  27. $dompdf->loadHtml($html,'UTF-8');
  28. // (Optional) Setup the paper size and orientation
  29. $dompdf->setPaper('A4', 'portrai');
  30. // Render the HTML as PDF
  31. $dompdf->render();
  32. //$filename = time().'.pdf';
  33. //$full_path = 'export/pdf/'.$filename;
  34. //$url = 'http://rockhome.hu/'.$full_path;
  35. //echo $url;
  36. $dompdf->stream(time());