Ejemplo n.º 1
0
 /**
  * tag : DRAW
  * mode : OPEN
  *
  * @param  array $param
  * @return boolean
  */
 protected function _tag_open_DRAW($param)
 {
     if ($this->_isForOneLine) {
         return false;
     }
     if ($this->_debugActif) {
         $this->_DEBUG_add('DRAW', true);
     }
     $this->parsingCss->save();
     $this->parsingCss->analyse('draw', $param);
     $this->parsingCss->fontSet();
     $alignObject = null;
     if ($this->parsingCss->value['margin-auto']) {
         $alignObject = 'center';
     }
     $overW = $this->parsingCss->value['width'];
     $overH = $this->parsingCss->value['height'];
     $this->parsingCss->value['old_maxX'] = $this->_maxX;
     $this->parsingCss->value['old_maxY'] = $this->_maxY;
     $this->parsingCss->value['old_maxH'] = $this->_maxH;
     $w = $this->parsingCss->value['width'];
     $h = $this->parsingCss->value['height'];
     if (!$this->parsingCss->value['position']) {
         if ($w < $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin() && $this->pdf->getX() + $w >= $this->pdf->getW() - $this->pdf->getrMargin()) {
             $this->_tag_open_BR(array());
         }
         if ($h < $this->pdf->getH() - $this->pdf->gettMargin() - $this->pdf->getbMargin() && $this->pdf->getY() + $h >= $this->pdf->getH() - $this->pdf->getbMargin() && !$this->_isInOverflow) {
             $this->_setNewPage();
         }
         $old = $this->parsingCss->getOldValues();
         $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
         if ($parentWidth > $w) {
             if ($alignObject == 'center') {
                 $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
             } else {
                 if ($alignObject == 'right') {
                     $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
                 }
             }
         }
         $this->parsingCss->setPosition();
     } else {
         $old = $this->parsingCss->getOldValues();
         $parentWidth = $old['width'] ? $old['width'] : $this->pdf->getW() - $this->pdf->getlMargin() - $this->pdf->getrMargin();
         if ($parentWidth > $w) {
             if ($alignObject == 'center') {
                 $this->pdf->setX($this->pdf->getX() + ($parentWidth - $w) * 0.5);
             } else {
                 if ($alignObject == 'right') {
                     $this->pdf->setX($this->pdf->getX() + $parentWidth - $w);
                 }
             }
         }
         $this->parsingCss->setPosition();
         $this->_saveMax();
         $this->_maxX = 0;
         $this->_maxY = 0;
         $this->_maxH = 0;
         $this->_maxE = 0;
     }
     $this->_drawRectangle($this->parsingCss->value['x'], $this->parsingCss->value['y'], $this->parsingCss->value['width'], $this->parsingCss->value['height'], $this->parsingCss->value['border'], $this->parsingCss->value['padding'], 0, $this->parsingCss->value['background']);
     $marge = array();
     $marge['l'] = $this->parsingCss->value['border']['l']['width'];
     $marge['r'] = $this->parsingCss->value['border']['r']['width'];
     $marge['t'] = $this->parsingCss->value['border']['t']['width'];
     $marge['b'] = $this->parsingCss->value['border']['b']['width'];
     $this->parsingCss->value['width'] -= $marge['l'] + $marge['r'];
     $this->parsingCss->value['height'] -= $marge['t'] + $marge['b'];
     $overW -= $marge['l'] + $marge['r'];
     $overH -= $marge['t'] + $marge['b'];
     // clipping to draw only in the size opf the DRAW tag
     $this->pdf->clippingPathStart($this->parsingCss->value['x'] + $marge['l'], $this->parsingCss->value['y'] + $marge['t'], $this->parsingCss->value['width'], $this->parsingCss->value['height']);
     // left and right of the DRAW tag
     $mL = $this->parsingCss->value['x'] + $marge['l'];
     $mR = $this->pdf->getW() - $mL - $overW;
     // position of the DRAW tag
     $x = $this->parsingCss->value['x'] + $marge['l'];
     $y = $this->parsingCss->value['y'] + $marge['t'];
     // prepare the drawing area
     $this->_saveMargin($mL, 0, $mR);
     $this->pdf->setXY($x, $y);
     // we are in a draw tag
     $this->_isInDraw = array('x' => $x, 'y' => $y, 'w' => $overW, 'h' => $overH);
     // init the translate matrix : (0,0) => ($x, $y)
     $this->pdf->doTransform(array(1, 0, 0, 1, $x, $y));
     $this->pdf->SetAlpha(1.0);
     return true;
 }