The PDF Formatter module uses pdftohtml to transform PDF to HTML, and show information.
Changing the module code, it is possible to show images too, but the path used for the image in the HTML markup is wrong.
What can I do to fix it?
The code used by the module is the following.
// PDF to html formatter
case 'file_pdf_to_html_formatter':
$pdftohtml_installed = pdf_formatter_pdftohtml_installed();
foreach ($items as $delta => $item) {
$html = '';
$html = shell_exec('pdftohtml -q -stdout '.escapeshellarg(drupal_realpath($item['uri'])));
// pdftohtml tends to generate too many non break spaces,
// replace them with standard spaces
$html = str_replace(' ',' ',$html);
// pdftohtml generates a complete HTML file.
// Drupal only waits for contents between the body tag
$html = preg_replace('/.*<BODY[^>]*>(.*)<\/BODY>.*/si', '\\1', $html);
}
$element[$delta] = array('#markup' => $html);
}
break;
The output I get is the following.
<img src="/var/www/html/drupal/sites/default/files/imgtest.jpg" />