I have a website that is generating a PDF file based from data.
I tried it in a free webhost and it is ok but when i upload it to my server i get this error:
TCPDF ERROR: Can't open image file: /var/www/html/tcpdf/cache/mska_1d34cb1ba2c1951624fbccb7556c6d1d
in the cache folder the mska_1d34cb1ba2c1951624fbccb7556c6d1d doesnt exist in the folder.
One cause is that folders inside tcpdf has no permissions of write and read. make sure the folder for cache and images has 644 or 755 (recommended) permission. these permission is very important because there is a process when generating pdf it write something is the cache or read into images.
It can be passed to TCPDF using an @ in the image's src-attribute, like so: An img-tag in HTML takes a BASE64 encoded string, unlike the Image () function, which takes unencoded data. I don't know if this is even documented, I found this by reading the code (tcpdf.php, line 18824 pp):
Open Source PHP class for generating PDF documents. Started in 2002, TCPDF is now one of the world's most active Open Source projects, used daily by millions of users and included in thousands of CMS and Web applications. Check the examples...
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: Show activity on this post. I use image data instead of paths. It can be passed to TCPDF using an @ in the image's src-attribute, like so:
I got the answer now.
For all who will be able to encounter this problem these are the possible solution.
One cause is that folders inside tcpdf has no permissions of write and read. make sure the folder for cache and images has 644 or 755 (recommended) permission. these permission is very important because there is a process when generating pdf it write something is the cache or read into images.
another cause is that tcpdf does not accept png file or with transparent images. my solution was to make the image into a jpeg and apply a white background for it. so avoid png with transparent.
hope it helped.
In Ubuntu this error was fixed by setting 777 permissions on the tcpdf/cache/
folder:
chmod 777 cache
I tried with 755 or 775 and did not work.
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