Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:10:34+00:00 2026-06-12T19:10:34+00:00

I have a script that generates a PDF in Zend. I copied the script

  • 0

I have a script that generates a PDF in Zend. I copied the script from converting image to pdf to another directory on the server. I now get the error:

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

Code of website, example link to image (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();
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:10:35+00:00Added an answer on June 12, 2026 at 7:10 pm

    Zend_Pdf_Image::imageWithPath expects a valid file and uses is_file function call to check the file existence.

    First of all, use absolute path to the image, instead of using the relative one. You can specify the absolute path by referring to your APPLICATION_PATH. For example,

      APPLICATION_PATH . '/../public/data
    

    If APPLICATION_PATH is not already defined in your code, paste this code in your public/index.php

     defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
    

    Then, check if ‘data/’.$GET[‘id’].’/crop‘.$_GET[‘id’].’.jpg’ exists. Also, check if the file has proper permissions to be accessed by PHP.

    Note : Use the Zend request object instead of the $_GET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that generates images from text using PHP. It's working fine
I have a php script that randomly generates an image. Something like this: <?php
I have a script that generates xml of products on users webstores. Now, this
I have a script that generates a temporary PDF file, binary-streams it to the
I have a php script that generates a pdf report. When we go to
i have a server, that generates or copies PDF-Files to a specific folder. i
I have an script that receives an encrypted url and from that generates a
I have a script that generates a new CSV file (in my web directory)
I have a script that generates DDL scripts to define materialized views for a
I have a script that generates two lines as output each time. I'm really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.