public function format(Node $node, Document $document) { $columnFormatter = new ColumnBreakingFormatter(); $this->node = $node; $this->totalVerticalTranslation = 0; $children = $this->node->getChildren(); foreach ($this->node->getChildren() as $child) { $child->translate(0, -$this->totalVerticalTranslation); if (!$node->isMarkedAsFormatted($child) && $child instanceof ColumnableContainer) { $columnFormatter->format($child, $document); $verticalTranslation = $columnFormatter->getLastVerticalTranslation(); } else { $verticalTranslation = 0; } $this->breakChildIfNecessary($child); $this->totalVerticalTranslation += -$verticalTranslation; } foreach ($node->getPages() as $page) { $page->setGraphicsContextFromSourceDocumentIfNecessary($document); } $this->node = null; }