TCPDF: How can I place an image into an HTML block?
Sorry, I know you've got an accepted answer. However, it does not appear to actually answer your question, with regards to an image that is NOT at the web level.
Have you considered using file_get_contents(); and the simple rendering the base_64 string. This way you can use an image from any level, without worrying about it being publicly accessible.
E.g:
$imageLocation = '/var/www/html/image.png';
$ext = end(explode(".", $imageLocation);
$image = base64_encode(file_get_contents($imageLocation));
$pdf->writeHTML("<img src='data:image/$ext;base64,$image'>");
Or, without relying on the HTML parser. Which from experience slows rendering of the resulting PDF by far to much you could use:
$image = file_get_contents('/var/www/html/image.png');
$pdf->Image('@'.$image);
Edit
For the sake of completeness, and in response to Roland. You could certainly use SplFileObject.
$image = new SplFileObject('/var/www/html/image.png', 'r');
$imageContents = $image->fread($image->getSize());
$imageExtension = $image->getExtension();
$pdf->writeHTML("<img src='data:image/$imageExtension;base64,$imageContents'>");
I am using html img tag and its working well.
$toolcopy = ' my content <br>';
$toolcopy .= '<img src="/images/logo.jpg" width="50" height="50">';
$toolcopy .= '<br> other content';
$pdf->writeHTML($toolcopy, true, 0, true, 0);