這是一個(gè)非常簡(jiǎn)單的格式轉(zhuǎn)換代碼,可以把.PDF文件轉(zhuǎn)換為.JPG文件,代碼要起作用,服務(wù)器必須要安裝Image Magick 擴(kuò)展。
$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;
更多信息請(qǐng)查看IT技術(shù)專欄
2025國(guó)考·省考課程試聽報(bào)名