释放双眼,带上耳机,听听看~!
通过PHP把PDF生成PNG图片,一般用在在线阅读浏览用的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 1function pdf2png($PDF,$Path){
2 if(!extension_loaded('imagick')){
3 return false;
4 }
5 if(!file_exists($PDF)){
6 return false;
7 }
8 $IM = new imagick();
9 $IM->setResolution(120,120);
10 $IM->setCompressionQuality(100);
11 $IM->readImage($PDF);
12 foreach ($IM as $Key => $Var){
13 $Var->setImageFormat('png');
14 $Filename = $Path.'/'.md5($Key.time()).'.png';
15 if($Var->writeImage($Filename) == true){
16 $Return[] = $Filename;
17 }
18 }
19 return $Return;
20