/** * tag : PATH * mode : OPEN * * @param array $param * @return boolean */ protected function _tag_open_PATH($param) { if (!$this->_isInDraw) { throw new HTML2PDF_exception(8, 'PATH'); } $this->pdf->doTransform(isset($param['transform']) ? $this->_prepareTransform($param['transform']) : null); $this->parsingCss->save(); $styles = $this->parsingCss->getSvgStyle('path', $param); $style = $this->pdf->svgSetStyle($styles); $path = isset($param['d']) ? $param['d'] : null; if ($path) { // prepare the path $path = str_replace(',', ' ', $path); $path = preg_replace('/([a-zA-Z])([0-9\\.\\-])/', '$1 $2', $path); $path = preg_replace('/([0-9\\.])([a-zA-Z])/', '$1 $2', $path); $path = preg_replace('/[\\s]+/', ' ', trim($path)); $path = preg_replace('/ ([a-z]{2})/', '$1', $path); $path = explode(' ', $path); foreach ($path as $k => $v) { $path[$k] = trim($v); if ($path[$k] === '') { unset($path[$k]); } } $path = array_values($path); // read each actions in the path $actions = array(); $action = array(); $lastAction = null; // last action found for ($k = 0; $k < count($path); true) { // for this actions, we can not have multi coordonate if (in_array($lastAction, array('z', 'Z'))) { $lastAction = null; } // read the new action (forcing if no action before) if (preg_match('/^[a-z]+$/i', $path[$k]) || $lastAction === null) { $lastAction = $path[$k]; $k++; } // current action $action = array(); $action[] = $lastAction; switch ($lastAction) { case 'C': case 'c': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x1 $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y1 $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x2 $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y2 $action[] = $this->parsingCss->ConvertToMM($path[$k + 4], $this->_isInDraw['w']); // x $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['h']); // y $k += 6; break; case 'Q': case 'S': case 'q': case 's': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x2 $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y2 $action[] = $this->parsingCss->ConvertToMM($path[$k + 2], $this->_isInDraw['w']); // x $action[] = $this->parsingCss->ConvertToMM($path[$k + 3], $this->_isInDraw['h']); // y $k += 4; break; case 'A': case 'a': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // rx $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // ry $action[] = 1.0 * $path[$k + 2]; // angle de deviation de l'axe X $action[] = $path[$k + 3] == '1' ? 1 : 0; // large-arc-flag $action[] = $path[$k + 4] == '1' ? 1 : 0; // sweep-flag $action[] = $this->parsingCss->ConvertToMM($path[$k + 5], $this->_isInDraw['w']); // x $action[] = $this->parsingCss->ConvertToMM($path[$k + 6], $this->_isInDraw['h']); // y $k += 7; break; case 'M': case 'L': case 'T': case 'm': case 'l': case 't': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x $action[] = $this->parsingCss->ConvertToMM($path[$k + 1], $this->_isInDraw['h']); // y $k += 2; break; case 'H': case 'h': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['w']); // x $k += 1; break; case 'V': case 'v': $action[] = $this->parsingCss->ConvertToMM($path[$k + 0], $this->_isInDraw['h']); // y $k += 1; break; case 'z': case 'Z': default: break; } // add the action $actions[] = $action; } // drawing $this->pdf->svgPolygone($actions, $style); } $this->pdf->undoTransform(); $this->parsingCss->load(); }