Home > Backend Development > PHP Tutorial > How to use Image Magick to convert PDF files to JPG files in php_PHP Tutorial

How to use Image Magick to convert PDF files to JPG files in php_PHP Tutorial

WBOY
Release: 2016-07-13 09:58:37
Original
1097 people have browsed it

php method to convert PDF files to JPG files using Image Magick

This is a very simple format conversion code that can convert .PDF files into .JPG files, code To work, the server must have the Image Magick extension installed.

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;

1 2 3

4

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 successfully converted pdf to jpg print "Conversion OK"; } else print "Conversion failed.".$output;
http://www.bkjia.com/PHPjc/977614.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977614.htmlTechArticlephp method to convert PDF files to JPG files using Image Magick This is a very simple format conversion code that can Convert .PDF files to .JPG files. For the code to work, the server must...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template