Skip to content
Snippets Groups Projects
Commit a8349130 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FIX #14661 TIME 1:35 fix convert html files to pdf in debian

parent de55032d
No related branches found
No related tags found
No related merge requests found
......@@ -36,11 +36,24 @@ class ConvertPdfController
{
$tmpPath = CoreConfigModel::getTmpPath();
$extension = pathinfo($aArgs['fullFilename'], PATHINFO_EXTENSION);
if (strtolower($extension) == 'html') {
if (strtolower($extension) == 'html' || strtolower($extension) == 'htm') {
$pdfFilepath = str_replace('.'.$extension, '', $aArgs['fullFilename']) . '.pdf';
$command = "wkhtmltopdf -B 10mm -L 10mm -R 10mm -T 10mm --load-error-handling ignore --load-media-error-handling ignore ".$aArgs['fullFilename']." ".$pdfFilepath;
exec('export DISPLAY=:0 && '.$command.' 2>&1', $output, $return);
// Check if xvfb-run is installed, and run wkhtmltopdf with it
// Necessary when running in a headless debian server
// src : https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2037
exec('whereis xvfb-run', $outputWhereIs, $returnWk);
$outputWhereIs = explode(':', $outputWhereIs[0]);
$xvfb = !empty($outputWhereIs[1]);
if ($xvfb) {
$command = 'xvfb-run ' . $command;
} else {
$command = 'export DISPLAY=:0 && ' . $command;
}
exec($command.' 2>&1', $output, $return);
} elseif (strtolower($extension) != 'pdf') {
$url = str_replace('rest/', '', UrlController::getCoreUrl());
if (OnlyOfficeController::canConvert(['url' => $url, 'fullFilename' => $aArgs['fullFilename']])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment