4 * Convertit un fichier en utilisant l’application libreoffice.
6 * @note : nécessite que libreoffice soit installée sur le serveur.
9 if (!defined('_ECRIRE_INC_VERSION')) {
15 * Convertit un document transmis dans le format spécifié.
17 * @param string $fichier (chemin)
18 * @param string $format_destination
21 function convertir_avec_libreoffice($fichier, $format_destination = 'odt') {
22 if (!file_exists($fichier) or !is_readable($fichier)) {
26 include_spip('inc/libreoffice');
27 $destination = odt2spip_get_repertoire_temporaire();
30 $libreoffice = (new LibreOffice($fichier))
31 ->setConvertTo($format_destination)
32 ->setOutputDir($destination)
34 } catch (\Exception
$e) {
35 spip_log($e->getMessage(), 'odtspip.' . _LOG_ERREUR
);
39 if ($libreoffice->getErrors()) {
43 return $libreoffice->getConvertedFile();