diff --git a/src/Smalot/PdfParser/Font.php b/src/Smalot/PdfParser/Font.php index 654af7eb..56dee588 100644 --- a/src/Smalot/PdfParser/Font.php +++ b/src/Smalot/PdfParser/Font.php @@ -287,8 +287,12 @@ public function calculateTextWidth(string $text, ?array &$missing = null): ?floa // Usually, Widths key is set in $details array, but if it isn't use an empty array instead. $widths = $details['Widths'] ?? []; - // Widths array is zero indexed but table is not. We must map them based on FirstChar and LastChar - // note: in some cases the values for FirstChar or LastChar are null here + /* + * Widths array is zero indexed but table is not. We must map them based on FirstChar and LastChar + * + * Note: Without the change you would see warnings in PHP 8.4 because the values of FirstChar or LastChar + * can be null sometimes. + */ $width_map = array_flip(range((int) $details['FirstChar'], (int) $details['LastChar'])); $width = null; diff --git a/src/Smalot/PdfParser/PDFObject.php b/src/Smalot/PdfParser/PDFObject.php index 84f3f15e..2c33e0e9 100644 --- a/src/Smalot/PdfParser/PDFObject.php +++ b/src/Smalot/PdfParser/PDFObject.php @@ -82,7 +82,7 @@ public function __construct( Document $document, ?Header $header = null, ?string $content = null, - ?Config $config = null, + ?Config $config = null ) { $this->document = $document; $this->header = $header ?? new Header(); @@ -1144,7 +1144,7 @@ public static function factory( Document $document, Header $header, ?string $content, - ?Config $config = null, + ?Config $config = null ): self { switch ($header->get('Type')->getContent()) { case 'XObject':