$maxTime) $timeover = true; return $timeover; } /** * Ecrit le contenu capturé dans un fichier * @param $file * @return void */ function print_write_content($file) { $length = ob_get_length(); $content = ob_get_contents(); if($content !== FALSE){ if( !file_put_contents($file, $content)) { //TODO : Gestion des erreurs } } if(ob_end_clean()===FALSE){ //TODO : Gestion des erreurs } } /** * Impression en PDF * @param $file * @return unknown_type */ function print_pdf($file){ $method = 'wkhtmltopdf'; return $method($file); } /** * Impression en HTML * @param $file * @return void */ function print_html($file){} /** * Imprime un fichier HTML en PDF avec l'utilitaire wkhtmltopdf * @param $file * @return unknown_type */ function wkhtmltopdf($file) { $date = date('d/m/Y H:i:s'); $output_file = str_replace('.html', '.pdf', $file); if(file_exists($output_file)){ unlink($output_file); } /* * -n, --disable-javascript Do not allow webpages to run javascript. * --disable-internal-links Do no make local links * --disable-external-links Do no make links to remote web pages * --user-style-sheet Specify a user style sheet, to load with every page. * --print-media-type Use print media-type instead of screen. * --header-left|right */ $options = '--disable-internal-links'; $options.= ' --footer-right "Page [page] sur [toPage]"'; $options.= ' --header-right "'.$date.'"'; if (stristr(PHP_OS, 'WIN')) { $wkhtmltopdf = 'windows/wkhtmltopdf.exe'; } else { switch(WKHTMLTOPDF_ARCH) { case 'amd64': $wkhtmltopdf = 'linux/wkhtmltopdf-amd64'; break; default: case 'i386': $wkhtmltopdf = 'linux/wkhtmltopdf-i386'; break; } } exec( realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR. $wkhtmltopdf.' '.$options.' "'.$file.'" "'.$output_file.'"'); return $output_file; }