Unstoppable Domains โ€” Get your daily AI drops report

Zend Pdf Images help.

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

pixelbypixel

Established Member
Impact
38
Hey,

Using Zend for pdf generation, which is all working fine and dandy.

However, I wish to include an image in the pdf which is user uploaded.
The upload works fine. Inserting the image into the PDF is fine.

My problem is, I want the image to be its original size, without forcing a fixed area for the image to 'fill'.
As it stands Zend_Pdf stretches the image to fill the area, or shrinks it to do so.

What I want is the image to stay at its real dimensions.

Currently I am using:

PHP:
	// Draw Logo 
		$imagePath = "../users/".$this->user."/logo.jpg";
		$image = Zend_Pdf_Image::imageWithPath($imagePath); 
		$page->drawImage($image, 50, 720, 400, 860);

The logo.jpg file is in reality 334 x 112. Which may vary depending on the users own logo.
What I am asking is, is there any way to get the dimensions of $image directly using Zend? Or am I going to have to use GD, if so, how would it be done using GD? (not used images in this way before)


Thanks for any help.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
No one can point me in the right direction at least? :(
 
0
•••
You could get the image dimensions and use them when drawing the image. For example,

PHP:
        // Draw Logo 
        $imagePath = "../users/".$this->user."/logo.jpg";
        list($width, $height, $type, $attr) = getimagesize($imagePath);
        $image = Zend_Pdf_Image::imageWithPath($imagePath); 
        $page->drawImage($image, 50, 720, 50+$width, 720+$height);
 
1
•••
Thanks, ill try that later =]
 
0
•••
Great, works just as required. Thanks
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back