src/Html2Pdf.php
protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
    {
        // get the current float margins, for top and bottom
        $oldTop    = $this->_getMargins($yTop);
        $oldBottom = $this->_getMargins($yBottom);

        // update the top float margin
        if ($float === 'left'  && $oldTop[0]<$xRight) {
            $oldTop[0] = $xRight;
        }
        if ($float === 'right' && $oldTop[1]>$xLeft) {
            $oldTop[1] = $xLeft;
        }

        $yTop = floor($yTop*100);
        $yBottom = floor($yBottom*100);

        // erase all the float margins that are smaller than the new one
        foreach ($this->_pageMarges as $mY => $mX) {
            if ($mY<$yTop) {
                continue;
            }
            if ($mY>$yBottom) {
                break;
            }
            if ($float === 'left' && $this->_pageMarges[$mY][0]<$xRight) {
                unset($this->_pageMarges[$mY]);
            }
            if ($float === 'right' && $this->_pageMarges[$mY][1]>$xLeft) {
                unset($this->_pageMarges[$mY]);
            }
        }

        // save the new Top and Bottom margins
        $this->_pageMarges[$yTop] = $oldTop;
        $this->_pageMarges[$yBottom] = $oldBottom;

        // sort the margins
        ksort($this->_pageMarges);

        // we are just after float
        $this->_isAfterFloat = true;
    }
protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
    {
        // get the current float margins, for top and bottom
        $oldTop    = $this->_getMargins($yTop);
        $oldBottom = $this->_getMargins($yBottom);

        // update the top float margin
        if ($float === 'left'  && $oldTop[0]<$xRight) {
            $oldTop[0] = $xRight;
        }
        if ($float === 'right' && $oldTop[1]>$xLeft) {
            $oldTop[1] = $xLeft;
        }

        $yTop = floor($yTop*100);
        $yBottom = floor($yBottom*100);

        // erase all the float margins that are smaller than the new one
        foreach ($this->_pageMarges as $mY => $mX) {
            if ($mY<$yTop) {
                continue;
            }
            if ($mY>$yBottom) {
                break;
            }
            if ($float === 'left' && $this->_pageMarges[$mY][0]<$xRight) {
                unset($this->_pageMarges[$mY]);
            }
            if ($float === 'right' && $this->_pageMarges[$mY][1]>$xLeft) {
                unset($this->_pageMarges[$mY]);
            }
        }

        // save the new Top and Bottom margins
        $this->_pageMarges[$yTop] = $oldTop;
        $this->_pageMarges[$yBottom] = $oldBottom;

        // sort the margins
        ksort($this->_pageMarges);

        // we are just after float
        $this->_isAfterFloat = true;
    }
protected function _addMargins ( $ float , $ xLeft , $ yTop , $ xRight , $ yBottom ) { // get the current float margins, for top and bottom $ oldTop = $ this -> _getMargins ( $ yTop ) ; $ oldBottom = $ this -> _getMargins ( $ yBottom ) ; // update the top float margin if ( $ float === 'left' && $ oldTop [ 0 ] < $ xRight ) { $ oldTop [ 0 ] = $ xRight ; } if ( $ float === 'right' && $ oldTop [ 1 ] > $ xLeft ) { $ oldTop [ 1 ] = $ xLeft ; } $ yTop = floor ( $ yTop * 100 ) ; $ yBottom = floor ( $ yBottom * 100 ) ; // erase all the float margins that are smaller than the new one foreach ( $ this -> _pageMarges as $ mY => $ mX ) { if ( $ mY < $ yTop ) { continue ; } if ( $ mY > $ yBottom ) { break ; } if ( $ float === 'left' && $ this -> _pageMarges [ $ mY ] [ 0 ] < $ xRight ) { unset ( $ this -> _pageMarges [ $ mY ] ) ; } if ( $ float === 'right' && $ this -> _pageMarges [ $ mY ] [ 1 ] > $ xLeft ) { unset ( $ this -> _pageMarges [ $ mY ] ) ; } } // save the new Top and Bottom margins $ this -> _pageMarges [ $ yTop ] = $ oldTop ; $ this -> _pageMarges [ $ yBottom ] = $ oldBottom ; // sort the margins ksort ( $ this -> _pageMarges ) ; // we are just after float $ this -> _isAfterFloat = true ; }
Add margins, for a float

@access protected
@param  string $float (left / right)
@param  float  $xLeft
@param  float  $yTop
@param  float  $xRight
@param  float  $yBottom
Add margins for a float