我有一个在 Zend 中生成 PDF 的脚本。我将脚本从将图像转换为 pdf 复制到服务器上的另一个目录。我现在得到错误:
Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Cannot create image resource.
File not found.' in /kalendarz/Zend/Pdf/Resource/ImageFactory.php:38
Stack trace:
#0 /kalendarz/Zend/Pdf/Image.php(124): Zend_Pdf_Resource_ImageFactory::factory('data/0116b4/cro...')
#1 /kalendarz/cms.php(56): Zend_Pdf_Image::imageWithPath('data/0116b4/cro...')
#2 {main} thrown in /kalendarz/Zend/Pdf/Resource/ImageFactory.php on line 38
网站代码,图片链接示例 (http://tinyurl.com/8srbfza):
else if($_GET['action']=='generate') {
//1 punkt typograficzny postscriptowy (cyfrowy) = 1/72 cala = 0,3528 mm
function mm_to_pt($size_mm) {
return $size_mm/0.3528;
}
require_once("Zend/Pdf.php");
$pdf = new Zend_Pdf();
$page_w = mm_to_pt(100);
$page_h = mm_to_pt(90);
$page = $pdf->newPage($page_w.':'.$page_h.':');
$pdf->pages[] = $page;
$imagePath= 'data/'.$_GET['id'].'/crop_'.$_GET['id'].'.jpg'; //to nie jest miniaturka
$image = Zend_Pdf_Image::imageWithPath($imagePath);
$left = mm_to_pt(0);
$right = mm_to_pt(100);
$top = mm_to_pt(90);
$bottom = mm_to_pt(0);
$page->drawImage($image, $left, $bottom, $right, $top);
$pdfData = $pdf->render();
header("Content-Disposition: inline; filename=".$_GET['id'].".pdf");
header("Content-type: application/x-pdf");
echo $pdfData;
die();
}