Guest User

Untitled

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