/** * IdmlGroups do not have <PathGeometry> or <GeometricBounds> so their overall bounds must be determined * after reading all children by getting the outer bounds of all encompassed children. * The true bounds of the children must take into account their transformation: their true boundaries are * determined by call IdmlBoundary::transform. * Once the group's absolute boundary is computed from the children's boundaries, the group's own transformation * must be accounted for by subtracting the tx and ty from the boundary points. */ public function determineBounds() { $boundary = null; foreach ($this->childrenElements as $child) { // If the child's boundary is not set, go to the next child. if (!isset($child->boundary)) { continue; } $childBoundary = IdmlBoundary::transform($child->boundary, $child->transformation); // For the first child's boundary, duplicate it if (is_null($boundary)) { $boundary = new IdmlBoundary($childBoundary->top, $childBoundary->left, $childBoundary->bottom, $childBoundary->right); continue; } // Add the child's dimensions to the group's boundary. if (get_class($child) == 'IdmlTextFrame') { // Add the height of the text frame, which stacks vertically. $boundary->bottom += $childBoundary->getHeight(); } else { // Use that new boundary to expand the bounds of the group. $boundary->encompass($childBoundary); } } // Now subtract the group's tx and ty from the boundary points to determine its actual position. $top = $boundary->top - $this->transformation->yTranslate(); $left = $boundary->left - $this->transformation->xTranslate(); $bottom = $boundary->bottom - $this->transformation->yTranslate(); $right = $boundary->right - $this->transformation->xTranslate(); $this->boundary = new IdmlBoundary($top, $left, $bottom, $right); }