我正在尝试使用 imagick php 扩展写入图像,但写入图像行的代码中断。我也在 policy.xml 中注释了此行
<!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
我正在尝试这个代码
private $path;
private $file;
function __construct($file){
$this->path = "upload/".$file;
$this->file = $file;
}
function convertDocument(){
if ( !is_dir("custom/modules/Contacts/temp") ) {
mkdir("custom/modules/Contacts/temp",0777,TRUE);
chmod("custom/modules/Contacts/temp", 0777);
}
$imagick = new imagick();
$imagick->setResolution(200, 200);
$imagick->readImage($this->path);
$imagick->setImageBackgroundColor('white');
$imagick->setImageAlphaChannel(11);
$GLOBALS['log']->fatal('Read Image');
$imagick->setImageResolution(2000, 2000);
$imagick->setImageFormat('jpg');
$pages = (int)$imagick->getNumberImages();
$GLOBALS['log']->fatal('Get Image Pages: '.$pages);
foreach($imagick as $i=>$imagick) {
$GLOBALS['log']->fatal('Write Images '.$i);
$imagick->writeImage("custom/modules/Contacts/temp/".$this->file."_".$i.".jpg");
}
$GLOBALS['log']->fatal('After Writing images, START MERGING');
$mpdf = new mPDF('en','Letter');
for($p = 0; $p < $pages; $p++){
$GLOBALS['log']->fatal('Write Image in PDF '.$p);
$mpdf->WriteHTML("<img src='custom/modules/Contacts/temp/".$this->file."_".$p.".jpg' />");
}
$mpdf->Output('custom/modules/Contacts/temp/'.$this->file.'.pdf');
$imagick->clear();
$GLOBALS['log']->fatal('Conversion End .... ');
return;
}
请帮助我解决这个问题。