php pdf转jpg的方法:首先安装Image Magick扩展;然后通过“exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'...)”方式进行转换即可。

推荐:《PHP视频教程》
这是一个非常简单的格式转换代码,可以把.PDF文件转换为.JPG文件,代码要起作用,服务器必须要安装Image Magick 扩展。
$pdf_file = './pdf/demo.pdf';
$save_to = './jpg/demo.jpg';
//make sure that apache has permissions to write in this folder!
//(common problem)
//execute ImageMagick command 'convert' and convert PDF
//to JPG with applied settings
exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);
if($return_var == 0) {
//if exec successfuly converted pdf to jpg
print "Conversion OK";
}
else print "Conversion failed.".$output;
全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号