1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- session_start();
- //include autoloader
- require_once 'dompdf/autoload.inc.php';
- // reference the Dompdf namespace
- use Dompdf\Dompdf;
- // instantiate and use the dompdf class
- $dompdf = new Dompdf();
- $dompdf->set_option('defaultFont', 'Helvetica');
- // execute shell python commande
- $command = escapeshellcmd('python scripts/catalogue_museum.py');
- $output = shell_exec($command);
- // get today date
- date_default_timezone_set('Europe/Brussels');
- $today = getdate();
- $d = $today[mday];
- $m = $today[mon];
- $y = $today[year];
- $h = $today[hours];
- $min = $today[minutes];
- $sec = $today[seconds];
- //get random word for the cover
- $word = explode(" ", $output);
- $randomWord = $word[70];
- $dompdf->loadHtml(
- '<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>20 OBJECTS WITH HAIR</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- </head>
- <body class="toPrint">
- <header>
- <div class="randomWord">'.$randomWord.'</div>
- <div class="title">
- <h3>Carmentis.be</h3>
- <h1>20 objects with hair</h1>
- <h2>Catalogue</h2>
- <h4>Musee du Cinquantenaire - Jubelparkmuseum</h4>
- </div>
- </header>
- <div class="blank-page">
- </div>
- <div class="blank-page">
- </div>
- <div class="page-titre">
- <h1>20 objects with hair</h1>
- </div>
- <main>'.
- $output.
- '</main>
- <footer>
- <p>
- 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>
- Developed in the framework of DiVersions, a worksession organised by Constant in collaboration with e-Collections.
- <p>
- </footer>
-
- <div class="last-page">
- </div>
- </body></html>'
- );
- //(Optional) Setup the paper size and orientation
- $dompdf->setPaper('A6', 'portrait');
- // Render the HTML as PDF
- $dompdf->render();
- // add the header
- $canvas = $dompdf->get_canvas();
- // the same call as in my previous example
- $font = $dompdf->getFontMetrics()->get_font("Reglo", "normal");
- $canvas->page_text(210, 380, "{PAGE_NUM} ",$font, 10, array(0,0,0));
- // Output the generated PDF to Browser
- $dompdf->stream("20 OBJECTS WITH HAIR", array("Attachment" => 0));
- ?>
|