I get my images in my pdf document on my localhost but on the production site i get the error TCPDF ERROR: [Image] Unable to get image
i am using an html img tag to get the images and the src is the directory path to this image not a url, but i found out that TCPDF is adding the path i give it with the path to my www folder like:
path to picture i give to tcpdf: home/inc_dir/img/pic.jpg
tcpdf looks for it here: home/www/home/inc_dir/pic.jpg
can someone please help me find out tcpdf is concatenating the directories?
You can also change only the image path instead of main path use:
define('K_PATH_IMAGES', '/path/to/images/');
require_once('tcpdf.php');
This won't break fonts/ and other tcpdf paths.
TCPDF is using $_SERVER['DOCUMENT_ROOT']
as a root directory of all your images, and builds their absolute paths in relation to it. You can change it either in $_SERVER
or with this PHP constant: K_PATH_MAIN
:
define('K_PATH_MAIN', '/path/to/my-images/');
require_once 'tcpdf.php';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With