wkthml = $c->profil->wkhtmltopdf->path; } /** * Défini les options supplémentaires à l'execution de wkhtmltopdf * -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 * @param string $name * @param string $value */ public function setOptions($name, $value = '') { $this->options[$name] = $value; } /** * Imprime un fichier HTML en PDF avec l'utilitaire wkhtmltopdf * @param string $fileIn * @param string $fileOut * @return string Nom du fichier */ public function exec($fileIn, $fileOut = '') { if (empty($fileOut)) {$fileOut = str_replace('.html', '.pdf', $fileIn); } if(file_exists($fileOut)){ unlink($fileOut); } $options = '--disable-internal-links'; if ( count($this->options) ) { foreach ( $this->options as $name => $value ) { $options.= ' --'.$name; if ($value!= '') $options.= ' "'.$value.'"'; } } if ( stristr(PHP_OS, 'WIN') ) { $wkhtmltopdf = 'windows/wkhtmltopdf.exe'; } else { switch ( $this->arch ) { default: case 'amd64': $wkhtmltopdf = 'linux/wkhtmltopdf-amd64'; break; case 'i386': $wkhtmltopdf = 'linux/wkhtmltopdf-i386'; break; } } $cmd = $this->wkhtml.' '.$options.' "'.$fileIn.'" "'.$fileOut.'"'; exec( $cmd ); return $fileOut; } }