Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PDF Catalogs V1.4


saxman513

Recommended Posts

Posted

Hello everyone...

Well after lots of tweaking, I finally got it to generate the pdf. but I'm getting a repeating error:

 

Warning: getimagesize(en) [function.getimagesize]: failed to create stream: No such file or directory in /......../public_html/admin/pdf_catalogue.php on line 369

 

I've got catalogues chmod'd to 777, images folder set to 777 and all of the images are 755.

 

But like I said it does create the catalog, however it is messed up. There is a border that wraps each image. Well, for some reason the image is showing on the right side of the document, making the border stretch all the way across causing havoc to the descriptions. Everything else works well, the descriptions, all info, and the pictures are lined up correctly with it's respective description.

 

here's the link to the file so you can see it yourself.

http://sweetnothingssugarfreeshoppe.com/ca...s/catalog_1.pdf

Thanks for your help in advance!

:listen: Musik Makin' Makes Me Mappy. . . I mean, Happy! :listen:

****Play that sax-a-ma-phone! - Homer J. Simpson****

Posted

It is the same error on my shop!!! Does anybody know how to solve the problem???

Posted

You've probably got a gif image as a category image (or elsewhere). All images MUST be either jpg or png, or the script will fail. Change it to a jpg or png and it will work.

Posted

all category images and all product images are jpg. don't think that i need to change more than that

Posted

All I can say is that I was getting this error until I deleted some gif category images. I wasn't using category images on my site, so I didn't think to check that right away. Since the function that's crashing is getimagesize, you probably have an image file type problem or an image that doesn't exist or is corrupted.

Posted

okay, I found the bug in the script:

replace the following line (near 369):

$heightwidth=getimagesize($data_array[11]);

with this one:

$heightwidth=getimagesize($data_array[12]);

and the warning is gone 8)

Posted

This is what defines $data_array in the DrawCells function:

$data_array=array($imagewidth,$imageheight,$model,$name,$date_added,$manufacturer,$description
,$tax_class_id,$specials_price,$price,$id,$languages_code,$imagepath);

$this->DrawCells($data_array);

So it looks to me as if what you've done there is to replace the unique product's id with the product's language id. I don't think that's what you want to do. Are you seeing the correct images with each product after making this change?

Posted

Of course, I am. Otherwise I wouldn't have posted the fix.

 

I made an echo array[11] and it showed de for my shop in German. But the function getimagesize(filename) in line 369 wants to have an image path and not a language code.

 

So I posted an echo[12] which is mentioned in other if clauses and it showed me the image path :wink:

Posted

Hmm...

 

Then you must be using a modified script (or a different version, perhaps?). I believe the code I posted is from the latest version of the contribution, and it has 13 elements in that array (not 12). So if I were to make the change that you posted to my script, it wouldn't work at all.

 

Glad it works for you, though.

Posted

Here is the if clause of the original code:

  if(SHOW_IMAGES && strlen($data_array[11]))

 {	

	 //If Small Image Width and Small Image Height are defined

	 if(strlen($data_array[0])>1 && strlen($data_array[1])>1)

 {

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

    //If only Small Image Width is defined

 else if(strlen($data_array[0])>1 && strlen($data_array[1]))

 {   

     $heightwidth=getimagesize($data_array[11]);

	 $data_array[0]=$data_array[0];

     $data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 //If only Small Image Height is defined

 else if(strlen($data_array[0]) && strlen($data_array[1])>1)

 {

	 $heightwidth=getimagesize($data_array[11]);

	 $data_array[0]=$width=$heightwidth[0]*PDF_TO_MM_FACTOR;

     $data_array[1]=$data_array[1];

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 else

 {

	 $heightwidth=getimagesize($data_array[12]);

	 $data_array[0]=$heightwidth[0]*PDF_TO_MM_FACTOR;

     $data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 

 //Margin=10

 $this->SetX(10);

}

 

and here is the if clause after my change:

  if(SHOW_IMAGES && strlen($data_array[11]))

 {	

	 //If Small Image Width and Small Image Height are defined

	 if(strlen($data_array[0])>1 && strlen($data_array[1])>1)

 {

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

    //If only Small Image Width is defined

 else if(strlen($data_array[0])>1 && strlen($data_array[1]))

 {   

     $heightwidth=getimagesize($data_array[11]);

	 $data_array[0]=$data_array[0];

     $data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 //If only Small Image Height is defined

 else if(strlen($data_array[0]) && strlen($data_array[1])>1)

 {

	 $heightwidth=getimagesize($data_array[12]);

	 $data_array[0]=$width=$heightwidth[0]*PDF_TO_MM_FACTOR;

     $data_array[1]=$data_array[1];

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 else

 {

	 $heightwidth=getimagesize($data_array[12]);

	 $data_array[0]=$heightwidth[0]*PDF_TO_MM_FACTOR;

     $data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

	 

   $this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

   $y1=$this->GetY();

 }

 

 //Margin=10

 $this->SetX(10);

}

  • 3 months later...
Posted
This is what defines $data_array in the DrawCells function:

$data_array=array($imagewidth,$imageheight,$model,$name,$date_added,$manufacturer,$description,$tax_class_id,$specials_price,$price,$id,$languages_code,$imagepath);

$this->DrawCells($data_array);

So it looks to me as if what you've done there is to replace the unique product's id with the product's language id. I don't think that's what you want to do. Are you seeing the correct images with each product after making this change?

Actually, there IS 13 elements to that array, but like most other languages, this one starts the count at zero, so $data_array[12] references $imagepath.

 

defender39:

You can possibly add a conditional statement to the beginning of bobbel's snippet of code. Not sure this'll work as is - just a concept - correct for syntax and validity before using.

 

Conditional BEFORE

if(SHOW_IMAGES && strlen($data_array[11]))

{

Conditional AFTER

// Get the last 4 chars of the file path
$temp_file_ext = substr($data_array[12],strlen($data_array[12])-4,4);
if (SHOW_IMAGES && strlen($data_array[11] && ($temp_file_ext == '.png' || $temp_file_ext == '.jpg'))

{
 

Posted

Here is the function to add an image. How can we change it to skip an image if it is a gif.

 

 

 

//Put an image on the page

if(!isset($this->images[$file]))

{

//First use of image, get info

if($type=='')

{

$pos=strrpos($file,'.');

if(!$pos)

$this->Error('Image file has no extension and no type was specified: '.$file);

$type=substr($file,$pos+1);

}

$type=strtolower($type);

$mqr=get_magic_quotes_runtime();

set_magic_quotes_runtime(0);

if($type=='jpg' or $type=='jpeg')

$info=$this->_parsejpg($file);

elseif($type=='png')

$info=$this->_parsepng($file);

else

$this->Error('Unsupported image file type: '.$type);

set_magic_quotes_runtime($mqr);

$info['i']=count($this->images)+1;

$this->images[$file]=$info;

}

else

$info=$this->images[$file];

//Automatic width or height calculation

if($w==0)

$w=$h*$info['w']/$info['h'];

if($h==0)

$h=$w*$info['h']/$info['w'];

$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));

if($link)

$this->Link($x,$y,$w,$h,$link);

}

Posted

Here is the function to add an image. How can we change it to skip an image if it is a gif.

 

 

 

//Put an image on the page

if(!isset($this->images[$file]))

{

//First use of image, get info

if($type=='')

{

$pos=strrpos($file,'.');

if(!$pos)

$this->Error('Image file has no extension and no type was specified: '.$file);

$type=substr($file,$pos+1);

}

$type=strtolower($type);

$mqr=get_magic_quotes_runtime();

set_magic_quotes_runtime(0);

if($type=='jpg' or $type=='jpeg')

$info=$this->_parsejpg($file);

elseif($type=='png')

$info=$this->_parsepng($file);

else

$this->Error('Unsupported image file type: '.$type);

set_magic_quotes_runtime($mqr);

$info['i']=count($this->images)+1;

$this->images[$file]=$info;

}

else

$info=$this->images[$file];

//Automatic width or height calculation

if($w==0)

$w=$h*$info['w']/$info['h'];

if($h==0)

$h=$w*$info['h']/$info['w'];

$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));

if($link)

$this->Link($x,$y,$w,$h,$link);

}

Posted

Here is the function to add an image. How can we change it to skip an image if it is a gif.

 

 

 

//Put an image on the page

if(!isset($this->images[$file]))

{

//First use of image, get info

if($type=='')

{

$pos=strrpos($file,'.');

if(!$pos)

$this->Error('Image file has no extension and no type was specified: '.$file);

$type=substr($file,$pos+1);

}

$type=strtolower($type);

$mqr=get_magic_quotes_runtime();

set_magic_quotes_runtime(0);

if($type=='jpg' or $type=='jpeg')

$info=$this->_parsejpg($file);

elseif($type=='png')

$info=$this->_parsepng($file);

else

$this->Error('Unsupported image file type: '.$type);

set_magic_quotes_runtime($mqr);

$info['i']=count($this->images)+1;

$this->images[$file]=$info;

}

else

$info=$this->images[$file];

//Automatic width or height calculation

if($w==0)

$w=$h*$info['w']/$info['h'];

if($h==0)

$h=$w*$info['h']/$info['w'];

$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));

if($link)

$this->Link($x,$y,$w,$h,$link);

}

Posted

Here is the function to add an image. How can we change it to skip an image if it is a gif.

 

 

 

//Put an image on the page

if(!isset($this->images[$file]))

{

//First use of image, get info

if($type=='')

{

$pos=strrpos($file,'.');

if(!$pos)

$this->Error('Image file has no extension and no type was specified: '.$file);

$type=substr($file,$pos+1);

}

$type=strtolower($type);

$mqr=get_magic_quotes_runtime();

set_magic_quotes_runtime(0);

if($type=='jpg' or $type=='jpeg')

$info=$this->_parsejpg($file);

elseif($type=='png')

$info=$this->_parsepng($file);

else

$this->Error('Unsupported image file type: '.$type);

set_magic_quotes_runtime($mqr);

$info['i']=count($this->images)+1;

$this->images[$file]=$info;

}

else

$info=$this->images[$file];

//Automatic width or height calculation

if($w==0)

$w=$h*$info['w']/$info['h'];

if($h==0)

$h=$w*$info['h']/$info['w'];

$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));

if($link)

$this->Link($x,$y,$w,$h,$link);

}

Posted

sorry for the triple post...I think the forums gave me a problem loading...

 

Still can anyone help with the code?

I think the easiest thing to do is add an option for gifs that will basically parse a "no_image_available.jpg"

 

So anything that doesnt have an image will just get a graphic saying the image is not available. I am not a php coder so I cant figure out how to do this.

Posted

That is easy:

 

In the line 162 you have:

else
  	 {
       echo "Only PNG and JPEG";
       exit();
  	 }

 

Just change that line with:

else
  	 {
  	 $path =	"/xxxxxx/images/no_image_available.jpg";
  	 $src=imagecreatefromjpeg($path);        
  	 }

 

and your problem will be solved.

Hope it will help you.

  • 5 months later...
Posted

I am running into another problem.

 

Irrespective of the image format, when I'm trying to create a PDF catalogue within admin, I get an error since imagecreatefrompng & imagecreatefromjpg functions that are called within php_catalogue.php do not exist.

 

Any ideas?

  • 2 weeks later...
Posted
when I'm trying to create a PDF catalogue within admin, I get an error since imagecreatefrompng & imagecreatefromjpg functions that are called within php_catalogue.php do not exist.

 

Google ruleZ! :)

 

I found out that imagecreatefrompng and imagecreatefromjpg are PHP functions, included in the GD2 library! To be able to use them, you have to enable the use of the GD2 library in your php.ini file!

Antonios

 

olympicslogo_en.gif

Posted
when I'm trying to create a PDF catalogue within admin, I get an error since imagecreatefrompng & imagecreatefromjpg functions that are called within php_catalogue.php do not exist.

 

Google ruleZ! :)

 

I found out that imagecreatefrompng and imagecreatefromjpg are PHP functions, included in the GD2 library! To be able to use them, you have to enable the use of the GD2 library in your php.ini file!

Thanx, I tried that shortly after I submitted my original post and it worked fine!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...