コード例 #1
0
 /**
  * @param ZendPage $page
  * @param Graphic $graphic
  * @param float $x
  * @param float $y
  * @param float $width
  * @param float $height
  * @param bool $keepRatio
  *
  * @throws \Exception
  */
 public function drawGraphic(ZendPage $page, Graphic $graphic, $x, $y, $width, $height, $keepRatio = true)
 {
     $page->saveGS();
     $this->translateAndClipToViewport($page, $graphic->getViewport(), $x, $y, $width, $height, $keepRatio);
     foreach ($graphic->getElements() as $element) {
         if (!$element->isVisible()) {
             continue;
         }
         if ($element instanceof Text) {
             $this->drawText($page, $element);
         } elseif ($element instanceof PathText) {
             $this->drawPathText($page, $element);
         } elseif ($element instanceof AbstractShape) {
             $this->drawShape($page, $element);
         } else {
             throw new InvalidArgumentException('unsupported graphic element: ' . get_class($element));
         }
     }
     $page->restoreGS();
 }
コード例 #2
0
 /**
  * @param Graphic $graphic
  * @param float $width in cm
  * @param float $height in cm
  * @param bool $keepRatio
  *
  * @return mixed
  */
 public function toSVG(Graphic $graphic, $width = 10.0, $height = 10.0, $keepRatio = true)
 {
     $viewport = $graphic->getViewport();
     return $this->addElements($this->createSVG($width, $height, $viewport, $keepRatio), $graphic->getElements(), $viewport->getYBase())->asXml();
 }