extranet/www/exportpdf.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2009-03-03 16:36:37 +00:00
<?php
2009-03-05 08:31:21 +00:00
2009-03-03 16:36:37 +00:00
function topdf($filename, $options = "") {
2009-03-05 11:24:43 +00:00
$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);
}
2009-03-03 16:36:37 +00:00
}
//Start...
2009-03-05 08:31:21 +00:00
$page = $_REQUEST['page'];
$idEntreprise = $_REQUEST['iden'];
$siret = $_REQUEST['siret'];
$siren = substr($siret,0,9);
2009-03-03 16:36:37 +00:00
//Construire le titre du fichier PDF en fonction des param<61>tres fournis
2009-03-05 08:31:21 +00:00
$path = realpath(dirname(__FILE__).'/../cache/');
if ($siren==0){
$fileName = $path.'/'.$page.'-'.$idEntreprise.'.html';
}else{
$fileName = $path.'/'.$page.'-'.$siren.'.html';
}
$firephp->log($fileName, 'FICHIER');
2009-03-05 16:19:38 +00:00
topdf($fileName, '--no-links');
2009-03-03 16:36:37 +00:00
?>