We have published an article on How to Convert HTML to PDF in PHP with fpdf and received many emails to write something on conversion from PDF to JPEG so today I am going to show you how we can convert PDF to JPEG and its a 4 lines script and very easy and simple to understand. We use PHP imagick extension which is mostly built-in in PHP installation so no need to include any thing.
$imagick = new Imagick();
In this code we have to give a PDF file and in output it will produce JPEG files for each page of your given PDF file.
If you want to convert first page of your PDF file only then define PDF file name like this mytest.pdf and run the script it will show convert only first page of your PDF file.
If you are using shared hosting and there is most of the time imagick extension not compiled with PHP only binaries available so here is to code to convert PDF to JPEG with imagick binaries.