catalogue~20170419-184926.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. session_start();
  3. //include autoloader
  4. require_once 'dompdf/autoload.inc.php';
  5. // reference the Dompdf namespace
  6. use Dompdf\Dompdf;
  7. // instantiate and use the dompdf class
  8. $dompdf = new Dompdf();
  9. $dompdf->set_option('defaultFont', 'Helvetica');
  10. // execute shell python commande
  11. $command = escapeshellcmd('python scripts/catalogue_museum.py');
  12. $output = shell_exec($command);
  13. // get today date
  14. date_default_timezone_set('Europe/Brussels');
  15. $today = getdate();
  16. $d = $today[mday];
  17. $m = $today[mon];
  18. $y = $today[year];
  19. $h = $today[hours];
  20. $min = $today[minutes];
  21. $sec = $today[seconds];
  22. //get random word for the cover
  23. $word = explode(" ", $output);
  24. $randomWord = $word[70];
  25. $dompdf->loadHtml(
  26. '<html>
  27. <head>
  28. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  29. <title>20 OBJECTS WITH HAIR</title>
  30. <link rel="stylesheet" type="text/css" href="style.css" />
  31. </head>
  32. <body class="toPrint">
  33. <header>
  34. <div class="randomWord">'.$randomWord.'</div>
  35. <div class="title">
  36. <h3>Carmentis.be</h3>
  37. <h1>20 objects with hair</h1>
  38. <h2>Catalogue</h2>
  39. <h4>Musee du Cinquantenaire - Jubelparkmuseum</h4>
  40. </div>
  41. </header>
  42. <div class="blank-page">
  43. </div>
  44. <div class="blank-page">
  45. </div>
  46. <div class="page-titre">
  47. <h1>20 objects with hair</h1>
  48. </div>
  49. <main>'.
  50. $output.
  51. '</main>
  52. <footer>
  53. <p>
  54. This publication was generated by An Mertens on '."$d-$m-$y". ' at ' . "$h:$min:$sec". ' with material scraped from carmentis.be, the online catalogue of Musée du Cinquantenaire-Jubelparkmuseum, Brussels.<br>
  55. Developed in the framework of DiVersions, a worksession organised by Constant in collaboration with e-Collections.
  56. <p>
  57. </footer>
  58. <div class="last-page">
  59. </div>
  60. </body></html>'
  61. );
  62. //(Optional) Setup the paper size and orientation
  63. $dompdf->setPaper('A6', 'portrait');
  64. // Render the HTML as PDF
  65. $dompdf->render();
  66. // add the header
  67. $canvas = $dompdf->get_canvas();
  68. // the same call as in my previous example
  69. $font = $dompdf->getFontMetrics()->get_font("Reglo", "normal");
  70. $canvas->page_text(210, 380, "{PAGE_NUM} ",$font, 10, array(0,0,0));
  71. // Output the generated PDF to Browser
  72. $dompdf->stream("20 OBJECTS WITH HAIR", array("Attachment" => 0));
  73. ?>