문제

I have to generate Pdf of images. I have tried the following code

  public function getPdf($paths)
 {
   try {
  $pdf = new Zend_Pdf(); 
  for($i=0; $i<5; $i++)
   {
   $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
    $image = Zend_Pdf_Image::imageWithPath($paths[$i]);  
    $page->drawImage($image, 20, 20, 50, 46);
    $pdf->pages[] = $page;
   }
   $pdf->save('document.pdf');
     echo 'SUCCESS: Document saved!';
    } catch (Zend_Pdf_Exception $e) {
     die ('PDF error: ' . $e->getMessage());  
     } catch (Exception $e) {
     die ('Application error: ' . $e->getMessage());    
    }
   }

Please note that $paths is an array which contains correct physical paths like C:/wamp/www/magento1.7/media/catalog/product/cache/1/small_image/9df78eab33525d08d6e5fb8d27136e95/p/o/portf1.jpg.... Now the problem is that it is not able to create Pdf and throws exception saying "PDF error: Cannot create image resource. File not found". Can anybody helps me in this or simply point out what's wrong with this code.

도움이 되었습니까?

해결책

You probably do not have required permissions. Look if file is_readable and if not try chmod it. You can also always change file permissions on your windows.

Edit1: Change your code:

$numPaths = count($paths);
for($i=0; $i < $numPaths; $i++) {
.. 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top