';
- //print '

';
- print img_mime($relativepath.$minifile);
+ $thumbshown=0;
+ if (preg_match('/\.pdf$/i', $file['name']))
+ {
+ $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'];
+ $fileimage = $conf->expensereport->dir_output.'/'.$relativepath.$file['name'].'_preview.png';
+ $relativepathimage = $relativepath.$file['name'].'_preview.png';
+
+ $pdfexists = file_exists($filepdf);
+
+ if ($pdfexists)
+ {
+ // Conversion du PDF en image png si fichier png non existant
+ if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
+ {
+ if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here.
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
+ if ($ret < 0) $error++;
+ }
+ }
+ }
+
+ if ($pdfexists && ! $error)
+ {
+ $heightforphotref=70;
+ if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60;
+ // If the preview file is found
+ if (file_exists($fileimage))
+ {
+ $thumbshown=1;
+ print '
.')
';
+ }
+ }
+ }
+
+ if (! $thumbshown)
+ {
+ print img_mime($minifile);
+ }
print '