Ejemplo n.º 1
0
 /**
  * @test
  */
 public function breakAt()
 {
     $this->node->setWidth(350)->setHeight(300);
     $boundary = $this->node->getBoundary();
     $boundary->setNext(50, 600)->setNext(400, 600)->setNext(400, 300)->setNext(50, 300)->close();
     $child1 = new Container();
     $child1->setWidth(350)->setHeight(100);
     $boundary = $child1->getBoundary();
     $boundary->setNext(50, 600)->setNext(400, 600)->setNext(400, 500)->setNext(50, 500)->close();
     $this->node->add($child1);
     $child2 = $child1->copy();
     foreach ($boundary as $point) {
         $child2->getBoundary()->setNext($point);
     }
     $child2->translate(0, 200);
     $this->node->add($child2);
     $result = $this->node->breakAt(250);
     $this->assertEquals(250, $this->node->getHeight());
     $children = $this->node->getChildren();
     $this->assertEquals(2, count($children));
     $this->assertEquals(100, $children[0]->getHeight());
     $this->assertEquals(50, $children[1]->getHeight());
     $this->assertEquals(array(400, 350), $children[1]->getEndDrawingPoint());
     $this->assertEquals(50, $result->getHeight());
     $children = $result->getChildren();
     $this->assertEquals(1, count($children));
     $this->assertEquals(50, $children[0]->getHeight());
     $this->assertEquals(array(50, 350), $children[0]->getStartDrawingPoint());
     $this->assertEquals(array(400, 300), $children[0]->getEndDrawingPoint());
 }
 private function injectBoundary(Container $container, $yStart = 0)
 {
     $parent = $container->getParent();
     $point = $parent->getFirstPoint();
     $boundary = new Boundary();
     $boundary->setNext($point->translate(0, $yStart))->setNext($point->translate($container->getWidth(), $yStart))->setNext($point->translate($container->getWidth(), $yStart + $container->getHeight()))->setNext($point->translate(0, $yStart + $container->getHeight()))->close();
     $this->invokeMethod($container, 'setBoundary', array($boundary));
 }
Ejemplo n.º 3
0
 public function getHeight()
 {
     $height = parent::getHeight();
     if ($height === null) {
         $height = $this->getAncestorByType('PHPPdf\\Core\\Node\\Table')->getRowHeight();
     }
     return $height;
 }
 /**
  * @test
  */
 public function drawingInSmallerContainer()
 {
     $page = new Page();
     $height = 100;
     $width = 120;
     $imagePath = 'image/path';
     $imageResource = $this->createImageResourceMock($width, $height);
     $this->document->expects($this->atLeastOnce())->method('createImage')->with($imagePath)->will($this->returnValue($imageResource));
     $image = new Image(array('src' => $imagePath));
     $container = new Container(array('width' => (int) ($width * 0.7), 'height' => (int) ($height * 0.5)));
     $container->add($image);
     $this->formatter->format($image, $this->document);
     $this->assertEquals($container->getHeight(), $image->getHeight());
     $this->assertTrue($container->getWidth() > $image->getWidth());
 }
Ejemplo n.º 5
0
 private function throwExceptionIfHeightIsntSet(Container $contaienr)
 {
     $height = $contaienr->getHeight();
     if ($height === null || !is_numeric($height)) {
         throw new InvalidArgumentException('Height of header and footer must be set.');
     }
 }
 private function shouldColumnsBeEqual(ColumnableContainer $columnableContainer, Container $container, $columnNumber, $rowNumber)
 {
     $parent = $columnableContainer->getParent();
     $height = $container->getFirstPoint()->getY() - ($this->getPageDiagonalYCoord($columnableContainer) - $rowNumber * $parent->getHeight());
     $freeSpace = $height * ($columnableContainer->getAttribute('number-of-columns') - $columnNumber);
     return $columnNumber == 0 && $columnableContainer->getAttribute('equals-columns') && $container->getHeight() < $freeSpace;
 }