Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1029 → Rev 1030

/trunk/modules/pdf_export/PdfExport.php
113,9 → 113,8
if (!empty($_POST['bloc'])) {
$this->blocs = $_POST['bloc'];
} else {
$this->blocs = array('description', 'ecologie', 'ethnobotanique',
'statuts', 'illustrations', 'bibliographie',
'repartition', 'nomenclature');
$this->blocs = array('description', 'ecologie', 'ethnobotanique', 'statuts', 'illustrations',
'bibliographie', 'repartition', 'nomenclature');
}
}
 
124,16 → 123,20
}
 
public function executerPdfExport(){
$this->capturerParametresFormulaire();
$donnees = $this->obtenirDonnees();
$this->construireHtml($donnees);
if ($this->transformerHtmlEnPdf()) {
$this->envoyerPdfAuNavigateur();
} else {
die('Erreur de generation du fichier PDF');
$nom_fichier = $this->getNomFichierValide();
$this->fichier_html = $this->chemin_pdf.''.$nom_fichier.'.html';
$this->fichier_pdf = $this->chemin_pdf.''.$nom_fichier.'.pdf';
 
if (file_exists($this->fichier_pdf) == false) {
$this->capturerParametresFormulaire();
$donnees = $this->obtenirDonnees();
$this->construireHtml($donnees);
if ($this->transformerHtmlEnPdf() == false) {
die('Erreur de generation du fichier PDF');
}
}
// important, autrement l'exécution de papyrus continue
// et du HTML inutile est ajouté à la fin du fichier PDF
$this->envoyerPdfAuNavigateur();
// ATTENTION : on doit stopper l'exécution de Papyrus sinon du HTML inutile est ajouté à la fin du fichier PDF
exit;
}
 
203,10 → 206,6
 
//version WKHTMLtoPDF en ligne de commande
private function transformerHtmlEnPdf() {
$nom_fichier = $this->getNomFichierValide();
$time = $_SERVER['REQUEST_TIME'] ;
$this->fichier_html = $this->chemin_pdf.''.$nom_fichier.'-'.$time.'.html';
$this->fichier_pdf = $this->chemin_pdf.''.$nom_fichier.'-'.$time.'.pdf';
$nom = $this->getNomRetenu();
file_put_contents($this->fichier_html, $this->html);
$commande = "{$this->wkhtml} --replace 'nom' '$nom' --encoding utf-8 --footer-html {$this->piedepage} {$this->fichier_html} {$this->fichier_pdf}";
214,7 → 213,8
$debug = array();
exec($commande, $debug, $ret);
//print_r( $debug ); echo $ret;
return ( $ret == 0 || $ret == 2 );
$ok = ($ret == 0 || $ret == 2) ? true : false;
return $ok;
}
}
?>