When open_basedir is set initializing tcpdf.php causes a php warning. Open basedir is common is shared hosting.
Created by: lolaslade
The full warning:
warning: file_exists(): open_basedir restriction in effect. File(/usr/share/doc/php-tcpdf/examples/images/) is not within the allowed path(s): (/var/www/mysite.ca/:/tmp/) in /var/www/mysite.ca/httpdocs/sites/all/modules/civicrm/packages/tcpdf/tcpdf_autoconfig.php on line 96.
The solution is to initialize K_PATH_IMAGES just before initializing TCPDF. I am not quite sure if the same thing happens during civicrm core usage of the library (for mailing labels I think).
I also suggest we move the require for tcpdf into just the two functions where we need it to reduce overhead. If we don't it is loaded on every Civicrm page.