TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

In TCPDF 6.3.4 after pdf render images with base64 not appear

Open eliel-jr opened this issue 5 years ago • 6 comments

I'm use PHP 7.2.5 and after update TCPDF to 6.3.4, not rendering images with base64

images with filepath render OK.

on v6.2.13 rendering OK.

HTML example in text that not rendering base64

html_example.txt

eliel-jr avatar Feb 13 '20 11:02 eliel-jr

I'm testing versions: v6.3.4, v6.3.3, v6.3.2, v6.3.1, v6.3.0, v6.2.26, v6.2.25, v6.2.23, v6.2.22 and all broken

in v6.2.21 render OK.

eliel-jr avatar Feb 13 '20 12:02 eliel-jr

Hi!

I'd the same problem, just replace the tcpdf/include/tcpdf_static.php function file_exists (L1879 in tcpdf 6.3.4) like this:

public static function file_exists($filename) {

if (preg_match('|^https?://|', $filename) == 1) {
    return self::url_exists($filename);
} 

if(stripos($filename,'data:')===0) {
    return true;
}

if (strpos($filename, '://')) {
      return false; // only support http and https wrappers for security reasons
}

return @file_exists($filename);

}

LittleBigFox avatar Feb 13 '20 12:02 LittleBigFox

https://github.com/spipu/html2pdf/issues/413

Vitexus avatar Mar 27 '20 18:03 Vitexus

Version 6.2.21 works fine in local and server. I have 6.3.2 and render Ok in local and not works in server. Above solution not working for me. I checked with 6.3.2 and 6.4.4

clickmeplz avatar Mar 30 '22 04:03 clickmeplz

Do this <img src="@/9j/4AAQ.... instead of <img src="data:image/png;base64,/9j/4AAQ....

detook avatar Oct 31 '22 09:10 detook

@detook solution works, but so is @LittleBigFox's if one is ok with modifying the static file.

I personally find it very sad that we have to add an @ instead of the default:

data:image/png;base64

I've created a PR with @LittleBigFox's fix: https://github.com/tecnickcom/TCPDF/pull/671

compojoom avatar Dec 01 '23 19:12 compojoom