Guest User

Untitled

a guest
Jan 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. protected function insertLogo(&$page, $store = null)
  2. {
  3. $this->y = $this->y ? $this->y : 815;
  4. $image = Mage::getStoreConfig('sales/identity/logo', $store);
  5. if ($image) {
  6. $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
  7. if (is_file($image)) {
  8. $image = Zend_Pdf_Image::imageWithPath($image);
  9. $top = 830; //top border of the page
  10. $widthLimit = 270; //half of the page width
  11. $heightLimit = 270; //assuming the image is not a "skyscraper"
  12. $width = $image->getPixelWidth();
  13. $height = $image->getPixelHeight();
  14.  
  15. //preserving aspect ratio (proportions)
  16. $ratio = $width / $height;
  17. if ($ratio > 1 && $width > $widthLimit) {
  18. $width = $widthLimit;
  19. $height = $width / $ratio;
  20. } elseif ($ratio < 1 && $height > $heightLimit) {
  21. $height = $heightLimit;
  22. $width = $height * $ratio;
  23. } elseif ($ratio == 1 && $height > $heightLimit) {
  24. $height = $heightLimit;
  25. $width = $widthLimit;
  26. }
  27.  
  28. $y1 = $top - $height;
  29. $y2 = $top;
  30. $x1 = 25;
  31. $x2 = $x1 + $width;
  32.  
  33. //coordinates after transformation are rounded by Zend
  34. $page->drawImage($image, $x1, $y1, $x2, $y2);
  35.  
  36. $this->y = $y1 - 10;
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment