From 5fce6fddd98211f6e138904145b71979eb87d52e Mon Sep 17 00:00:00 2001 From: Mitchel Date: Sun, 22 Dec 2019 23:17:36 +0100 Subject: [PATCH] Update StandardPositionFormatter.php Fix width warning --- .../Core/Formatter/StandardPositionFormatter.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/PHPPdf/Core/Formatter/StandardPositionFormatter.php b/lib/PHPPdf/Core/Formatter/StandardPositionFormatter.php index 22f440e1..a7a0e920 100644 --- a/lib/PHPPdf/Core/Formatter/StandardPositionFormatter.php +++ b/lib/PHPPdf/Core/Formatter/StandardPositionFormatter.php @@ -27,13 +27,16 @@ public function format(Nodes\Node $node, Document $document) list($x, $y) = $boundary->getFirstPoint()->toArray(); $attributesSnapshot = $node->getAttributesSnapshot(); - $diffWidth = $node->getWidth() - $attributesSnapshot['width']; - $width = $node->getWidth(); - $x += $width; + + $width = (isset($attributesSnapshot['width']) ? (int) $attributesSnapshot['width'] : 0); + + $diffWidth = $node->getWidth() - $width; + $nodeWidth = $node->getWidth(); + $x += $nodeWidth; $yEnd = $y - $node->getHeight(); $boundary->setNext($x, $y) ->setNext($x, $yEnd) - ->setNext($x - $width, $yEnd) + ->setNext($x - $nodeWidth, $yEnd) ->close(); if($node->hadAutoMargins()) @@ -42,4 +45,4 @@ public function format(Nodes\Node $node, Document $document) } } } -} \ No newline at end of file +}