PHP - PDF Grab with URL that does not have .pdf extension


I'm using to upload PDFs to my application. I have all those URLs and now I am trying to merge some of those PDFs using the PDF Tool Kit PHP library. It was not working for me so I ran some tests using the "file_exists" on PHP and it kept returning false.

I think this has to do with the fact that the URL does not have a ".pdf" extension at the end. This is what they look like: ""

Does anyone know how I can pull the PDF using PHP in order to merge those files using the PDF Toolkit Library?


Alain F.

file_exists doesn't work with URLs, only with local files. Instead download the file to the temp dir using the copy command.

If the file can't be downloaded, the copy command will return false.

$exists = copy('', '/tmp/example.pdf');
if (!$exists) throw new Exception("PDF could not be downloaded");

Use the downloaded file in the PDF Tool Kit.