PDF2JPG-使用ImageMagick将PDF转换为JPG图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PDF2JPG-使用ImageMagick将PDF转换为JPG图像相关的知识,希望对你有一定的参考价值。

#ImageMagick must be installed on server for this operation
  1. /**
  2.  * PDF2JPG script
  3.  * with ImageMagick
  4.  */
  5.  
  6. $pdf_file = './pdf/demo.pdf';
  7. $save_to = './jpg/demo.jpg'; //make sure that apache has permissions to write in this folder! (common problem)
  8.  
  9. //execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
  10. exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);
  11.  
  12.  
  13. if($return_var == 0) { //if exec successfuly converted pdf to jpg
  14. print "Conversion OK";
  15. }
  16. else print "Conversion failed.<br />".$output;

以上是关于PDF2JPG-使用ImageMagick将PDF转换为JPG图像的主要内容,如果未能解决你的问题,请参考以下文章