一个非常简单的格式转换代码,可以把.PDF文件转换为.JPG文件,代码要起作用,服务器必须要安装Image Magick 扩展。
/**
* PHP调用Image Magick将.PDF文件转换为.JPG文件
*
* @param
* @author 网: 512Pic.com
**/
$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;
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528675.html