Пример #1
0
 protected function beforeFormat(Document $document)
 {
     $image = $this->getAttribute('image');
     if (is_string($image)) {
         $image = $document->createImage($image);
         $this->setAttribute('image', $image);
     }
 }
Пример #2
0
 /**
  * @param Document $document
  *
  * @return \PHPPdf\Core\Engine\Image
  */
 protected function createImageSource(Document $document)
 {
     $src = $this->getAttribute('src');
     return is_string($src) ? $document->createImage($src) : $src;
 }
Пример #3
0
 private function drawRectangleBackground(GraphicsContext $graphicsContext, Node $node, Document $document)
 {
     if ($this->getColor() !== null) {
         $boundary = $this->getBoundary($node);
         if ($this->getRadius() !== null) {
             $firstPoint = $boundary->getPoint(3);
             $diagonalPoint = $boundary->getPoint(1);
             $this->drawRoundedBoundary($graphicsContext, $firstPoint->getX(), $firstPoint->getY(), $diagonalPoint->getX(), $diagonalPoint->getY(), GraphicsContext::SHAPE_DRAW_FILL_AND_STROKE);
         } else {
             $this->drawBoundary($graphicsContext, $boundary, GraphicsContext::SHAPE_DRAW_FILL);
         }
     }
     $image = $this->getImage();
     $image = $image ? $document->createImage($image) : null;
     if ($image !== null) {
         $positionTranslation = $node->getPositionTranslation();
         list($x, $y) = $this->getFirstPoint($node)->translate($positionTranslation->getX(), $positionTranslation->getY())->toArray();
         list($endX, $endY) = $this->getDiagonalPoint($node)->translate($positionTranslation->getX(), $positionTranslation->getY())->toArray();
         list($width, $height) = $this->getImageDimension($document, $image, $node);
         $graphicsContext->saveGS();
         $graphicsContext->clipRectangle($x, $y, $x + $this->getWidth($node), $y - $this->getHeight($node));
         $repeatX = $this->repeat & self::REPEAT_X;
         $repeatY = $this->repeat & self::REPEAT_Y;
         $currentX = $this->getXCoord($node, $width, $x, $document);
         $currentY = $y = $this->getYCoord($node, $height, $y, $document);
         do {
             $currentY = $y;
             do {
                 $graphicsContext->drawImage($image, $currentX, $currentY - $height, $currentX + $width, $currentY);
                 $currentY -= $height;
             } while ($repeatY && $currentY > $endY);
             $currentX += $width;
         } while ($repeatX && $currentX < $endX);
         $graphicsContext->restoreGS();
     }
 }