Home > php教程 > php手册 > php使用Image Magick将PDF文件转换为JPG文件的方法

php使用Image Magick将PDF文件转换为JPG文件的方法

WBOY
Release: 2016-06-13 09:08:10
Original
900 people have browsed it

php使用Image Magick将PDF文件转换为JPG文件的方法

 这是一个非常简单的格式转换代码,可以把.PDF文件转换为.JPG文件,代码要起作用,服务器必须要安装Image Magick 扩展。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

$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;

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template