public function format(Nodes\Node $node, Document $document) { $boundary = $node->getBoundary(); list($x, $y) = $node->getFirstPoint()->toArray(); $boundary->reset(); $boundary->setNext($x, $y); }
private function getMinimumYCoordOfChildren(Node $node) { $minYCoord = $node->getFirstPoint()->getY() - $node->getPaddingTop(); foreach ($node->getChildren() as $child) { $minYCoord = min($minYCoord, $child->getDiagonalPoint()->getY()); } return $minYCoord; }
private function designateLinesOfWords(Node $node) { $currentPoint = $node->getFirstPoint(); $partsOfLine = array(); $yTranslation = 0; $line = new Line($node, 0, $yTranslation); foreach ($node->getChildren() as $textNode) { $words = $textNode->getWords(); $wordsSizes = $textNode->getWordsSizes(); $currentWordLine = array(); $currentWidthOfLine = 0; $numberOfWords = count($words); $first = true; $lineWidth = 0; foreach ($words as $index => $word) { $wordSize = $wordsSizes[$index]; $newLineWidth = $currentWidthOfLine + $wordSize; $endXCoord = $newLineWidth + $currentPoint->getX(); $maxLineXCoord = $this->getMaxXCoord($node); $isEndOfLine = $endXCoord > $maxLineXCoord; if ($isEndOfLine) { if ($currentWordLine) { $partOfLine = new LinePart($currentWordLine, $currentWidthOfLine, $currentPoint->getX() - $node->getFirstPoint()->getX(), $textNode); $partsOfLine[] = $partOfLine; $line->addParts($partsOfLine); $node->addLine($line); $yTranslation += $line->getHeight(); $line = new Line($node, 0, $yTranslation); $partsOfLine = array(); $currentWidthOfLine = 0; $currentWordLine = array(); } else { $line->addParts($partsOfLine); $node->addLine($line); $yTranslation += $line->getHeight(); $line = new Line($node, 0, $yTranslation); $partsOfLine = array(); } $currentPoint = Point::getInstance($node->getFirstPoint()->getX(), 0); } $currentWidthOfLine = $currentWidthOfLine + $wordSize; $currentWordLine[] = $word; } if ($currentWordLine) { $partOfLine = new LinePart($currentWordLine, $currentWidthOfLine, $currentPoint->getX() - $node->getFirstPoint()->getX(), $textNode); $partsOfLine[] = $partOfLine; $currentPoint = $currentPoint->translate($currentWidthOfLine, 0); } } if ($partsOfLine) { $yTranslation += $line->getHeight(); $line = new Line($node, 0, $yTranslation); $line->addParts($partsOfLine); $node->addLine($line); } }
private function getChildYCoordOfFirstPoint(Node $node) { $yCoordOfFirstPoint = $node->getFirstPoint()->getY(); return $yCoordOfFirstPoint; }
private function isOutOfPage(Node $node) { $page = $node->getParent(); if ($node->getAttribute('break')) { return true; } return $page->getDiagonalPoint()->getY() > $node->getFirstPoint()->getY() && $node->getFloat() == Node::FLOAT_NONE; }
private function getFirstPoint(Node $node) { if ($this->useRealDimension) { return $node->getRealFirstPoint(); } return $node->getFirstPoint(); }