37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
function topdf($filename, $options = "") {
|
|
$pdfFile = str_replace('.html','.pdf',$filename);
|
|
$pdfNameFile = substr($pdfFile, strrpos($pdfFile, "/")+1);
|
|
if (file_exists($pdfFile)){
|
|
// Run HTMLDOC to provide the PDF file to the user...
|
|
// Use the --no-localfiles option for enhanced security!
|
|
// Use ulimit to limit the maximum amount of memory used by each instance!
|
|
passthru("ulimit -m 16384 -t 5; htmldoc -t pdf14 --quiet --jpeg --webpage $options '$filename' -f $pdfFile");
|
|
}
|
|
if (file_exist($pdfFile)){
|
|
// Write the content type to the client...
|
|
header("Content-Type: application/pdf");
|
|
//header("Content-Disposition: inline; filename=\"$pdfFile\"");
|
|
header("Content-Disposition: attachement; filename=\"$pdfNameFile\"");
|
|
flush();
|
|
print file_get_contents($pdfFile);
|
|
}
|
|
}
|
|
|
|
//Start...
|
|
$page = $_REQUEST['page'];
|
|
$idEntreprise = $_REQUEST['iden'];
|
|
$siret = $_REQUEST['siret'];
|
|
$siren = substr($siret,0,9);
|
|
//Construire le titre du fichier PDF en fonction des paramètres fournis
|
|
$path = realpath(dirname(__FILE__).'/../cache/');
|
|
if ($siren==0){
|
|
$fileName = $path.'/'.$page.'-'.$idEntreprise.'.html';
|
|
}else{
|
|
$fileName = $path.'/'.$page.'-'.$siren.'.html';
|
|
}
|
|
$firephp->log($fileName, 'FICHIER');
|
|
topdf($fileName, '--no-links');
|
|
|
|
?>
|