Php – How to put an image url from internet in tcpdf file

pdf-generationPHPtcpdf

Hi I want to put an image into the PDF file I'm making using TCPDF. It is an image generated by an online API so I cannot store it on my webhost. But when I put the image URL for creating I'm getting error while generating the PDF file.

Best Answer

TCPDF can only use images saved on your webhost - local files, as it needs a physical path to the image in order to include it in the document. The only way you could grab an image from HTTP to be used for TCPDF would be to use cURL, which is something I have only used for text and html, but have no experience grabbing images with, but I'm sure there's a way it can be done.