Is there a plugin / extension that exists for PHP to convert PDF docs to a JPG format on a windows server 2000 machine?
3 Answers
ImageMagick is probably the best choice. See e.g. this question: How to get PDF first page and convert it to JPG
Note that ImageMagick needs Ghostscript installed in order to process PDFs.
You can install ImageMagick and call it via system()
. Here's the command to convert a PDF into it's individual pages (in JPEG):
convert foobar.pdf foobar.jpg
Once you make temporary images, you can just display them. I think that you can extract the first page using this command:
convert sample.pdf[0] sample.jpg

- 289,723
- 53
- 439
- 496
As pointed out by Pekka ImageMagick is able to do this via Ghostscript, there are other libraries that wrap Ghostscript and give you a little more control over the process. Andreas Heigl's PHP Ghostscript Wrapper is an example.
Depending on the PDF you are trying to convert you may discover that the colours become washed out, this is caused by the conversion between CMYK (or possibly CMYKA) and RGB. Depending on your needs you may need to convert to TIFF (that supports CMYK) then use another library with a better color space conversion algorithm.

- 6,313
- 4
- 53
- 81