About drupal_realpath() and PDF Formatter
To get the web-accessible URL for a local file, you should use file_create_url().

$html = shell_exec('pdftohtml -q -stdout '.escapeshellarg(file_create_url($item['uri'])));


Using it would probably not work, anyway: I think that pdftohtml first tries to access the local file to see if it is a PDF file, and it outputs what you see when the file is an image. I doubt that pdftohtml uses &lt;img /&gt; for every file that is not a PDF file or that is not able to access.
In your case, file_create_url('public://imgtest.jpg') would return $base_url/sites/default/files/imgtest.jpg where $base_url is the content of the global $base_url, which includes the http:// or https:// part. While that would be perfect to be used for the &lt;img /&gt; tag, it could not be used as filename, since pdftohtml is not probably able to handle a filename starting with http:// or https://. (In other words, it expects the filename of a local file.)

It is probably easier to check if the file is an image, and output the &lt;img&gt; tag using the output of file_create_url() as image URL in that case, or the output from pdftohtml when it is not an image.