summaryrefslogtreecommitdiff
path: root/src/Latex.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Latex.php')
-rw-r--r--src/Latex.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/Latex.php b/src/Latex.php
index f49fdea..c638264 100644
--- a/src/Latex.php
+++ b/src/Latex.php
@@ -57,6 +57,36 @@ abstract class Latex
57 // puis la mémoire est libérée à la fin de la fonction 57 // puis la mémoire est libérée à la fin de la fonction
58 // le PHP inséré fait donc partie de cette "mémoire" 58 // le PHP inséré fait donc partie de cette "mémoire"
59 } 59 }
60
61 public function makeTexAndPdf(): void // document polymorphe
62 {
63 if(get_class($this) !== 'EnveloppeVersoLatex')
64 {
65 File::makeFolder($this->latex_path);
66 File::makeFolder($this->pdf_path);
67 }
68 File::makeFile($this->latex_path, $this->file_name, $this->latex); // fichier .tex
69 $this->latexToPdf();
70 }
71
72 // commande système pdflatex
73 private function latexToPdf(): void
74 {
75 // paramètre optionnel
76 $output_dir = '';
77 if($this->pdf_path !== '')
78 {
79 $output_dir = '-output-directory=' . $this->pdf_path;
80 }
81
82 // compilation
83 exec('pdflatex ' . $output_dir . ' ' . $this->latex_path . $this->file_name);
84
85 // nettoyage
86 $basename = basename($this->file_name, '.tex');
87 unlink($this->pdf_path . $basename . '.aux');
88 unlink($this->pdf_path . $basename . '.log');
89 }
60 90
61 // getters 91 // getters
62 public function getFileName(): string 92 public function getFileName(): string
@@ -109,8 +139,8 @@ abstract class PrestaLatex extends Latex
109 { 139 {
110 $this->file_name = $Object->getCodePresta() . '.tex'; 140 $this->file_name = $Object->getCodePresta() . '.tex';
111 $this->date_array = explode('-', $Object->getdate()); 141 $this->date_array = explode('-', $Object->getdate());
112 $this->latex_path = Config::$latex_path . $this->date_array[0] . '/'; 142 $this->latex_path = Config::$latex_path . $this->date_array[0] . DIRECTORY_SEPARATOR;
113 $this->pdf_path = Config::$pdf_path . $this->date_array[0] . '/'; 143 $this->pdf_path = Config::$pdf_path . $this->date_array[0] . DIRECTORY_SEPARATOR;
114 } 144 }
115 145
116 return $this; // pour chainer les méthodes 146 return $this; // pour chainer les méthodes