extranet/www/exportpdf.php
Michael RICOIS 6d1cd3bf42 idEntreprise
2009-03-11 07:51:18 +00:00

49 lines
1.5 KiB
PHP

<?php
function topdf($filename, $options = "") {
global $firephp;
$pdfFile = str_replace('.html','.pdf',$filename);
$firephp->log($pdfFile, 'pdfFile');
$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_exists($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['idEntreprise'];
$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 (($siret*1)==0 || ($siren*1)<100){
$fileName = $path.'/'.$page.'-'.$idEntreprise;
}else{
$fileName = $path.'/'.$page.'-'.$siret;
}
//Gestion des cas particulier
if($page=='dirigeants' && $_REQUEST['vue']=='histo'){
$fileName.= '-histo';
}
//Ajout de l'extension
$fileName.='.html';
$firephp->log($fileName, 'FICHIER');
topdf($fileName, '--no-links');
?>