Exemplo n.º 1
0
 /**
  * add header to new page, includes logo
  * sets final height of logo on helper object
  * optionally print the incrementId as barcode
  *
  * @param Fooman_PdfCustomiser_Helper_Pdf $helper
  * @param                                 $title
  * @param bool                            $incrementId
  */
 public function printHeader(Fooman_PdfCustomiser_Helper_Pdf $helper, $title, $incrementId = false)
 {
     if ($incrementId) {
         $style = array();
         //$style = array('text' => true, 'fontsize'=>8);
         parent::write1DBarcode($incrementId, $helper->getBarcodeType(), $helper->getPdfMargins('sides'), 5, 50, 5, '', $style);
         $this->SetXY($helper->getPdfMargins('sides'), $helper->getPdfMargins('top'));
     }
     // Place Logo
     if ($helper->getPdfLogo()) {
         if ($helper->getPdfLogoPlacement() == 'auto-right') {
             $maxLogoHeight = 25;
             $currentY = $this->GetY();
             //Figure out if logo is too wide - half the page width minus margins
             $maxWidth = $helper->getPageWidth() / 2 - $helper->getPdfMargins('sides');
             if ($helper->getPdfLogoDimensions('w') > $maxWidth) {
                 $logoWidth = $maxWidth;
             } else {
                 $logoWidth = $helper->getPdfLogoDimensions('w');
             }
             //centered
             /*
                             $this->Image(
                                 $helper->getPdfLogo(),
                                 $this->getPageWidth()/2 +(($this->getPageWidth()/ -$helper->getPdfMargins('sides')-$logoWidth)/2),
                                 $helper->getPdfMargins('top'),
                                 $logoWidth,
                                 $maxLogoHeight,
                                 $type='',
                                 $link='',
                                 $align='',
                                 $resize=false,
                                 $dpi=300,
                                 $palign='',
                                 $ismask=false,
                                 $imgmask=false,
                                 $border=0,
                                 $fitbox=true
                             );*/
             $this->Image($helper->getPdfLogo(), $this->getPageWidth() / 2, $helper->getPdfMargins('top'), $logoWidth, $maxLogoHeight, $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = true);
             $helper->setImageHeight($this->getImageRBY() + 3 - $currentY);
         } elseif ($helper->getPdfLogoPlacement() == 'auto') {
             $maxLogoHeight = 25;
             $currentY = $this->GetY();
             //Figure out if logo is too wide - half the page width minus margins
             $maxWidth = $helper->getPageWidth() / 2 - $helper->getPdfMargins('sides');
             if ($helper->getPdfLogoDimensions('w') > $maxWidth) {
                 $logoWidth = $maxWidth;
             } else {
                 $logoWidth = $helper->getPdfLogoDimensions('w');
             }
             //centered
             /*
                             $this->Image(
                                 $helper->getPdfLogo(),
                                 $this->getPageWidth()/2 +(($this->getPageWidth()/2-$helper->getPdfMargins('sides')-$logoWidth)/2),
                                 $helper->getPdfMargins('top'),
                                 $logoWidth,
                                 $maxLogoHeight,
                                 $type='',
                                 $link='',
                                 $align='',
                                 $resize=false,
                                 $dpi=300,
                                 $palign='',
                                 $ismask=false,
                                 $imgmask=false,
                                 $border=0,
                                 $fitbox=true
                             );*/
             $this->Image($helper->getPdfLogo(), $helper->getPdfMargins('sides'), $helper->getPdfMargins('top'), $logoWidth, $maxLogoHeight, $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = true);
             $helper->setImageHeight($this->getImageRBY() + 3 - $currentY);
         } elseif ($helper->getPdfLogoPlacement() == 'no-scaling-right') {
             $currentY = $this->GetY();
             $this->Image($helper->getPdfLogo(), $this->getPageWidth() / 2, $helper->getPdfMargins('top'), $helper->getPdfLogoDimensions('w'), $helper->getPdfLogoDimensions('h'), $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false);
             $helper->setImageHeight($this->getImageRBY() + 3 - $currentY);
         } elseif ($helper->getPdfLogoPlacement() == 'no-scaling') {
             $currentY = $this->GetY();
             $this->Image($helper->getPdfLogo(), $helper->getPdfMargins('sides'), $helper->getPdfMargins('top'), $helper->getPdfLogoDimensions('w'), $helper->getPdfLogoDimensions('h'), $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false);
             $helper->setImageHeight($this->getImageRBY() + 3 - $currentY);
         } else {
             $currentY = $this->GetY();
             $coords = $helper->getPdfLogoCoords();
             $this->Image($helper->getPdfLogo(), $coords['x'], $coords['y'], $coords['w'] * self::FACTOR_PIXEL_PER_MM, $coords['h'] * self::FACTOR_PIXEL_PER_MM, $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = true);
             $helper->setImageHeight($this->getImageRBY() + 3 - $currentY);
         }
     } else {
         $helper->setImageHeight(false);
     }
 }