用tcpdf生成的pdf的Imagick错误用pdf生成Imagick:“Postscript委托失败了`/ tmp / magick-KKLAvA”

时间:2012-04-19 09:32:52

标签: php imagemagick tcpdf imagick

我将pdf保存在服务器中(生成py TCPDF),我需要预览它们。 我的预览代码适用于某些pdf,但它不适用于其他人。

我的代码:

$filehandle = fopen( $urlPdf, "rb");
$img = new Imagick();
$img->readimagefile($filehandle);

代码继续,但问题发生在上面的行之后,因为当我把die()放在它们之后我有同样的错误:

Postscript delegate failed `/tmp/magick-XXtHvIKA': No such file or directory

以下是我生成pdf的方法:

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('CSI');
$pdf->SetTitle('Pismo');
$pdf->SetSubject('Pismo');
$pdf->SetKeywords('CSI');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// add a page
$pdf->AddPage();
$pdf->SetFont('dejavusans', '', 10);

// create some HTML content
if ($image->kind == 0){
$html ='<img src="../public/img/ci2.png"/ style="width: 620px"/><br>';
}
else {
    $html ='<img src="../public/img/kan.png"/ style="width: 620px"/><br>';
}
$pdf->writeHTML($html, true, 0, true, true);
$tbl = <<<EOD
<table cellspacing="0" cellpadding="1" border="0">
<tr>
    <td><img src="../barcodes/$image->id.png" style="width: 200px;position:absolute;left:550px;top:50px;"/></td>
    <td>$line</td>
</tr>
<tr>
<td></td>
<td  style="text-align:right;">Warszawa, $image->date</td>
</tr>
</table>
EOD;

$pdf->writeHTML($tbl, true, false, true, false, '');

$html = '<br>'.stripslashes($image->content);

// output the HTML content
$pdf->writeHTML($html, true, 0, true, true);

// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
$pdfPreviewUrl = Doctrine::getTable('Configurations')->find('pdfPreviewUrl');
$pdf->Output($pdfPreviewUrl->value.$image->id.'.pdf', 'F');

0 个答案:

没有答案