简体   繁体   中英

PHP/WinServer PDF to JPG

是否存在PHP可以在Windows Server 2000计算机上将PDF文档转换为JPG格式的插件/扩展程序?

ImageMagick is probably the best choice. See eg 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM