diff options
Diffstat (limited to 'php/compileLatex.php')
| -rw-r--r-- | php/compileLatex.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/php/compileLatex.php b/php/compileLatex.php new file mode 100644 index 0000000..ccd9dab --- /dev/null +++ b/php/compileLatex.php | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | <?php | ||
| 2 | // compileLatex.php | ||
| 3 | |||
| 4 | // contenu | ||
| 5 | $codeLaTeX = '\documentclass{article} | ||
| 6 | |||
| 7 | \usepackage[francais]{babel} | ||
| 8 | \usepackage[utf8]{inputenc} | ||
| 9 | \usepackage[T1]{fontenc} | ||
| 10 | |||
| 11 | \begin{document} | ||
| 12 | Bravo, ça compile !! | ||
| 13 | \end{document}'; | ||
| 14 | |||
| 15 | |||
| 16 | // ficher tex | ||
| 17 | // regarder la doc, php-cli permettrait de manipuler les fichiers directement comme le bash | ||
| 18 | $fichier = fopen("latex.tex", "w+"); | ||
| 19 | fputs($fichier, $codeLaTeX); | ||
| 20 | fclose($fichier); | ||
| 21 | |||
| 22 | // compilation | ||
| 23 | exec('pdflatex latex.tex'); | ||
| 24 | |||
| 25 | // nettoyage | ||
| 26 | unlink("latex.aux"); | ||
| 27 | unlink("latex.log"); | ||
| 28 | unlink("latex.tex"); | ||
| 29 | |||
| 30 | exec('xdg-open latex.pdf'); | ||
