blob: 9e1a3f5bdf86d58bf030b86242f47c69a322d0ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<?php
// src/files.php
//
// fonctions pour manipuler les fichiers latex et pdf
function makeFile($path, $file_name, $data)
{
file_put_contents($path. $file_name, $data);
chmod($path . $file_name, 0644); // droits en octal
}
function makeFolder(string $path)
{
if(!file_exists($path))
{
mkdir($path);
chmod($path, 0755); // droits en octal
}
}
// commande système pdflatex
function latexToPdf(string $latex_path, string $file_name, string $pdf_path)
{
$output_dir = '';
if($pdf_path !== '')
{
$output_dir = '-output-directory=' . $pdf_path . ' ';
}
// compilation
//echo 'pdflatex ' . $output_dir . $latex_path . $file_name . "\n";
exec('pdflatex ' . $output_dir . $latex_path . $file_name);
// nettoyage
$basename = basename($file_name, '.tex');
unlink($pdf_path . $basename . '.aux');
unlink($pdf_path . $basename . '.log');
}
|