set_option('defaultFont', 'Helvetica'); // execute shell python commande // change the command with the name of your script $command = escapeshellcmd('python scripts/perec.py'); $output = shell_exec($command); //get random word for the cover $word = explode("

", $output); $randomWord = $word[rand(0, count($word))]; $dompdf->loadHtml( ' PEREC

'.$randomWord.'

Frankenstein

Marie Shelley

'. $output. '

' ); //(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(); // Add font for page number $font = $dompdf->getFontMetrics()->get_font("Reglo", "normal"); // Add page number $canvas->page_text(145, 390, "{PAGE_NUM} ",$font, 7, array(0,0,0)); // Output the generated PDF to Browser //Change the name of the pdf by changing "Perec" $dompdf->stream("Perec", array("Attachment" => 0)); ?>