Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $y1 = $top - $height;
- $y2 = $top;
- $x1 = 25; //left margin
- $x2 = $x1 + $width;
- $this->insertLogo($page, $invoice->getStore());
- $this->insertLogo($page, $invoice->getStore(),225);//225 is the margin from left
- public function insertLogo(&$page, $store = null, $x1 = 25){
- $this->y = $this->y ? $this->y : 815;
- $image = Mage::getStoreConfig('sales/identity/logo', $store);
- if ($image) {
- $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
- if (is_file($image)) {
- $image = Zend_Pdf_Image::imageWithPath($image);
- $top = 830; //top border of the page
- $widthLimit = 270; //half of the page width
- $heightLimit = 270; //assuming the image is not a "skyscraper"
- $width = $image->getPixelWidth();
- $height = $image->getPixelHeight();
- //preserving aspect ratio (proportions)
- $ratio = $width / $height;
- if ($ratio > 1 && $width > $widthLimit) {
- $width = $widthLimit;
- $height = $width / $ratio;
- } elseif ($ratio < 1 && $height > $heightLimit) {
- $height = $heightLimit;
- $width = $height * $ratio;
- } elseif ($ratio == 1 && $height > $heightLimit) {
- $height = $heightLimit;
- $width = $widthLimit;
- }
- $y1 = $top - $height;
- $y2 = $top;
- //$x1 = 25; hide this
- $x2 = $x1 + $width;
- //coordinates after transformation are rounded by Zend
- $page->drawImage($image, $x1, $y1, $x2, $y2);
- $this->y = $y1 - 10;
- }
- }
- }
Add Comment
Please, Sign In to add comment