diff options
Diffstat (limited to 'php/latexToPdf.php')
| -rw-r--r-- | php/latexToPdf.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/php/latexToPdf.php b/php/latexToPdf.php new file mode 100644 index 0000000..18ff452 --- /dev/null +++ b/php/latexToPdf.php | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | <?php | ||
| 2 | // php/latexToPdf.php | ||
| 3 | |||
| 4 | // contenu | ||
| 5 | $latex = '\documentclass{article} | ||
| 6 | |||
| 7 | \usepackage[french]{babel} | ||
| 8 | \usepackage[utf8]{inputenc} | ||
| 9 | \usepackage[T1]{fontenc} | ||
| 10 | |||
| 11 | \begin{document} | ||
| 12 | Bravo, ça compile !! | ||
| 13 | \end{document}'; | ||
| 14 | |||
| 15 | $fileName = 'latex.tex'; | ||
| 16 | $latexPath = ''; | ||
| 17 | $pdfPath = ''; | ||
| 18 | |||
| 19 | //~ writeLatex($latex, $fileName, $latexPath); | ||
| 20 | |||
| 21 | function latexToPdf(string $fileName, string $latexPath, string $pdfPath) | ||
| 22 | { | ||
| 23 | $outputDir = ''; | ||
| 24 | if($pdfPath !== '') | ||
| 25 | { | ||
| 26 | $outputDir = '-output-directory=' . $pdfPath . ' '; | ||
| 27 | } | ||
| 28 | |||
| 29 | // compilation | ||
| 30 | exec('pdflatex ' . $outputDir . $latexPath . $fileName); | ||
| 31 | |||
| 32 | // nettoyage | ||
| 33 | $basename = basename($fileName, '.tex'); | ||
| 34 | unlink($pdfPath . $basename . '.aux'); | ||
| 35 | unlink($pdfPath . $basename . '.log'); | ||
| 36 | } | ||
| 37 | |||
| 38 | //~ latexToPdf($fileName, $latexPath, $pdfPath); | ||
