--- a/intranet/vendor/setasign/fpdf/tutorial/tuto6.php
+++ b/intranet/vendor/setasign/fpdf/tutorial/tuto6.php
@@ -1,6 +1,7 @@
 <?php
 require('../fpdf.php');
 
+#[\AllowDynamicProperties]
 class PDF extends FPDF
 {
 protected $B = 0;
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/DefinedName.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/DefinedName.php
@@ -4,6 +4,7 @@
 
 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 
+#[\AllowDynamicProperties]
 abstract class DefinedName
 {
     protected const REGEXP_IDENTIFY_FORMULA = '[^_\p{N}\p{L}:, \$\'!]';
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php
@@ -8,6 +8,7 @@
 use PhpOffice\PhpSpreadsheet\Worksheet\Iterator;
 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 
+#[\AllowDynamicProperties]
 class Spreadsheet
 {
     // Allowable values for workbook window visilbity
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php
@@ -5,6 +5,7 @@
 /**
  * @template T of IComparable
  */
+#[\AllowDynamicProperties]
 class HashTable
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php
@@ -4,6 +4,7 @@
 
 use PhpOffice\PhpSpreadsheet\RichText\RichText;
 
+#[\AllowDynamicProperties]
 class Comment implements IComparable
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php
@@ -334,7 +334,7 @@
         //~ http://schemas.openxmlformats.org/package/2006/relationships"
         $workbookBasename = $this->getWorkbookBaseName($zip);
         $wbRels = simplexml_load_string(
-            $this->securityScanner->scan($this->getFromZipArchive($zip, "xl/_rels/${workbookBasename}.rels")),
+            $this->securityScanner->scan($this->getFromZipArchive($zip, "xl/_rels/{$workbookBasename}.rels")),
             'SimpleXMLElement',
             Settings::getLibXmlLoaderOptions()
         );
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php
@@ -277,8 +277,8 @@
      */
     public function loadIntoExisting(string $pFilename, Spreadsheet $spreadsheet): Spreadsheet
     {
-        $lineEnding = ini_get('auto_detect_line_endings') ?: '0';
-        ini_set('auto_detect_line_endings', '1');
+        $lineEnding = '0' ?: '0';
+        false;
 
         // Open file
         $this->openFileOrMemory($pFilename);
@@ -326,7 +326,7 @@
         // Close file
         fclose($fileHandle);
 
-        ini_set('auto_detect_line_endings', $lineEnding);
+        false;
 
         // Return
         return $spreadsheet;
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php
@@ -2,6 +2,7 @@
 
 namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
 
+#[\AllowDynamicProperties]
 class Theme
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php
@@ -71,21 +71,12 @@
 
     private function disableEntityLoaderCheck(): void
     {
-        if (Settings::getLibXmlDisableEntityLoader() && \PHP_VERSION_ID < 80000) {
-            $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true);
-
-            if (self::$libxmlDisableEntityLoaderValue === null) {
-                self::$libxmlDisableEntityLoaderValue = $libxmlDisableEntityLoaderValue;
-            }
-        }
+        // PHP 8 uses libxml with external entity loading disabled by default.
     }
 
     public static function shutdown(): void
     {
-        if (self::$libxmlDisableEntityLoaderValue !== null && \PHP_VERSION_ID < 80000) {
-            libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue);
-            self::$libxmlDisableEntityLoaderValue = null;
-        }
+        self::$libxmlDisableEntityLoaderValue = null;
     }
 
     public function __destruct()
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php
@@ -5,6 +5,7 @@
 use PhpOffice\PhpSpreadsheet\IComparable;
 use PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting\ConditionalDataBar;
 
+#[\AllowDynamicProperties]
 class Conditional implements IComparable
 {
     // Condition types
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php
@@ -6,6 +6,7 @@
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 
+#[\AllowDynamicProperties]
 abstract class Supervisor implements IComparable
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php
@@ -10,6 +10,7 @@
 use PhpOffice\PhpSpreadsheet\Style\Color;
 use PhpOffice\PhpSpreadsheet\Style\Font;
 
+#[\AllowDynamicProperties]
 class Html
 {
     protected static $colourMap = [
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php
@@ -6,6 +6,7 @@
 use PhpOffice\PhpSpreadsheet\Cell\DataType;
 use PhpOffice\PhpSpreadsheet\IComparable;
 
+#[\AllowDynamicProperties]
 class RichText implements IComparable
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php
@@ -2,6 +2,7 @@
 
 namespace PhpOffice\PhpSpreadsheet\RichText;
 
+#[\AllowDynamicProperties]
 class TextElement implements ITextElement
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php
@@ -2,6 +2,7 @@
 
 namespace PhpOffice\PhpSpreadsheet\Cell;
 
+#[\AllowDynamicProperties]
 class DataValidation
 {
     // Data validation types
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php
@@ -10,6 +10,7 @@
 use PhpOffice\PhpSpreadsheet\Style\Style;
 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
 
+#[\AllowDynamicProperties]
 class Cell
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php
@@ -66,7 +66,7 @@
      *
      * @return bool
      */
-    public function valid()
+    public function valid(): bool
     {
         return $this->position < $this->subject->getSheetCount() && $this->position >= 0;
     }
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php
@@ -63,6 +63,7 @@
  * &H - code for "shadow style"
  * </code>
  */
+#[\AllowDynamicProperties]
 class HeaderFooter
 {
     // Header/footer image location
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php
@@ -156,7 +156,7 @@
      *
      * @return bool
      */
-    public function valid()
+    public function valid(): bool
     {
         return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex;
     }
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php
@@ -2,6 +2,7 @@
 
 namespace PhpOffice\PhpSpreadsheet\Worksheet;
 
+#[\AllowDynamicProperties]
 class PageMargins
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php
@@ -4,6 +4,7 @@
 
 use PhpOffice\PhpSpreadsheet\Shared\PasswordHasher;
 
+#[\AllowDynamicProperties]
 class Protection
 {
     const ALGORITHM_MD2 = 'MD2';
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php
@@ -4,6 +4,7 @@
 
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 
+#[\AllowDynamicProperties]
 abstract class Dimension
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php
@@ -6,6 +6,7 @@
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 use PhpOffice\PhpSpreadsheet\IComparable;
 
+#[\AllowDynamicProperties]
 class BaseDrawing implements IComparable
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php
@@ -9,6 +9,7 @@
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 use PhpOffice\PhpSpreadsheet\Shared\Date;
 
+#[\AllowDynamicProperties]
 class AutoFilter
 {
     /**
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php
@@ -118,7 +118,7 @@
      *
      * @return Row
      */
-    public function current()
+    public function current(): mixed
     {
         return new Row($this->subject, $this->position);
     }
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php
@@ -4,6 +4,7 @@
 
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 
+#[\AllowDynamicProperties]
 class SheetView
 {
     // Sheet View types
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php
@@ -25,6 +25,7 @@
 use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
 use PhpOffice\PhpSpreadsheet\Style\Style;
 
+#[\AllowDynamicProperties]
 class Worksheet implements IComparable
 {
     // Break types
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php
@@ -77,6 +77,7 @@
  * 68 = A3 extra transverse paper (322 mm by 445 mm)
  * </code>
  */
+#[\AllowDynamicProperties]
 class PageSetup
 {
     // Paper size
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php
@@ -134,7 +134,7 @@
      *
      * @return Column
      */
-    public function current()
+    public function current(): mixed
     {
         return new Column($this->worksheet, Coordinate::stringFromColumnIndex($this->currentColumnIndex));
     }
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
@@ -5,6 +5,7 @@
 use PhpOffice\PhpSpreadsheet\IComparable;
 use PhpOffice\PhpSpreadsheet\Style\Color;
 
+#[\AllowDynamicProperties]
 class Shadow implements IComparable
 {
     // Shadow alignment
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
@@ -5,6 +5,7 @@
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter;
 
+#[\AllowDynamicProperties]
 class Column
 {
     const AUTOFILTER_FILTERTYPE_FILTER = 'filters';
--- a/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php
+++ b/intranet/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php
@@ -5,6 +5,7 @@
 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
 use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
 
+#[\AllowDynamicProperties]
 class Rule
 {
     const AUTOFILTER_RULETYPE_FILTER = 'filter';
--- a/intranet/vendor/composer/html2pdf-5.2.4/src/MyPdf.php
+++ b/intranet/vendor/composer/html2pdf-5.2.4/src/MyPdf.php
@@ -16,6 +16,9 @@
 
 class MyPdf extends \TCPDF
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $ws;
+
     protected $_footerParam = array();
     protected $_transf      = array();
     protected $_myLastPageGroup = null;
--- a/intranet/vendor/composer/html2pdf-5.2.4/src/Html2Pdf.php
+++ b/intranet/vendor/composer/html2pdf-5.2.4/src/Html2Pdf.php
@@ -31,6 +31,9 @@
 
 class Html2Pdf
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_pdfa;
+
     /**
      * myPdf object, extends from TCPDF
      * @var MyPdf
--- a/intranet/vendor/tecnickcom/tcpdf/tcpdf.php
+++ b/intranet/vendor/tecnickcom/tcpdf/tcpdf.php
@@ -134,6 +134,7 @@
  * @IgnoreAnnotation("public")
  * @IgnoreAnnotation("pre")
  */
+#[\AllowDynamicProperties]
 class TCPDF {
 
 	// Protected properties
@@ -11005,14 +11006,11 @@
 			$this->encryptdata['StrF'] = 'StdCF';
 		}
 		if ($mode > 1) { // AES
-			if (!extension_loaded('openssl') && !extension_loaded('mcrypt')) {
-				$this->Error('AES encryption requires openssl or mcrypt extension (http://www.php.net/manual/en/mcrypt.requirements.php).');
+			if (!extension_loaded('openssl')) {
+				$this->Error('AES encryption requires the OpenSSL extension.');
 			}
 			if (extension_loaded('openssl') && !in_array('aes-256-cbc', openssl_get_cipher_methods())) {
 				$this->Error('AES encryption requires openssl/aes-256-cbc cypher.');
-			}
-			if (extension_loaded('mcrypt') && mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) === false) {
-				$this->Error('AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
 			}
 			if (($mode == 3) AND !function_exists('hash')) {
 				// the Hash extension requires no external libraries and is enabled by default as of PHP 5.1.2.
@@ -16500,7 +16498,7 @@
 		// define self-closing tags
 		$selfclosingtags = array('area','base','basefont','br','hr','input','img','link','meta');
 		// remove all unsupported tags (the line below lists all supported tags)
-		$html = strip_tags($html, '<marker/><a><b><blockquote><body><br><br/><dd><del><div><dl><dt><em><font><form><h1><h2><h3><h4><h5><h6><hr><hr/><i><img><input><label><li><ol><option><p><pre><s><select><small><span><strike><strong><sub><sup><table><tablehead><tcpdf><td><textarea><th><thead><tr><tt><u><ul>');
+		$html = strip_tags($html, '<marker><a><b><blockquote><body><br><br><dd><del><div><dl><dt><em><font><form><h1><h2><h3><h4><h5><h6><hr><hr><i><img><input><label><li><ol><option><p><pre><s><select><small><span><strike><strong><sub><sup><table><tablehead><tcpdf><td><textarea><th><thead><tr><tt><u><ul>');
 		//replace some blank characters
 		$html = preg_replace('/<pre/', '<xre', $html); // preserve pre tag
 		$html = preg_replace('/<(table|tr|td|th|tcpdf|blockquote|dd|div|dl|dt|form|h1|h2|h3|h4|h5|h6|br|hr|li|ol|ul|p)([^\>]*)>[\n\r\t]+/', '<\\1\\2>', $html);
--- a/intranet/vendor/tecnickcom/tcpdf/include/tcpdf_static.php
+++ b/intranet/vendor/tecnickcom/tcpdf/include/tcpdf_static.php
@@ -403,7 +403,7 @@
 
 	/**
 	 * Returns the input text encrypted using AES algorithm and the specified key.
-	 * This method requires openssl or mcrypt. Text is padded to 16bytes blocks
+	 * This method requires OpenSSL. Text is padded to 16bytes blocks
 	 * @param string $key encryption key
 	 * @param string $text input text to be encrypted
 	 * @return string encrypted text
@@ -424,15 +424,12 @@
 			$text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
 			return $iv.substr($text, 0, -16);
 		}
-		$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
-		$text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
-		$text = $iv.$text;
-		return $text;
+		throw new \RuntimeException('OpenSSL is required for PDF encryption.');
 	}
 
 	/**
 	 * Returns the input text encrypted using AES algorithm and the specified key.
-	 * This method requires openssl or mcrypt. Text is not padded
+	 * This method requires OpenSSL. Text is not padded
 	 * @param string $key encryption key
 	 * @param string $text input text to be encrypted
 	 * @return string encrypted text
@@ -450,9 +447,7 @@
 			$text = openssl_encrypt($text, $algo, $key, OPENSSL_RAW_DATA, $iv);
 			return substr($text, 0, -16);
 		}
-		$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
-		$text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
-		return $text;
+		throw new \RuntimeException('OpenSSL is required for PDF encryption.');
 	}
 
 	/**
@@ -468,10 +463,6 @@
 	 * @public static
 	 */
 	public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) {
-		if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
-			// try to use mcrypt function if exist
-			return $out;
-		}
 		if ($last_enc_key != $key) {
 			$k = str_repeat($key, (int) ((256 / strlen($key)) + 1));
 			$rc4 = range(0, 255);
@@ -1825,7 +1816,7 @@
 		curl_setopt($crs, CURLOPT_URL, $url);
 		curl_setopt($crs, CURLOPT_NOBODY, true);
 		curl_setopt($crs, CURLOPT_FAILONERROR, true);
-		if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
+		if ((ini_get('open_basedir') == '') && (!'0')) {
 			curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
 		}
 		curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
@@ -1961,7 +1952,7 @@
 				curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
 				curl_setopt($crs, CURLOPT_FAILONERROR, true);
 				curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
-				if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
+				if ((ini_get('open_basedir') == '') && (!'0')) {
 				    curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
 				}
 				curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
--- a/intranet/vendor/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php
+++ b/intranet/vendor/microsoft/azure-storage-common/src/Common/SharedAccessSignatureHelper.php
@@ -149,7 +149,7 @@
         $parameters[] = $signedVersion;
 
         // implode the parameters into a string
-        $stringToSign = utf8_encode(implode("\n", $parameters) . "\n");
+        $stringToSign = mb_convert_encoding(implode("\n", $parameters) . "\n", 'UTF-8', 'ISO-8859-1');
 
         // decode the account key from base64
         $decodedAccountKey = base64_decode($this->accountKey);
--- a/intranet/vendor/microsoft/azure-storage-common/src/Common/Internal/Middlewares/CommonRequestMiddleware.php
+++ b/intranet/vendor/microsoft/azure-storage-common/src/Common/Internal/Middlewares/CommonRequestMiddleware.php
@@ -60,7 +60,7 @@
      * @param array       $headers              The headers to be added.
      */
     public function __construct(
-        IAuthScheme $authenticationScheme = null,
+        ?IAuthScheme $authenticationScheme,
         $storageAPIVersion,
         $serviceSDKVersion,
         array $headers = array()
--- a/intranet/vendor/markbaker/complex/classes/Bootstrap.php
+++ b/intranet/vendor/markbaker/complex/classes/Bootstrap.php
@@ -18,7 +18,7 @@
 class FilenameFilter extends FilesystemRegexFilter
 {
     // Filter files against the regex
-    public function accept()
+    public function accept(): bool
     {
         return (!$this->isFile() || preg_match($this->regex, $this->getFilename()));
     }
--- a/intranet/vendor/Spipu/Html2Pdf/MyPdf.php
+++ b/intranet/vendor/Spipu/Html2Pdf/MyPdf.php
@@ -16,6 +16,9 @@
 
 class MyPdf extends \TCPDF
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $ws;
+
     protected $_footerParam = array();
     protected $_transf      = array();
     protected $_myLastPageGroup = null;
--- a/intranet/vendor/Spipu/Html2Pdf/Html2Pdf.php
+++ b/intranet/vendor/Spipu/Html2Pdf/Html2Pdf.php
@@ -31,6 +31,9 @@
 
 class Html2Pdf
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_pdfa;
+
     /**
      * myPdf object, extends from TCPDF
      * @var MyPdf
--- a/intranet/vendor/mpdf/mpdf/src/Mpdf.php
+++ b/intranet/vendor/mpdf/mpdf/src/Mpdf.php
@@ -25,6 +25,7 @@
  *
  * @license GPL-2.0
  */
+#[\AllowDynamicProperties]
 class Mpdf implements \Psr\Log\LoggerAwareInterface
 {
 
@@ -9691,7 +9692,7 @@
 			setlocale(LC_NUMERIC, 'C');
 		}
 
-		if (ini_get('mbstring.func_overload')) {
+		if ('0') {
 			throw new \Mpdf\MpdfException('Mpdf cannot function properly with mbstring.func_overload enabled');
 		}
 
--- a/intranet/vendor/mpdf/mpdf/src/PageBox.php
+++ b/intranet/vendor/mpdf/mpdf/src/PageBox.php
@@ -18,7 +18,7 @@
 	}
 
 	#[\ReturnTypeWillChange]
-	public function offsetSet($offset, $value)
+	public function offsetSet($offset, $value): void
 	{
 		if (!$this->offsetExists($offset)) {
 			throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
@@ -28,13 +28,13 @@
 	}
 
 	#[\ReturnTypeWillChange]
-	public function offsetExists($offset)
+	public function offsetExists($offset): bool
 	{
 		return array_key_exists($offset, $this->container);
 	}
 
 	#[\ReturnTypeWillChange]
-	public function offsetUnset($offset)
+	public function offsetUnset($offset): void
 	{
 		if (!$this->offsetExists($offset)) {
 			throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
@@ -44,7 +44,7 @@
 	}
 
 	#[\ReturnTypeWillChange]
-	public function offsetGet($offset)
+	public function offsetGet($offset): mixed
 	{
 		if (!$this->offsetExists($offset)) {
 			throw new \Mpdf\MpdfException('Invalid key to set for PageBox');
--- a/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php
+++ b/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php
@@ -803,7 +803,7 @@
         if ($index !== false) {
             $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
         }
-        $mq = $mq_fix && version_compare(PHP_VERSION, '7.4.0', '<') && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc();
+        $mq = $mq_fix && version_compare(PHP_VERSION, '7.4.0', '<') && function_exists('get_magic_quotes_gpc') && false;
 
         $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
         $ret = array();
--- a/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php
+++ b/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php
@@ -30,7 +30,7 @@
      * @return bool
      */
     #[\ReturnTypeWillChange]
-    public function accept()
+    public function accept(): bool
     {
         $key = $this->getInnerIterator()->key();
         if (strncmp($key, $this->filter, $this->l) !== 0) {
--- a/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/StringHash.php
+++ b/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/StringHash.php
@@ -21,7 +21,7 @@
      * @return mixed
      */
     #[\ReturnTypeWillChange]
-    public function offsetGet($index)
+    public function offsetGet($index): mixed
     {
         $this->accessed[$index] = true;
         return parent::offsetGet($index);
--- a/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language.php
+++ b/intranet/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language.php
@@ -4,6 +4,7 @@
  * Represents a language and defines localizable string formatting and
  * other functions, as well as the localized messages for HTML Purifier.
  */
+#[\AllowDynamicProperties]
 class HTMLPurifier_Language
 {
 
--- a/intranet/vendor/myclabs/php-enum/src/Enum.php
+++ b/intranet/vendor/myclabs/php-enum/src/Enum.php
@@ -311,7 +311,7 @@
      * @psalm-pure
      */
     #[\ReturnTypeWillChange]
-    public function jsonSerialize()
+    public function jsonSerialize(): mixed
     {
         return $this->getValue();
     }
--- a/intranet/jpgraph/src/jpgraph_ttf.inc.php
+++ b/intranet/jpgraph/src/jpgraph_ttf.inc.php
@@ -169,10 +169,10 @@
             return $unistring;
         } elseif( LANGUAGE_CYRILLIC ) {
             if( CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251')) ) {
-                $aTxt = convert_cyr_string($aTxt, "w", "k");
+                $aTxt = mb_convert_encoding(($aTxt ?? ''), 'KOI8-R', 'Windows-1251');
             }
             if( !defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
-                $isostring = convert_cyr_string($aTxt, "k", "i");
+                $isostring = mb_convert_encoding(($aTxt ?? ''), 'ISO-8859-5', 'KOI8-R');
                 $unistring = LanguageConv::iso2uni($isostring);
             }
             else {
@@ -193,14 +193,14 @@
                 JpGraphError::RaiseL(25006);
                 //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
             }
-            return iconv('BIG5','UTF-8',$aTxt);
+            return iconv('BIG5','UTF-8',($aTxt ?? ''));
         }
         elseif( ASSUME_EUCJP_ENCODING &&
         ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC) ) {
             if( !function_exists('mb_convert_encoding') ) {
                 JpGraphError::RaiseL(25127);
             }
-            return mb_convert_encoding($aTxt, 'UTF-8','EUC-JP');
+            return mb_convert_encoding(($aTxt ?? ''), 'UTF-8','EUC-JP');
         }
         elseif( $aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON ) {
             return LanguageConv::heb_iso2uni($aTxt);
@@ -212,9 +212,9 @@
     // Translate iso encoding to unicode
     public static function iso2uni ($isoline){
         $uniline='';
-        for ($i=0; $i < strlen($isoline); $i++){
-            $thischar=substr($isoline,$i,1);
-            $charcode=ord($thischar);
+        for ($i=0; $i < strlen(($isoline ?? '')); $i++){
+            $thischar=substr(($isoline ?? ''),$i,1);
+            $charcode=ord(($thischar ?? ''));
             $uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;
         }
         return $uniline;
@@ -223,9 +223,9 @@
     // Translate greek iso encoding to unicode
     public static function gr_iso2uni ($isoline) {
         $uniline='';
-        for ($i=0; $i < strlen($isoline); $i++) {
-            $thischar=substr($isoline,$i,1);
-            $charcode=ord($thischar);
+        for ($i=0; $i < strlen(($isoline ?? '')); $i++) {
+            $thischar=substr(($isoline ?? ''),$i,1);
+            $charcode=ord(($thischar ?? ''));
             $uniline.=($charcode>179 && $charcode!=183 && $charcode!=187 && $charcode!=189) ? "&#" . (900+($charcode-180)). ";" : $thischar;
         }
         return $uniline;
@@ -234,9 +234,9 @@
     // Translate greek win encoding to unicode
     public static function gr_win2uni ($winline) {
         $uniline='';
-        for ($i=0; $i < strlen($winline); $i++) {
-            $thischar=substr($winline,$i,1);
-            $charcode=ord($thischar);
+        for ($i=0; $i < strlen(($winline ?? '')); $i++) {
+            $thischar=substr(($winline ?? ''),$i,1);
+            $charcode=ord(($thischar ?? ''));
             if ($charcode==161 || $charcode==162) {
                 $uniline.="&#" . (740+$charcode). ";";
             }
@@ -251,12 +251,12 @@
         $isoline = hebrev($isoline);
         $o = '';
 
-        $n = strlen($isoline);
+        $n = strlen(($isoline ?? ''));
         for($i=0; $i < $n; $i++) {
-            $c=ord( substr($isoline,$i,1) );
-            $o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr($c);
-        }
-        return utf8_encode($o);
+            $c=ord( (substr(($isoline ?? ''),$i,1) ?? '') );
+            $o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr((int) ($c));
+        }
+        return mb_convert_encoding(($o ?? ''), 'UTF-8', 'ISO-8859-1');
     }
 }
 
@@ -607,16 +607,16 @@
 
         );
 
-        $n = count($iSymbols);
+        $n = count(($iSymbols ?? []));
         $i=0;
         $found = false;
-        $aSymb = strtolower($aSymb);
+        $aSymb = strtolower(($aSymb ?? ''));
         while( $i < $n && !$found ) {
             $found = $aSymb === $iSymbols[$i++][0];
         }
         if( $found ) {
             $ca = $iSymbols[--$i];
-            if( $aCapital && count($ca)==3 )
+            if( $aCapital && count(($ca ?? []))==3 )
                 $s = $ca[2];
             else
                 $s = $ca[1];
--- a/intranet/jpgraph/src/jpgraph_gb2312.php
+++ b/intranet/jpgraph/src/jpgraph_gb2312.php
@@ -1507,17 +1507,17 @@
     0 => 0 );
 
     function gb2utf8($gb) {
-        if( !trim($gb) ) return $gb;
+        if( !trim(($gb ?? '')) ) return $gb;
         $utf8='';
         while($gb) {
-            if( ord(substr($gb,0,1)) > 127 ) {
-                $t=substr($gb,0,2);
-                $gb=substr($gb,2);
-                $utf8 .= $this->u2utf8($this->codetable[hexdec(bin2hex($t))-0x8080]);
+            if( ord((substr(($gb ?? ''),0,1) ?? '')) > 127 ) {
+                $t=substr(($gb ?? ''),0,2);
+                $gb=substr(($gb ?? ''),2);
+                $utf8 .= $this->u2utf8($this->codetable[hexdec(bin2hex(($t ?? '')))-0x8080]);
             }
             else {
-                $t=substr($gb,0,1);
-                $gb=substr($gb,1);
+                $t=substr(($gb ?? ''),0,1);
+                $gb=substr(($gb ?? ''),1);
                 $utf8 .= $this->u2utf8($t);
             }
         }
@@ -1530,19 +1530,19 @@
             $str.=$c;
         }
         else if ($c < 0x800) {
-            $str.=chr(0xC0 | $c>>6);
-            $str.=chr(0x80 | $c & 0x3F);
+            $str.=chr((int) (0xC0 | $c>>6));
+            $str.=chr((int) (0x80 | $c & 0x3F));
         }
         else if ($c < 0x10000) {
-            $str.=chr(0xE0 | $c>>12);
-            $str.=chr(0x80 | $c>>6 & 0x3F);
-            $str.=chr(0x80 | $c & 0x3F);
+            $str.=chr((int) (0xE0 | $c>>12));
+            $str.=chr((int) (0x80 | $c>>6 & 0x3F));
+            $str.=chr((int) (0x80 | $c & 0x3F));
         }
         else if ($c < 0x200000) {
-            $str.=chr(0xF0 | $c>>18);
-            $str.=chr(0x80 | $c>>12 & 0x3F);
-            $str.=chr(0x80 | $c>>6 & 0x3F);
-            $str.=chr(0x80 | $c & 0x3F);
+            $str.=chr((int) (0xF0 | $c>>18));
+            $str.=chr((int) (0x80 | $c>>12 & 0x3F));
+            $str.=chr((int) (0x80 | $c>>6 & 0x3F));
+            $str.=chr((int) (0x80 | $c & 0x3F));
         }
         return $str;
     }
--- a/intranet/jpgraph/src/jpgraph_antispam.php
+++ b/intranet/jpgraph/src/jpgraph_antispam.php
@@ -562,14 +562,14 @@
         for($i=0; $i < $aLen; ++$i) {
             if( rand(0,9) < 6 ) {
                 // Digits
-                $d .= chr( ord('1') + rand(0,8) );
+                $d .= chr( (int) (ord('1') + rand(0,8)) );
             }
             else {
                 // Letters
                 do {
                     $offset = rand(0,25);
                 } while ( $offset==14 );
-                $d .= chr( ord('a') + $offset );
+                $d .= chr( (int) (ord('a') + $offset) );
             }
         }
         $this->iData = $d;
@@ -578,34 +578,34 @@
 
     function Stroke() {
 
-        $n=strlen($this->iData);
+        $n=strlen(($this->iData ?? ''));
         if( $n==0 ) {
             return false;
         }
 
         for($i=0; $i < $n; ++$i ) {
-            if( $this->iData[$i]==='0' || strtolower($this->iData[$i])==='o') {
+            if( $this->iData[$i]==='0' || strtolower(($this->iData[$i] ?? ''))==='o') {
                 return false;
             }
         }
 
-        $img = @imagecreatetruecolor($n*$this->iDD->iWidth, $this->iDD->iHeight);
+        $img = @imagecreatetruecolor((int) ($n*$this->iDD->iWidth), (int) ($this->iDD->iHeight));
         if( $img < 1 ) {
             return false;
         }
 
         $start=0;
         for($i=0; $i < $n; ++$i ) {
-            $dimg = imagecreatefromstring(base64_decode($this->iDD->chars[strtolower($this->iData[$i])][1]));
-            imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $this->iDD->iHeight);
+            $dimg = imagecreatefromstring(base64_decode(($this->iDD->chars[strtolower(($this->iData[$i] ?? ''))][1] ?? '')));
+            imagecopy($img,$dimg,(int) ($start),0,0,0,(int) (imagesx($dimg)), (int) ($this->iDD->iHeight));
             $start += imagesx($dimg);
         }
-        $resimg = @imagecreatetruecolor($start+4, $this->iDD->iHeight+4);
+        $resimg = @imagecreatetruecolor((int) ($start+4), (int) ($this->iDD->iHeight+4));
         if( $resimg < 1 ) {
             return false;
         }
 
-        imagecopy($resimg,$img,2,2,0,0,$start, $this->iDD->iHeight);
+        imagecopy($resimg,$img,2,2,0,0,(int) ($start), (int) ($this->iDD->iHeight));
         header("Content-type: image/jpeg");
         imagejpeg($resimg);
         return true;
--- a/intranet/jpgraph/src/jpgraph_imgtrans.php
+++ b/intranet/jpgraph/src/jpgraph_imgtrans.php
@@ -43,14 +43,14 @@
     else
     $hh = $h;
 
-    $newgdh = imagecreatetruecolor($ww,$hh);
+    $newgdh = imagecreatetruecolor((int) ($ww),(int) ($hh));
     $crgb = new RGB( $newgdh );
     $fillColor = $crgb->Allocate($aFillColor);
-    imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor);
+    imagefilledrectangle($newgdh,0,0,(int) ($ww-1),(int) ($hh-1),(int) ($fillColor));
 
     if( $aBorder ) {
         $colidx = $crgb->Allocate($aBorder);
-        imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx);
+        imagerectangle($newgdh,0,0,(int) ($ww-1),(int) ($hh-1),(int) ($colidx));
     }
 
     $mid = round($w * $aHorizonPos);
@@ -69,13 +69,13 @@
         for($x=0; $x < $w; ++$x) {
             $xt = ($x-$mid) * $aSkewDist / ($aSkewDist + $yp);
             if( $aDir == SKEW3D_UP )
-            $rgb = imagecolorat($aGdImg,$x,$h-$y-1);
+            $rgb = imagecolorat($aGdImg,(int) ($x),(int) ($h-$y-1));
             else
-            $rgb = imagecolorat($aGdImg,$x,$y);
+            $rgb = imagecolorat($aGdImg,(int) ($x),(int) ($y));
             $r = ($rgb >> 16) & 0xFF;
             $g = ($rgb >> 8) & 0xFF;
             $b = $rgb & 0xFF;
-            $colidx = imagecolorallocate($newgdh,$r,$g,$b);
+            $colidx = imagecolorallocate($newgdh,(int) ($r),(int) ($g),(int) ($b));
             $xt = round($xt+$mid);
             if( $aDir == SKEW3D_UP ) {
                 $syt = $yt;
@@ -85,15 +85,15 @@
             }
 
             if( !empty($set[$yt]) ) {
-                $nrgb = imagecolorat($newgdh,$xt,$syt);
+                $nrgb = imagecolorat($newgdh,(int) ($xt),(int) ($syt));
                 $nr = ($nrgb >> 16) & 0xFF;
                 $ng = ($nrgb >> 8) & 0xFF;
                 $nb = $nrgb & 0xFF;
-                $colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2),
-                floor(($g+$ng)/2),floor(($b+$nb)/2));
-            }
-
-            imagesetpixel($newgdh,$xt,$syt,$colidx);
+                $colidx = imagecolorallocate($newgdh,(int) (floor(($r+$nr)/2)),
+                (int) (floor(($g+$ng)/2)),(int) (floor(($b+$nb)/2)));
+            }
+
+            imagesetpixel($newgdh,(int) ($xt),(int) ($syt),(int) ($colidx));
         }
 
         $set[$yt] = true;
@@ -118,14 +118,14 @@
         else
         $ww = $w;
 
-        $newgdh = imagecreatetruecolor($ww,$hh);
+        $newgdh = imagecreatetruecolor((int) ($ww),(int) ($hh));
         $crgb = new RGB( $newgdh );
         $fillColor = $crgb->Allocate($aFillColor);
-        imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor);
+        imagefilledrectangle($newgdh,0,0,(int) ($ww-1),(int) ($hh-1),(int) ($fillColor));
 
         if( $aBorder ) {
             $colidx = $crgb->Allocate($aBorder);
-            imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx);
+            imagerectangle($newgdh,0,0,(int) ($ww-1),(int) ($hh-1),(int) ($colidx));
         }
 
         $mid = round($h * $aHorizonPos);
@@ -143,13 +143,13 @@
                 $yt = ($yp-$mid) * $aSkewDist / ($aSkewDist + $x);
 
                 if( $aDir == SKEW3D_RIGHT )
-                $rgb = imagecolorat($aGdImg,$w-$x-1,$y);
+                $rgb = imagecolorat($aGdImg,(int) ($w-$x-1),(int) ($y));
                 else
-                $rgb = imagecolorat($aGdImg,$x,$y);
+                $rgb = imagecolorat($aGdImg,(int) ($x),(int) ($y));
                 $r = ($rgb >> 16) & 0xFF;
                 $g = ($rgb >> 8) & 0xFF;
                 $b = $rgb & 0xFF;
-                $colidx = imagecolorallocate($newgdh,$r,$g,$b);
+                $colidx = imagecolorallocate($newgdh,(int) ($r),(int) ($g),(int) ($b));
                 $yt = floor($hh-$yt-$mid-1);
                 if( $aDir == SKEW3D_RIGHT ) {
                     $sxt = $ww-$xt-1;
@@ -158,14 +158,14 @@
                 $sxt = $xt ;
 
                 if( !empty($set[$xt]) ) {
-                    $nrgb = imagecolorat($newgdh,$sxt,$yt);
+                    $nrgb = imagecolorat($newgdh,(int) ($sxt),(int) ($yt));
                     $nr = ($nrgb >> 16) & 0xFF;
                     $ng = ($nrgb >> 8) & 0xFF;
                     $nb = $nrgb & 0xFF;
-                    $colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2),
-                    floor(($g+$ng)/2),floor(($b+$nb)/2));
+                    $colidx = imagecolorallocate($newgdh,(int) (floor(($r+$nr)/2)),
+                    (int) (floor(($g+$ng)/2)),(int) (floor(($b+$nb)/2)));
                 }
-                imagesetpixel($newgdh,$sxt,$yt,$colidx);
+                imagesetpixel($newgdh,(int) ($sxt),(int) ($yt),(int) ($colidx));
             }
 
             $set[$xt] = true;
--- a/intranet/jpgraph/src/jpgraph_bar.php
+++ b/intranet/jpgraph/src/jpgraph_bar.php
@@ -141,12 +141,12 @@
         // If we are using a log Y-scale we want the base to be at the
         // minimum Y-value unless the user have specifically set some other
         // value than the default.
-        if( substr($graph->axtype,-3,3)=="log" && $this->ybase==0 )
+        if( substr(($graph->axtype ?? ''),-3,3)=="log" && $this->ybase==0 )
         $this->ybase = $graph->yaxis->scale->GetMinVal();
 
         // For a "text" X-axis scale we will adjust the
         // display of the bars a little bit.
-        if( substr($graph->axtype,0,3)=="tex" ) {
+        if( substr(($graph->axtype ?? ''),0,3)=="tex" ) {
             // Position the ticks between the bars
             $graph->xaxis->scale->ticks->SetXLabelOffset(0.5,0);
 
@@ -236,12 +236,12 @@
 
     function SetPattern($aPattern, $aColor='black'){
         if( is_array($aPattern) ) {
-            $n = count($aPattern);
+            $n = count(($aPattern ?? []));
             $this->iPattern = array();
             $this->iPatternDensity = array();
             if( is_array($aColor) ) {
                 $this->iPatternColor = array();
-                if( count($aColor) != $n ) {
+                if( count(($aColor ?? [])) != $n ) {
                     JpGraphError::RaiseL(2001);//('NUmber of colors is not the same as the number of patterns in BarPlot::SetPattern()');
                 }
             }
@@ -311,10 +311,10 @@
 
     function Stroke($img,$xscale,$yscale) {
 
-        $numpoints = count($this->coords[0]);
+        $numpoints = count(($this->coords[0] ?? []));
         if( isset($this->coords[1]) ) {
-            if( count($this->coords[1])!=$numpoints ) {
-                JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
+            if( count(($this->coords[1] ?? []))!=$numpoints ) {
+                JpGraphError::RaiseL(2003,count(($this->coords[1] ?? [])),$numpoints);
             //"Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])."Number of Y-points:$numpoints");
             }
             else {
@@ -326,7 +326,7 @@
         }
 
 
-        $numbars=count($this->coords[0]);
+        $numbars=count(($this->coords[0] ?? []));
 
         // Use GetMinVal() instead of scale[0] directly since in the case
         // of log scale we get a correct value. Log scales will have negative
@@ -346,7 +346,7 @@
 
         // Count pontetial pattern array to avoid doing the count for each iteration
         if( is_array($this->iPattern) ) {
-            $np = count($this->iPattern);
+            $np = count(($this->iPattern ?? []));
         }
 
         $grad = null;
@@ -391,7 +391,7 @@
                     // an array to specify both (from, to style) for each individual bar. The way to know the difference is
                     // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB
                     // triple.
-                    $ng = count($this->grad_fromcolor);
+                    $ng = count(($this->grad_fromcolor ?? []));
                     if( $ng === 3 ) {
                         if( is_numeric($this->grad_fromcolor[0]) && $this->grad_fromcolor[0] > 0 && $this->grad_fromcolor[0] < 256 ) {
                             // RGB Triple
@@ -422,7 +422,7 @@
             }
             elseif( !empty($this->fill_color) ) {
                 if(is_array($this->fill_color)) {
-                    $img->PushColor($this->fill_color[$i % count($this->fill_color)]);
+                    $img->PushColor($this->fill_color[$i % count(($this->fill_color ?? []))]);
                 } else {
                     $img->PushColor($this->fill_color);
                 }
@@ -463,7 +463,7 @@
                     $sp[10]=$pts[4]+$ssh; $sp[11]=$pts[5]-$ssv;
                 }
                 if( is_array($this->bar_shadow_color) ) {
-                    $numcolors = count($this->bar_shadow_color);
+                    $numcolors = count(($this->bar_shadow_color ?? []));
                     if( $numcolors == 0 ) {
                         JpGraphError::RaiseL(2005);//('You have specified an empty array for shadow colors in the bar plot.');
                     }
@@ -564,7 +564,7 @@
 
             // Stroke the outline of the bar
             if( is_array($this->color) ) {
-                $img->SetColor($this->color[$i % count($this->color)]);
+                $img->SetColor($this->color[$i % count(($this->color ?? []))]);
             }
             else {
                 $img->SetColor($this->color);
@@ -654,7 +654,7 @@
             }
             if( !empty($this->csimtargets[$i]) ) {
                 $this->csimareas .= '<area shape="poly" coords="'.$csimcoord.'" ';
-                $this->csimareas .= " href=\"".htmlentities($this->csimtargets[$i])."\"";
+                $this->csimareas .= " href=\"".htmlentities(($this->csimtargets[$i] ?? ''))."\"";
 
                 if( !empty($this->csimwintargets[$i]) ) {
                     $this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" ";
@@ -681,10 +681,10 @@
     private $nbrplots=0;
     //---------------
     // CONSTRUCTOR
-    function GroupBarPlot($plots) {
+    function __construct($plots) {
         $this->width=0.7;
         $this->plots = $plots;
-        $this->nbrplots = count($plots);
+        $this->nbrplots = count(($plots ?? []));
         if( $this->nbrplots < 1 ) {
             JpGraphError::RaiseL(2007);//('Cannot create GroupBarPlot from empty plot array.');
         }
@@ -700,7 +700,7 @@
     //---------------
     // PUBLIC METHODS
     function Legend($graph) {
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n; ++$i) {
             $c = get_class($this->plots[$i]);
             if( !($this->plots[$i] instanceof BarPlot) ) {
@@ -713,7 +713,7 @@
 
     function Min() {
         list($xmin,$ymin) = $this->plots[0]->Min();
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n; ++$i) {
             list($xm,$ym) = $this->plots[$i]->Min();
             $xmin = max($xmin,$xm);
@@ -724,7 +724,7 @@
 
     function Max() {
         list($xmax,$ymax) = $this->plots[0]->Max();
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n; ++$i) {
             list($xm,$ym) = $this->plots[$i]->Max();
             $xmax = max($xmax,$xm);
@@ -734,7 +734,7 @@
     }
 
     function GetCSIMareas() {
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         $csimareas='';
         for($i=0; $i < $n; ++$i) {
             $csimareas .= $this->plots[$i]->csimareas;
@@ -745,7 +745,7 @@
     // Stroke all the bars next to each other
     function Stroke($img,$xscale,$yscale) {
         $tmp=$xscale->off;
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         $subwidth = $this->width/$this->nbrplots ;
 
         for( $i=0; $i < $n; ++$i ) {
@@ -775,7 +775,7 @@
     // CONSTRUCTOR
     function __construct($plots) {
         $this->plots = $plots;
-        $this->nbrplots = count($plots);
+        $this->nbrplots = count(($plots ?? []));
         if( $this->nbrplots < 1 ) {
             JpGraphError::RaiseL(2010);//('Cannot create AccBarPlot from empty plot array.');
         }
@@ -804,7 +804,7 @@
     //---------------
     // PUBLIC METHODS
     function Legend($graph) {
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for( $i=$n-1; $i >= 0; --$i ) {
             $c = get_class($this->plots[$i]);
             if( !($this->plots[$i] instanceof BarPlot) ) {
@@ -818,8 +818,8 @@
     function Max() {
         list($xmax) = $this->plots[0]->Max();
         $nmax=0;
-        for($i=0; $i < count($this->plots); ++$i) {
-            $n = count($this->plots[$i]->coords[0]);
+        for($i=0; $i < count(($this->plots ?? [])); ++$i) {
+            $n = count(($this->plots[$i]->coords[0] ?? []));
             $nmax = max($nmax,$n);
             list($x) = $this->plots[$i]->Max();
             $xmax = max($xmax,$x);
@@ -856,8 +856,8 @@
     function Min() {
         $nmax=0;
         list($xmin,$ysetmin) = $this->plots[0]->Min();
-        for($i=0; $i < count($this->plots); ++$i) {
-            $n = count($this->plots[$i]->coords[0]);
+        for($i=0; $i < count(($this->plots ?? [])); ++$i) {
+            $n = count(($this->plots[$i]->coords[0] ?? []));
             $nmax = max($nmax,$n);
             list($x,$y) = $this->plots[$i]->Min();
             $xmin = Min($xmin,$x);
@@ -947,7 +947,7 @@
                         // the total value is larger than 0 then we
                         // add the shadow.
                         if( is_array($this->bar_shadow_color) ) {
-                            $numcolors = count($this->bar_shadow_color);
+                            $numcolors = count(($this->bar_shadow_color ?? []));
                             if( $numcolors == 0 ) {
                                 JpGraphError::RaiseL(2013);//('You have specified an empty array for shadow colors in the bar plot.');
                             }
@@ -987,7 +987,7 @@
                         // an array to specify both (from, to style) for each individual bar. The way to know the difference is
                         // to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB
                         // triple.
-                        $ng = count($this->plots[$j]->grad_fromcolor);
+                        $ng = count(($this->plots[$j]->grad_fromcolor ?? []));
                         if( $ng === 3 ) {
                             if( is_numeric($this->plots[$j]->grad_fromcolor[0]) && $this->plots[$j]->grad_fromcolor[0] > 0 &&
                                  $this->plots[$j]->grad_fromcolor[0] < 256 ) {
@@ -1020,7 +1020,7 @@
                     }
                 } else {
                     if (is_array($this->plots[$j]->fill_color) ) {
-                        $numcolors = count($this->plots[$j]->fill_color);
+                        $numcolors = count(($this->plots[$j]->fill_color ?? []));
                         $fillcolor = $this->plots[$j]->fill_color[$i % $numcolors];
                         // If the bar is specified to be non filled then the fill color is false
                         if( $fillcolor !== false ) {
@@ -1065,7 +1065,7 @@
 
                 // CSIM array
 
-                if( $i < count($this->plots[$j]->csimtargets) ) {
+                if( $i < count(($this->plots[$j]->csimtargets ?? [])) ) {
                     // Create the client side image map
                     $rpts = $img->ArrRotate($pts);
                     $csimcoord=round($rpts[0]).", ".round($rpts[1]);
--- a/intranet/jpgraph/src/gd_image.inc.php
+++ b/intranet/jpgraph/src/gd_image.inc.php
@@ -33,6 +33,7 @@
 //              class RotImage which extends the Image class with transparent
 //              rotation.
 //=========================================================================
+#[\AllowDynamicProperties]
 class Image {
     public $img=null;
     public $rgb=null;
@@ -124,7 +125,7 @@
             JpGraphError::RaiseL(25082,$aWidth,$aHeight);//("Illegal sizes specified for width or height when creating an image, (width=$aWidth, height=$aHeight)");
         }
 
-        $this->img = @imagecreatetruecolor($aWidth, $aHeight);
+        $this->img = @imagecreatetruecolor((int) ($aWidth), (int) ($aHeight));
         if( $this->img < 1 ) {
             JpGraphError::RaiseL(25126);
             //die("Can't create truecolor image. Check that you really have GD2 library installed.");
@@ -145,7 +146,7 @@
     function CloneCanvasH() {
         $oldimage = $this->img;
         $this->CreateRawCanvas($this->width,$this->height);
-        imagecopy($this->img,$oldimage,0,0,0,0,$this->width,$this->height);
+        imagecopy($this->img,$oldimage,0,0,0,0,(int) ($this->width),(int) ($this->height));
         return $oldimage;
     }
 
@@ -206,7 +207,7 @@
                     JpGraphError::RaiseL(25083);//('Illegal image size when copying image. Size for copied to image is 1 pixel or less.');
                 }
 
-                $tmpimg = @imagecreatetruecolor($toWidth, $toHeight);
+                $tmpimg = @imagecreatetruecolor((int) ($toWidth), (int) ($toHeight));
 
                 if( $tmpimg < 1 ) {
                     JpGraphError::RaiseL(25084);//('Failed to create temporary GD canvas. Out of memory ?');
@@ -215,21 +216,15 @@
                 $toWidth,$toHeight,$fromWidth,$fromHeight);
                 $fromImg = $tmpimg;
             }
-            imagecopymerge($this->img,$fromImg,$toX,$toY,$fromX,$fromY,$toWidth,$toHeight,$aMix);
-        }
-    }
-
-    static function GetWidth($aImg=null) {
-        if( $aImg === null ) {
-            $aImg = $this->img;
-        }
+            imagecopymerge($this->img,$fromImg,(int) ($toX),(int) ($toY),(int) ($fromX),(int) ($fromY),(int) ($toWidth),(int) ($toHeight),(int) ($aMix));
+        }
+    }
+
+    static function GetWidth($aImg) {
         return imagesx($aImg);
     }
 
-    static function GetHeight($aImg=null) {
-        if( $aImg === null ) {
-            $aImg = $this->img;
-        }
+    static function GetHeight($aImg) {
         return imagesy($aImg);
     }
 
@@ -290,11 +285,11 @@
 
     // Get the specific height for a text string
     function GetTextHeight($txt="",$angle=0) {
-        $tmp = preg_split('/\n/',$txt);
-        $n = count($tmp);
+        $tmp = preg_split('/\n/',($txt ?? ''));
+        $n = count(($tmp ?? []));
         $m=0;
         for($i=0; $i< $n; ++$i) {
-            $m = max($m,strlen($tmp[$i]));
+            $m = max($m,strlen(($tmp[$i] ?? '')));
         }
 
         if( $this->font_family <= FF_FONT2+1 ) {
@@ -338,13 +333,13 @@
     // etxt width.
     function GetTextWidth($txt,$angle=0) {
 
-        $tmp = preg_split('/\n/',$txt);
-        $n = count($tmp);
+        $tmp = preg_split('/\n/',($txt ?? ''));
+        $n = count(($tmp ?? []));
         if( $this->font_family <= FF_FONT2+1 ) {
 
             $m=0;
             for($i=0; $i < $n; ++$i) {
-                $l=strlen($tmp[$i]);
+                $l=strlen(($tmp[$i] ?? ''));
                 if( $l > $m ) {
                     $m = $l;
                 }
@@ -653,7 +648,7 @@
         $use_font = $this->font_family;
 
         if( $dir==90 ) {
-            imagestringup($this->img,$use_font,$x,$y,$txt,$this->current_color);
+            imagestringup($this->img,$use_font,(int) ($x),(int) ($y),$txt,(int) ($this->current_color));
             $aBoundingBox = array(round($x),round($y),round($x),round($y-$w),round($x+$h),round($y-$w),round($x+$h),round($y));
             if( $aDebug ) {
                 // Draw bounding box
@@ -663,24 +658,24 @@
             }
         }
         else {
-            if( preg_match('/\n/',$txt) ) {
-                $tmp = preg_split('/\n/',$txt);
-                for($i=0; $i < count($tmp); ++$i) {
+            if( preg_match('/\n/',($txt ?? '')) ) {
+                $tmp = preg_split('/\n/',($txt ?? ''));
+                for($i=0; $i < count(($tmp ?? [])); ++$i) {
                     $w1 = $this->GetTextWidth($tmp[$i]);
                     if( $paragraph_align=="left" ) {
-                        imagestring($this->img,$use_font,$x,$y-$h+1+$i*$fh,$tmp[$i],$this->current_color);
+                        imagestring($this->img,$use_font,(int) ($x),(int) ($y-$h+1+$i*$fh),$tmp[$i],(int) ($this->current_color));
                     }
                     elseif( $paragraph_align=="right" ) {
-                        imagestring($this->img,$use_font,$x+($w-$w1),$y-$h+1+$i*$fh,$tmp[$i],$this->current_color);
+                        imagestring($this->img,$use_font,(int) ($x+($w-$w1)),(int) ($y-$h+1+$i*$fh),$tmp[$i],(int) ($this->current_color));
                     }
                     else {
-                        imagestring($this->img,$use_font,$x+$w/2-$w1/2,$y-$h+1+$i*$fh,$tmp[$i],$this->current_color);
+                        imagestring($this->img,$use_font,(int) ($x+$w/2-$w1/2),(int) ($y-$h+1+$i*$fh),$tmp[$i],(int) ($this->current_color));
                     }
                 }
             }
             else {
                 //Put the text
-                imagestring($this->img,$use_font,$x,$y-$h+1,$txt,$this->current_color);
+                imagestring($this->img,$use_font,(int) ($x),(int) ($y-$h+1),$txt,(int) ($this->current_color));
             }
             if( $aDebug ) {
                 // Draw the bounding rectangle and the bounding box
@@ -701,10 +696,10 @@
         // instead of '\n\t' we have to add '\r' since
         // the width will be too muchy otherwise since when
         // we print we stroke the individually lines by hand.
-        $e = explode("\n",$aTxt);
-        $n = count($e);
+        $e = explode("\n",($aTxt ?? ''));
+        $n = count(($e ?? []));
         for($i=0; $i<$n; ++$i) {
-            $e[$i]=str_replace("\r","",$e[$i]);
+            $e[$i]=str_replace("\r","",($e[$i] ?? ''));
         }
         return implode("\n\r",$e);
     }
@@ -893,7 +888,7 @@
             $oy=$y;
         }
 
-        if( !preg_match('/\n/',$txt) || ($dir>0 && preg_match('/\n/',$txt)) ) {
+        if( !preg_match('/\n/',($txt ?? '')) || ($dir>0 && preg_match('/\n/',($txt ?? ''))) ) {
             // Format a single line
 
             $txt = $this->AddTxtCR($txt);
@@ -936,8 +931,8 @@
                     // Do nothing the text is drawn at baseline by default
                 }
             } 
-            ImageTTFText ($this->img, $this->font_size, $dir, $x, $y,
-                          $this->current_color,$this->font_file,$txt);
+            ImageTTFText ($this->img, $this->font_size, $dir, (int) ($x), (int) ($y),
+                          (int) ($this->current_color),$this->font_file,$txt);
 
             // Calculate and return the co-ordinates for the bounding box
             $box = $this->imagettfbbox_fixed($this->font_size,$dir,$this->font_file,$txt);
@@ -992,8 +987,8 @@
             $w=$this->GetTextWidth($txt);
 
             $y -= $linemargin/2;
-            $tmp = preg_split('/\n/',$txt);
-            $nl = count($tmp);
+            $tmp = preg_split('/\n/',($txt ?? ''));
+            $nl = count(($tmp ?? []));
             $h = $nl * $fh;
 
             if( $this->text_halign=='right') {
@@ -1043,8 +1038,8 @@
                 $xl -= $bbox[0]/2;
                 $yl = $y - $yadj;
                 //$xl = $xl- $xadj;
-                ImageTTFText($this->img, $this->font_size, $dir, $xl, $yl-($h-$fh)+$fh*$i,
-                             $this->current_color,$this->font_file,$tmp[$i]);
+                ImageTTFText($this->img, $this->font_size, $dir, (int) ($xl), (int) ($yl-($h-$fh)+$fh*$i),
+                             (int) ($this->current_color),$this->font_file,$tmp[$i]);
 
                // echo "xl=$xl,".$tmp[$i]." <br>";
                 if( $debug  ) {
@@ -1162,7 +1157,7 @@
 
     function SetLineWeight($weight) {
         $old = $this->line_weight;
-        imagesetthickness($this->img,$weight);
+        imagesetthickness($this->img,(int) ($weight));
         $this->line_weight = $weight;
         return $old;
     }
@@ -1176,7 +1171,7 @@
         // GD Arc doesn't like negative angles
         while( $s < 0) $s += 360;
         while( $e < 0) $e += 360;
-        imagearc($this->img,round($cx),round($cy),round($w),round($h),$s,$e,$this->current_color);
+        imagearc($this->img,(int) (round($cx)),(int) (round($cy)),(int) (round($w)),(int) (round($h)),(int) ($s),(int) ($e),(int) ($this->current_color));
     }
 
     function FilledArc($xc,$yc,$w,$h,$s,$e,$style='') {
@@ -1187,7 +1182,7 @@
         if( $style=='' )
         $style=IMG_ARC_PIE;
         if( abs($s-$e) > 0 ) {
-            imagefilledarc($this->img,round($xc),round($yc),round($w),round($h),$s,$e,$this->current_color,$style);
+            imagefilledarc($this->img,(int) (round($xc)),(int) (round($yc)),(int) (round($w)),(int) (round($h)),(int) ($s),(int) ($e),(int) ($this->current_color),(int) ($style));
 //            $this->DrawImageSmoothArc($this->img,round($xc),round($yc),round($w),round($h),$s,$e,$this->current_color,$style);
         }
     }
@@ -1203,7 +1198,7 @@
         if( $s == $e ) {
             // A full circle. We draw this a plain circle
             $this->PushColor($fillcolor);
-            imagefilledellipse($this->img,$xc,$yc,2*$w,2*$h,$this->current_color);
+            imagefilledellipse($this->img,(int) ($xc),(int) ($yc),(int) (2*$w),(int) (2*$h),(int) ($this->current_color));
 
             // If antialiasing is used then we often don't have any color no the surrounding
             // arc. So, we need to check for this special case so we don't send an empty
@@ -1212,7 +1207,7 @@
                 $this->PopColor();
                 $this->PushColor($arccolor);
             }
-            imageellipse($this->img,$xc,$yc,2*$w,2*$h,$this->current_color);
+            imageellipse($this->img,(int) ($xc),(int) ($yc),(int) (2*$w),(int) (2*$h),(int) ($this->current_color));
             $this->Line($xc,$yc,cos($s*M_PI/180)*$w+$xc,$yc+sin($s*M_PI/180)*$h);
             $this->PopColor();
         }
@@ -1224,7 +1219,7 @@
                 $this->PushColor($arccolor);
                 // We add 2 pixels to make the Arc() better aligned with
                 // the filled arc.
-                imagefilledarc($this->img,$xc,$yc,2*$w,2*$h,$s,$e,$this->current_color,IMG_ARC_NOFILL | IMG_ARC_EDGED ) ;
+                imagefilledarc($this->img,(int) ($xc),(int) ($yc),(int) (2*$w),(int) (2*$h),(int) ($s),(int) ($e),(int) ($this->current_color),(int) (IMG_ARC_NOFILL | IMG_ARC_EDGED) ) ;
                 $this->PopColor();
             }
         }
@@ -1235,13 +1230,13 @@
     }
 
     function Circle($xc,$yc,$r) {
-        imageellipse($this->img,round($xc),round($yc),$r*2,$r*2,$this->current_color);
+        imageellipse($this->img,(int) (round($xc)),(int) (round($yc)),(int) ($r*2),(int) ($r*2),(int) ($this->current_color));
 //        $this->DrawImageSmoothArc($this->img,round($xc),round($yc),$r*2+1,$r*2+1,0,360,$this->current_color);
 //        $this->imageSmoothCircle($this->img, round($xc),round($yc), $r*2+1, $this->current_color);
     }
 
     function FilledCircle($xc,$yc,$r) {
-        imagefilledellipse($this->img,round($xc),round($yc),2*$r,2*$r,$this->current_color);
+        imagefilledellipse($this->img,(int) (round($xc)),(int) (round($yc)),(int) (2*$r),(int) (2*$r),(int) ($this->current_color));
 //        $this->DrawImageSmoothArc($this->img, round($xc), round($yc), 2*$r, 2*$r, 0, 360, $this->current_color);
     }
 
@@ -1349,7 +1344,7 @@
         $style = array_fill(0,$dash_length,$this->current_color);
         $style = array_pad($style,$dash_space,IMG_COLOR_TRANSPARENT);
         imagesetstyle($this->img, $style);
-        imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
+        imageline($this->img, (int) ($x1), (int) ($y1), (int) ($x2), (int) ($y2), (int) (IMG_COLOR_STYLED));
 
         $this->lastx = $x2;
         $this->lasty = $y2;
@@ -1382,7 +1377,7 @@
         $style = array_fill(0,$dash_length, $this->current_color); //hexdec('CCCCCC'));
         $style = array_pad($style,$dash_space,IMG_COLOR_TRANSPARENT);
         imagesetstyle($this->img, $style);
-        imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
+        imageline($this->img, (int) ($x1), (int) ($y1), (int) ($x2), (int) ($y2), (int) (IMG_COLOR_STYLED));
 
         $this->lastx = $x2;
         $this->lasty = $y2;
@@ -1397,7 +1392,7 @@
         $y1 = round($y1);
         $y2 = round($y2);
 
-        imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color);
+        imageline($this->img,(int) ($x1),(int) ($y1),(int) ($x2),(int) ($y2),(int) ($this->current_color));
 //        $this->DrawLine($this->img, $x1, $y1, $x2, $y2, $this->line_weight, $this->current_color);
         $this->lastx=$x2;
         $this->lasty=$y2;
@@ -1407,17 +1402,17 @@
 
         if( $this->line_weight <= 0 ) return;
 
-        $n=count($p);
+        $n=count(($p ?? []));
         $oldx = $p[0];
         $oldy = $p[1];
         if( $fast ) {
             for( $i=2; $i < $n; $i+=2 ) {
-                imageline($this->img,$oldx,$oldy,$p[$i],$p[$i+1],$this->current_color);
+                imageline($this->img,(int) ($oldx),(int) ($oldy),(int) ($p[$i]),(int) ($p[$i+1]),(int) ($this->current_color));
                 $oldx = $p[$i];
                 $oldy = $p[$i+1];
             }
             if( $closed ) {
-                imageline($this->img,$p[$n*2-2],$p[$n*2-1],$p[0],$p[1],$this->current_color);
+                imageline($this->img,(int) ($p[$n*2-2]),(int) ($p[$n*2-1]),(int) ($p[0]),(int) ($p[1]),(int) ($this->current_color));
             }
         }
         else {
@@ -1433,7 +1428,7 @@
     }
 
     function FilledPolygon($pts) {
-        $n=count($pts);
+        $n=count(($pts ?? []));
         if( $n == 0 ) {
             JpGraphError::RaiseL(25105);//('NULL data specified for a filled polygon. Check that your data is not NULL.');
         }
@@ -1442,9 +1437,9 @@
         }
         $old = $this->line_weight;
         imagesetthickness($this->img,1);
-        imagefilledpolygon($this->img,$pts,count($pts)/2,$this->current_color);
+        imagefilledpolygon($this->img, $pts, (int) ($this->current_color));
         $this->line_weight = $old;
-        imagesetthickness($this->img,$old);
+        imagesetthickness($this->img,(int) ($old));
     }
 
     function Rectangle($xl,$yu,$xr,$yl) {
@@ -1607,11 +1602,11 @@
     }
 
     function Point($x,$y) {
-        imagesetpixel($this->img,round($x),round($y),$this->current_color);
+        imagesetpixel($this->img,(int) (round($x)),(int) (round($y)),(int) ($this->current_color));
     }
 
     function Fill($x,$y) {
-        imagefill($this->img,round($x),round($y),$this->current_color);
+        imagefill($this->img,(int) (round($x)),(int) (round($y)),(int) ($this->current_color));
     }
 
     function FillToBorder($x,$y,$aBordColor) {
@@ -1619,7 +1614,7 @@
         if( $bc == -1 ) {
             JpGraphError::RaiseL(25106);//('Image::FillToBorder : Can not allocate more colors');
         }
-        imagefilltoborder($this->img,round($x),round($y),$bc,$this->current_color);
+        imagefilltoborder($this->img,(int) (round($x)),(int) (round($y)),(int) ($bc),(int) ($this->current_color));
     }
 
     function SetExpired($aFlg=true) {
@@ -1699,8 +1694,8 @@
             return $this->img;
         }
 
-        $dst_img = @imagecreatetruecolor($this->original_width, $this->original_height);
-        imagecopyresampled($dst_img, $this->img, 0, 0, 0, 0, $this->original_width, $this->original_height, $this->width, $this->height);
+        $dst_img = @imagecreatetruecolor((int) ($this->original_width), (int) ($this->original_height));
+        imagecopyresampled($dst_img, $this->img, 0, 0, 0, 0, (int) ($this->original_width), (int) ($this->original_height), (int) ($this->width), (int) ($this->height));
         $this->Destroy();
         return $this->img = $dst_img;
     }
@@ -1715,7 +1710,7 @@
     // of PHP not all formats may be supported.
     function SetImgFormat($aFormat,$aQuality=75) {
         $this->quality = $aQuality;
-        $aFormat = strtolower($aFormat);
+        $aFormat = strtolower(($aFormat ?? ''));
         $tst = true;
         $supported = imagetypes();
         if( $aFormat=="auto" ) {
@@ -1755,7 +1750,7 @@
     */
     function DrawLine($im, $x1, $y1, $x2, $y2, $weight, $color) {
         if ($weight == 1) {
-            return imageline($im,$x1,$y1,$x2,$y2,$color);
+            return imageline($im,(int) ($x1),(int) ($y1),(int) ($x2),(int) ($y2),(int) ($color));
         }
 
         $angle=(atan2(($y1 - $y2), ($x2 - $x1))); 
@@ -1773,19 +1768,19 @@
         $p4y=ceil(($y1 - $dist_y));
 
         $array=array($p1x,$p1y,$p2x,$p2y,$p3x,$p3y,$p4x,$p4y);
-        imagefilledpolygon ( $im, $array, (count($array)/2), $color );
+        imagefilledpolygon($im, $array, (int) ($color));
 
         // for antialias
-        imageline($im, $p1x, $p1y, $p2x, $p2y, $color);
-        imageline($im, $p3x, $p3y, $p4x, $p4y, $color);
+        imageline($im, (int) ($p1x), (int) ($p1y), (int) ($p2x), (int) ($p2y), (int) ($color));
+        imageline($im, (int) ($p3x), (int) ($p3y), (int) ($p4x), (int) ($p4y), (int) ($color));
         return;
 
 
 
-          return imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color);
+          return imageline($this->img,(int) ($x1),(int) ($y1),(int) ($x2),(int) ($y2),(int) ($this->current_color));
       $weight = 8;
         if ($weight <= 1) {
-          return imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color);
+          return imageline($this->img,(int) ($x1),(int) ($y1),(int) ($x2),(int) ($y2),(int) ($this->current_color));
         }
 
         $pts = array();
@@ -1829,12 +1824,12 @@
         }
 
 //print_r($pts);exit;
-        if (count($pts)/2 < 3) {
+        if (count(($pts ?? []))/2 < 3) {
             return;
         } 
 
         imagesetthickness($im, 1);
-        imagefilledpolygon($im, $pts,count($pts)/2, $color);
+        imagefilledpolygon($im, $pts, (int) ($color));
 
 
         $weight *= 2;
@@ -1869,16 +1864,16 @@
         $ig = 2 * $ir - 3;
         $idgr = -6;
         $idgd = 4 * $ir - 10;
-        $fill = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 0 );
-        imageLine( $img, $cx + $cr - 1, $cy, $cx, $cy, $fill );
-        imageLine( $img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill );
-        imageLine( $img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill );
-        imageLine( $img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill );
-        $draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 42 );
-        imageSetPixel( $img, $cx + $cr, $cy, $draw );
-        imageSetPixel( $img, $cx - $cr, $cy, $draw );
-        imageSetPixel( $img, $cx, $cy + $cr, $draw );
-        imageSetPixel( $img, $cx, $cy - $cr, $draw );
+        $fill = imageColorExactAlpha( $img, (int) ($color[ 'R' ]), (int) ($color[ 'G' ]), (int) ($color[ 'B' ]), 0 );
+        imageLine( $img, (int) ($cx + $cr - 1), (int) ($cy), (int) ($cx), (int) ($cy), (int) ($fill) );
+        imageLine( $img, (int) ($cx - $cr + 1), (int) ($cy), (int) ($cx - 1), (int) ($cy), (int) ($fill) );
+        imageLine( $img, (int) ($cx), (int) ($cy + $cr - 1), (int) ($cx), (int) ($cy + 1), (int) ($fill) );
+        imageLine( $img, (int) ($cx), (int) ($cy - $cr + 1), (int) ($cx), (int) ($cy - 1), (int) ($fill) );
+        $draw = imageColorExactAlpha( $img, (int) ($color[ 'R' ]), (int) ($color[ 'G' ]), (int) ($color[ 'B' ]), 42 );
+        imageSetPixel( $img, (int) ($cx + $cr), (int) ($cy), (int) ($draw) );
+        imageSetPixel( $img, (int) ($cx - $cr), (int) ($cy), (int) ($draw) );
+        imageSetPixel( $img, (int) ($cx), (int) ($cy + $cr), (int) ($draw) );
+        imageSetPixel( $img, (int) ($cx), (int) ($cy - $cr), (int) ($draw) );
         while ( $ix <= $iy - 2 ) {
             if ( $ig < 0 ) {
                 $ig += $idgd;
@@ -1890,37 +1885,37 @@
             }
             $idgr -= 4;
             $ix++;
-            imageLine( $img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill );
-            imageLine( $img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill );
-            imageLine( $img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill );
-            imageLine( $img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill );
-            imageLine( $img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill );
-            imageLine( $img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill );
-            imageLine( $img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill );
-            imageLine( $img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill );
+            imageLine( $img, (int) ($cx + $ix), (int) ($cy + $iy - 1), (int) ($cx + $ix), (int) ($cy + $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx + $ix), (int) ($cy - $iy + 1), (int) ($cx + $ix), (int) ($cy - $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx - $ix), (int) ($cy + $iy - 1), (int) ($cx - $ix), (int) ($cy + $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx - $ix), (int) ($cy - $iy + 1), (int) ($cx - $ix), (int) ($cy - $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx + $iy - 1), (int) ($cy + $ix), (int) ($cx + $ix), (int) ($cy + $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx + $iy - 1), (int) ($cy - $ix), (int) ($cx + $ix), (int) ($cy - $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx - $iy + 1), (int) ($cy + $ix), (int) ($cx - $ix), (int) ($cy + $ix), (int) ($fill) );
+            imageLine( $img, (int) ($cx - $iy + 1), (int) ($cy - $ix), (int) ($cx - $ix), (int) ($cy - $ix), (int) ($fill) );
             $filled = 0;
             for ( $xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2 ) {
                 for ( $yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2 ) {
                     if ( sqrt( pow( $xx, 2 ) + pow( $yy, 2 ) ) < $cr ) $filled += 4;
                 }
             }
-            $draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], ( 100 - $filled ) );
-            imageSetPixel( $img, $cx + $ix, $cy + $iy, $draw );
-            imageSetPixel( $img, $cx + $ix, $cy - $iy, $draw );
-            imageSetPixel( $img, $cx - $ix, $cy + $iy, $draw );
-            imageSetPixel( $img, $cx - $ix, $cy - $iy, $draw );
-            imageSetPixel( $img, $cx + $iy, $cy + $ix, $draw );
-            imageSetPixel( $img, $cx + $iy, $cy - $ix, $draw );
-            imageSetPixel( $img, $cx - $iy, $cy + $ix, $draw );
-            imageSetPixel( $img, $cx - $iy, $cy - $ix, $draw );
+            $draw = imageColorExactAlpha( $img, (int) ($color[ 'R' ]), (int) ($color[ 'G' ]), (int) ($color[ 'B' ]), ( (int) (100 - $filled) ) );
+            imageSetPixel( $img, (int) ($cx + $ix), (int) ($cy + $iy), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx + $ix), (int) ($cy - $iy), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx - $ix), (int) ($cy + $iy), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx - $ix), (int) ($cy - $iy), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx + $iy), (int) ($cy + $ix), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx + $iy), (int) ($cy - $ix), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx - $iy), (int) ($cy + $ix), (int) ($draw) );
+            imageSetPixel( $img, (int) ($cx - $iy), (int) ($cy - $ix), (int) ($draw) );
         }
     }
 
     function __get($name) {
 
-        if (strpos($name, 'raw_') !== false) {
+        if (strpos(($name ?? ''), 'raw_') !== false) {
             // if $name == 'raw_left_margin' , return $this->_left_margin;
-            $variable_name = '_' . str_replace('raw_', '', $name);
+            $variable_name = '_' . str_replace('raw_', '', ($name ?? ''));
             return $this->$variable_name;
         }
 
@@ -2043,7 +2038,7 @@
     }
 
     function ArrRotate($pnts) {
-        $n = count($pnts)-1;
+        $n = count(($pnts ?? []))-1;
         for($i=0; $i < $n; $i+=2) {
             list ($x,$y) = $this->Rotate($pnts[$i],$pnts[$i+1]);
             $pnts[$i] = $x; $pnts[$i+1] = $y;
--- a/intranet/jpgraph/src/jpgraph_pie.php
+++ b/intranet/jpgraph/src/jpgraph_pie.php
@@ -270,17 +270,17 @@
         $colors = array_keys($graph->img->rgb->rgb_table);
         sort($colors);
         $ta=$this->themearr[$this->theme];
-        $n = count($this->data);
+        $n = count(($this->data ?? []));
 
         if( $this->setslicecolors==null ) {
-            $numcolors=count($ta);
+            $numcolors=count(($ta ?? []));
             if( class_exists('PiePlot3D',false) && ($this instanceof PiePlot3D) ) {
                 $ta = array_reverse(array_slice($ta,0,$n));
             }
         }
         else {
             $this->setslicecolors = array_slice($this->setslicecolors,0,$n);
-            $numcolors=count($this->setslicecolors);
+            $numcolors=count(($this->setslicecolors ?? []));
             if( $graph->pieaa && !($this instanceof PiePlot3D) ) {
                 $this->setslicecolors = array_reverse($this->setslicecolors);
             }
@@ -296,14 +296,14 @@
 
         // Make sure we don't plot more values than data points
         // (in case the user added more legends than data points)
-        $n = min(count($this->legends),count($this->data));
+        $n = min(count(($this->legends ?? [])),count(($this->data ?? [])));
         if( $this->legends != "" ) {
             $this->legends = array_reverse(array_slice($this->legends,0,$n));
         }
         for( $i=$n-1; $i >= 0; --$i ) {
             $l = $this->legends[$i];
             // Replace possible format with actual values
-            if( count($this->csimalts) > $i ) {
+            if( count(($this->csimalts ?? [])) > $i ) {
                 $fmt = $this->csimalts[$i];
             }
             else {
@@ -355,7 +355,7 @@
         $tmp = array();
         $result = array();
         $quote_sum=0;
-        $n = count($aData) ;
+        $n = count(($aData ?? [])) ;
         for( $i=0, $sum=0; $i < $n; ++$i )
         $sum+=$aData[$i];
         foreach($aData as $index => $value) {
@@ -412,15 +412,15 @@
         $colors = array_keys($img->rgb->rgb_table);
         sort($colors);
         $ta=$this->themearr[$this->theme];
-        $n = count($this->data);
+        $n = count(($this->data ?? []));
 
         if( $this->setslicecolors==null ) {
-            $numcolors=count($ta);
+            $numcolors=count(($ta ?? []));
         }
         else {
             // We need to create an array of colors as long as the data
             // since we need to reverse it to get the colors in the right order
-            $numcolors=count($this->setslicecolors);
+            $numcolors=count(($this->setslicecolors ?? []));
             $i = 2*$numcolors;
             while( $n > $i ) {
                 $this->setslicecolors = array_merge($this->setslicecolors,$this->setslicecolors);
@@ -463,7 +463,7 @@
             $yc = $this->posy ;
         }
 
-        $n = count($this->data);
+        $n = count(($this->data ?? []));
 
         if( $this->explode_all ) {
             for($i=0; $i < $n; ++$i) {
@@ -674,7 +674,7 @@
     }
 
     function StrokeGuideLabels($img,$xc,$yc,$radius) {
-        $n = count($this->labels);
+        $n = count(($this->labels ?? []));
 
         //-----------------------------------------------------------------------
         // Step 1 of the algorithm is to construct a number of clusters
@@ -813,7 +813,7 @@
         $this->value->SetMargin(0);
 
         // Number of clusters found
-        $nc = count($clusters);
+        $nc = count(($clusters ?? []));
 
         // Walk through all the clusters
         for($i=0; $i < $nc; ++$i) {
@@ -942,7 +942,7 @@
 
     function StrokeAllLabels($img,$xc,$yc,$radius) {
         // First normalize all angles for labels
-        $n = count($this->la);
+        $n = count(($this->la ?? []));
         for($i=0; $i < $n; ++$i) {
             $this->la[$i] = $this->NormAngle($this->la[$i]);
         }
@@ -950,7 +950,7 @@
             $this->StrokeGuideLabels($img,$xc,$yc,$radius);
         }
         else {
-            $n = count($this->labels);
+            $n = count(($this->labels ?? []));
             for($i=0; $i < $n; ++$i) {
                 $this->StrokeLabel($this->labels[$i],$img,$xc,$yc,
                 $this->la[$i],
@@ -1258,7 +1258,7 @@
     // PUBLIC METHODS
     function Add($aObj) {
 
-        if( is_array($aObj) && count($aObj) > 0 )
+        if( is_array($aObj) && count(($aObj ?? [])) > 0 )
         $cl = $aObj[0];
         else
         $cl = $aObj;
@@ -1269,7 +1269,7 @@
         $this->AddIcon($aObj);
         else {
             if( is_array($aObj) ) {
-                $n = count($aObj);
+                $n = count(($aObj ?? []));
                 for($i=0; $i < $n; ++$i ) {
                     //if ($aObj[$i]->theme) {
                     //    $this->ClearTheme();
@@ -1309,19 +1309,19 @@
         }
         
         $csim.= $this->legend->GetCSIMareas();
-        if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", $csim, $coords)) {
+        if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", ($csim ?? ''), $coords)) {
             $this->img->SetColor($this->csimcolor);
-            $n = count($coords[0]);
+            $n = count(($coords[0] ?? []));
             for ($i=0; $i < $n; $i++) {
                 if ($coords[1][$i]=="poly") {
-                    preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',$coords[2][$i],$pts);
-                    $this->img->SetStartPoint($pts[1][count($pts[0])-1],$pts[2][count($pts[0])-1]);
-                    $m = count($pts[0]);
+                    preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',($coords[2][$i] ?? ''),$pts);
+                    $this->img->SetStartPoint($pts[1][count(($pts[0] ?? []))-1],$pts[2][count(($pts[0] ?? []))-1]);
+                    $m = count(($pts[0] ?? []));
                     for ($j=0; $j < $m; $j++) {
                         $this->img->LineTo($pts[1][$j],$pts[2][$j]);
                     }
                 } else if ($coords[1][$i]=="rect") {
-                    $pts = preg_split('/,/', $coords[2][$i]);
+                    $pts = preg_split('/,/', ($coords[2][$i] ?? ''));
                     $this->img->SetStartPoint($pts[0],$pts[1]);
                     $this->img->LineTo($pts[2],$pts[1]);
                     $this->img->LineTo($pts[2],$pts[3]);
@@ -1357,7 +1357,7 @@
         // CSIM without storing an image to disk GetCSIM must call Stroke.
         $this->iHasStroked = true;
 
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
 
         if( $this->pieaa ) {
 
@@ -1383,7 +1383,7 @@
 
             // Make all icons *2 i size since we will be scaling down the
             // imahe to do the anti aliasing
-            $ni = count($this->iIcons);
+            $ni = count(($this->iIcons ?? []));
             for($i=0; $i < $ni; ++$i) {
                 $this->iIcons[$i]->iScale *= 2 ;
                 if( $this->iIcons[$i]->iX > 1 )
@@ -1451,7 +1451,7 @@
 
             // Stroke texts
             if( $this->texts != null ) {
-                $n = count($this->texts);
+                $n = count(($this->texts ?? []));
                 for($i=0; $i < $n; ++$i ) {
                     $this->texts[$i]->Stroke($this->img);
                 }
--- a/intranet/jpgraph/src/jpgraph_plotmark.inc.php
+++ b/intranet/jpgraph/src/jpgraph_plotmark.inc.php
@@ -125,13 +125,13 @@
 
     function AddCSIMPoly($aPts) {
         $coords = round($aPts[0]).", ".round($aPts[1]);
-        $n = count($aPts)/2;
+        $n = count(($aPts ?? []))/2;
         for( $i=1; $i < $n; ++$i){
             $coords .= ", ".round($aPts[2*$i]).", ".round($aPts[2*$i+1]);
         }
         $this->csimareas="";
         if( !empty($this->csimtarget) ) {
-            $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->csimtarget)."\"";
+            $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities(($this->csimtarget ?? ''))."\"";
 
             if( !empty($this->csimwintarget) ) {
                 $this->csimareas .= " target=\"".$this->csimwintarget."\" ";
@@ -149,7 +149,7 @@
         $x = round($x); $y=round($y); $r=round($r);
         $this->csimareas="";
         if( !empty($this->csimtarget) ) {
-            $this->csimareas .= "<area shape=\"circle\" coords=\"$x,$y,$r\" href=\"".htmlentities($this->csimtarget)."\"";
+            $this->csimareas .= "<area shape=\"circle\" coords=\"$x,$y,$r\" href=\"".htmlentities(($this->csimtarget ?? ''))."\"";
 
             if( !empty($this->csimwintarget) ) {
                 $this->csimareas .= " target=\"".$this->csimwintarget."\" ";
@@ -298,7 +298,7 @@
             if( !empty($this->csimtarget) ) {
                 $this->csimareas = "<area shape=\"rect\" coords=\"".
                 $dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '.
-      "href=\"".htmlentities($this->csimtarget)."\"";
+      "href=\"".htmlentities(($this->csimtarget ?? ''))."\"";
 
                 if( !empty($this->csimwintarget) ) {
                     $this->csimareas .= " target=\"".$this->csimwintarget."\" ";
@@ -470,7 +470,7 @@
         }
         else
         $idx = $aIdx ;
-        return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
+        return Image::CreateFromString(base64_decode(($this->{$n}[$idx][1] ?? '')));
     }
     
     function GetAnchor() {
--- a/intranet/jpgraph/src/jpgraph_rgb.inc.php
+++ b/intranet/jpgraph/src/jpgraph_rgb.inc.php
@@ -491,13 +491,13 @@
             // 8: adjust value prefixed with : if supplied
             // 9: adjust value with : stripped
             $regex = '/(#([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2}))?([\w]+)?(@([\d\.,]+))?(:([\d\.,]+))?/';
-            if(!preg_match($regex, $aColor, $matches)) {
+            if(!preg_match(($regex ?? ''), ($aColor ?? ''), $matches)) {
                 JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor");
             }
             if(empty($matches[5])) {
-                $r = strlen($matches[2]) == 1 ? $matches[2].$matches[2] : $matches[2];
-                $g = strlen($matches[3]) == 1 ? $matches[3].$matches[3] : $matches[3];
-                $b = strlen($matches[4]) == 1 ? $matches[4].$matches[4] : $matches[4];
+                $r = strlen(($matches[2] ?? '')) == 1 ? $matches[2].$matches[2] : $matches[2];
+                $g = strlen(($matches[3] ?? '')) == 1 ? $matches[3].$matches[3] : $matches[3];
+                $b = strlen(($matches[4] ?? '')) == 1 ? $matches[4].$matches[4] : $matches[4];
                 $r = hexdec($r);
                 $g = hexdec($g);
                 $b = hexdec($b);
@@ -509,8 +509,8 @@
                 $g = $this->rgb_table[$matches[5]][1];
                 $b = $this->rgb_table[$matches[5]][2];
             }
-            $alpha	= isset($matches[7]) ? str_replace(',','.',$matches[7]) : 0;
-            $adj	= isset($matches[9]) ? str_replace(',','.',$matches[9]) : 1.0;
+            $alpha	= isset($matches[7]) ? str_replace(',','.',($matches[7] ?? '')) : 0;
+            $adj	= isset($matches[9]) ? str_replace(',','.',($matches[9] ?? '')) : 1.0;
 
             if( $adj < 0 ) {
                 JpGraphError::RaiseL(25077);//('Adjustment factor for color must be > 0');
@@ -535,7 +535,7 @@
             return $aColor;
         }
         else {
-            JpGraphError::RaiseL(25079,$aColor,count($aColor));//(" Unknown color specification: $aColor , size=".count($aColor));
+            JpGraphError::RaiseL(25079,$aColor,count(($aColor ?? [])));//(" Unknown color specification: $aColor , size=".count($aColor));
         }
     }
 
@@ -559,7 +559,7 @@
         if( $aAlpha < 0 || $aAlpha > 1 ) {
             JpGraphError::RaiseL(25080);//('Alpha parameter for color must be between 0.0 and 1.0');
         }
-        return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
+        return imagecolorresolvealpha($this->img, (int) ($r), (int) ($g), (int) ($b), (int) (round($aAlpha * 127)));
     }
 
     // Try to convert an array with three valid numbers to the corresponding hex array
@@ -569,7 +569,7 @@
     // a single color (specifeid as an RGB triple)
     static function tryHexConversion($aColor) {
         if( is_array( $aColor ) ) {
-            if( count( $aColor ) == 3 ) {
+            if( count( ($aColor ?? []) ) == 3 ) {
                 if( is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2]) ) {
                     if( ($aColor[0] >= 0 && $aColor[0] <= 255) &&
                         ($aColor[1] >= 0 && $aColor[1] <= 255) &&
--- a/intranet/jpgraph/src/jpgraph_date.php
+++ b/intranet/jpgraph/src/jpgraph_date.php
@@ -300,7 +300,7 @@
         array(1,SECADJ_1)),
         );
 
-        $ns = count($scalePoints);
+        $ns = count(($scalePoints ?? []));
         // Establish major and minor scale units for the date scale
         $diff = $aEndTime - $aStartTime;
         if( $diff < 1 ) return false;
@@ -310,12 +310,12 @@
             if( $diff > $scalePoints[2*$i] ) {
                 // Get major and minor scale for this intervall
                 $scaleSteps = $scalePoints[2*$i+1];
-                $major = $scaleSteps[0][min($aDensity,count($scaleSteps[0])-1)];
+                $major = $scaleSteps[0][min($aDensity,count(($scaleSteps[0] ?? []))-1)];
                 // Try to find out which minor step looks best
-                $minor = $scaleSteps[1][min($aDensity,count($scaleSteps[1])-1)];
+                $minor = $scaleSteps[1][min($aDensity,count(($scaleSteps[1] ?? []))-1)];
                 if( $aAdjust ) {
                     // Find out how we should align the start and end timestamps
-                    $idx = 2*min($aDensity,floor(count($scaleSteps[2])/2)-1);
+                    $idx = 2*min($aDensity,floor(count(($scaleSteps[2] ?? []))/2)-1);
                     if( $scaleSteps[2][$idx] === 0 ) {
                         // Use date adjustment
                         $adj = $scaleSteps[2][$idx+1];
--- a/intranet/jpgraph/src/jpgraph_windrose.php
+++ b/intranet/jpgraph/src/jpgraph_windrose.php
@@ -45,6 +45,10 @@
 // CLASS WindrosePlotScale
 //===================================================
 class WindrosePlotScale {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $iZeroSum;
+    public $iMaxVal;
+
     private $iMax,$iDelta=5;
     private $iNumCirc=3;
     public $iMaxNum=0;
@@ -66,7 +70,7 @@
         $this->iZeroSum=0;
         foreach( $aData as $idx => $legdata ) {
             $legsum = array_sum($legdata);
-            $maxnum = max($maxnum,count($legdata)-1);
+            $maxnum = max($maxnum,count(($legdata ?? []))-1);
             $max = max($legsum-$legdata[0],$max);
             $totlegsum += $legsum;
             $this->iZeroSum += $legdata[0] ;
@@ -383,6 +387,9 @@
 // CLASS WindrosePlot
 //===================================================
 class WindrosePlot {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $scale;
+
     private $iAntiAlias=true;
     private $iData=array();
     public $iX=0.5,$iY=0.5;
@@ -477,7 +484,7 @@
     }
 
     function SetCompassLabels($aLabels) {
-        if( count($aLabels) != 16 ) {
+        if( count(($aLabels ?? [])) != 16 ) {
             JpgraphError::RaiseL(22004); //('Label specification for windrose directions must have 16 values (one for each compass direction).');
         }
         $this->iAllDirectionLabels = $aLabels ;
@@ -518,7 +525,7 @@
     }
 
     function SetRadialGridStyle($aStyle) {
-        $aStyle = strtolower($aStyle);
+        $aStyle = strtolower(($aStyle ?? ''));
         if( !in_array($aStyle,array('solid','dotted','dashed','longdashed')) ) {
             JpGraphError::RaiseL(22005); //("Line style for radial lines must be on of ('solid','dotted','dashed','longdashed') ");
         }
@@ -538,7 +545,7 @@
     }
 
     function SetRangeWeights($aWeights) {
-        $n=count($aWeights);
+        $n=count(($aWeights ?? []));
         for($i=0; $i< $n; ++$i ) {
             $aWeights[$i] = floor($aWeights[$i]/2);
         }
@@ -570,7 +577,7 @@
         $this->iCircGridWeight = 1;
     }
 
-    function _ThickCircle($aImg,$aXC,$aYC,$aRad,$aWeight=2,$aColor) {
+    function _ThickCircle($aImg,$aXC,$aYC,$aRad,$aWeight,$aColor) {
 
         $aImg->SetColor($aColor);
         $aRad *= 2 ;
@@ -617,8 +624,8 @@
 
         if( ! $this->legend->iShow ) return 0;
 
-        $nlc = count($this->iLegColors);
-        $nlw = count($this->iLegweights);
+        $nlc = count(($this->iLegColors ?? []));
+        $nlw = count(($this->iLegweights ?? []));
 
         // Setup font for ranges
         $value = new Text();
@@ -675,7 +682,7 @@
         // Stroke all used ranges
         $txty = $y -
         round($this->iLegweights[($this->scale->iMaxNum-1)%$nlw]*$scaling) - 4*$scaling;
-        if( $this->scale->iMaxNum >= count($this->iRanges) ) {
+        if( $this->scale->iMaxNum >= count(($this->iRanges ?? [])) ) {
             JpGraphError::RaiseL(22007); //('To few values for the range legend.');
         }
         $i=0;$idx=0;
@@ -740,8 +747,8 @@
                 if( !empty($this->iData[$dtxt]) ) {
                     $data[$i] = $this->iData[$dtxt];
                 }
-                elseif( !empty($this->iData[strtolower($dtxt)]) ) {
-                    $data[$i] = $this->iData[strtolower($dtxt)];
+                elseif( !empty($this->iData[strtolower(($dtxt ?? ''))]) ) {
+                    $data[$i] = $this->iData[strtolower(($dtxt ?? ''))];
                 }
                 elseif( !empty($this->iData[$i]) ) {
                     $data[$i] = $this->iData[$i];
@@ -772,10 +779,10 @@
             $this->scale->iAngle = $found*22.5;
         }
         else {
-            $n = count($this->iData);
+            $n = count(($this->iData ?? []));
             foreach( $this->iData as $dir => $leg ) {
                 if( !is_numeric($dir) ) {
-                    $pos = array_search(strtoupper($dir),$this->iAllDirectionLabels);
+                    $pos = array_search(strtoupper(($dir ?? '')),$this->iAllDirectionLabels);
                     if( $pos !== false ) {
                         $dir = $pos*22.5;
                     }
@@ -787,7 +794,7 @@
             $keys = array_keys($data);
             sort($keys, SORT_NUMERIC);
 
-            $n = count($data);
+            $n = count(($data ?? []));
             $found = false;
             $max = 0 ;
             for( $i=0; $i < 15; ++$i ) {
@@ -875,19 +882,19 @@
         // (or none) data.
         $this->SetAutoScaleAngle(false);
 
-        $nlc = count($this->iLegColors);
-        $nlw = count($this->iLegweights);
+        $nlc = count(($this->iLegColors ?? []));
+        $nlw = count(($this->iLegweights ?? []));
 
         // Stroke grid lines for directions and remember the
         // position for the labels
         $txtpos=array();
-        $num = count($this->iData);
+        $num = count(($this->iData ?? []));
 
         $keys = array_keys($this->iData);
 
         foreach( $this->iData as $dir => $legdata ) {
             if( in_array($dir,$this->iAllDirectionLabels,true) === true) {
-                $a = $this->iStandardDirections[strtoupper($dir)];
+                $a = $this->iStandardDirections[strtoupper(($dir ?? ''))];
                 if( in_array($a*180/M_PI,$keys) ) {
                     JpGraphError::RaiseL(22009,round($a*180/M_PI));
                     //('You have specified the same direction twice, once with an angle and once with a compass direction ('.$a*180/M_PI.' degrees.)');
@@ -1000,7 +1007,7 @@
         $i=0;
         foreach($this->iData as $dir => $legdata) {
             $legdata = array_slice($legdata,1);
-            $nn = count($legdata);
+            $nn = count(($legdata ?? []));
 
             $a = $txtpos[$i][2];
             $rri = $ri/$scaling;
@@ -1025,7 +1032,7 @@
         $keys = array_keys($aDataArray);
         foreach($aDataArray as $idx => $data) {
             if( is_string($idx) ) {
-                $idx = strtoupper($idx);
+                $idx = strtoupper(($idx ?? ''));
                 $res = array_search($idx,$this->iAllDirectionLabels);
                 if( $res === false ) {
                     JpGraphError::RaiseL(22011,$idx); //('Windrose index must be numeric or direction label. You have specified index='.$idx);
@@ -1068,8 +1075,8 @@
         // (or none) data.
         $this->SetAutoScaleAngle(true);
 
-        $nlc = count($this->iLegColors);
-        $nlw = count($this->iLegweights);
+        $nlc = count(($this->iLegColors ?? []));
+        $nlw = count(($this->iLegweights ?? []));
 
         $this->iRadialColorArray = $this->FixupIndexes($this->iRadialColorArray,$num);
         $this->iRadialWeightArray = $this->FixupIndexes($this->iRadialWeightArray,$num);
@@ -1162,9 +1169,9 @@
         $keys = array_keys($this->iData);
         foreach($this->iData as $idx => $legdata) {
             $legdata = array_slice($legdata,1);
-            $nn = count($legdata);
+            $nn = count(($legdata ?? []));
             if( is_string($idx) ) {
-                $idx = strtoupper($idx);
+                $idx = strtoupper(($idx ?? ''));
                 $idx = array_search($idx,$this->iAllDirectionLabels);
                 if( $idx === false ) {
                     JpGraphError::RaiseL(22016);//('Windrose leg index must be numeric or direction label.');
@@ -1215,7 +1222,7 @@
         // The code below gives a possible a little to large margin. The
         // really, really proper way would be to account for what angle
         // the label are at
-        $n = count($this->iLabels);
+        $n = count(($this->iLabels ?? []));
         if( $n > 0 ) {
             $maxh=0;$maxw=0;
             foreach($this->iLabels as $key => $lbl) {
@@ -1255,7 +1262,7 @@
         // The code below gives a possible a little to large margin. The
         // really, really proper way would be to account for what angle
         // the label are at
-        $n = count($this->iLabels);
+        $n = count(($this->iLabels ?? []));
         if( $n > 0 ) {
             $maxh=0;$maxw=0;
             foreach($this->iLabels as $key => $lbl) {
@@ -1400,7 +1407,7 @@
                     $const1 = 4; $const2 = 4;
                 }
                 $tmp = array();
-                $n=count($this->iData);
+                $n=count(($this->iData ?? []));
                 foreach( $this->iData as $key => $val ) {
                     if( is_numeric($key) ) {
                         $key = ($const1 - $key) % $const2 ;
@@ -1463,7 +1470,7 @@
 
     function StrokeTexts() {
         if( $this->texts != null ) {
-            $n = count($this->texts);
+            $n = count(($this->texts ?? []));
             for($i=0; $i < $n; ++$i ) {
                 $this->texts[$i]->Stroke($this->img);
             }
@@ -1472,7 +1479,7 @@
 
     function StrokeIcons() {
         if( $this->iIcons != null ) {
-            $n = count($this->iIcons);
+            $n = count(($this->iIcons ?? []));
             for( $i=0; $i < $n; ++$i ) {
                 // Since Windrose graphs doesn't have any linear scale the position of
                 // each icon has to be given as absolute coordinates
@@ -1484,7 +1491,7 @@
     //---------------
     // PUBLIC METHODS
     function Add($aObj) {
-        if( is_array($aObj) && count($aObj) > 0 ) {
+        if( is_array($aObj) && count(($aObj ?? [])) > 0 ) {
             $cl = $aObj[0];
         }
         else {
@@ -1538,7 +1545,7 @@
         }
 
         // n holds number of plots
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n ; ++$i) {
      		$this->plots[$i]->Stroke($this);
         }
--- a/intranet/jpgraph/src/jpgraph_pie3d.php
+++ b/intranet/jpgraph/src/jpgraph_pie3d.php
@@ -37,7 +37,7 @@
 
     // Set label arrays
     function SetLegends($aLegend) {
-        $this->legends = array_reverse(array_slice($aLegend,0,count($this->data)));
+        $this->legends = array_reverse(array_slice($aLegend,0,count(($this->data ?? []))));
     }
 
     function SetSliceColors($aColors) {
@@ -440,7 +440,7 @@
         // indication of the inclination angle
         $h = ($angle/90.0)*$d;
         $sum = 0;
-        for($i=0; $i<count($data); ++$i ) {
+        for($i=0; $i<count(($data ?? [])); ++$i ) {
             $sum += $data[$i];
         }
 
@@ -461,8 +461,8 @@
         //
         $idx=0;
         $adjexplode=array();
-        $numcolors = count($colors);
-        for($i=0; $i<count($data); ++$i, ++$idx ) {
+        $numcolors = count(($colors ?? []));
+        for($i=0; $i<count(($data ?? [])); ++$i, ++$idx ) {
             $da = $data[$i]/$sum * 360;
 
             if( empty($this->explode_radius[$i]) ) {
@@ -556,7 +556,7 @@
         }
 
         // Total number of slices
-        $n = count($angles);
+        $n = count(($angles ?? []));
 
         for($i=0; $i<$n; ++$i) {
             list($dbgs,$dbge) = $angles[$i];
@@ -650,7 +650,7 @@
             // Now print possible labels and add csim
             $this->value->ApplyFont($img);
             $margin = $img->GetFontHeight()/2 + $this->value->margin ;
-            for($i=0; $i < count($data); ++$i ) {
+            for($i=0; $i < count(($data ?? [])); ++$i ) {
                 $la = $labeldata[$i][0];
                 $x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin)*$this->ilabelposadj;
                 $y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin)*$this->ilabelposadj;
@@ -695,7 +695,7 @@
         $img->SetLineWeight($edgeweight);
 
         $fulledge = true;
-        for($i=0; $i < count($data) && $fulledge; ++$i ) {
+        for($i=0; $i < count(($data ?? [])) && $fulledge; ++$i ) {
             if( empty($this->explode_radius[$i]) ) {
                 $this->explode_radius[$i]=0;
             }
@@ -705,7 +705,7 @@
         }
          
 
-        for($i=0; $i < count($data); ++$i, ++$idx ) {
+        for($i=0; $i < count(($data ?? [])); ++$i, ++$idx ) {
 
             $da = $data[$i]/$sum * 2*M_PI;
             $this->StrokeFullSliceFrame($img,$xc,$yc,$a,$a+$da,$d,$h,$z,$edgecolor,
@@ -776,7 +776,7 @@
     }
 
     function Stroke($img,$aaoption=0) {
-        $n = count($this->data);
+        $n = count(($this->data ?? []));
 
         // If user hasn't set the colors use the theme array
         if( $this->setslicecolors==null ) {
@@ -784,7 +784,7 @@
             sort($colors);
             $idx_a=$this->themearr[$this->theme];
             $ca = array();
-            $m = count($idx_a);
+            $m = count(($idx_a ?? []));
             for($i=0; $i < $m; ++$i) {
                 $ca[$i] = $colors[$idx_a[$i]];
             }
--- a/intranet/jpgraph/src/jpgraph_radar.php
+++ b/intranet/jpgraph/src/jpgraph_radar.php
@@ -251,7 +251,7 @@
         $this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel);
         $ncolor=0;
         if( isset($this->ticks_label_colors) ) {
-            $ncolor=count($this->ticks_label_colors);
+            $ncolor=count(($this->ticks_label_colors ?? []));
         }
 
         // Draw labels
@@ -262,7 +262,7 @@
 
             // majpos contains (x,y) coordinates for labels
             if( ! $this->hide_labels ) {
-                $n = floor(count($majpos)/2);
+                $n = floor(count(($majpos ?? []))/2);
                 for($i=0; $i < $n; ++$i) {
                     // Set specific label color if specified
                     if( $ncolor > 0 ) {
@@ -365,8 +365,8 @@
             return;
         }
 
-        $nbrticks = count($grid[0])/2;
-        $nbrpnts = count($grid);
+        $nbrticks = count(($grid[0] ?? []))/2;
+        $nbrpnts = count(($grid ?? []));
         $img->SetColor($this->grid_color);
         $img->SetLineWeight($this->weight);
 
@@ -466,7 +466,7 @@
     }
 
     function Stroke($img, $pos, $scale, $startangle) {
-        $nbrpnts = count($this->data);
+        $nbrpnts = count(($this->data ?? []));
         $astep=2*M_PI/$nbrpnts;
         $a=$startangle;
 
@@ -531,7 +531,7 @@
     }
 
     function GetCount() {
-        return count($this->data);
+        return count(($this->data ?? []));
     }
 
     function Legend($graph) {
@@ -659,7 +659,7 @@
     	if( $aPlot == null ) {
             JpGraphError::RaiseL(25010);//("Graph::Add() You tried to add a null plot to the graph.");
         }
-        if( is_array($aPlot) && count($aPlot) > 0 ) {
+        if( is_array($aPlot) && count(($aPlot ?? [])) > 0 ) {
             $cl = $aPlot[0];
         }
         else {
@@ -689,7 +689,7 @@
 
     function StrokeIcons() {
     	if( $this->iIcons != null ) {
-        	$n = count($this->iIcons);
+        	$n = count(($this->iIcons ?? []));
         	for( $i=0; $i < $n; ++$i ) {
             	$this->iIcons[$i]->Stroke($this->img);
         	}
@@ -698,7 +698,7 @@
 
 	function StrokeTexts() {
         if( $this->texts != null ) {
-			$n = count($this->texts);
+			$n = count(($this->texts ?? []));
             for( $i=0; $i < $n; ++$i ) {
                 $this->texts[$i]->Stroke($this->img);
             }
@@ -723,10 +723,10 @@
         // CSIM without storing an image to disk GetCSIM must call Stroke.
         $this->iHasStroked = true;
 
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         // Set Y-scale
 
-        if( !$this->yscale->IsSpecified() && count($this->plots) > 0 ) {
+        if( !$this->yscale->IsSpecified() && count(($this->plots ?? [])) > 0 ) {
             list($min,$max) = $this->GetPlotsYMinMax($this->plots);
             $this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor);
         }
@@ -757,7 +757,7 @@
                 $this->axis_title[$i] = $i+1;
             }
         }
-        elseif( count($this->axis_title) < $nbrpnts) {
+        elseif( count(($this->axis_title ?? [])) < $nbrpnts) {
             JpGraphError::RaiseL(18007);
             // ("Number of titles does not match number of points in plot.");
         }
--- a/intranet/jpgraph/src/jpgraph_canvtools.php
+++ b/intranet/jpgraph/src/jpgraph_canvtools.php
@@ -94,7 +94,7 @@
     }
 
     function Polygon($p,$aClosed=false) {
-        $n=count($p);
+        $n=count(($p ?? []));
         for($i=0; $i < $n; $i+=2 ) {
             $p[$i]   = $this->scale->TranslateX($p[$i]);
             $p[$i+1] = $this->scale->TranslateY($p[$i+1]);
@@ -103,7 +103,7 @@
     }
 
     function FilledPolygon($p) {
-        $n=count($p);
+        $n=count(($p ?? []));
         for($i=0; $i < $n; $i+=2 ) {
             $p[$i]   = $this->scale->TranslateX($p[$i]);
             $p[$i+1] = $this->scale->TranslateY($p[$i+1]);
--- a/intranet/jpgraph/src/jpgraph_contour.php
+++ b/intranet/jpgraph/src/jpgraph_contour.php
@@ -20,6 +20,9 @@
  *
  */
 class Contour {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $edges;
+
 
     private $dataPoints = array();
     private $nbrCols=0,$nbrRows=0;
@@ -42,13 +45,13 @@
      */
     function __construct($aMatrix,$aIsobars=10, $aColors=null) {
 
-        $this->nbrRows = count($aMatrix);
-        $this->nbrCols = count($aMatrix[0]);
+        $this->nbrRows = count(($aMatrix ?? []));
+        $this->nbrCols = count(($aMatrix[0] ?? []));
         $this->dataPoints = $aMatrix;
 
         if( is_array($aIsobars) ) {
             // use the isobar values supplied
-            $this->nbrIsobars = count($aIsobars);
+            $this->nbrIsobars = count(($aIsobars ?? []));
             $this->isobarValues = $aIsobars;
         }
         else {
@@ -63,14 +66,14 @@
             }
         }
 
-        if( $aColors !== null && count($aColors) > 0 ) {
+        if( $aColors !== null && count(($aColors ?? [])) > 0 ) {
 
             if( !is_array($aColors) ) {
                 JpGraphError::RaiseL(28001);
                 //'Third argument to Contour must be an array of colors.'
             }
 
-            if( count($aColors) != count($this->isobarValues) ) {
+            if( count(($aColors ?? [])) != count(($this->isobarValues ?? [])) ) {
                 JpGraphError::RaiseL(28002);
                 //'Number of colors must equal the number of isobar lines specified';
             }
@@ -249,7 +252,7 @@
      */
     function adjustDataPointValues() {
 
-        $ni = count($this->isobarValues);
+        $ni = count(($this->isobarValues ?? []));
         for ($k = 0; $k < $ni; $k++) {
             $ib = $this->isobarValues[$k];
             for ($row = 0 ; $row < $this->nbrRows-1; ++$row) {
@@ -371,7 +374,7 @@
             }
         }
 
-        if( count($this->isobarColors) == 0 ) {
+        if( count(($this->isobarColors ?? [])) == 0 ) {
             // No manually specified colors. Calculate them automatically.
             $this->CalculateColors();
         }
@@ -385,6 +388,9 @@
  *
  */
 class ContourPlot extends Plot {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $nbrContours;
+
 
     private $contour, $contourCoord, $contourVal, $contourColor;
     private $nbrCountours = 0 ;
@@ -432,7 +438,7 @@
         $this->contour = new Contour($this->dataMatrix,$this->isobar,$aIsobarColors);
 
         if( is_array($aIsobar) )
-            $this->nbrContours = count($aIsobar);
+            $this->nbrContours = count(($aIsobar ?? []));
         else
             $this->nbrContours = $aIsobar;
     }
@@ -488,7 +494,7 @@
      *
      */
     function Max() {
-        return array(count($this->dataMatrix[0])-1,count($this->dataMatrix)-1);
+        return array(count(($this->dataMatrix[0] ?? []))-1,count(($this->dataMatrix ?? []))-1);
     }
 
     /**
@@ -520,8 +526,8 @@
      *
      */
     function PreScaleSetup($aGraph) {
-        $xn = count($this->dataMatrix[0])-1;
-        $yn = count($this->dataMatrix)-1;
+        $xn = count(($this->dataMatrix[0] ?? []))-1;
+        $yn = count(($this->dataMatrix ?? []))-1;
 
         $aGraph->xaxis->scale->Update($aGraph->img,0,$xn);
         $aGraph->yaxis->scale->Update($aGraph->img,0,$yn);
@@ -551,9 +557,9 @@
      */
     function Stroke($img,$xscale,$yscale) {
 
-        if( count($this->manualIsobarColors) > 0 ) {
+        if( count(($this->manualIsobarColors ?? [])) > 0 ) {
             $this->contourColor = $this->manualIsobarColors;
-            if( count($this->manualIsobarColors) != $this->nbrContours ) {
+            if( count(($this->manualIsobarColors ?? [])) != $this->nbrContours ) {
                 JpGraphError::RaiseL(28002);
             }
         }
@@ -564,7 +570,7 @@
 
             $img->SetColor( $this->contourColor[$c] );
 
-            $n = count($this->contourCoord[$c]);
+            $n = count(($this->contourCoord[$c] ?? []));
             $i = 0;
             while ( $i < $n ) {
                 list($x1,$y1) = $this->contourCoord[$c][$i][0];
--- a/intranet/jpgraph/src/jpgraph_legend.inc.php
+++ b/intranet/jpgraph/src/jpgraph_legend.inc.php
@@ -171,7 +171,7 @@
     }
 
     function HasItems() {
-        return (boolean)(count($this->txtcol));
+        return (boolean)(count(($this->txtcol ?? [])));
     }
 
     function Stroke($aImg) {
@@ -186,7 +186,7 @@
             $this->txtcol = array_reverse($this->txtcol);
         }
 
-        $n=count($this->txtcol);
+        $n=count(($this->txtcol ?? []));
         if( $n == 0 ) return;
 
         // Find out the max width and height of each column to be able
@@ -340,7 +340,7 @@
             // and that is fine. However for a multiline paragraph there is no single baseline
             // and in that case the y1 corresponds to the lowest y for the bounding box. In that
             // case we center the mark in the middle of the paragraph
-            if( !preg_match('/\n/',$p[0]) ) {
+            if( !preg_match('/\n/',($p[0] ?? '')) ) {
                 // Single line
                 $marky = ceil($y1-$this->mark_abs_vsize/2)-1;
             } else {
@@ -427,7 +427,7 @@
                     $prect=null;
                 }
                 else {
-                    if( is_array($color) && count($color)==2 ) {
+                    if( is_array($color) && count(($color ?? []))==2 ) {
                         // The client want a gradient color
                         $grad->FilledRectangle($x1-$boxsize/2,$ym,
                                                $x1+$boxsize/2,$ym+$boxsize,
@@ -462,7 +462,7 @@
                 $ye = $y1-$rowheight[$row]+1;
                 $coords = "$xs,$ys,$xe,$y1,$xe,$ye,$xs,$ye";
                 if( ! empty($p[4]) ) {
-                    $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($p[4])."\"";
+                    $this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities(($p[4] ?? ''))."\"";
 
                     if( !empty($p[6]) ) {
                         $this->csimareas .= " target=\"".$p[6]."\"";
--- a/intranet/jpgraph/src/jpgraph_regstat.php
+++ b/intranet/jpgraph/src/jpgraph_regstat.php
@@ -26,9 +26,9 @@
         $this->xdata = $xdata;
         $this->ydata = $ydata;
 
-        $n = count($ydata);
+        $n = count(($ydata ?? []));
         $this->n = $n;
-        if( $this->n !== count($xdata) ) {
+        if( $this->n !== count(($xdata ?? [])) ) {
             JpGraphError::RaiseL(19001);
             //('Spline: Number of X and Y coordinates must be the same');
         }
@@ -123,8 +123,8 @@
 
     function __construct($datax, $datay, $attraction_factor = 1) {
         // Adding control point multiple time will raise their attraction power over the curve
-        $this->n = count($datax);
-        if( $this->n !== count($datay) ) {
+        $this->n = count(($datax ?? []));
+        if( $this->n !== count(($datay ?? [])) ) {
             JpGraphError::RaiseL(19003);
             //('Bezier: Number of X and Y coordinates must be the same');
         }
--- a/intranet/jpgraph/src/imgdata_squares.inc.php
+++ b/intranet/jpgraph/src/imgdata_squares.inc.php
@@ -19,7 +19,7 @@
     protected $maxidx = 7 ;
     protected $imgdata ;
 
-    function ImgData_Squares () {
+    function __construct () {
         //==========================================================
         //sq_lblue.png
         //==========================================================
--- a/intranet/jpgraph/src/jpgraph_canvas.php
+++ b/intranet/jpgraph/src/jpgraph_canvas.php
@@ -34,12 +34,12 @@
     // Method description
     function Stroke($aStrokeFileName="") {
         if( $this->texts != null ) {
-            for($i=0; $i < count($this->texts); ++$i) {
+            for($i=0; $i < count(($this->texts ?? [])); ++$i) {
                 $this->texts[$i]->Stroke($this->img);
             }
         }
         if( $this->iTables !== null ) {
-            for($i=0; $i < count($this->iTables); ++$i) {
+            for($i=0; $i < count(($this->iTables ?? [])); ++$i) {
                 $this->iTables[$i]->Stroke($this->img);
             }
         }
--- a/intranet/jpgraph/src/imageSmoothArc.php
+++ b/intranet/jpgraph/src/imageSmoothArc.php
@@ -42,7 +42,7 @@
     
     // Please do not use THIS function directly. Scroll down to imageSmoothArc(...).
     
-    $fillColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], $color[3] );
+    $fillColor = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) ($color[3]) );
     
     $xStart = abs($a * cos($start));
     $yStart = abs($b * sin($start));
@@ -112,23 +112,23 @@
                     $xp = -1; $yp = +1; $xa = 0; $ya = +1;
                 }
                 if ( $stop < ($i+1)*(M_PI/2) && $x <= $xStop ) {
-                    $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
-                    $y1 = $_y1; if ($aaStopX) imageSetPixel($img, $cx+$xp*($x)+$xa, $cy+$yp*($y1+1)+$ya, $diffColor1);
+                    $diffColor1 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error1) );
+                    $y1 = $_y1; if ($aaStopX) imageSetPixel($img, (int) ($cx+$xp*($x)+$xa), (int) ($cy+$yp*($y1+1)+$ya), (int) ($diffColor1));
                     
                 } else {
                     $y = $b * sqrt( 1 - ($x*$x)/($a*$a) );
                     $error = $y - (int)($y);
                     $y = (int)($y);
-                    $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );
-                    $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor);
+                    $diffColor = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error) );
+                    $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*($y1+1)+$ya), (int) ($diffColor));
                 }
                 if ($start > $i*M_PI/2 && $x <= $xStart) {
-                    $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
-                    $y2 = $_y2; if ($aaStartX) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y2-1)+$ya, $diffColor2);
+                    $diffColor2 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error2) );
+                    $y2 = $_y2; if ($aaStartX) imageSetPixel($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*($y2-1)+$ya), (int) ($diffColor2));
                 } else {
                     $y2 = 0;
                 }
-                if ($y2 <= $y1) imageLine($img, $cx+$xp*$x+$xa, $cy+$yp*$y1+$ya , $cx+$xp*$x+$xa, $cy+$yp*$y2+$ya, $fillColor);
+                if ($y2 <= $y1) imageLine($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*$y1+$ya) , (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*$y2+$ya), (int) ($fillColor));
             }
         }
         
@@ -142,23 +142,23 @@
                     $xp = +1; $yp = +1; $xa = 1; $ya = 1;
                 }
                 if ( $start > $i*M_PI/2 && $x < $xStart ) {
-                    $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
-                    $y1 = $_y2; if ($aaStartX) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor2);
+                    $diffColor2 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error2) );
+                    $y1 = $_y2; if ($aaStartX) imageSetPixel($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*($y1+1)+$ya), (int) ($diffColor2));
                     
                 } else {
                     $y = $b * sqrt( 1 - ($x*$x)/($a*$a) );
                     $error = $y - (int)($y);
                     $y = (int) $y;
-                    $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );
-                    $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y1+1)+$ya, $diffColor);
+                    $diffColor = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error) );
+                    $y1 = $y; if ($x < $aaAngleX ) imageSetPixel($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*($y1+1)+$ya), (int) ($diffColor));
                 }
                 if ($stop < ($i+1)*M_PI/2 && $x <= $xStop) {
-                    $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
-                    $y2 = $_y1; if ($aaStopX)  imageSetPixel($img, $cx+$xp*$x+$xa, $cy+$yp*($y2-1)+$ya, $diffColor1);
+                    $diffColor1 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error1) );
+                    $y2 = $_y1; if ($aaStopX)  imageSetPixel($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*($y2-1)+$ya), (int) ($diffColor1));
                 } else {
                     $y2 = 0;
                 }
-                if ($y2 <= $y1) imageLine($img, $cx+$xp*$x+$xa, $cy+$yp*$y1+$ya, $cx+$xp*$x+$xa, $cy+$yp*$y2+$ya, $fillColor);
+                if ($y2 <= $y1) imageLine($img, (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*$y1+$ya), (int) ($cx+$xp*$x+$xa), (int) ($cy+$yp*$y2+$ya), (int) ($fillColor));
             }
         }
     }
@@ -206,18 +206,18 @@
                     $xp = -1; $yp = +1; $xa = 0; $ya = 1;
                 }
                 if ( $stop < ($i+1)*(M_PI/2) && $y <= $yStop ) {
-                    $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
-                    $x1 = $_x1; if (!$aaStopX) imageSetPixel($img, $cx+$xp*($x1-1)+$xa, $cy+$yp*($y)+$ya, $diffColor1);
+                    $diffColor1 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error1) );
+                    $x1 = $_x1; if (!$aaStopX) imageSetPixel($img, (int) ($cx+$xp*($x1-1)+$xa), (int) ($cy+$yp*($y)+$ya), (int) ($diffColor1));
                 } 
                 if ($start > $i*M_PI/2 && $y < $yStart) {
-                    $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
-                    $x2 = $_x2; if (!$aaStartX) imageSetPixel($img, $cx+$xp*($x2+1)+$xa, $cy+$yp*($y)+$ya, $diffColor2);
+                    $diffColor2 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error2) );
+                    $x2 = $_x2; if (!$aaStartX) imageSetPixel($img, (int) ($cx+$xp*($x2+1)+$xa), (int) ($cy+$yp*($y)+$ya), (int) ($diffColor2));
                 } else {
                     $x = $a * sqrt( 1 - ($y*$y)/($b*$b) );
                     $error = $x - (int)($x);
                     $x = (int)($x);
-                    $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );
-                    $x1 = $x; if ($y < $aaAngleY && $y <= $yStop ) imageSetPixel($img, $cx+$xp*($x1+1)+$xa, $cy+$yp*$y+$ya, $diffColor);
+                    $diffColor = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error) );
+                    $x1 = $x; if ($y < $aaAngleY && $y <= $yStop ) imageSetPixel($img, (int) ($cx+$xp*($x1+1)+$xa), (int) ($cy+$yp*$y+$ya), (int) ($diffColor));
                 }
             }
         }
@@ -232,18 +232,18 @@
                     $xp = +1; $yp = +1; $xa = 1; $ya = 1;
                 }
                 if ( $start > $i*M_PI/2 && $y < $yStart ) {
-                    $diffColor2 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error2 );
-                    $x1 = $_x2; if (!$aaStartX) imageSetPixel($img, $cx+$xp*($x1-1)+$xa, $cy+$yp*$y+$ya,  $diffColor2);
+                    $diffColor2 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error2) );
+                    $x1 = $_x2; if (!$aaStartX) imageSetPixel($img, (int) ($cx+$xp*($x1-1)+$xa), (int) ($cy+$yp*$y+$ya),  (int) ($diffColor2));
                 } 
                 if ($stop < ($i+1)*M_PI/2 && $y <= $yStop) {
-                    $diffColor1 = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error1 );
-                    $x2 = $_x1; if (!$aaStopX)  imageSetPixel($img, $cx+$xp*($x2+1)+$xa, $cy+$yp*$y+$ya, $diffColor1);
+                    $diffColor1 = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error1) );
+                    $x2 = $_x1; if (!$aaStopX)  imageSetPixel($img, (int) ($cx+$xp*($x2+1)+$xa), (int) ($cy+$yp*$y+$ya), (int) ($diffColor1));
                 } else {
                     $x = $a * sqrt( 1 - ($y*$y)/($b*$b) );
                     $error = $x - (int)($x);
                     $x = (int)($x);
-                    $diffColor = imageColorExactAlpha( $img, $color[0], $color[1], $color[2], 127-(127-$color[3])*$error );
-                    $x1 = $x; if ($y < $aaAngleY  && $y < $yStart) imageSetPixel($img,$cx+$xp*($x1+1)+$xa,  $cy+$yp*$y+$ya, $diffColor);
+                    $diffColor = imageColorExactAlpha( $img, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]), (int) (127-(127-$color[3])*$error) );
+                    $x1 = $x; if ($y < $aaAngleY  && $y < $yStart) imageSetPixel($img,(int) ($cx+$xp*($x1+1)+$xa),  (int) ($cy+$yp*$y+$ya), (int) ($diffColor));
                 }
             }
         }
--- a/intranet/jpgraph/src/jpgraph.php
+++ b/intranet/jpgraph/src/jpgraph.php
@@ -1,4 +1,5 @@
 <?php
+require_once __DIR__ . '/../../core/legacy-date-format.php';
 //=======================================================================
 // File:        JPGRAPH.PHP
 // Description: PHP Graph Plotting library. Base module.
@@ -228,8 +229,8 @@
 // Check minimum PHP version
 //
 function CheckPHPVersion($aMinVersion) {
-    list($majorC, $minorC, $editC) = preg_split('/[\/.-]/', PHP_VERSION);
-    list($majorR, $minorR, $editR) = preg_split('/[\/.-]/', $aMinVersion);
+    list($majorC, $minorC, $editC) = preg_split('/[\/.-]/', (PHP_VERSION ?? ''));
+    list($majorR, $minorR, $editR) = preg_split('/[\/.-]/', ($aMinVersion ?? ''));
 
     if ($majorC < $majorR) return false;
 
@@ -279,7 +280,7 @@
 // case we raise it immediately since otherwise the image will not show and makes
 // debugging difficult. This is controlled by the user setting CATCH_PHPERRMSG
 //
-if( isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG && !preg_match('/|Deprecated|/i', $GLOBALS['php_errormsg']) ) {
+if( isset($GLOBALS['php_errormsg']) && CATCH_PHPERRMSG && !preg_match('/|Deprecated|/i', ($GLOBALS['php_errormsg'] ?? '')) ) {
     JpGraphError::RaiseL(25004,$GLOBALS['php_errormsg']);
 }
 
@@ -309,10 +310,10 @@
     $fname = basename($_SERVER['PHP_SELF']);
     if( !empty($_SERVER['QUERY_STRING']) ) {
         $q = @$_SERVER['QUERY_STRING'];
-        $fname .= '_'.preg_replace("/\W/", "_", $q).'.'.$img_format;
+        $fname .= '_'.preg_replace("/\W/", "_", ($q ?? '')).'.'.$img_format;
     }
     else {
-        $fname = substr($fname,0,strlen($fname)-4).'.'.$img_format;
+        $fname = substr(($fname ?? ''),0,strlen(($fname ?? ''))-4).'.'.$img_format;
     }
     return $fname;
 }
@@ -332,7 +333,7 @@
 
     // Push a new timer start on stack
     function Push() {
-        list($ms,$s)=explode(" ",microtime());
+        list($ms,$s)=explode(" ",(microtime() ?? ''));
         $this->start[$this->idx++]=floor($ms*1000) + 1000*$s;
     }
 
@@ -340,7 +341,7 @@
     // current time
     function Pop() {
         assert($this->idx>0);
-        list($ms,$s)=explode(" ",microtime());
+        list($ms,$s)=explode(" ",(microtime() ?? ''));
         $etime=floor($ms*1000) + (1000*$s);
         $this->idx--;
         return $etime-$this->start[$this->idx];
@@ -392,17 +393,17 @@
         }
 
         $this->iLocale = $aLocale;
-        for( $i = 0, $ofs = 0 - strftime('%w'); $i < 7; $i++, $ofs++ ) {
-            $day = strftime('%a', strtotime("$ofs day"));
-            $day[0] = strtoupper($day[0]);
+        for( $i = 0, $ofs = 0 - prowinch_format_legacy_date('%w'); $i < 7; $i++, $ofs++ ) {
+            $day = prowinch_format_legacy_date('%a', strtotime("$ofs day"));
+            $day[0] = strtoupper(($day[0] ?? ''));
             $this->iDayAbb[$aLocale][]= $day[0];
             $this->iShortDay[$aLocale][]= $day;
         }
 
         for($i=1; $i<=12; ++$i) {
-            list($short ,$full) = explode('|', strftime("%b|%B",strtotime("2001-$i-01")));
-            $this->iShortMonth[$aLocale][] = ucfirst($short);
-            $this->iMonthName [$aLocale][] = ucfirst($full);
+            list($short ,$full) = explode('|', (prowinch_format_legacy_date("%b|%B",strtotime("2001-$i-01")) ?? ''));
+            $this->iShortMonth[$aLocale][] = ucfirst(($short ?? ''));
+            $this->iMonthName [$aLocale][] = ucfirst(($full ?? ''));
         }
 
         setlocale(LC_TIME, $pLocale);
@@ -600,7 +601,7 @@
         $this->cache  = new ImgStreamCache();
 
         // Window doesn't like '?' in the file name so replace it with an '_'
-        $aCachedName = str_replace("?","_",$aCachedName);
+        $aCachedName = str_replace("?","_",($aCachedName ?? ''));
         $this->SetupCache($aCachedName, $aTimeout);
 
         $this->title = new Text();
@@ -765,7 +766,7 @@
         if( $aPlot == null ) {
             JpGraphError::RaiseL(25010);//("Graph::Add() You tried to add a null plot to the graph.");
         }
-        if( is_array($aPlot) && count($aPlot) > 0 ) {
+        if( is_array($aPlot) && count(($aPlot ?? [])) > 0 ) {
             $cl = $aPlot[0];
         }
         else {
@@ -793,7 +794,7 @@
 
     function AddTable($aTable) {
         if( is_array($aTable) ) {
-            for($i=0; $i < count($aTable); ++$i ) {
+            for($i=0; $i < count(($aTable ?? [])); ++$i ) {
                 $this->iTables[]=$aTable[$i];
             }
         }
@@ -804,7 +805,7 @@
 
     function AddIcon($aIcon) {
         if( is_array($aIcon) ) {
-            for($i=0; $i < count($aIcon); ++$i ) {
+            for($i=0; $i < count(($aIcon ?? [])); ++$i ) {
                 $this->iIcons[]=$aIcon[$i];
             }
         }
@@ -819,7 +820,7 @@
             JpGraphError::RaiseL(25011);//("Graph::AddY2() You tried to add a null plot to the graph.");
         }
 
-        if( is_array($aPlot) && count($aPlot) > 0 ) {
+        if( is_array($aPlot) && count(($aPlot ?? [])) > 0 ) {
             $cl = $aPlot[0];
         }
         else {
@@ -851,7 +852,7 @@
             JpGraphError::RaiseL(25012);//("Graph::AddYN() You tried to add a null plot to the graph.");
         }
 
-        if( is_array($aPlot) && count($aPlot) > 0 ) {
+        if( is_array($aPlot) && count(($aPlot ?? [])) > 0 ) {
             $cl = $aPlot[0];
         }
         else {
@@ -879,7 +880,7 @@
         }
         if( $aToY2 ) {
             if( is_array($aTxt) ) {
-                for($i=0; $i < count($aTxt); ++$i ) {
+                for($i=0; $i < count(($aTxt ?? [])); ++$i ) {
                     $this->y2texts[]=$aTxt[$i];
                 }
             }
@@ -889,7 +890,7 @@
         }
         else {
             if( is_array($aTxt) ) {
-                for($i=0; $i < count($aTxt); ++$i ) {
+                for($i=0; $i < count(($aTxt ?? [])); ++$i ) {
                     $this->texts[]=$aTxt[$i];
                 }
             }
@@ -907,7 +908,7 @@
 
         if( $aToY2 ) {
             if( is_array($aLine) ) {
-                for($i=0; $i < count($aLine); ++$i ) {
+                for($i=0; $i < count(($aLine ?? [])); ++$i ) {
                     //$this->y2lines[]=$aLine[$i];
                     $this->y2plots[]=$aLine[$i];
                 }
@@ -919,7 +920,7 @@
         }
         else {
             if( is_array($aLine) ) {
-                for($i=0; $i<count($aLine); ++$i ) {
+                for($i=0; $i<count(($aLine ?? [])); ++$i ) {
                     //$this->lines[]=$aLine[$i];
                     $this->plots[]=$aLine[$i];
                 }
@@ -939,7 +940,7 @@
 
         if( $aToY2 ) {
             if( is_array($aBand) ) {
-                for($i=0; $i < count($aBand); ++$i ) {
+                for($i=0; $i < count(($aBand ?? [])); ++$i ) {
                     $this->y2bands[] = $aBand[$i];
                 }
             }
@@ -949,7 +950,7 @@
         }
         else {
             if( is_array($aBand) ) {
-                for($i=0; $i < count($aBand); ++$i ) {
+                for($i=0; $i < count(($aBand ?? [])); ++$i ) {
                     $this->bands[] = $aBand[$i];
                 }
             }
@@ -992,13 +993,13 @@
 
         // Get extension to determine image type
         if( $aImgFormat == 'auto' ) {
-            $e = explode('.',$aFileName);
+            $e = explode('.',($aFileName ?? ''));
             if( !$e ) {
                 JpGraphError::RaiseL(25018,$aFileName);//('Incorrect file name for Graph::SetBackgroundImage() : '.$aFileName.' Must have a valid image extension (jpg,gif,png) when using autodetection of image type');
             }
 
             $valid_formats = array('png', 'jpg', 'gif');
-            $aImgFormat = strtolower($e[count($e)-1]);
+            $aImgFormat = strtolower(($e[count(($e ?? []))-1] ?? ''));
             if ($aImgFormat == 'jpeg')  {
                 $aImgFormat = 'jpg';
             }
@@ -1080,7 +1081,7 @@
             JpGraphError::RaiseL(25020);//('Graph::SetScale(): Specified Max value must be larger than the specified Min value.');
         }
 
-        $yt=substr($aAxisType,-3,3);
+        $yt=substr(($aAxisType ?? ''),-3,3);
         if( $yt == 'lin' ) {
             $this->yscale = new LinearScale($aYMin,$aYMax);
         }
@@ -1095,7 +1096,7 @@
             JpGraphError::RaiseL(25021,$aAxisType);//("Unknown scale specification for Y-scale. ($aAxisType)");
         }
 
-        $xt=substr($aAxisType,0,3);
+        $xt=substr(($aAxisType ?? ''),0,3);
         if( $xt == 'lin' || $xt == 'tex' ) {
             $this->xscale = new LinearScale($aXMin,$aXMax,'x');
             $this->xscale->textscale = ($xt == 'tex');
@@ -1254,14 +1255,14 @@
         }
 
         if( $this->texts != null ) {
-            $n = count($this->texts);
+            $n = count(($this->texts ?? []));
             for($i=0; $i < $n; ++$i ) {
                 $csim .= $this->texts[$i]->GetCSIMAreas();
             }
         }
 
         if( $this->y2texts != null && $this->y2scale != null ) {
-            $n = count($this->y2texts);
+            $n = count(($this->y2texts ?? []));
             for($i=0; $i < $n; ++$i ) {
                 $csim .= $this->y2texts[$i]->GetCSIMAreas();
             }
@@ -1272,25 +1273,25 @@
             $csim .= $this->xaxis->title->GetCSIMAreas();
         }
 
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for( $i=0; $i < $n; ++$i ) {
             $csim .= $this->plots[$i]->GetCSIMareas();
         }
 
-        $n = count($this->y2plots);
+        $n = count(($this->y2plots ?? []));
         for( $i=0; $i < $n; ++$i ) {
             $csim .= $this->y2plots[$i]->GetCSIMareas();
         }
 
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for( $i=0; $i < $n; ++$i ) {
-            $m = count($this->ynplots[$i]);
+            $m = count(($this->ynplots[$i] ?? []));
             for($j=0; $j < $m; ++$j ) {
                 $csim .= $this->ynplots[$i][$j]->GetCSIMareas();
             }
         }
 
-        $n = count($this->iTables);
+        $n = count(($this->iTables ?? []));
         for( $i=0; $i < $n; ++$i ) {
             $csim .= $this->iTables[$i]->GetCSIMareas();
         }
@@ -1367,14 +1368,14 @@
 
         // Now reconstruct any user URL argument
         reset($_GET);
-        while( list($key,$value) = each($_GET) ) {
+        foreach ($_GET as $key => $value) {
             if( is_array($value) ) {
                 foreach ( $value as $k => $v ) {
-                    $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode($v);
+                    $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode(($v ?? ''));
                 }
             }
             else {
-                $urlarg .= '&amp;'.$key.'='.urlencode($value);
+                $urlarg .= '&amp;'.$key.'='.urlencode(($value ?? ''));
             }
         }
 
@@ -1382,14 +1383,14 @@
         // but there is little else we can do. One idea for the
         // future might be recreate the POST header in case.
         reset($_POST);
-        while( list($key,$value) = each($_POST) ) {
+        foreach ($_POST as $key => $value) {
             if( is_array($value) ) {
                 foreach ( $value as $k => $v ) {
-                    $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode($v);
+                    $urlarg .= '&amp;'.$key.'%5B'.$k.'%5D='.urlencode(($v ?? ''));
                 }
             }
             else {
-                $urlarg .= '&amp;'.$key.'='.urlencode($value);
+                $urlarg .= '&amp;'.$key.'='.urlencode(($value ?? ''));
             }
         }
 
@@ -1445,7 +1446,7 @@
 
                 // In the src URL we must replace the '?' with its encoding to prevent the arguments
                 // to be converted to real arguments.
-                $tmp = str_replace('?','%3f',$baseimg);
+                $tmp = str_replace('?','%3f',($baseimg ?? ''));
                 $htmlwrap = $this->GetHTMLImageMap($aCSIMName)."\n".
                             '<img src="'.CSIMCACHE_HTTP_DIR.$tmp.'" ismap="ismap" usemap="#'.$aCSIMName.' width="'.$this->img->width.'" height="'.$this->img->height."\" alt=\"".$this->iCSIMImgAlt."\" />\n";
 
@@ -1492,7 +1493,7 @@
         else {
             $txts = $this->texts;
         }
-        $n = count($txts);
+        $n = count(($txts ?? []));
         $min=null;
         $max=null;
         for( $i=0; $i < $n; ++$i ) {
@@ -1521,7 +1522,7 @@
         else {
             $txts = $this->texts;
         }
-        $n = count($txts);
+        $n = count(($txts ?? []));
         $min=null;
         $max=null;
         for( $i=0; $i < $n; ++$i ) {
@@ -1552,7 +1553,7 @@
         // Some plots, e.g. PlotLine should not affect the scale
         // and will return (null,null). We should ignore those
         // values.
-        while( ($min===null || $max === null) && ($i < count($this->plots)-1) ) {
+        while( ($min===null || $max === null) && ($i < count(($this->plots ?? []))-1) ) {
             ++$i;
             list($min,$ymin) = $this->plots[$i]->Min();
             list($max,$ymax) = $this->plots[$i]->Max();
@@ -1577,7 +1578,7 @@
             }
         }
 
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for( $i=0; $i < $n; ++$i ) {
             if( $this->ynaxis[$i] != null) {
                 foreach( $this->ynplots[$i] as $p ) {
@@ -1674,9 +1675,9 @@
     function doAutoscaleXAxis() {
     //Check if we should autoscale x-axis
         if( !$this->xscale->IsSpecified() ) {
-            if( substr($this->axtype,0,4) == "text" ) {
+            if( substr(($this->axtype ?? ''),0,4) == "text" ) {
                 $max=0;
-                $n = count($this->plots);
+                $n = count(($this->plots ?? []));
                 for($i=0; $i < $n; ++$i ) {
                     $p = $this->plots[$i];
                     // We need some unfortunate sub class knowledge here in order
@@ -1686,7 +1687,7 @@
                     // settings means that we will shift the entire plot half a tick step
                     // to the right in oder to align with the center of the bars.
                     if( class_exists('BarPlot',false) ) {
-                        $cl = strtolower(get_class($p));
+                        $cl = strtolower((get_class($p) ?? ''));
                         if( (class_exists('BarPlot',false) && ($p instanceof BarPlot)) || empty($p->barcenter) ) {
                             $max=max($max,$p->numpoints-1);
                         }
@@ -1709,7 +1710,7 @@
                         $max=max($max,$p->numpoints-1);
                     }
                 }
-                $n = count($this->ynaxis);
+                $n = count(($this->ynaxis ?? []));
                 for( $i=0; $i < $n; ++$i ) {
                     if( $this->ynaxis[$i] != null) {
                         foreach( $this->ynplots[$i] as $p ) {
@@ -1793,7 +1794,7 @@
             $this->y2axis->SetTitleSide(SIDE_RIGHT);
         }
 
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         $nY2adj = $this->y2axis != null ? $this->iYAxisDeltaPos : 0;
         for( $i=0; $i < $n; ++$i ) {
             if( $this->ynaxis[$i] != null ) {
@@ -1810,7 +1811,7 @@
     function doAutoScaleYnAxis() {
 
         if( $this->y2scale != null) {
-            if( !$this->y2scale->IsSpecified() && count($this->y2plots)>0 ) {
+            if( !$this->y2scale->IsSpecified() && count(($this->y2plots ?? []))>0 ) {
                 list($min,$max) = $this->GetPlotsYMinMax($this->y2plots);
 
                 $lres = $this->GetLinesYMinMax($this->y2lines);
@@ -1857,10 +1858,10 @@
         //
         // Autoscale the extra Y-axises
         //
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for( $i=0; $i < $n; ++$i ) {
             if( $this->ynscale[$i] != null) {
-                if( !$this->ynscale[$i]->IsSpecified() && count($this->ynplots[$i])>0 ) {
+                if( !$this->ynscale[$i]->IsSpecified() && count(($this->ynplots[$i] ?? []))>0 ) {
                     list($min,$max) = $this->GetPlotsYMinMax($this->ynplots[$i]);
                     $this->ynscale[$i]->AutoScale($this->img,$min,$max,$this->img->plotheight/$this->ytick_factor);
                 }
@@ -1894,7 +1895,7 @@
     function doAutoScaleYAxis() {
 
         //Check if we should autoscale y-axis
-        if( !$this->yscale->IsSpecified() && count($this->plots)>0 ) {
+        if( !$this->yscale->IsSpecified() && count(($this->plots ?? []))>0 ) {
             list($min,$max) = $this->GetPlotsYMinMax($this->plots);
             $lres = $this->GetLinesYMinMax($this->lines);
             if( is_array($lres) ) {
@@ -1944,7 +1945,7 @@
         if( $this->xscale ) $this->xscale->InitConstants($this->img);
         if( $this->y2scale ) $this->y2scale->InitConstants($this->img);
 
-        $n=count($this->ynscale);
+        $n=count(($this->ynscale ?? []));
         for($i=0; $i < $n; ++$i) {
             if( $this->ynscale[$i] ) {
                 $this->ynscale[$i]->InitConstants($this->img);
@@ -1956,26 +1957,26 @@
 
         // Do any pre-stroke adjustment that is needed by the different plot types
         // (i.e bar plots want's to add an offset to the x-labels etc)
-        for($i=0; $i < count($this->plots) ; ++$i ) {
+        for($i=0; $i < count(($this->plots ?? [])) ; ++$i ) {
             $this->plots[$i]->PreStrokeAdjust($this);
             $this->plots[$i]->DoLegend($this);
         }
 
         // Any plots on the second Y scale?
         if( $this->y2scale != null ) {
-            for($i=0; $i<count($this->y2plots) ; ++$i ) {
+            for($i=0; $i<count(($this->y2plots ?? [])) ; ++$i ) {
                 $this->y2plots[$i]->PreStrokeAdjust($this);
                 $this->y2plots[$i]->DoLegend($this);
             }
         }
 
         // Any plots on the extra Y axises?
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for($i=0; $i<$n ; ++$i ) {
             if( $this->ynplots == null || $this->ynplots[$i] == null) {
                 JpGraphError::RaiseL(25032,$i);//("No plots for Y-axis nbr:$i");
             }
-            $m = count($this->ynplots[$i]);
+            $m = count(($this->ynplots[$i] ?? []));
             for($j=0; $j < $m; ++$j ) {
                 $this->ynplots[$i][$j]->PreStrokeAdjust($this);
                 $this->ynplots[$i][$j]->DoLegend($this);
@@ -1986,7 +1987,7 @@
     function StrokeBands($aDepth,$aCSIM) {
     // Stroke bands
         if( $this->bands != null && !$aCSIM) {
-            for($i=0; $i < count($this->bands); ++$i) {
+            for($i=0; $i < count(($this->bands ?? [])); ++$i) {
             // Stroke all bands that asks to be in the background
                 if( $this->bands[$i]->depth == $aDepth ) {
                     $this->bands[$i]->Stroke($this->img,$this->xscale,$this->yscale);
@@ -1995,7 +1996,7 @@
         }
 
         if( $this->y2bands != null && $this->y2scale != null && !$aCSIM ) {
-            for($i=0; $i < count($this->y2bands); ++$i) {
+            for($i=0; $i < count(($this->y2bands ?? [])); ++$i) {
             // Stroke all bands that asks to be in the foreground
                 if( $this->y2bands[$i]->depth == $aDepth ) {
                     $this->y2bands[$i]->Stroke($this->img,$this->xscale,$this->y2scale);
@@ -2020,7 +2021,7 @@
         // Give the plot a chance to do any scale adjuments the individual plots
         // wants to do. Right now this is only used by the contour plot to set scale
         // limits
-        for($i=0; $i < count($this->plots) ; ++$i ) {
+        for($i=0; $i < count(($this->plots ?? [])) ; ++$i ) {
             $this->plots[$i]->PreScaleSetup($this);
         }
 
@@ -2060,8 +2061,8 @@
         // has no plots. (This means it is impossible to do autoscaling and
         // no other scale was given so we can't possible draw anything). If you use manual
         // scaling you also have to supply the tick steps as well.
-        if( (!$this->yscale->IsSpecified() && count($this->plots)==0) ||
-            ($this->y2scale!=null && !$this->y2scale->IsSpecified() && count($this->y2plots)==0) ) {
+        if( (!$this->yscale->IsSpecified() && count(($this->plots ?? []))==0) ||
+            ($this->y2scale!=null && !$this->y2scale->IsSpecified() && count(($this->y2plots ?? []))==0) ) {
             //$e = "n=".count($this->y2plots)."\n";
             // $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n";
             // $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n";
@@ -2070,7 +2071,7 @@
         }
 
         // Bail out if no plots and no specified X-scale
-        if( (!$this->xscale->IsSpecified() && count($this->plots)==0 && count($this->y2plots)==0) ) {
+        if( (!$this->xscale->IsSpecified() && count(($this->plots ?? []))==0 && count(($this->y2plots ?? []))==0) ) {
             JpGraphError::RaiseL(25034);//("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>");
         }
 
@@ -2095,7 +2096,7 @@
         // for 'text'
         if( ($this->yaxis->pos==$this->xscale->GetMinVal() || (is_string($this->yaxis->pos) && $this->yaxis->pos=='min')) &&
             !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 &&
-            substr($this->axtype,0,4) != 'text' && $this->xaxis->pos != 'min' ) {
+            substr(($this->axtype ?? ''),0,4) != 'text' && $this->xaxis->pos != 'min' ) {
 
             //$this->yscale->ticks->SupressZeroLabel(false);
             $this->xscale->ticks->SupressFirst();
@@ -2130,13 +2131,13 @@
         }
 
         // Stroke yn-axis
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for( $i=0; $i < $n; ++$i ) {
             $this->ynaxis[$i]->Stroke($this->xscale);
         }
 
         $oldoff=$this->xscale->off;
-        if( substr($this->axtype,0,4) == 'text' ) {
+        if( substr(($this->axtype ?? ''),0,4) == 'text' ) {
             if( $this->text_scale_abscenteroff > -1 ) {
                 // For a text scale the scale factor is the number of pixel per step.
                 // Hence we can use the scale factor as a substitute for number of pixels
@@ -2155,7 +2156,7 @@
 
         if( ! $this->y2orderback ) {
             // Stroke all plots for Y1 axis
-            for($i=0; $i < count($this->plots); ++$i) {
+            for($i=0; $i < count(($this->plots ?? [])); ++$i) {
                 $this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale);
                 $this->plots[$i]->StrokeMargin($this->img);
             }
@@ -2163,22 +2164,22 @@
 
         // Stroke all plots for Y2 axis
         if( $this->y2scale != null ) {
-            for($i=0; $i< count($this->y2plots); ++$i ) {
+            for($i=0; $i< count(($this->y2plots ?? [])); ++$i ) {
                 $this->y2plots[$i]->Stroke($this->img,$this->xscale,$this->y2scale);
             }
         }
 
         if( $this->y2orderback ) {
             // Stroke all plots for Y1 axis
-            for($i=0; $i < count($this->plots); ++$i) {
+            for($i=0; $i < count(($this->plots ?? [])); ++$i) {
                 $this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale);
                 $this->plots[$i]->StrokeMargin($this->img);
             }
         }
 
-        $n = count($this->ynaxis);
+        $n = count(($this->ynaxis ?? []));
         for( $i=0; $i < $n; ++$i ) {
-            $m = count($this->ynplots[$i]);
+            $m = count(($this->ynplots[$i] ?? []));
             for( $j=0; $j < $m; ++$j ) {
                 $this->ynplots[$i][$j]->Stroke($this->img,$this->xscale,$this->ynscale[$i]);
                 $this->ynplots[$i][$j]->StrokeMargin($this->img);
@@ -2466,13 +2467,13 @@
 
         // Remove case sensitivity and setup appropriate function to create image
         // Get file extension. This should be the LAST '.' separated part of the filename
-        $e = explode('.',$aFile);
-        $ext = strtolower($e[count($e)-1]);
+        $e = explode('.',($aFile ?? ''));
+        $ext = strtolower(($e[count(($e ?? []))-1] ?? ''));
         if ($ext == "jpeg")  {
             $ext = "jpg";
         }
 
-        if( trim($ext) == '' ) {
+        if( trim(($ext ?? '')) == '' ) {
             $ext = 'png';  // Assume PNG if no extension specified
         }
 
@@ -2752,7 +2753,7 @@
     }
 
     function StrokeIcons() {
-        $n = count($this->iIcons);
+        $n = count(($this->iIcons ?? []));
         for( $i=0; $i < $n; ++$i ) {
             $this->iIcons[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale);
         }
@@ -2956,13 +2957,13 @@
     function StrokeTexts() {
         // Stroke any user added text objects
         if( $this->texts != null ) {
-            for($i=0; $i < count($this->texts); ++$i) {
+            for($i=0; $i < count(($this->texts ?? [])); ++$i) {
                 $this->texts[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale);
             }
         }
 
         if( $this->y2texts != null && $this->y2scale != null ) {
-            for($i=0; $i < count($this->y2texts); ++$i) {
+            for($i=0; $i < count(($this->y2texts ?? [])); ++$i) {
                 $this->y2texts[$i]->StrokeWithScale($this->img,$this->xscale,$this->y2scale);
             }
         }
@@ -2971,7 +2972,7 @@
 
     function StrokeTables() {
         if( $this->iTables != null ) {
-            $n = count($this->iTables);
+            $n = count(($this->iTables ?? []));
             for( $i=0; $i < $n; ++$i ) {
                 $this->iTables[$i]->StrokeWithScale($this->img,$this->xscale,$this->yscale);
             }
@@ -2985,19 +2986,19 @@
             $csim.= $p->GetCSIMareas();
         }
         $csim .= $this->legend->GetCSIMareas();
-        if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", $csim, $coords)) {
+        if (preg_match_all("/area shape=\"(\w+)\" coords=\"([0-9\, ]+)\"/", ($csim ?? ''), $coords)) {
             $this->img->SetColor($this->csimcolor);
-            $n = count($coords[0]);
+            $n = count(($coords[0] ?? []));
             for ($i=0; $i < $n; $i++) {
                 if ( $coords[1][$i] == 'poly' ) {
-                    preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',$coords[2][$i],$pts);
-                    $this->img->SetStartPoint($pts[1][count($pts[0])-1],$pts[2][count($pts[0])-1]);
-                    $m = count($pts[0]);
+                    preg_match_all('/\s*([0-9]+)\s*,\s*([0-9]+)\s*,*/',($coords[2][$i] ?? ''),$pts);
+                    $this->img->SetStartPoint($pts[1][count(($pts[0] ?? []))-1],$pts[2][count(($pts[0] ?? []))-1]);
+                    $m = count(($pts[0] ?? []));
                     for ($j=0; $j < $m; $j++) {
                         $this->img->LineTo($pts[1][$j],$pts[2][$j]);
                     }
                 } elseif ( $coords[1][$i] == 'rect' ) {
-                    $pts = preg_split('/,/', $coords[2][$i]);
+                    $pts = preg_split('/,/', ($coords[2][$i] ?? ''));
                     $this->img->SetStartPoint($pts[0],$pts[1]);
                     $this->img->LineTo($pts[2],$pts[1]);
                     $this->img->LineTo($pts[2],$pts[3]);
@@ -3021,7 +3022,7 @@
 
     // Get Y min and max values for added lines
     function GetLinesYMinMax( $aLines ) {
-        $n = count($aLines);
+        $n = count($aLines ?? array());
         if( $n == 0 ) return false;
         $min = $aLines[0]->scaleposition ;
         $max = $min ;
@@ -3039,7 +3040,7 @@
 
     // Get X min and max values for added lines
     function GetLinesXMinMax( $aLines ) {
-        $n = count($aLines);
+        $n = count($aLines ?? array());
         if( $n == 0 ) return false ;
         $min = $aLines[0]->scaleposition ;
         $max = $min ;
@@ -3057,7 +3058,7 @@
 
     // Get min and max values for all included plots
     function GetPlotsYMinMax($aPlots) {
-        $n = count($aPlots);
+        $n = count(($aPlots ?? []));
         $i=0;
         do {
             list($xmax,$max) = $aPlots[$i]->Max();
@@ -3580,7 +3581,7 @@
     // Draw the grid
     function DoStroke($aTicksPos,$aType,$aColor,$aWeight) {
         if( !$this->show ) return;
-        $nbrgrids = count($aTicksPos);
+        $nbrgrids = count(($aTicksPos ?? []));
 
         if( $this->scale->type == 'y' ) {
             $xl=$this->img->left_margin;
@@ -3642,7 +3643,7 @@
             // to many gridlines
             $i=0;
             $x=$aTicksPos[$i];
-            while( $i<count($aTicksPos) && ($x=$aTicksPos[$i]) <= $limit ) {
+            while( $i<count(($aTicksPos ?? [])) && ($x=$aTicksPos[$i]) <= $limit ) {
                 if    ( $aType == 'solid' )      $this->img->Line($x,$yl,$x,$yu);
                 elseif( $aType == 'dotted' )     $this->img->DashedLineForGrid($x,$yl,$x,$yu,1,6);
                 elseif( $aType == 'dashed' )     $this->img->DashedLineForGrid($x,$yl,$x,$yu,2,4);
@@ -4007,7 +4008,7 @@
     // Draw all the tick labels on major tick marks
     function StrokeLabels($aPos,$aMinor=false,$aAbsLabel=false) {
 
-        if( is_array($this->label_color) && count($this->label_color) > 3 ) {
+        if( is_array($this->label_color) && count(($this->label_color ?? [])) > 3 ) {
             $this->ticks_label_colors = $this->label_color;
             $this->img->SetColor($this->label_color[0]);
         }
@@ -4018,7 +4019,7 @@
         $yoff=$this->img->GetFontHeight()/2;
 
         // Only draw labels at major tick marks
-        $nbr = count($this->scale->ticks->maj_ticks_label);
+        $nbr = count(($this->scale->ticks->maj_ticks_label ?? []));
 
         // We have the option to not-display the very first mark
         // (Usefull when the first label might interfere with another
@@ -4031,7 +4032,7 @@
         // of the scale.
         $ncolor=0;
         if( isset($this->ticks_label_colors) ) {
-            $ncolor=count($this->ticks_label_colors);
+            $ncolor=count(($this->ticks_label_colors ?? []));
         }
         while( $i < $nbr ) {
             // $tpos holds the absolute text position for the label
@@ -4059,8 +4060,8 @@
                 // that holds the labels set by the user. If the user hasn't
                 // specified any values we use whats in the automatically asigned
                 // labels in the maj_ticks_label
-                if( isset($this->ticks_label[$i*$m]) ) {
-                    $label=$this->ticks_label[$i*$m];
+                if( isset($this->ticks_label[(int) ($i*$m)]) ) {
+                    $label=$this->ticks_label[(int) ($i*$m)];
                 }
                 else {
                     if( $aAbsLabel ) {
@@ -4278,6 +4279,9 @@
 // Description: Draw linear ticks on axis
 //===================================================
 class LinearTicks extends Ticks {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $ticks_label;
+
     public $minor_step=1, $major_step=2;
     public $xlabel_offset=0,$xtick_offset=0;
     private $label_offset=0; // What offset should the displayed label have
@@ -4325,8 +4329,8 @@
             JpGraphError::RaiseL(25065);//('Tick positions must be specifued as an array()');
             return;
         }
-        $n=count($aMajPos);
-        if( is_array($aLabels) && (count($aLabels) != $n) ) {
+        $n=count(($aMajPos ?? []));
+        if( is_array($aLabels) && (count(($aLabels ?? [])) != $n) ) {
             JpGraphError::RaiseL(25066);//('When manually specifying tick positions and labels the number of labels must be the same as the number of specified ticks.');
         }
         $this->iManualTickPos = $aMajPos;
@@ -4335,14 +4339,14 @@
     }
 
     function HaveManualLabels() {
-        return count($this->iManualTickLabels) > 0;
+        return count(($this->iManualTickLabels ?? [])) > 0;
     }
 
     // Specify all the tick positions manually and possible also the exact labels
     function _doManualTickPos($aScale) {
-        $n=count($this->iManualTickPos);
-        $m=count($this->iManualMinTickPos);
-        $doLbl=count($this->iManualTickLabels) > 0;
+        $n=count(($this->iManualTickPos ?? []));
+        $m=count(($this->iManualMinTickPos ?? []));
+        $doLbl=count(($this->iManualTickLabels ?? [])) > 0;
 
         $this->maj_ticks_pos = array();
         $this->maj_ticklabels_pos = array();
@@ -4376,7 +4380,7 @@
         }
 
         // Some sanity check
-        if( count($this->maj_ticks_pos) < 2 ) {
+        if( count(($this->maj_ticks_pos ?? [])) < 2 ) {
             JpGraphError::RaiseL(25067);//('Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tickl marks.');
         }
 
@@ -4564,7 +4568,7 @@
             // Stroke minor ticks
             $yu = $aPos - $this->direction*$this->GetMinTickAbsSize();
             $xr = $aPos + $this->direction*$this->GetMinTickAbsSize();
-            $n = count($this->ticks_pos);
+            $n = count(($this->ticks_pos ?? []));
             for($i=0; $i < $n; ++$i ) {
                 if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) {
                     if( $this->mincolor != '') {
@@ -4589,7 +4593,7 @@
         $yu = $aPos - $this->direction*$this->GetMajTickAbsSize();
         $xr = $aPos + $this->direction*$this->GetMajTickAbsSize();
         $nbrmajticks=round(($aScale->GetMaxVal()-$aScale->GetMinVal()-$this->text_label_start )/$this->major_step)+1;
-        $n = count($this->maj_ticks_pos);
+        $n = count(($this->maj_ticks_pos ?? []));
         for($i=0; $i < $n ; ++$i ) {
             if(!($this->xtick_offset > 0 && $i==$nbrmajticks-1) && !$this->supress_tickmarks) {
                 if( $this->majcolor != '') {
@@ -4655,6 +4659,7 @@
 // CLASS LinearScale
 // Description: Handle linear scaling between screen and world
 //===================================================
+#[\AllowDynamicProperties]
 class LinearScale {
     public $textscale=false; // Just a flag to let the Plot class find out if
     // we are a textscale or not. This is a cludge since
@@ -5391,7 +5396,7 @@
     protected $isRunningClear = false;
 
     function __construct($aDatay,$aDatax=false) {
-        $this->numpoints = count($aDatay);
+        $this->numpoints = count(($aDatay ?? []));
         if( $this->numpoints==0 ) {
             JpGraphError::RaiseL(25121);//("Empty input data array specified for plot. Must have at least one data point.");
         }
@@ -5405,7 +5410,7 @@
         $this->coords[0]=$aDatay;
         if( is_array($aDatax) ) {
             $this->coords[1]=$aDatax;
-            $n = count($aDatax);
+            $n = count(($aDatax ?? []));
             for( $i=0; $i < $n; ++$i ) {
                 if( !is_numeric($aDatax[$i]) ) {
                     JpGraphError::RaiseL(25070);
@@ -5450,7 +5455,7 @@
     // "Virtual" function which gets called before any scale
     // or axis are stroked used to do any plot specific adjustment
     function PreStrokeAdjust($aGraph) {
-        if( substr($aGraph->axtype,0,4) == "text" && (isset($this->coords[1])) ) {
+        if( substr(($aGraph->axtype ?? ''),0,4) == "text" && (isset($this->coords[1])) ) {
             JpGraphError::RaiseL(25123);//("JpGraph: You can't use a text X-scale with specified X-coords. Use a \"int\" or \"lin\" scale instead.");
         }
         return true;
@@ -5470,14 +5475,14 @@
         else {
             $x='';
         }
-        if( $x != '' && count($x) > 0 ) {
+        if( $x != '' && count(($x ?? [])) > 0 ) {
             $xm=min($x);
         }
         else {
             $xm=0;
         }
         $y=$this->coords[0];
-        $cnt = count($y);
+        $cnt = count(($y ?? []));
         if( $cnt > 0 ) {
             $i=0;
             while( $i<$cnt && !is_numeric($ym=$y[$i]) ) {
@@ -5505,15 +5510,15 @@
             $x='';
         }
 
-        if( $x!='' && count($x) > 0 ) {
+        if( $x!='' && count(($x ?? [])) > 0 ) {
             $xm=max($x);
         }
         else {
             $xm = $this->numpoints-1;
         }
         $y=$this->coords[0];
-        if( count($y) > 0 ) {
-            $cnt = count($y);
+        if( count(($y ?? [])) > 0 ) {
+            $cnt = count(($y ?? []));
             $i=0;
             while( $i<$cnt && !is_numeric($ym=$y[$i]) ) {
                 $i++;
--- a/intranet/jpgraph/src/jpgraph_scatter.php
+++ b/intranet/jpgraph/src/jpgraph_scatter.php
@@ -68,9 +68,9 @@
     private $iCallback = '';
 
     function __construct($datay,$datax,$angles) {
-        if( (count($datax) != count($datay)) )
+        if( (count(($datax ?? [])) != count(($datay ?? []))) )
         JpGraphError::RaiseL(20001);//("Fieldplots must have equal number of X and Y points.");
-        if( (count($datax) != count($angles)) )
+        if( (count(($datax ?? [])) != count(($angles ?? []))) )
         JpGraphError::RaiseL(20002);//("Fieldplots must have an angle specified for each X and Y points.");
 
         $this->iAngles = $angles;
@@ -136,7 +136,7 @@
     //---------------
     // CONSTRUCTOR
     function __construct($datay,$datax=false) {
-        if( (count($datax) != count($datay)) && is_array($datax)) {
+        if( (count(($datax ?? [])) != count(($datay ?? []))) && is_array($datax)) {
         	JpGraphError::RaiseL(20003);//("Scatterplot must have equal number of X and Y points.");
         }
         parent::__construct($datay,$datax);
--- a/intranet/jpgraph/src/jpgraph_error.php
+++ b/intranet/jpgraph/src/jpgraph_error.php
@@ -41,13 +41,13 @@
 
     // Method description
     function Stroke($img,$xscale,$yscale) {
-        $numpoints=count($this->coords[0])/2;
+        $numpoints=count(($this->coords[0] ?? []))/2;
         $img->SetColor($this->color);
         $img->SetLineWeight($this->weight);
 
         if( isset($this->coords[1]) ) {
-            if( count($this->coords[1])!=$numpoints )
-            JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
+            if( count(($this->coords[1] ?? []))!=$numpoints )
+            JpGraphError::RaiseL(2003,count(($this->coords[1] ?? [])),$numpoints);
             //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
             else
             $exist_x = true;
@@ -91,7 +91,7 @@
     function __construct($datay,$datax=false) {
         parent::__construct($datay,$datax);
         // Calculate line coordinates as the average of the error limits
-        $n = count($datay);
+        $n = count(($datay ?? []));
         for($i=0; $i < $n; $i+=2 ) {
             $ly[]=($datay[$i]+$datay[$i+1])/2;
         }
@@ -124,7 +124,7 @@
     // Data is (val, errdeltamin, errdeltamax)
     function __construct($datay,$datax=false) {
         $ly=array(); $ey=array();
-        $n = count($datay);
+        $n = count(($datay ?? []));
         if( $n % 3 != 0 ) {
             JpGraphError::RaiseL(4002);
             //('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3');
--- a/intranet/jpgraph/src/jpgraph_mgraph.php
+++ b/intranet/jpgraph/src/jpgraph_mgraph.php
@@ -14,6 +14,9 @@
 // Description: Create a container image that can hold several graph
 //=============================================================================
 class MGraph {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $background_image_format;
+
 
     public $title = null, $subtitle = null, $subsubtitle = null;
 
@@ -103,14 +106,14 @@
         }
 
         // Get extension to determine image type
-        $e = explode('.',$aFileName);
+        $e = explode('.',($aFileName ?? ''));
         if( !$e ) {
             JpGraphError::RaiseL(12002,$aFileName);
             //('Incorrect file name for MGraph::SetBackgroundImage() : '.$aFileName.' Must have a valid image extension (jpg,gif,png) when using autodetection of image type');
         }
 
         $valid_formats = array('png', 'jpg', 'gif');
-        $aImgFormat = strtolower($e[count($e)-1]);
+        $aImgFormat = strtolower(($e[count(($e ?? []))-1] ?? ''));
         if ($aImgFormat == 'jpeg')  {
             $aImgFormat = 'jpg';
         }
@@ -158,7 +161,7 @@
             $x = $this->background_image_x;
             $y = $this->background_image_y;
         }
-        imagecopymerge($this->img,$bkgimg,$x,$y,0,0,$bw,$bh,$this->background_image_mix);
+        imagecopymerge($this->img,$bkgimg,(int) ($x),(int) ($y),0,0,(int) ($bw),(int) ($bh),(int) ($this->background_image_mix));
     }
 
     function AddMix($aGraph,$x=0,$y=0,$mix=100,$fx=0,$fy=0,$w=0,$h=0) {
--- a/intranet/jpgraph/src/jpgraph_stock.php
+++ b/intranet/jpgraph/src/jpgraph_stock.php
@@ -20,7 +20,7 @@
     //---------------
     // CONSTRUCTOR
     function __construct($datay,$datax=false) {
-        if( count($datay) % $this->iTupleSize ) {
+        if( count(($datay ?? [])) % $this->iTupleSize ) {
             JpGraphError::RaiseL(21001,$this->iTupleSize);
             //('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.');
         }
@@ -63,8 +63,8 @@
         $n=$this->numpoints;
         if( $this->center ) $n--;
         if( isset($this->coords[1]) ) {
-            if( count($this->coords[1])!=$n ) {
-                JpGraphError::RaiseL(2003,count($this->coords[1]),$n);
+            if( count(($this->coords[1] ?? []))!=$n ) {
+                JpGraphError::RaiseL(2003,count(($this->coords[1] ?? [])),$n);
                 // ("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
             }
             else {
--- a/intranet/jpgraph/src/jpgraph_gradient.php
+++ b/intranet/jpgraph/src/jpgraph_gradient.php
@@ -176,7 +176,7 @@
                 min(255,$from_color[1]+$m), min(255,$from_color[2]+$m));
 
                 $this->GetColArray($from_color2,$to_color,$steps1,$colors,$this->numcolors);
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Line($x,$yb,$x,$yt);
@@ -190,7 +190,7 @@
                 }
                 $steps = abs($xr-$xl)-$steps1-$steps2;
                 $this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($i=0; $i < $steps && $i < $n; ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Line($x,$yb,$x,$yt);
@@ -203,7 +203,7 @@
                 $delta = $xr>=$xl ? 1 : -1;
 
                 $this->GetColArray($from_color,$to_color,$steps1,$colors,$this->numcolors);
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Line($x,$yb,$x,$yt);
@@ -224,7 +224,7 @@
 
                 $steps = abs($xr-$xl)-$steps1-$steps2;
                 $this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($i=0; $i < $steps && $i < $n; ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Line($x,$yb,$x,$yt);
@@ -238,7 +238,7 @@
                 $dx = ($xr-$xl)/2;
                 $dy = ($yb-$yt)/2;
                 $x=$xl;$y=$yt;$x2=$xr;$y2=$yb;
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($x=$xl, $i=0; $x < $xl+$dx && $y < $yt+$dy && $i < $n; ++$x, ++$y, --$x2, --$y2, ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Rectangle($x,$y,$x2,$y2);
@@ -251,7 +251,7 @@
                 $steps1 = $xr-$xl;
                 $delta = $xr>=$xl ? 1 : -1;
                 $this->GetColArray($to_color,$from_color,$steps1,$colors,$this->numcolors);
-                $n = count($colors);
+                $n = count(($colors ?? []));
                 for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
                     $this->img->current_color = $colors[$i];
                     $this->img->Line($x,$yb,$x,$yt);
@@ -281,7 +281,7 @@
                     $steps = $xr-$xl;
                     $delta = $xr>=$xl ? 1 : -1;
                     $this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
-                    $n = count($colors);
+                    $n = count(($colors ?? []));
 
                     for($x=$xl, $i=0; $i < $steps && $i < $n; ++$i) {
                         $this->img->current_color = $colors[$i];
@@ -301,7 +301,7 @@
                     $steps = $yb-$yt;
                     $delta = $yb>=$yt ? 1 : -1;
                     $this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
-                    $n = count($colors);
+                    $n = count(($colors ?? []));
 
                     for($y=$yt, $i=0; $i < $steps && $i < $n; ++$i) {
                         $this->img->current_color = $colors[$i];
@@ -333,11 +333,11 @@
     // routine. It assumes that the bottom is flat (like a drawing
     // of a mountain)
     function FilledFlatPolygon($pts,$from_color,$to_color) {
-        if( count($pts) == 0 ) return;
+        if( count(($pts ?? [])) == 0 ) return;
 
         $maxy=$pts[1];
         $miny=$pts[1];
-        $n = count($pts) ;
+        $n = count(($pts ?? [])) ;
         for( $i=0, $idx=0; $i < $n; $i += 2) {
             $x = round($pts[$i]);
             $y = round($pts[$i+1]);
@@ -351,7 +351,7 @@
             $colmap[$i] = $colors[$idx++];
         }
 
-        $n = count($pts)/2 ;
+        $n = count(($pts ?? []))/2 ;
         $idx = 0 ;
         while( $idx < $n-1 ) {
             $p1 = array(round($pts[$idx*2]),round($pts[$idx*2+1]));
--- a/intranet/jpgraph/src/jpgraph_led.php
+++ b/intranet/jpgraph/src/jpgraph_led.php
@@ -275,18 +275,18 @@
             $aColor = 0;
         }
 
-        if(($n = mb_strlen($aValStr,'utf8')) == 0) {
+        if(($n = mb_strlen(($aValStr ?? ''),'utf8')) == 0) {
             $aValStr = ' ';
             $n = 1;
         }
 
         for($i = 0; $i < $n; ++$i) {
-            $d = mb_substr($aValStr, $i, 1, 'utf8');
+            $d = mb_substr(($aValStr ?? ''), $i, 1, 'utf8');
             if(  ctype_digit($d) ) {
                 $d = (int)$d;
             }
             else {
-               $d = strtoupper($d);
+               $d = strtoupper(($d ?? ''));
             }
             $digit_img[$i] = $this->_GetLED($d, $aColor);
         }
--- a/intranet/jpgraph/src/jpgraph_polar.php
+++ b/intranet/jpgraph/src/jpgraph_polar.php
@@ -46,7 +46,7 @@
     private $coord=null;
 
     function __construct($aData) {
-        $n = count($aData);
+        $n = count(($aData ?? []));
         if( $n & 1 ) {
             JpGraphError::RaiseL(17001);
             //('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).');
@@ -223,7 +223,7 @@
         // Stroke the minor arcs
         $pmin = array();
         $p = $this->scale->ticks->ticks_pos;
-        $n = count($p);
+        $n = count(($p ?? []));
         $i = 0;
         $this->img->SetColor($this->gridminor_color);
         while( $i < $n ) {
@@ -265,7 +265,7 @@
             else {
                 $step=9;
             }
-            $n = round(count($pmin)/$step);
+            $n = round(count(($pmin ?? []))/$step);
             $i = 0;
             $this->img->SetColor($this->gridmajor_color);
             $limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ;
@@ -529,7 +529,7 @@
         // Mirror the positions for the left side of the scale
         //
         $mid = 2*($this->img->left_margin+$this->img->plotwidth/2);
-        $n = count($this->scale->ticks->ticks_pos);
+        $n = count(($this->scale->ticks->ticks_pos ?? []));
         $i=0;
         while( $i < $n ) {
             $this->scale->ticks->ticks_pos[$i] =
@@ -537,7 +537,7 @@
             ++$i;
         }
 
-        $n = count($this->scale->ticks->maj_ticks_pos);
+        $n = count(($this->scale->ticks->maj_ticks_pos ?? []));
         $i=0;
         while( $i < $n ) {
             $this->scale->ticks->maj_ticks_pos[$i] =
@@ -545,7 +545,7 @@
             ++$i;
         }
 
-        $n = count($this->scale->ticks->maj_ticklabels_pos);
+        $n = count(($this->scale->ticks->maj_ticklabels_pos ?? []));
         $i=1;
         while( $i < $n ) {
             $this->scale->ticks->maj_ticklabels_pos[$i] =
@@ -554,7 +554,7 @@
         }
 
         // Draw the left side of the scale
-        $n = count($this->scale->ticks->ticks_pos);
+        $n = count(($this->scale->ticks->ticks_pos ?? []));
         $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMinTickAbsSize();
 
 
@@ -568,7 +568,7 @@
             }
         }
 
-        $n = count($this->scale->ticks->maj_ticks_pos);
+        $n = count(($this->scale->ticks->maj_ticks_pos ?? []));
         $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMajTickAbsSize();
 
 
@@ -734,7 +734,7 @@
 
     // Private methods
     function GetPlotsMax() {
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         $m = $this->plots[0]->Max();
         $i=1;
         while($i < $n) {
@@ -765,7 +765,7 @@
         $this->iHasStroked = true;
 
         //Check if we should autoscale axis
-        if( !$this->scale->IsSpecified() && count($this->plots)>0 ) {
+        if( !$this->scale->IsSpecified() && count(($this->plots ?? []))>0 ) {
             $max = $this->GetPlotsMax();
             $t1 = $this->img->plotwidth;
             $this->img->plotwidth /= 2;
@@ -816,7 +816,7 @@
         }
 
         // Stroke all plots for Y1 axis
-        for($i=0; $i < count($this->plots); ++$i) {
+        for($i=0; $i < count(($this->plots ?? [])); ++$i) {
             $this->plots[$i]->Stroke($this->img,$this->scale);
         }
 
@@ -863,7 +863,7 @@
             $this->StrokeTitles();
         }
 
-        for($i=0; $i < count($this->plots) ; ++$i ) {
+        for($i=0; $i < count(($this->plots ?? [])) ; ++$i ) {
             $this->plots[$i]->Legend($this);
         }
 
--- a/intranet/jpgraph/src/jpgraph_line.php
+++ b/intranet/jpgraph/src/jpgraph_line.php
@@ -35,7 +35,7 @@
 
     //---------------
     // CONSTRUCTOR
-    function LinePlot($datay,$datax=false) {
+    function __construct($datay,$datax=false) {
         parent::__construct($datay,$datax);
         $this->mark = new PlotMark() ;
         $this->color = ColorFactory::getColor();
@@ -144,7 +144,7 @@
         // An optimized stroke for many data points with no extra
         // features but 60% faster. You can't have values or line styles, or null
         // values in plots.
-        $numpoints=count($this->coords[0]);
+        $numpoints=count(($this->coords[0] ?? []));
         if( $this->barcenter ) {
             $textadj = 0.5-$xscale->text_scale_off;
         }
@@ -183,10 +183,10 @@
 
     function Stroke($img,$xscale,$yscale) {
         $idx=0;
-        $numpoints=count($this->coords[0]);
+        $numpoints=count(($this->coords[0] ?? []));
         if( isset($this->coords[1]) ) {
-            if( count($this->coords[1])!=$numpoints ) {
-                JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
+            if( count(($this->coords[1] ?? []))!=$numpoints ) {
+                JpGraphError::RaiseL(2003,count(($this->coords[1] ?? [])),$numpoints);
             //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
             }
             else {
@@ -381,7 +381,7 @@
                 // Remove first and last coordinate before drawing the line
                 // sine we otherwise get the vertical start and end lines which
                 // doesn't look appropriate
-                $img->Polygon(array_slice($cord,2,count($cord)-4));
+                $img->Polygon(array_slice($cord,2,count(($cord ?? []))-4));
             }
         }
 
@@ -474,7 +474,7 @@
     // CONSTRUCTOR
     function __construct($plots) {
         $this->plots = $plots;
-        $this->nbrplots = count($plots);
+        $this->nbrplots = count(($plots ?? []));
         $this->numpoints = $plots[0]->numpoints;
 
         // Verify that all plots have the same number of data points
@@ -500,9 +500,9 @@
     function Max() {
         list($xmax) = $this->plots[0]->Max();
         $nmax=0;
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n; ++$i) {
-            $nc = count($this->plots[$i]->coords[0]);
+            $nc = count(($this->plots[$i]->coords[0] ?? []));
             $nmax = max($nmax,$nc);
             list($x) = $this->plots[$i]->Max();
             $xmax = Max($xmax,$x);
@@ -526,9 +526,9 @@
     function Min() {
         $nmax=0;
         list($xmin,$ysetmin) = $this->plots[0]->Min();
-        $n = count($this->plots);
+        $n = count(($this->plots ?? []));
         for($i=0; $i < $n; ++$i) {
-            $nc = count($this->plots[$i]->coords[0]);
+            $nc = count(($this->plots[$i]->coords[0] ?? []));
             $nmax = max($nmax,$nc);
             list($x,$y) = $this->plots[$i]->Min();
             $xmin = Min($xmin,$x);
@@ -582,7 +582,7 @@
     // will be replaced by the the first valid data point
     function LineInterpolate(&$aData) {
 
-        $n=count($aData);
+        $n=count(($aData ?? []));
         $i=0;
 
         // If first point is undefined we will set it to the same as the first
@@ -651,7 +651,7 @@
     // since this method would have a side effect.
     function Stroke($img,$xscale,$yscale) {
         $img->SetLineWeight($this->weight);
-        $this->numpoints = count($this->plots[0]->coords[0]);
+        $this->numpoints = count(($this->plots[0]->coords[0] ?? []));
         // Allocate array
         $coords[$this->nbrplots][$this->numpoints]=0;
         for($i=0; $i<$this->numpoints; $i++) {
--- a/intranet/jpgraph/src/jpgraph_text.inc.php
+++ b/intranet/jpgraph/src/jpgraph_text.inc.php
@@ -14,6 +14,7 @@
 // CLASS Text
 // Description: Arbitrary text object that can be added to the graph
 //===================================================
+#[\AllowDynamicProperties]
 class Text {
     public $t;
     public $x=0,$y=0,$halign="left",$valign="top",$color=array(0,0,0);
@@ -288,12 +289,12 @@
 
         // Create CSIM targets
         $coords = $bbox[0].','.$bbox[1].','.$bbox[2].','.$bbox[3].','.$bbox[4].','.$bbox[5].','.$bbox[6].','.$bbox[7];
-        $this->iCSIMarea = "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->iCSIMtarget)."\" ";
-        if( trim($this->iCSIMalt) != '' ) {
+        $this->iCSIMarea = "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities(($this->iCSIMtarget ?? ''))."\" ";
+        if( trim(($this->iCSIMalt ?? '')) != '' ) {
             $this->iCSIMarea .= " alt=\"".$this->iCSIMalt."\" ";
             $this->iCSIMarea .= " title=\"".$this->iCSIMalt."\" ";
         }
-        if( trim($this->iCSIMWinTarget) != '' ) {
+        if( trim(($this->iCSIMWinTarget ?? '')) != '' ) {
             $this->iCSIMarea .= " target=\"".$this->iCSIMWinTarget."\" ";
         }
         $this->iCSIMarea .= " />\n";
@@ -303,9 +304,9 @@
 
     function __get($name) {
 
-        if (strpos($name, 'raw_') !== false) {
+        if (strpos(($name ?? ''), 'raw_') !== false) {
             // if $name == 'raw_left_margin' , return $this->_left_margin;
-            $variable_name = '_' . str_replace('raw_', '', $name);
+            $variable_name = '_' . str_replace('raw_', '', ($name ?? ''));
             return $this->$variable_name;
         }
 
--- a/intranet/jpgraph/src/jpgraph_flags.php
+++ b/intranet/jpgraph/src/jpgraph_flags.php
@@ -267,7 +267,7 @@
     private $iFlagData ;
     private $iOrdIdx=array();
 
-    function FlagImages($aSize=FLAGSIZE1) {
+    function __construct($aSize=FLAGSIZE1) {
         switch($aSize) {
             case FLAGSIZE1 :
             case FLAGSIZE2 :
@@ -282,7 +282,7 @@
                 JpGraphError::RaiseL(5001,$aSize);
                 //('Unknown flag size. ('.$aSize.')');
         }
-        $this->iFlagCount = count($this->iCountryNameMap);
+        $this->iFlagCount = count(($this->iCountryNameMap ?? []));
     }
 
     function GetNum() {
@@ -307,12 +307,12 @@
 
     function GetIdxByOrdinal($aOrd,&$outFullName) {
         $aOrd--;
-        $n = count($this->iOrdIdx);
+        $n = count(($this->iOrdIdx ?? []));
         if( $n == 0 ) {
             reset($this->iCountryNameMap);
             $this->iOrdIdx=array();
             $i=0;
-            while( list($key,$val) = each($this->iCountryNameMap) ) {
+            foreach ($this->iCountryNameMap as $key => $val) {
                 $this->iOrdIdx[$i++] = array($val,$key);
             }
             $tmp=$this->iOrdIdx[$aOrd];
@@ -339,12 +339,12 @@
         }
 
         $found=false;
-        $aName = strtolower($aName);
-        $nlen = strlen($aName);
+        $aName = strtolower(($aName ?? ''));
+        $nlen = strlen(($aName ?? ''));
         reset($this->iCountryNameMap);
         // Start by trying to match exact index name
-        while( list($key,$val) = each($this->iCountryNameMap) ) {
-            if( $nlen == strlen($val) && $val == $aName )  {
+        foreach ($this->iCountryNameMap as $key => $val) {
+            if( $nlen == strlen(($val ?? '')) && $val == $aName )  {
                 $found=true;
                 break;
             }
@@ -352,8 +352,8 @@
         if( !$found ) {
             reset($this->iCountryNameMap);
             // If the exact index doesn't work try a (partial) full name
-            while( list($key,$val) = each($this->iCountryNameMap) ) {
-                if( strpos(strtolower($key), $aName) !== false ) {
+            foreach ($this->iCountryNameMap as $key => $val) {
+                if( strpos((strtolower(($key ?? '')) ?? ''), ($aName ?? '')) !== false ) {
                     $found=true;
                     break;
                 }
--- a/intranet/jpgraph/src/jpgraph_utils.inc.php
+++ b/intranet/jpgraph/src/jpgraph_utils.inc.php
@@ -318,7 +318,7 @@
     }
 
     static function GetTicks($aData,$aType=1,$aMinor=false,$aEndPoints=false) {
-        $n = count($aData);
+        $n = count(($aData ?? []));
         return self::GetTicksFromMinMax($aData[0],$aData[$n-1],$aType,$aMinor,$aEndPoints);
     }
 
@@ -343,12 +343,12 @@
             array($spy, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',4,DSUTILS_DAY4,'d M',7,DSUTILS_WEEK1,$w,14,DSUTILS_WEEK2,$w,30,DSUTILS_MONTH1,'M',60,DSUTILS_MONTH2,'M',-1,DSUTILS_MONTH3,'M')),
             array(-1, array(30,DSUTILS_MONTH1,'M-Y',60,DSUTILS_MONTH2,'M-Y',90,DSUTILS_MONTH3,'M-Y',180,DSUTILS_MONTH6,'M-Y',352,DSUTILS_YEAR1,'Y',704,DSUTILS_YEAR2,'Y',-1,DSUTILS_YEAR5,'Y')));
 
-        $ntt = count($tt);
+        $ntt = count(($tt ?? []));
         $nd = floor($diff/$spd);
         for($i=0; $i < $ntt; ++$i ) {
             if( $diff <= $tt[$i][0] || $i==$ntt-1) {
                 $t = $tt[$i][1];
-                $n = count($t)/3;
+                $n = count(($t ?? []))/3;
                 for( $j=0; $j < $n; ++$j ) {
                     if( $nd/$t[3*$j] <= $aMaxTicks || $j==$n-1) {
                         $type = $t[3*$j+1];
@@ -432,7 +432,7 @@
 
         // Now make sure that all data is numeric. By default
         // all data is read as strings
-        $n = count($tmp);
+        $n = count(($tmp ?? []));
         $aData = array();
         $cnt=0;
         for($i=0; $i < $n; ++$i) {
@@ -502,10 +502,10 @@
         }
 
         $num_lines = 0;
-        $num_cols  = count($aLine);
+        $num_cols  = count(($aLine ?? []));
 
         while ($aLine !== false) {
-            if( is_array($aLine) && count($aLine) != $num_cols ) {
+            if( is_array($aLine) && count(($aLine ?? [])) != $num_cols ) {
                 JpGraphError::RaiseL(24004);
                 // 'ReadCSV2: Column count mismatch in %s line %d'
             }
@@ -552,12 +552,12 @@
                         $s = '/[\s]*;[\s]*/';
         }
         foreach( $lines as $line => $datarow ) {
-                $split = preg_split($s,$datarow);
-                $aCol1[] = floatval(trim($split[0]));
-                $aCol2[] = floatval(trim($split[1]));
-        }
-
-        return count($lines);
+                $split = preg_split(($s ?? ''),($datarow ?? ''));
+                $aCol1[] = floatval(trim(($split[0] ?? '')));
+                $aCol2[] = floatval(trim(($split[1] ?? '')));
+        }
+
+        return count(($lines ?? []));
     }
 
     // Read data from one columns in a plain text file
@@ -567,10 +567,10 @@
                 return false;
         }
         foreach( $lines as $line => $datarow ) {
-                $aCol1[] = floatval(trim($datarow));
-        }
-
-        return count($lines);
+                $aCol1[] = floatval(trim(($datarow ?? '')));
+        }
+
+        return count(($lines ?? []));
     }
 
     static function FromMatrix($aFile,$aSepChar=' ') {
@@ -581,9 +581,9 @@
         $mat = array();
         $reg = '/'.$aSepChar.'/';
         foreach( $lines as $line => $datarow ) {
-                $row = preg_split($reg,trim($datarow));
+                $row = preg_split(($reg ?? ''),(trim(($datarow ?? '')) ?? ''));
                 foreach ($row as $key => $cell ) {
-                        $row[$key] = floatval(trim($cell));
+                        $row[$key] = floatval(trim(($cell ?? '')));
                 }
                 $mat[] = $row;
         }
@@ -604,7 +604,7 @@
         public $iDet=0, $iCorr=0, $iStdErr=0;
 
         public function __construct($aDataX,$aDataY) {
-                if( count($aDataX) !== count($aDataY) ) {
+                if( count(($aDataX ?? [])) !== count(($aDataY ?? [])) ) {
                         JpGraph::Raise('LinearRegression: X and Y data array must be of equal length.');
                 }
                 $this->ix = $aDataX;
@@ -615,7 +615,7 @@
 
                 $this->icalculated = true;
 
-                $n = count($this->ix);
+                $n = count(($this->ix ?? []));
                 $sx2 = 0 ;
                 $sy2 = 0 ;
                 $sxy = 0 ;
--- a/intranet/jpgraph/src/jpgraph_meshinterpolate.inc.php
+++ b/intranet/jpgraph/src/jpgraph_meshinterpolate.inc.php
@@ -72,8 +72,8 @@
     function Linear( &$aData, $aIntFactor ) {
         $step = pow( 2, $aIntFactor-1 );
 
-        $orig_cols = count( $aData[0] );
-        $orig_rows = count( $aData );
+        $orig_cols = count( ($aData[0] ?? []) );
+        $orig_rows = count( ($aData ?? []) );
         // Number of new columns/rows
         // N = (a-1) * 2^(f-1) + 1
         $p = pow( 2, $aIntFactor-1 );
--- a/intranet/jpgraph/src/jpgraph_errhandler.inc.php
+++ b/intranet/jpgraph/src/jpgraph_errhandler.inc.php
@@ -155,7 +155,7 @@
     	}
         $errobj->Raise($this->getMessage());
     }
-    static public function defaultHandler(Exception $exception) {
+    static public function defaultHandler(\Throwable $exception) {
         global $__jpg_OldHandler;
         if( $exception instanceof JpGraphException ) {
             $exception->Stroke();
@@ -290,7 +290,7 @@
         $lines = substr_count($aMsg,"\n");
 
         // Create the error icon GD
-        $erricon = Image::CreateFromString(base64_decode($img_iconerror));
+        $erricon = Image::CreateFromString(base64_decode(($img_iconerror ?? '')));
 
         // Create an image that contains the error text.
         $w=400;
--- a/intranet/jpgraph/src/jpgraph_theme.inc.php
+++ b/intranet/jpgraph/src/jpgraph_theme.inc.php
@@ -19,6 +19,9 @@
 // Description: 
 //===================================================
 abstract class Theme {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $graph;
+
     protected $color_index;
     
     function __construct() {
@@ -87,7 +90,7 @@
   
         $i = 0;
         while (true) {
-            for ($j = 0; $j < count($this->GetColorList()); $j++) {
+            for ($j = 0; $j < count(($this->GetColorList() ?? [])); $j++) {
                 if (++$count > $num) {
                     break 2;
                 }
@@ -111,7 +114,7 @@
         if (isset($color_list[$this->color_index])) {
             $color = $color_list[$this->color_index];
         } else {
-            $color_count = count($color_list);
+            $color_count = count(($color_list ?? []));
             if ($color_count <= $this->color_index) {
                 $color_tmp = $color_list[$this->color_index % $color_count];
                 $brightness = 1.0 - intval($this->color_index / $color_count) * 0.2;
--- a/intranet/jpgraph/src/jpgraph_log.php
+++ b/intranet/jpgraph/src/jpgraph_log.php
@@ -131,7 +131,7 @@
     private $ticklabels_pos = array();
     //---------------
     // CONSTRUCTOR
-    function LogTicks() {
+    function __construct() {
     }
     //---------------
     // PUBLIC METHODS
--- a/intranet/jpgraph/src/jpgraph_gantt.php
+++ b/intranet/jpgraph/src/jpgraph_gantt.php
@@ -1,4 +1,5 @@
 <?php
+require_once __DIR__ . '/../../core/legacy-date-format.php';
 /*=======================================================================
  // File:        JPGRAPH_GANTT.PHP
  // Description: JpGraph Gantt plot extension
@@ -198,7 +199,7 @@
     }
 
     function SetMinColWidth($aWidths) {
-        $n = min(count($this->iTitles),count($aWidths));
+        $n = min(count(($this->iTitles ?? [])),count(($aWidths ?? [])));
         for($i=0; $i < $n; ++$i ) {
             if( !empty($aWidths[$i]) ) {
                 if( empty($this->iWidth[$i]) ) {
@@ -214,7 +215,7 @@
     function GetWidth($aImg) {
         $txt = new TextProperty();
         $txt->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
-        $n = count($this->iTitles) ;
+        $n = count(($this->iTitles ?? [])) ;
         $rm=$this->iRightColMargin;
         $w = 0;
         for($h=0, $i=0; $i < $n; ++$i ) {
@@ -236,7 +237,7 @@
     }
 
     function GetColStart($aImg,&$aStart,$aAddLeftMargin=false) {
-        $n = count($this->iTitles) ;
+        $n = count(($this->iTitles ?? [])) ;
         $adj = $aAddLeftMargin ? $this->iLeftColMargin : 0;
         $aStart=array($aImg->left_margin+$adj);
         for( $i=1; $i < $n; ++$i ) {
@@ -257,7 +258,7 @@
         $txt->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
         $txt->SetColor($this->iFontColor);
         $txt->SetAlign($this->iHeaderAlign,'top');
-        $n=count($this->iTitles);
+        $n=count(($this->iTitles ?? []));
 
         if( $n == 0 )
         return;
@@ -314,7 +315,7 @@
         // Stroke vertical column dividers
         $cols=array();
         $this->GetColStart($aImg,$cols);
-        $n=count($cols);
+        $n=count(($cols ?? []));
         for( $i=1; $i < $n; ++$i ) {
             $this->vgrid->Stroke($aImg,$cols[$i],$aYBottom,$cols[$i],
             $aImg->height - $aImg->bottom_margin);
@@ -382,7 +383,7 @@
 
     // A utility function to help create basic Gantt charts
     function CreateSimple($data,$constrains=array(),$progress=array()) {
-        $num = count($data);
+        $num = count(($data ?? []));
         for( $i=0; $i < $num; ++$i) {
             switch( $data[$i][1] ) {
                 case ACTYPE_GROUP:
@@ -412,9 +413,9 @@
                     $a->SetPattern($this->iSimpleStyle,$this->iSimpleColor);
                     $a->SetFillColor($this->iSimpleBkgColor);
                     // Check if this activity should have a constrain line
-                    $n = count($constrains);
+                    $n = count(($constrains ?? []));
                     for( $j=0; $j < $n; ++$j ) {
-                        if( empty($constrains[$j]) || (count($constrains[$j]) != 3) ) {
+                        if( empty($constrains[$j]) || (count(($constrains[$j] ?? [])) != 3) ) {
                             JpGraphError::RaiseL(6003,$j);
                             //("Invalid format for Constrain parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)");
                         }
@@ -424,10 +425,10 @@
                     }
 
                     // Check if this activity have a progress bar
-                    $n = count($progress);
+                    $n = count(($progress ?? []));
                     for( $j=0; $j < $n; ++$j ) {
 
-                        if( empty($progress[$j]) || (count($progress[$j]) != 2) ) {
+                        if( empty($progress[$j]) || (count(($progress[$j] ?? [])) != 2) ) {
                             JpGraphError::RaiseL(6004,$j);
                             //("Invalid format for Progress parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)");
                         }
@@ -496,7 +497,7 @@
 
     // Add a new Gantt object
     function Add($aObject) {
-        if( is_array($aObject) && count($aObject) > 0 ) {
+        if( is_array($aObject) && count(($aObject ?? [])) > 0 ) {
             $cl = $aObject[0];
             if( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) {
                 $this->AddIcon($aObject);
@@ -505,7 +506,7 @@
             	$this->AddText($aObject);
             }
             else {
-                $n = count($aObject);
+                $n = count(($aObject ?? []));
                 for($i=0; $i < $n; ++$i)
                 $this->iObj[] = $aObject[$i];
             }
@@ -526,7 +527,7 @@
 	function StrokeTexts() {
         // Stroke any user added text objects
         if( $this->texts != null ) {
-        	$n = count($this->texts);
+        	$n = count(($this->texts ?? []));
             for($i=0; $i < $n; ++$i) {
             	if( $this->texts[$i]->iScalePosX !== null && $this->texts[$i]->iScalePosY !== null ) {
             		$x = $this->scale->TranslateDate($this->texts[$i]->iScalePosX);
@@ -552,9 +553,9 @@
     function SetDateRange($aStart,$aEnd) {
         // Adjust the start and end so that the indicate the
         // begining and end of respective start and end days
-        if( strpos($aStart,':') === false )
+        if( strpos(($aStart ?? ''),':') === false )
         $aStart = date('Y-m-d 00:00',strtotime($aStart));
-        if( strpos($aEnd,':') === false )
+        if( strpos(($aEnd ?? ''),':') === false )
         $aEnd = date('Y-m-d 23:59',strtotime($aEnd));
         $this->scale->SetRange($aStart,$aEnd);
     }
@@ -567,7 +568,7 @@
         $m=10;
         if( $this->iObj != null ) {
             $marg = $this->scale->actinfo->iLeftColMargin+$this->scale->actinfo->iRightColMargin;
-            $n = count($this->iObj);
+            $n = count(($this->iObj ?? []));
             for($i=0; $i < $n; ++$i) {
                 if( !empty($this->iObj[$i]->title) ) {
                     if( $this->iObj[$i]->title->HasTabs() ) {
@@ -586,7 +587,7 @@
     function GetMaxLabelHeight() {
         $m=10;
         if( $this->iObj != null ) {
-            $n = count($this->iObj);
+            $n = count(($this->iObj ?? []));
             // We can not include the title of GnttVLine since that title is stroked at the bottom
             // of the Gantt bar and not in the activity title columns
             for($i=0; $i < $n; ++$i) {
@@ -602,7 +603,7 @@
         $m=0;
         if( $this->iObj != null ) {
             $m = $this->iObj[0]->GetAbsHeight($this->img);
-            $n = count($this->iObj);
+            $n = count(($this->iObj ?? []));
             for($i=1; $i < $n; ++$i) {
                 $m=max($m,$this->iObj[$i]->GetAbsHeight($this->img));
             }
@@ -615,7 +616,7 @@
         $m=1;
         if( $this->iObj != null ) {
             $m = $this->iObj[0]->GetLineNbr();
-            $n = count($this->iObj);
+            $n = count(($this->iObj ?? []));
             for($i=1; $i < $n; ++$i) {
                 $m=max($m,$this->iObj[$i]->GetLineNbr());
             }
@@ -626,7 +627,7 @@
     // Get the minumum and maximum used dates for all bars
     function GetBarMinMax() {
         $start = 0 ;
-        $n = count($this->iObj);
+        $n = count(($this->iObj ?? []));
         while( $start < $n && $this->iObj[$start]->GetMaxDate() === false )
         ++$start;
         if( $start >= $n ) {
@@ -677,7 +678,7 @@
 
             // If there are any added GanttVLine we must make sure that the
             // bottom margin is wide enough to hold a title.
-            $n = count($this->iObj);
+            $n = count(($this->iObj ?? []));
         	for($i=0; $i < $n; ++$i) {
             	if( $this->iObj[$i] instanceof GanttVLine ) {
 					$bm = max($bm,$this->iObj[$i]->title->GetHeight($this->img)+10);
@@ -855,7 +856,7 @@
             if( $this->scale->IsDisplayWeek() ) {
                 // Depending on what format the user has choose we need different amount
                 // of space
-                $fsw = strlen($this->scale->week->iLabelFormStr);
+                $fsw = strlen(($this->scale->week->iLabelFormStr ?? ''));
                 if( $this->scale->week->iStyle==WEEKSTYLE_FIRSTDAY2WNBR ) {
                     $fsw += 8;
                 }
@@ -929,14 +930,14 @@
     // to find out the maximum width of each column. In order to do that we
     // must walk through all the objects, sigh...
     function GetMaxActInfoColWidth() {
-        $n = count($this->iObj);
+        $n = count(($this->iObj ?? []));
         if( $n == 0 ) return;
         $w = array();
         $m = $this->scale->actinfo->iLeftColMargin + $this->scale->actinfo->iRightColMargin;
 
         for( $i=0; $i < $n; ++$i ) {
             $tmp = $this->iObj[$i]->title->GetColWidth($this->img,$m);
-            $nn = count($tmp);
+            $nn = count(($tmp ?? []));
             for( $j=0; $j < $nn; ++$j ) {
                 if( empty($w[$j]) )
                 $w[$j] = $tmp[$j];
@@ -1007,7 +1008,7 @@
         // Stroke Grid line
         $this->hgrid->Stroke($this->img,$this->scale);
 
-        $n = count($this->iObj);
+        $n = count(($this->iObj ?? []));
         for($i=0; $i < $n; ++$i) {
             //$this->iObj[$i]->SetLabelLeftMargin(round($maxwidth*$this->iLabelHMarginFactor/2));
             $this->iObj[$i]->Stroke($this->img,$this->scale);
@@ -1056,7 +1057,7 @@
     }
 
     function StrokeConstrains() {
-        $n = count($this->iObj);
+        $n = count(($this->iObj ?? []));
 
         // Stroke all constrains
         for($i=0; $i < $n; ++$i) {
@@ -1065,7 +1066,7 @@
             // for example we can add IconPlots which doesn't have this property.
             if( empty($this->iObj[$i]->constraints) ) continue;
 
-            $numConstrains = count($this->iObj[$i]->constraints);
+            $numConstrains = count(($this->iObj[$i]->constraints ?? []));
 
             for( $k = 0; $k < $numConstrains; $k++ ) {
                 $vpos = $this->iObj[$i]->constraints[$k]->iConstrainRow;
@@ -1084,7 +1085,7 @@
                         //('You have specifed a constrain from row='.$this->iObj[$i]->iVPos.' to row='.$vpos.' which does not have any activity.');
                     }
                     $c2 = $this->iObj[$targetobj]->iConstrainPos;
-                    if( count($c1) == 4 && count($c2 ) == 4) {
+                    if( count(($c1 ?? [])) == 4 && count(($c2 ?? []) ) == 4) {
                         switch( $this->iObj[$i]->constraints[$k]->iConstrainType ) {
                             case CONSTRAIN_ENDSTART:
                                 if( $c1[1] < $c2[1] ) {
@@ -1147,7 +1148,7 @@
         $csim .= $this->subtitle->GetCSIMAreas();
         $csim .= $this->subsubtitle->GetCSIMAreas();
 
-        $n = count($this->iObj);
+        $n = count(($this->iObj ?? []));
         for( $i=$n-1; $i >= 0; --$i )
         $csim .= $this->iObj[$i]->GetCSIMArea();
         return $csim;
@@ -1184,7 +1185,7 @@
             JpGraphError::RaiseL(6010,$aIdx);
             //('Illegal icon index for Gantt builtin icon ['.$aIdx.']');
         }
-        return Image::CreateFromString(base64_decode($this->iBuiltinIcon[$aIdx][1]));
+        return Image::CreateFromString(base64_decode(($this->iBuiltinIcon[$aIdx][1] ?? '')));
     }
 
     function __construct() {
@@ -1464,7 +1465,7 @@
      'bGUHIAIuydTIE5zfc5Wr4lJcahHnHTP3CVGm78DrgY38N+DEibp7dmYKdAQmBh1hjEFjis+9CTWYGK21H6PxPyOI0DobYwzZF/z7'.
      '7jadTvJtYG0kCD7lfwl49ijgT1gc0AH+dZSJA/xB+Mz/GSIvFoj/B7H1mAd8CO/zAAAAAElFTkSuQmCC' ;
 
-        $this->iLen = count($this->iBuiltinIcon);
+        $this->iLen = count(($this->iBuiltinIcon ?? []));
     }
 }
 
@@ -1628,7 +1629,7 @@
     }
 
     function SetColumnFonts($aFontArray) {
-        if( !is_array($aFontArray) || count($aFontArray[0]) != 3 ) {
+        if( !is_array($aFontArray) || count(($aFontArray[0] ?? [])) != 3 ) {
             JpGraphError::RaiseL(6033);
             // 'Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)'
         }
@@ -1647,15 +1648,15 @@
         $extra_margin=4;
         $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
         if( is_string($this->iText) ) {
-            if( strlen($this->iText) == 0 ) return 0;
-            $tmp = preg_split('/\t/',$this->iText);
-            if( count($tmp) <= 1 || !$aUseTabs ) {
+            if( strlen(($this->iText ?? '')) == 0 ) return 0;
+            $tmp = preg_split('/\t/',($this->iText ?? ''));
+            if( count(($tmp ?? [])) <= 1 || !$aUseTabs ) {
                 $w = $aImg->GetTextWidth($this->iText);
                 return $w + 2*$extra_margin;
             }
             else {
                 $tot=0;
-                $n = count($tmp);
+                $n = count(($tmp ?? []));
                 for($i=0; $i < $n; ++$i) {
                     $res[$i] = $aImg->GetTextWidth($tmp[$i]);
                     $tot += $res[$i]*$aTabExtraMargin;
@@ -1670,8 +1671,8 @@
         elseif( is_array($this->iText) ) {
             // Must be an array of texts. In this case we return the sum of the
             // length + a fixed margin of 4 pixels on each text string
-            $n = count($this->iText);
-            $nf = count($this->iFontArray);
+            $n = count(($this->iText ?? []));
+            $nf = count(($this->iFontArray ?? []));
             for( $i=0, $w=0; $i < $n; ++$i ) {
                 if( $i < $nf ) {
                     $aImg->SetFont($this->iFontArray[$i][0],$this->iFontArray[$i][1],$this->iFontArray[$i][2]);
@@ -1703,8 +1704,8 @@
     function GetColWidth($aImg,$aMargin=0) {
         $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
         if( is_array($this->iText) ) {
-            $n = count($this->iText);
-            $nf = count($this->iFontArray);
+            $n = count(($this->iText ?? []));
+            $nf = count(($this->iFontArray ?? []));
             for( $i=0, $w=array(); $i < $n; ++$i ) {
                 $tmp = $this->iText[$i];
                 if( is_string($tmp) ) {
@@ -1732,7 +1733,7 @@
 
     // Get total height of text
     function GetHeight($aImg) {
-        $nf = count($this->iFontArray);
+        $nf = count(($this->iFontArray ?? []));
         $maxheight = -1;
 
         if( $nf > 0 ) {
@@ -1770,7 +1771,7 @@
                     if( is_array($aY) ) $aY=$aY[0];
                     $aImg->StrokeText($aX,$aY,$this->iText);
                 }
-                elseif( is_array($this->iText) && ($n = count($this->iText)) > 0 ) {
+                elseif( is_array($this->iText) && ($n = count(($this->iText ?? []))) > 0 ) {
                     $ax = is_array($aX) ;
                     $ay = is_array($aY) ;
                     if( $ax && $ay ) {
@@ -1786,31 +1787,31 @@
                         $aX = array_fill(0,$n,$aX);
                         $aY = array_fill(0,$n,$aY);
                     }
-                    $n = min($n, count($aX) ) ;
-                    $n = min($n, count($aY) ) ;
+                    $n = min($n, count(($aX ?? [])) ) ;
+                    $n = min($n, count(($aY ?? [])) ) ;
                     for($i=0; $i < $n; ++$i ) {
                         $tmp = $this->iText[$i];
                         if( is_object($tmp) ) {
                             $tmp->Stroke($aImg,$aX[$i],$aY[$i]);
                         }
                         else {
-                            if( $i < count($this->iFontArray) ) {
+                            if( $i < count(($this->iFontArray ?? [])) ) {
                                 $font = $this->iFontArray[$i];
                                 $aImg->SetFont($font[0],$font[1],$font[2]);
                             }
                             else {
                                 $aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
                             }
-                        	$aImg->StrokeText($aX[$i],$aY[$i],str_replace("\t"," ",$tmp));
+                        	$aImg->StrokeText($aX[$i],$aY[$i],str_replace("\t"," ",($tmp ?? '')));
                         }
                     }
                 }
             }
             else {
-                $tmp = preg_split('/\t/',$this->iText);
-                $n = min(count($tmp),count($aX));
+                $tmp = preg_split('/\t/',($this->iText ?? ''));
+                $n = min(count(($tmp ?? [])),count(($aX ?? [])));
                 for($i=0; $i < $n; ++$i) {
-                    if( $i < count($this->iFontArray) ) {
+                    if( $i < count(($this->iFontArray ?? [])) ) {
                         $font = $this->iFontArray[$i];
                         $aImg->SetFont($font[0],$font[1],$font[2]);
                     }
@@ -2128,8 +2129,8 @@
         }
 
         // Get day in week for start and ending date (Sun==0)
-        $ds=strftime("%w",$this->iStartDate);
-        $de=strftime("%w",$this->iEndDate);
+        $ds=prowinch_format_legacy_date("%w",$this->iStartDate);
+        $de=prowinch_format_legacy_date("%w",$this->iEndDate);
 
         // We want to start on iWeekStart day. But first we subtract a week
         // if the startdate is "behind" the day the week start at.
@@ -2216,11 +2217,11 @@
 
     // Get week number
     function GetWeekNbr($aDate,$aSunStart=true) {
-        // We can't use the internal strftime() since it gets the weeknumber
+        // We can't use the internal prowinch_format_legacy_date() since it gets the weeknumber
         // wrong since it doesn't follow ISO on all systems since this is
         // system linrary dependent.
         // Even worse is that this works differently if we are on a Windows
-        // or UNIX box (it even differs between UNIX boxes how strftime()
+        // or UNIX box (it even differs between UNIX boxes how prowinch_format_legacy_date()
         // is natively implemented)
         //
         // Credit to Nicolas Hoizey <nhoizey@phpheaven.net> for this elegant
@@ -2278,17 +2279,17 @@
 
     // Get day in month
     function GetMonthDayNbr($aDate) {
-        return 0+strftime("%d",$aDate);
+        return 0+prowinch_format_legacy_date("%d",$aDate);
     }
 
     // Get day in year
     function GetYearDayNbr($aDate) {
-        return 0+strftime("%j",$aDate);
+        return 0+prowinch_format_legacy_date("%j",$aDate);
     }
 
     // Get month number
     function GetMonthNbr($aDate) {
-        return 0+strftime("%m",$aDate);
+        return 0+prowinch_format_legacy_date("%m",$aDate);
     }
 
     // Translate a date to screen coordinates (horizontal scale)
@@ -2366,15 +2367,15 @@
 
     function TimeToMinutes($aTimeString) {
         // Split in hours and minutes
-        $pos=strpos($aTimeString,':');
+        $pos=strpos(($aTimeString ?? ''),':');
         $minint=60;
         if( $pos === false ) {
             $hourint = $aTimeString;
             $minint = 0;
         }
         else {
-            $hourint = floor(substr($aTimeString,0,$pos));
-            $minint = floor(substr($aTimeString,$pos+1));
+            $hourint = floor(substr(($aTimeString ?? ''),0,$pos));
+            $minint = floor(substr(($aTimeString ?? ''),$pos+1));
         }
         $minint += 60 * $hourint;
         return $minint;
@@ -2599,64 +2600,64 @@
                     $x+$daywidth,$yb-$this->day->iFrameWeight);
                 }
 
-                $mn = strftime('%m',$datestamp);
+                $mn = prowinch_format_legacy_date('%m',$datestamp);
                 if( $mn[0]=='0' )
                     $mn = $mn[1];
 
                 switch( $this->day->iStyle ) {
                     case DAYSTYLE_LONG:
                         // "Monday"
-                        $txt = strftime('%A',$datestamp);
+                        $txt = prowinch_format_legacy_date('%A',$datestamp);
                         break;
                     case DAYSTYLE_SHORT:
                         // "Mon"
-                        $txt = strftime('%a',$datestamp);
+                        $txt = prowinch_format_legacy_date('%a',$datestamp);
                         break;
                     case DAYSTYLE_SHORTDAYDATE1:
                         // "Mon 23/6"
-                        $txt = strftime('%a %d/'.$mn,$datestamp);
+                        $txt = prowinch_format_legacy_date('%a %d/'.$mn,$datestamp);
                         break;
                     case DAYSTYLE_SHORTDAYDATE2:
                         // "Mon 23 Jun"
-                        $txt = strftime('%a %d %b',$datestamp);
+                        $txt = prowinch_format_legacy_date('%a %d %b',$datestamp);
                         break;
                     case DAYSTYLE_SHORTDAYDATE3:
                         // "Mon 23 Jun 2003"
-                        $txt = strftime('%a %d %b %Y',$datestamp);
+                        $txt = prowinch_format_legacy_date('%a %d %b %Y',$datestamp);
                         break;
                     case DAYSTYLE_LONGDAYDATE1:
                         // "Monday 23 Jun"
-                        $txt = strftime('%A %d %b',$datestamp);
+                        $txt = prowinch_format_legacy_date('%A %d %b',$datestamp);
                         break;
                     case DAYSTYLE_LONGDAYDATE2:
                         // "Monday 23 Jun 2003"
-                        $txt = strftime('%A %d %b %Y',$datestamp);
+                        $txt = prowinch_format_legacy_date('%A %d %b %Y',$datestamp);
                         break;
                     case DAYSTYLE_SHORTDATE1:
                         // "23/6"
-                        $txt = strftime('%d/'.$mn,$datestamp);
+                        $txt = prowinch_format_legacy_date('%d/'.$mn,$datestamp);
                         break;
                     case DAYSTYLE_SHORTDATE2:
                         // "23 Jun"
-                        $txt = strftime('%d %b',$datestamp);
+                        $txt = prowinch_format_legacy_date('%d %b',$datestamp);
                         break;
                     case DAYSTYLE_SHORTDATE3:
                         // "Mon 23"
-                        $txt = strftime('%a %d',$datestamp);
+                        $txt = prowinch_format_legacy_date('%a %d',$datestamp);
                         break;
                     case DAYSTYLE_SHORTDATE4:
                         // "23"
-                        $txt = strftime('%d',$datestamp);
+                        $txt = prowinch_format_legacy_date('%d',$datestamp);
                         break;
                     case DAYSTYLE_CUSTOM:
                         // Custom format
-                        $txt = strftime($this->day->iLabelFormStr,$datestamp);
+                        $txt = prowinch_format_legacy_date($this->day->iLabelFormStr,$datestamp);
                         break;
                     case DAYSTYLE_ONELETTER:
                     default:
                         // "M"
-                        $txt = strftime('%A',$datestamp);
-                        $txt = strtoupper($txt[0]);
+                        $txt = prowinch_format_legacy_date('%A',$datestamp);
+                        $txt = strtoupper(($txt[0] ?? ''));
                         break;
                 }
 
@@ -2808,7 +2809,7 @@
 
             $img->SetLineWeight($this->month->grid->iWeight);
             $img->SetColor($this->month->iTextColor);
-            $year = 0+strftime("%Y",$this->iStartDate);
+            $year = 0+prowinch_format_legacy_date("%Y",$this->iStartDate);
             $img->SetTextAlign("center");
             if( $this->GetMonthNbr($this->iStartDate) == $this->GetMonthNbr($this->iEndDate)
                 && $this->GetYear($this->iStartDate)==$this->GetYear($this->iEndDate) ) {
@@ -3063,12 +3064,12 @@
 
     function SetCSIMTarget($aTarget,$aAlt='',$aWinTarget='') {
         if( !is_string($aTarget) ) {
-            $tv = substr(var_export($aTarget,true),0,40);
+            $tv = substr((var_export($aTarget,true) ?? ''),0,40);
             JpGraphError::RaiseL(6024,$tv);
             //('CSIM Target must be specified as a string.'."\nStart of target is:\n$tv");
         }
         if( !is_string($aAlt) ) {
-            $tv = substr(var_export($aAlt,true),0,40);
+            $tv = substr((var_export($aAlt,true) ?? ''),0,40);
             JpGraphError::RaiseL(6025,$tv);
             //('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
         }
@@ -3080,7 +3081,7 @@
 
     function SetCSIMAlt($aAlt) {
         if( !is_string($aAlt) ) {
-            $tv = substr(var_export($aAlt,true),0,40);
+            $tv = substr((var_export($aAlt,true) ?? ''),0,40);
             JpGraphError::RaiseL(6025,$tv);
             //('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
         }
@@ -3264,7 +3265,7 @@
         if( is_string($aEnd) ) {
             // If end date has been specified without a time we will asssume
             // end date is at the end of that date
-            if( strpos($aEnd,':') === false ) {
+            if( strpos(($aEnd ?? ''),':') === false ) {
             	$this->iEnd = strtotime($aEnd)+SECPERDAY-1;
             }
             else {
@@ -3372,7 +3373,7 @@
             $colwidth = $this->title->GetColWidth($aImg);
             $colstarts=array();
             $aScale->actinfo->GetColStart($aImg,$colstarts,true);
-            $n = min(count($colwidth),count($this->title->csimtarget));
+            $n = min(count(($colwidth ?? [])),count(($this->title->csimtarget ?? [])));
             for( $i=0; $i < $n; ++$i ) {
                 $title_xt = $colstarts[$i];
                 $title_xb = $title_xt + $colwidth[$i];
@@ -3559,7 +3560,7 @@
             $colwidth = $this->title->GetColWidth($aImg);
             $colstarts=array();
             $aScale->actinfo->GetColStart($aImg,$colstarts,true);
-            $n = min(count($colwidth),count($this->title->csimtarget));
+            $n = min(count(($colwidth ?? [])),count(($this->title->csimtarget ?? [])));
             for( $i=0; $i < $n; ++$i ) {
                 $title_xt = $colstarts[$i];
                 $title_xb = $title_xt + $colwidth[$i];
--- a/intranet/jpgraph/src/jpgraph_table.php
+++ b/intranet/jpgraph/src/jpgraph_table.php
@@ -215,8 +215,8 @@
     }
 
     function SetAlign($aHorAlign='left',$aVertAlign='bottom') {
-        $aHorAlign = strtolower($aHorAlign);
-        $aVertAlign = strtolower($aVertAlign);
+        $aHorAlign = strtolower(($aHorAlign ?? ''));
+        $aVertAlign = strtolower(($aVertAlign ?? ''));
         $chk = array('left','right','center','bottom','top','middle');
         if( !in_array($aHorAlign,$chk) || !in_array($aVertAlign,$chk) ) {
             JpGraphError::RaiseL(27011,$aHorAlign,$aVertAlign);
@@ -607,11 +607,11 @@
         if( $aArg2===NULL && $aArg3===NULL ) {
             if( is_array($aArg1) ) {
                 if( is_array($aArg1[0]) ) {
-                    $m = count($aArg1);
+                    $m = count(($aArg1 ?? []));
                     // Find the longest row
                     $n=0;
                     for($i=0; $i < $m; ++$i)
-                    $n = max(count($aArg1[$i]),$n);
+                    $n = max(count(($aArg1[$i] ?? [])),$n);
                     for($i=0; $i < $m; ++$i) {
                         for($j=0; $j < $n; ++$j) {
                             if( isset($aArg1[$i][$j]) ){
@@ -1238,7 +1238,7 @@
         // adjust row and column size depending on cell content
         $this->_autoSizeTable($aImg);
 
-        if( $this->iSize[1] != count($this->iColWidth) || $this->iSize[0] != count($this->iRowHeight) ) {
+        if( $this->iSize[1] != count(($this->iColWidth ?? [])) || $this->iSize[0] != count(($this->iRowHeight ?? [])) ) {
             JpGraphError::RaiseL(27008);
             //('Column and row size arrays must match the dimesnions of the table');
         }
@@ -1256,7 +1256,7 @@
         // Adjust the X,Y position to alway be at the top left corner
         // The anchor position, i.e. how the client want to interpret the specified
         // x and y coordinate must be taken into account
-        switch( strtolower($this->iXAnchor) ) {
+        switch( strtolower(($this->iXAnchor ?? '')) ) {
             case 'left' :
                 break;
             case 'center':
@@ -1266,7 +1266,7 @@
                 $this->iXPos -= $width;
                 break;
         }
-        switch( strtolower($this->iYAnchor) ) {
+        switch( strtolower(($this->iYAnchor ?? '')) ) {
             case 'top' :
                 break;
             case 'center':
--- a/intranet/jpgraph/src/jpgraph_antispam-digits.php
+++ b/intranet/jpgraph/src/jpgraph_antispam-digits.php
@@ -171,7 +171,7 @@
 
     function Stroke() {
 
-        $n=strlen($this->iNumber);
+        $n=strlen(($this->iNumber ?? ''));
         for($i=0; $i < $n; ++$i ) {
             if( !is_numeric($this->iNumber[$i]) || $this->iNumber[$i]==0 ) {
                 return false;
@@ -179,23 +179,23 @@
         }
 
         $dd = new HandDigits();
-        $n = strlen($this->iNumber);
-        $img = @imagecreatetruecolor($n*$dd->iWidth, $dd->iHeight);
+        $n = strlen(($this->iNumber ?? ''));
+        $img = @imagecreatetruecolor((int) ($n*$dd->iWidth), (int) ($dd->iHeight));
         if( $img < 1 ) {
             return false;
         }
         $start=0;
         for($i=0; $i < $n; ++$i ) {
             $size = $dd->digits[$this->iNumber[$i]][0];
-            $dimg = imagecreatefromstring(base64_decode($dd->digits[$this->iNumber[$i]][1]));
-            imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $dd->iHeight);
+            $dimg = imagecreatefromstring(base64_decode(($dd->digits[$this->iNumber[$i]][1] ?? '')));
+            imagecopy($img,$dimg,(int) ($start),0,0,0,(int) (imagesx($dimg)), (int) ($dd->iHeight));
             $start += imagesx($dimg);
         }
-        $resimg = @imagecreatetruecolor($start+4, $dd->iHeight+4);
+        $resimg = @imagecreatetruecolor((int) ($start+4), (int) ($dd->iHeight+4));
         if( $resimg < 1 ) {
             return false;
         }
-        imagecopy($resimg,$img,2,2,0,0,$start, $dd->iHeight);
+        imagecopy($resimg,$img,2,2,0,0,(int) ($start), (int) ($dd->iHeight));
         header("Content-type: image/jpeg");
         imagejpeg($resimg);
         return true;
--- a/intranet/jpgraph/src/barcode/mkbarcode.php
+++ b/intranet/jpgraph/src/barcode/mkbarcode.php
@@ -18,7 +18,7 @@
 class ParseArgs {
     var $argc,$argv;
 
-    function ParseArgs() {
+    function __construct() {
         // Get command line argument
         $this->argv = ($_SERVER['argv']);
         $this->argc = ($_SERVER['argc']);
@@ -146,12 +146,12 @@
         	exit(1);
         }
 
-        if( strlen($filename) > 256 ) {
+        if( strlen(($filename ?? '')) > 256 ) {
         	fwrite(STDERR,"Too long filename\n");
         	exit(1);
         }
 
-        if( trim($data) == '' ) {
+        if( trim(($data ?? '')) == '' ) {
 			fwrite(STDERR,"No input data specified\n");
 			exit(1);
         }
@@ -170,7 +170,7 @@
             'CODABAR' => ENCODING_CODABAR,
             'BOOKLAND' => ENCODING_BOOKLAND,
         );
-        $barcode = strtoupper($barcode);
+        $barcode = strtoupper(($barcode ?? ''));
         if( key_exists($barcode,$barcodes) ) {
         	$barcode = $barcodes[$barcode];
         }
--- a/intranet/jpgraph/src/barcode/examples/barcode_usps_example.php
+++ b/intranet/jpgraph/src/barcode/examples/barcode_usps_example.php
@@ -11,24 +11,24 @@
 // "Ship to/Deliver To Postal Code (within single authority)
 //
 class USPS_Confirmation {
-    function USPS_Confirmation() {
+    function __construct() {
     }
 
     // Private utility function
     function _USPS_chkd($aData) {
-	$n = strlen($aData);
+	$n = strlen(($aData ?? ''));
 
 	// Add all even numbers starting from position 1 from the end
 	$et = 0 ;
 	for( $i=1; $i <= $n; $i+=2 ) {
-	    $d = intval(substr($aData,-$i,1));
+	    $d = intval(substr(($aData ?? ''),-$i,1));
 	    $et += $d;
 	}
 
 	// Add all odd numbers starting from position 2 from the end
 	$ot = 0 ;
 	for( $i=2; $i <= $n; $i+=2 ) {
-	    $d = intval(substr($aData,-$i,1));
+	    $d = intval(substr(($aData ?? ''),-$i,1));
 	    $ot += $d;
 	}
 	$tot = 3*$et + $ot;
@@ -42,7 +42,7 @@
 	$data = '420'. $aZIP . '91' . $aServiceType . $aDUNS . $aSeqNbr;
 	// Only calculate the checkdigit from the AI=91 and forward
 	// and do not include the ~1 (FUNC1) in the calculation
-	$cd = $this->_USPS_chkd(substr($data,8));
+	$cd = $this->_USPS_chkd(substr(($data ?? ''),8));
 	$data = '420'. $aZIP . '~191' . $aServiceType . $aDUNS . $aSeqNbr;
 	return $data . $cd;
     }
--- a/intranet/jpgraph/src/Examples/ganttex30.php
+++ b/intranet/jpgraph/src/Examples/ganttex30.php
@@ -61,7 +61,7 @@
         $bar->rightMark->SetWidth(10);
 
         // Title for the mark
-        $bar->rightMark->title->Set("".$i+1);
+        $bar->rightMark->title->Set("".($i+1));
         $bar->rightMark->title->SetColor("white");
         $bar->rightMark->title->SetFont(FF_ARIAL,FS_BOLD,10);
         $bar->rightMark->Show();
--- a/intranet/jpgraph/src/Examples/balloonex2.php
+++ b/intranet/jpgraph/src/Examples/balloonex2.php
@@ -15,7 +15,7 @@
 
 // We need to create X,Y data vectors suitable for the
 // library from the above raw data.
-$n = count($data);
+$n = count(($data ?? []));
 for( $i=0; $i < $n; ++$i ) {
     
     $datax[$i] = $data[$i][0];
--- a/intranet/jpgraph/src/Examples/sunspotsex3.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex3.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/dateaxisex1.php
+++ b/intranet/jpgraph/src/Examples/dateaxisex1.php
@@ -13,7 +13,7 @@
 for( $i=0; $i < 360; $i += 10 ) {
     $datax[] = $now + $i;
 }
-$n = count($datax);
+$n = count(($datax ?? []));
 $datay=array();
 for( $i=0; $i < $n; ++$i ) {
     $datay[] = rand(30,150);
--- a/intranet/jpgraph/src/Examples/testsuit.php
+++ b/intranet/jpgraph/src/Examples/testsuit.php
@@ -20,7 +20,7 @@
     private $iType;
     private $iDir;
 
-    function TestDriver($aType=1,$aDir='') {
+    function __construct($aType=1,$aDir='') {
 	$this->iType = $aType;
 	if( $aDir == '' ) {
 	    $aDir = getcwd();
@@ -40,7 +40,7 @@
 	    }
 	}
 	$d->Close();
-	if( count($a) == 0 ) {
+	if( count(($a ?? [])) == 0 ) {
 	    die("PANIC: Apache/PHP does not have enough permission to read the scripts in directory: $this->iDir");	    
 	}
 	sort($a);
@@ -56,7 +56,7 @@
 	    }
 	}
 	$d->Close();
-	if( count($a) == 0 ) {
+	if( count(($a ?? [])) == 0 ) {
 	    die("PANIC: Apache/PHP does not have enough permission to read the CSIM scripts in directory: $this->iDir");	    
 	}
 	sort($a);
@@ -76,7 +76,7 @@
 		die('Panic: Unknown type of test');
 		break;
 	}
-	$n = count($files);
+	$n = count(($files ?? []));
 	echo "<h2>Visual test suit for JpGraph</h2>";
 	echo "Testtype: " . ($this->iType==1 ? ' Standard images ':' Image map tests ');
 	echo "<br>Number of tests: $n<p>";
@@ -84,10 +84,10 @@
 	
 	for( $i=0; $i<$n; ++$i ) {
 	    if( $this->iType ==1 ) {
-	    echo '<li><a href="show-example.php?target='.urlencode($files[$i]).'"><img src="'.$files[$i].'" border=0 align=top></a><br><strong>Filename:</strong> <i>'.basename($files[$i])."</i>\n";
+	    echo '<li><a href="show-example.php?target='.urlencode(($files[$i] ?? '')).'"><img src="'.$files[$i].'" border=0 align=top></a><br><strong>Filename:</strong> <i>'.basename($files[$i])."</i>\n";
 	    }
 	    else {
-		echo '<li><a href="show-example.php?target='.urlencode($files[$i]).'">'.$files[$i]."</a>\n";
+		echo '<li><a href="show-example.php?target='.urlencode(($files[$i] ?? '')).'">'.$files[$i]."</a>\n";
 	    }
 	}
 	echo "</ol>";
--- a/intranet/jpgraph/src/Examples/barcode_usps_example.php
+++ b/intranet/jpgraph/src/Examples/barcode_usps_example.php
@@ -11,24 +11,24 @@
 // "Ship to/Deliver To Postal Code (within single authority)
 //
 class USPS_Confirmation {
-    function USPS_Confirmation() {
+    function __construct() {
     }
 
     // Private utility function
     function _USPS_chkd($aData) {
-	$n = strlen($aData);
+	$n = strlen(($aData ?? ''));
 
 	// Add all even numbers starting from position 1 from the end
 	$et = 0 ;
 	for( $i=1; $i <= $n; $i+=2 ) {
-	    $d = intval(substr($aData,-$i,1));
+	    $d = intval(substr(($aData ?? ''),-$i,1));
 	    $et += $d;
 	}
 
 	// Add all odd numbers starting from position 2 from the end
 	$ot = 0 ;
 	for( $i=2; $i <= $n; $i+=2 ) {
-	    $d = intval(substr($aData,-$i,1));
+	    $d = intval(substr(($aData ?? ''),-$i,1));
 	    $ot += $d;
 	}
 	$tot = 3*$et + $ot;
@@ -42,7 +42,7 @@
 	$data = '420'. $aZIP . '91' . $aServiceType . $aDUNS . $aSeqNbr;
 	// Only calculate the checkdigit from the AI=91 and forward
 	// and do not include the ~1 (FUNC1) in the calculation
-	$cd = $this->_USPS_chkd(substr($data,8));
+	$cd = $this->_USPS_chkd(substr(($data ?? ''),8));
 	$data = '420'. $aZIP . '~191' . $aServiceType . $aDUNS . $aSeqNbr;
 	return $data . $cd;
     }
--- a/intranet/jpgraph/src/Examples/sunspotsex7.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex7.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/sunspotsex2.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex2.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/checkgd2.php
+++ b/intranet/jpgraph/src/Examples/checkgd2.php
@@ -5,10 +5,10 @@
 $darkgreen = imagecolorallocate ($im,  80, 140, 80);
 $white = imagecolorallocate ($im,  255, 255, 255);
 
-imagefilledrectangle ($im,0,0,299,199 ,$lightgray);
-imagerectangle ($im,0,0,299,199,$black);
-imagefilledellipse ($im,150,100,210,110,$white);
-imagefilledellipse ($im,150,100,200,100,$darkgreen);
+imagefilledrectangle ($im,0,0,299,199 ,(int) ($lightgray));
+imagerectangle ($im,0,0,299,199,(int) ($black));
+imagefilledellipse ($im,150,100,210,110,(int) ($white));
+imagefilledellipse ($im,150,100,200,100,(int) ($darkgreen));
 header ("Content-type: image/png");
 imagepng ($im);
 ?>
--- a/intranet/jpgraph/src/Examples/mkgrad.php
+++ b/intranet/jpgraph/src/Examples/mkgrad.php
@@ -20,7 +20,7 @@
 class Form {
     var $iColors;
     var $iGradstyles;
-    function Form() {
+    function __construct() {
 
 	$rgb = new RGB();
 	$this->iColors = array_keys($rgb->rgb_table);
@@ -76,7 +76,7 @@
 	    $txt .= " size=$size >";
 	else 
 	    $txt .= ">";
-	for($i=0; $i<count($option); $i++) {
+	for($i=0; $i<count(($option ?? [])); $i++) {
 	    if( $selected==$option[$i] )
 		$txt=$txt."<option selected value=\"$option[$i]\">$option[$i]</option>\n";		
 	    else
@@ -91,7 +91,7 @@
 	    $txt .= " size=$size >";
 	else 
 	    $txt .= ">";
-	for($i=0; $i<count($option); $i += 2) {
+	for($i=0; $i<count(($option ?? [])); $i += 2) {
 	    if( $selected==$option[($i+1)] )
 		$txt=$txt."<option selected value=".$option[($i+1)].">$option[$i]</option>\n";		
 	    else
@@ -105,13 +105,17 @@
 // Basic application driver
 
 class Driver {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $graph;
+    public $grad;
+
     var $iGraph, $iGrad;
     var $iWidth,$iHeight;
     var $iFromColor, $iToColor;
     var $iStyle;
     var $iForm;
 
-    function Driver() {
+    function __construct() {
 	$this->iForm = new Form();
     }
 
@@ -149,7 +153,7 @@
 
     function Run() {
 	
-	global $HTTP_POST_VARS;
+	global $_POST;
 
 	// Two modes:
 	// 1) If the script is called with no posted arguments
--- a/intranet/jpgraph/src/Examples/sunspotsex5.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex5.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/ccbpgraph.class.php
+++ b/intranet/jpgraph/src/Examples/ccbpgraph.class.php
@@ -82,12 +82,12 @@
     * of each color indicator
     */
 	public function SetColorIndication(array $aSpec,array $aColors=null) {
-		if( count($aSpec) !== 3 ) {
+		if( count(($aSpec ?? [])) !== 3 ) {
 			JpgraphError::Raise('Specification of scale values for background indicators must be an array with three elements.');
 		}
 		$this->iColorInd = $aSpec;	
 		if( $aColors !== null ) {
-            if( is_array($aColors) && count($aColors) == 4 ) {
+            if( is_array($aColors) && count(($aColors ?? [])) == 4 ) {
 			    $this->iColorSpec = $aColors;
             }
             else {
@@ -248,7 +248,7 @@
     */
 	public function Stroke($aFile='') {
 		$this->Init();
-        if( count($this->iPlots) > 0 )  {
+        if( count(($this->iPlots ?? [])) > 0 )  {
 		    $this->graph->Add($this->iPlots);
         }
 		$this->graph->Stroke($aFile);
--- a/intranet/jpgraph/src/Examples/barlinefreq_csimex1.php
+++ b/intranet/jpgraph/src/Examples/barlinefreq_csimex1.php
@@ -14,7 +14,7 @@
     $s = array_sum($data);
     $as = array($data[0]);
     $asp = array(100*$as[0]/$s);
-    $n = count($data);
+    $n = count(($data ?? []));
     for( $i=1; $i < $n; ++$i ) {
 	$as[$i] = $as[$i-1]+$data[$i];
 	$asp[$i] = 100.0*$as[$i]/$s;
--- a/intranet/jpgraph/src/Examples/colormaps.php
+++ b/intranet/jpgraph/src/Examples/colormaps.php
@@ -51,7 +51,7 @@
 	        $cm->SetMap($mapidx,$aReverse);
 	        $n = $cm->SetNumColors($n);
 	        list( $mapidx, $maparray ) = $cm->GetCurrMap();
-	        $ncols = count($maparray);
+	        $ncols = count(($maparray ?? []));
 	        $colbuckets = $cm->GetBuckets();
 
 	        // The module width will depend on the actual number of colors
--- a/intranet/jpgraph/src/Examples/sunspotsex6.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex6.php
@@ -10,9 +10,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/inyaxisex1.php
+++ b/intranet/jpgraph/src/Examples/inyaxisex1.php
@@ -11,7 +11,7 @@
 $ydata = array(0,1,4,5,8,9,10,14,16,16,16,18,20,20,20,22,22.5,22,19,19,15,15,15,15,10,10,10,6,5,5,5,4,4,2,1,0);
 
 // Negate all data
-$n = count($ydata);
+$n = count(($ydata ?? []));
 for($i=0; $i<$n; ++$i) {
     $ydata[$i] = round(-$ydata[$i]);
 }
--- a/intranet/jpgraph/src/Examples/barlinefreqex1.php
+++ b/intranet/jpgraph/src/Examples/barlinefreqex1.php
@@ -13,7 +13,7 @@
     $s = array_sum($data);
     $as = array($data[0]);
     $asp = array(100*$as[0]/$s);
-    $n = count($data);
+    $n = count(($data ?? []));
     for( $i=1; $i < $n; ++$i ) {
 	$as[$i] = $as[$i-1]+$data[$i];
 	$asp[$i] = 100.0*$as[$i]/$s;
--- a/intranet/jpgraph/src/Examples/inyaxisex2.php
+++ b/intranet/jpgraph/src/Examples/inyaxisex2.php
@@ -11,7 +11,7 @@
 $ydata = array(0,1,4,5,8,9,10,14,16,16,16,18,20,20,20,22,22.5,22,19,19,15,15,15,15,10,10,10,6,5,5,5,4,4,2,1,0);
 
 // Negate all data
-$n = count($ydata);
+$n = count(($ydata ?? []));
 for($i=0; $i<$n; ++$i) {
     $ydata[$i] = round(-$ydata[$i]);
 }
--- a/intranet/jpgraph/src/Examples/example3.4.1.php
+++ b/intranet/jpgraph/src/Examples/example3.4.1.php
@@ -20,7 +20,7 @@
          $matches = intval($n / $value);
 
          // Store that many characters
-         $result .= str_repeat($roman, $matches);
+         $result .= str_repeat(($roman ?? ''), $matches);
 
          // Substract that from the number
          $n = $n % $value;
--- a/intranet/jpgraph/src/Examples/inyaxisex3.php
+++ b/intranet/jpgraph/src/Examples/inyaxisex3.php
@@ -10,14 +10,14 @@
 // A fake depth curve
 $ydata = array(0,1,4,5,8,9,10,14,16,16,16,18,20,20,20,22,22.5,22,19,19,15,15,15,15,10,10,10,6,5,5,5,4,4,2,1,0);
 
-$n = count($ydata);
+$n = count(($ydata ?? []));
 $y2data = array();
 for( $i=0; $i< $n; ++$i ) {
     $y2data[] = $ydata[$i]+10;
 }
 
 // Negate all data
-$n = count($ydata);
+$n = count(($ydata ?? []));
 for($i=0; $i<$n; ++$i) {
     $ydata[$i] = round(-$ydata[$i]);
     $y2data[$i] = round(-$y2data[$i]);
--- a/intranet/jpgraph/src/Examples/listallflags.php
+++ b/intranet/jpgraph/src/Examples/listallflags.php
@@ -12,7 +12,7 @@
 // Create a nice table wil all flags and their full name (and index)
 echo "<table width=100%><tr>\n";
 $cols=0;
-while( list($key,$val) = each($flags->iCountryNameMap) ) {
+foreach ($flags->iCountryNameMap as $key => $val) {
 
     echo '<td width=20%><a href="javascript:window.open(\'listallflags_helper.php?size=4&idx='.$val.'\',\'_new\',\'width=500,height=350\');void(0)"><img src="listallflags_helper.php?size='.$s.'&idx='.$val.'"></a><br>';
     echo "<small>$key</small><br><small><font color=blue><i>idx=$val</i></font></small></td>\n";
--- a/intranet/jpgraph/src/Examples/show-example.php
+++ b/intranet/jpgraph/src/Examples/show-example.php
@@ -1,4 +1,4 @@
-<?php $target = urldecode($_GET['target']); ?>
+<?php $target = urldecode(($_GET['target'] ?? '')); ?>
 <!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN">
 <html>
 <head>
--- a/intranet/jpgraph/src/Examples/checkgd.php
+++ b/intranet/jpgraph/src/Examples/checkgd.php
@@ -4,8 +4,8 @@
 $border_color = imagecolorallocate ($im, 50, 50, 50);
 $text_color = imagecolorallocate ($im, 233, 14, 91);
 
-imagerectangle($im,0,0,199,99,$border_color);
-imagestring ($im, 5, 10, 40, "a simple text string", $text_color );
+imagerectangle($im,0,0,199,99,(int) ($border_color));
+imagestring ($im, 5, 10, 40, "a simple text string", (int) ($text_color) );
 header ("content-type: image/png");
 imagepng ($im);
 ?>
--- a/intranet/jpgraph/src/Examples/sunspotsex1.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex1.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/sunspotsex4.php
+++ b/intranet/jpgraph/src/Examples/sunspotsex4.php
@@ -9,9 +9,9 @@
         throw new JpGraphException('Can not read sunspot data file.');
     }
     foreach( $lines as $line => $datarow ) {
-        $split = preg_split('/[\s]+/',$datarow);
-        $aYears[] = substr(trim($split[0]),0,4);
-        $aSunspots[] = trim($split[1]);
+        $split = preg_split('/[\s]+/',($datarow ?? ''));
+        $aYears[] = substr((trim(($split[0] ?? '')) ?? ''),0,4);
+        $aSunspots[] = trim(($split[1] ?? ''));
     }
 }
 
--- a/intranet/jpgraph/src/Examples/checkttf.php
+++ b/intranet/jpgraph/src/Examples/checkttf.php
@@ -13,9 +13,9 @@
 $black = imagecolorallocate ($im, 0, 0, 0);
 $border_color = imagecolorallocate ($im, 50, 50, 50);
 
-imagefilledrectangle($im,0,0,399,99,$white);
-imagerectangle($im,0,0,399,99,$border_color);
-imagettftext ($im, 30, 0, 90, 60, $black, TTF_DIR.TTF_FONTFILE,TTF_TEXT);
+imagefilledrectangle($im,0,0,399,99,(int) ($white));
+imagerectangle($im,0,0,399,99,(int) ($border_color));
+imagettftext ($im, 30, 0, 90, 60, (int) ($black), TTF_DIR.TTF_FONTFILE,TTF_TEXT);
 
 header ("Content-type: image/png");
 imagepng ($im);
--- a/intranet/xajax/tests/basicPluginTest.php
+++ b/intranet/xajax/tests/basicPluginTest.php
@@ -15,7 +15,7 @@
 {
 	var $sDefer;
 	
-	function testPlugin()
+	function __construct()
 	{
 		$this->sDefer = '';
 	}
--- a/intranet/xajax/tests/suite/theFrame.php
+++ b/intranet/xajax/tests/suite/theFrame.php
@@ -13,7 +13,7 @@
 	$xajax->configure('javascript URI', '../../');
 
 	class clsFunctions {
-		function clsFunctions() {
+		function __construct() {
 		}
 		
 		function confirm($seconds) {
--- a/intranet/xajax/tests/suite/delayEvents.php
+++ b/intranet/xajax/tests/suite/delayEvents.php
@@ -13,7 +13,7 @@
 	
 	class clsRequests
 	{
-		function clsRequests() {
+		function __construct() {
 		}
 		
 		function clearLog() {
@@ -85,7 +85,7 @@
 		'longdelays' => array('callback' => 'local.callback', 'mode' => '"synchronous"')
 		);
 
-	$objRequests =& new clsRequests();
+	$objRequests = new clsRequests();
 	$aRequests = $xajax->register(XAJAX_CALLABLE_OBJECT, $objRequests, $configuration);
 
 	$xajax->processRequest();
@@ -280,7 +280,7 @@
 			}
 			/* ]]> */
 		</style>
-<?
+<?php 
 	$objTestScriptPlugin->printHeader($xajax, "Callback Event Handlers", ob_get_clean(),"setupCallbacks();");
 	ob_start();
 ?>
@@ -311,7 +311,7 @@
 								</tr>
 							</tbody>
 						</table>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 	ob_start();
 ?>
@@ -383,7 +383,7 @@
 								</tr>
 							</tbody>
 						</table>
-<?
+<?php 
 	$objTestScriptPlugin->printStatusPanel(ob_get_clean());
 	$objTestScriptPlugin->printLogPanel();
 	$objTestScriptPlugin->printDescriptionPanel("
--- a/intranet/xajax/tests/suite/functions.php
+++ b/intranet/xajax/tests/suite/functions.php
@@ -11,7 +11,7 @@
 	require_once('./testScriptPlugin.inc.php');
 	
 	class clsRequests {
-		function clsRequests() {
+		function __construct() {
 		}
 		
 		function insertFunction() {
@@ -47,7 +47,7 @@
 		}
 	}
 	
-	$objRequests =& new clsRequests();
+	$objRequests = new clsRequests();
 	$aRequests = $xajax->register(XAJAX_CALLABLE_OBJECT, $objRequests);
 	
 	$xajax->processRequest();
@@ -112,7 +112,7 @@
 	$objTestScriptPlugin->printHeader($xajax, "Javascript Functions", ob_get_clean());
 ?>
 		<form id='mainForm' onsubmit='return false;'>
-<?
+<?php 
 ob_start();
 ?>
 							<table class=''>
@@ -142,7 +142,7 @@
 									</tr>
 								</tbody>
 							</table>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 ?>
 		</form>
--- a/intranet/xajax/tests/suite/index.php
+++ b/intranet/xajax/tests/suite/index.php
@@ -11,7 +11,7 @@
 
 	require("../../xajax_core/xajax.inc.php");
 
-	$xajax =& new xajax();
+	$xajax = new xajax();
 
 	$xajax->configure('javascript URI', '../../');
 //	$xajax->configure('deferScriptGeneration', true);
@@ -468,7 +468,7 @@
 	class clsRequests {
 		var $tests = array();
 
-		function clsRequests() {
+		function __construct() {
 			$this->tests['./none.php'] = '--- Select Test ---';
 			$this->tests['./alert_confirm.php'] = 'Alert and Confirm Commands';
 			$this->tests['./assign_append.php'] = 'Assign and Append';
--- a/intranet/xajax/tests/suite/tables.php
+++ b/intranet/xajax/tests/suite/tables.php
@@ -28,7 +28,7 @@
 	$objResponse = new xajaxResponse();
 	
 	class clsPage {
-		function clsPage() {
+		function __construct() {
 		}
 		
 		function generateTable() {
@@ -704,7 +704,7 @@
 			background: #ccccee;
 		}
 		</style>
-<?
+<?php 
 
 
 
@@ -721,7 +721,7 @@
 		<br />
 		<div id='content'></div>	
 	
-	<?
+	<?php 
 	$objTestScriptPlugin->printStatusPanel();
 	$objTestScriptPlugin->printLogPanel();
 	$objTestScriptPlugin->printDescriptionPanel();
--- a/intranet/xajax/tests/suite/iframe.php
+++ b/intranet/xajax/tests/suite/iframe.php
@@ -30,7 +30,7 @@
 	}
 	
 	class clsFunctions {
-		function clsFunctions() {
+		function __construct() {
 		}
 		
 		function showIsLoaded() {
--- a/intranet/xajax/tests/suite/pluginTest.php
+++ b/intranet/xajax/tests/suite/pluginTest.php
@@ -111,7 +111,7 @@
 	echo "<a href='" . $newRequestURI . "'>PHP5 (type 2)</a>";
 ?>
 </div>
-<?	
+<?php 	
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 	$objTestScriptPlugin->printStatusPanel();
 	$objTestScriptPlugin->printLogPanel();	
--- a/intranet/xajax/tests/suite/css.php
+++ b/intranet/xajax/tests/suite/css.php
@@ -15,7 +15,7 @@
 	$objResponse = new xajaxResponse();
 	
 	class clsFunctions {
-		function clsFunctions() {
+		function __construct() {
 		}
 		
 		function loadCSS1() {
@@ -212,7 +212,7 @@
 			}
 			/* ]]> */
 		</style>
-<?
+<?php 
 	$objTestScriptPlugin->printHeader($xajax, "Load / Unload CSS files",ob_get_clean());
 
 	ob_start();
@@ -241,7 +241,7 @@
 								</tr>
 							</tbody>
 						</table>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 
 	$objTestScriptPlugin->printStatusPanel();
--- a/intranet/xajax/tests/suite/transport.php
+++ b/intranet/xajax/tests/suite/transport.php
@@ -49,7 +49,7 @@
 			}
 			/* ]]> */
 		</script>
-<?
+<?php 
 	$objTestScriptPlugin->printHeader($xajax, "Character Encoding Test | xajax Tests", ob_get_clean());
 	ob_start();
 ?>
@@ -62,7 +62,7 @@
 			<p><input type="text" value="Enter test text here" id="textField1" name="textField1" size="60" /></p>
 			<p><input type="submit" value="Submit Text" onclick="<?php $testForm->printScript() ?>;" /></p>
 		</form>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 	$objTestScriptPlugin->printStatusPanel();
 	$objTestScriptPlugin->printLogPanel();
--- a/intranet/xajax/tests/suite/events.php
+++ b/intranet/xajax/tests/suite/events.php
@@ -71,9 +71,9 @@
 	{
 		var $aPartners;
 		
-		function clsMutuallyExclusiveButton($sId, $sName, $sValue)
-		{
-			xajaxControl::xajaxControl('input', array(
+		function __construct($sId, $sName, $sValue)
+		{
+			xajaxControl::__construct('input', array(
 				'attributes' => array(
 					'id' => $sId,
 					'type' => 'submit',
@@ -160,7 +160,7 @@
 	}
 
 	// one
-	$inputAddOne =& new clsMutuallyExclusiveButton('add_one', 'add_one', 'Add');
+	$inputAddOne = new clsMutuallyExclusiveButton('add_one', 'add_one', 'Add');
 	$inputAddOne->setEvent('onclick', 
 		$requestAdd, array(
 			array(0, XAJAX_QUOTED_VALUE, 'clicker'),
@@ -168,7 +168,7 @@
 			)
 		);
 	
-	$inputRemoveOne =& new clsMutuallyExclusiveButton('remove_one', 'remove_one', 'Remove');
+	$inputRemoveOne = new clsMutuallyExclusiveButton('remove_one', 'remove_one', 'Remove');
 	$inputRemoveOne->setEvent('onclick', 
 		$requestRemove, array(
 			array(0, XAJAX_QUOTED_VALUE, 'clicker'),
@@ -180,7 +180,7 @@
 	$inputRemoveOne->setAttribute('disabled', 'disabled');
 
 	// two
-	$inputAddTwo =& new clsMutuallyExclusiveButton('add_two', 'add_two', 'Add');
+	$inputAddTwo = new clsMutuallyExclusiveButton('add_two', 'add_two', 'Add');
 	$inputAddTwo->setEvent('onclick', 
 		$requestAdd, array(
 			array(0, XAJAX_QUOTED_VALUE, 'clicker'),
@@ -188,7 +188,7 @@
 			)
 		);
 	
-	$inputRemoveTwo =& new clsMutuallyExclusiveButton('remove_two', 'remove_two', 'Remove');
+	$inputRemoveTwo = new clsMutuallyExclusiveButton('remove_two', 'remove_two', 'Remove');
 	$inputRemoveTwo->setEvent('onclick', 
 		$requestRemove, array(
 			array(0, XAJAX_QUOTED_VALUE, 'clicker'),
@@ -248,7 +248,7 @@
 			white-space: nowrap;
 		}
 		</style>
-<?
+<?php 
 	$objTestScriptPlugin->printHeader($xajax, "Client-side Event Handlers", ob_get_clean());
 	ob_start();
 ?>		
@@ -280,7 +280,7 @@
 				</table>
 			</div>
 		</form>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 	$objTestScriptPlugin->printStatusPanel();
 	$objTestScriptPlugin->printLogPanel();
--- a/intranet/xajax/tests/suite/server_events.php
+++ b/intranet/xajax/tests/suite/server_events.php
@@ -56,12 +56,12 @@
 			/* <![CDATA[ */
 			/* ]]> */
 		</style>
-<?
+<?php 
 	$objTestScriptPlugin->printHeader($xajax, "Server-side Events", ob_get_clean());
 	ob_start();	
 ?>
 		<button onclick='alert("The event handlers returned ["+<?php $requestEvent->printScript(); ?>+"]");'>Fire event</button>
-<?
+<?php 
 	$objTestScriptPlugin->printControlPanel(ob_get_clean());
 	$objTestScriptPlugin->printStatusPanel();
 	$objTestScriptPlugin->printLogPanel();	
--- a/intranet/xajax/tests/suite/none.php
+++ b/intranet/xajax/tests/suite/none.php
@@ -1,4 +1,4 @@
-<?
+<?php 
 	require_once("./options.inc.php");
 	require_once('./testScriptPlugin.inc.php');
 
@@ -6,6 +6,6 @@
 	$objTestScriptPlugin->printHeader($xajax, "Xajax Test Suite");
 ?>
 		Please select the xajax options above, then select a test page from the drop down.
-<?
+<?php 
 
 	$objTestScriptPlugin->printFooter();	
--- a/intranet/xajax/tests/suite/testScriptPlugin.inc.php
+++ b/intranet/xajax/tests/suite/testScriptPlugin.inc.php
@@ -8,7 +8,7 @@
 		
 		Constructor
 	*/
-	function testScriptPlugin() {
+	function __construct() {
 		$this->bDeferScriptGeneration = false;
 	}
 
--- a/intranet/xajax/tests/suite/alert_confirm.php
+++ b/intranet/xajax/tests/suite/alert_confirm.php
@@ -42,7 +42,7 @@
 			
 			Constructor
 		*/
-		function clsPage() {
+		function __construct() {
 		}
 		
 		/*
--- a/intranet/xajax/tests/suite/assign_append.php
+++ b/intranet/xajax/tests/suite/assign_append.php
@@ -13,7 +13,7 @@
 	$objResponse = new xajaxResponse();
 	
 	class clsPage {
-		function clsPage() {
+		function __construct() {
 		}
 		
 		function sendAssignInnerHTML() {
--- a/intranet/xajax/tests/legacy_tests/jsLoadingTest.php
+++ b/intranet/xajax/tests/legacy_tests/jsLoadingTest.php
@@ -31,7 +31,7 @@
 $xajax->registerFunction("testForm");
 $xajax->processRequests();
 ?>
-<?xml version="1.0" encoding="UTF-8"?>
+<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
--- a/intranet/xajax/tests/legacy_tests/catchAllFunctionTest.php
+++ b/intranet/xajax/tests/legacy_tests/catchAllFunctionTest.php
@@ -46,7 +46,7 @@
 //$xajax->registerFunction("testForm");
 $xajax->processRequests();
 ?>
-<?xml version="1.0" encoding="UTF-8"?>
+<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
--- a/intranet/xajax/tests/legacy_tests/preFunctionTest.php
+++ b/intranet/xajax/tests/legacy_tests/preFunctionTest.php
@@ -67,7 +67,7 @@
 $xajax->registerFunction("testRegularFunction");
 $xajax->processRequests();
 ?>
-<?xml version="1.0" encoding="UTF-8"?>
+<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
--- a/intranet/xajax/xajax_core/legacy.inc.php
+++ b/intranet/xajax/xajax_core/legacy.inc.php
@@ -26,7 +26,7 @@
 }
 
 class legacyXajax extends xajax {
-	function legacyXajax($sRequestURI='', $sWrapperPrefix='xajax_', $sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bDebug=false)
+	function __construct($sRequestURI='', $sWrapperPrefix='xajax_', $sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bDebug=false)
 	{
 		parent::xajax();
 		$this->configure('requestURI', $sRequestURI);
@@ -36,7 +36,7 @@
 	}
 	function registerExternalFunction($mFunction, $sInclude)
 	{
-		$xuf =& new xajaxUserFunction($mFunction, $sInclude);
+		$xuf = new xajaxUserFunction($mFunction, $sInclude);
 		$this->register(XAJAX_FUNCTION, $xuf);
 	}
 	function registerCatchAllFunction($mFunction)
--- a/intranet/xajax/xajax_core/xajaxControl.inc.php
+++ b/intranet/xajax/xajax_core/xajaxControl.inc.php
@@ -456,9 +456,9 @@
 		aConfiguration - (array):  See <xajaxControl->xajaxControl> for more
 			information.
 	*/
-	function xajaxControlContainer($sTag, $aConfiguration=array())
-	{
-		xajaxControl::xajaxControl($sTag, $aConfiguration);
+	function __construct($sTag, $aConfiguration=array())
+	{
+		xajaxControl::__construct($sTag, $aConfiguration);
 
 		$this->clearChildren();
 		
--- a/intranet/xajax/xajax_core/xajaxArgumentManager.inc.php
+++ b/intranet/xajax/xajax_core/xajaxArgumentManager.inc.php
@@ -310,7 +310,7 @@
 			}
 		}
 		else if (is_string($mArg))
-			$mArg = utf8_decode($mArg);
+			$mArg = mb_convert_encoding($mArg, 'ISO-8859-1', 'UTF-8');
 	}
 	
 	/*
@@ -372,7 +372,7 @@
 			$this->aArgs = $_GET['xjxargs'];
 		}
 		
-		if (1 == get_magic_quotes_gpc())
+		if (1 == false)
 			array_walk($this->aArgs, array(&$this, 'argumentStripSlashes'));
 		
 		array_walk($this->aArgs, array(&$this, 'argumentDecodeXML'));
--- a/intranet/xajax/xajax_core/xajaxResponseManager.inc.php
+++ b/intranet/xajax/xajax_core/xajaxResponseManager.inc.php
@@ -56,7 +56,7 @@
 		
 		Construct and initialize the one and only xajaxResponseManager object.
 	*/
-	function xajaxResponseManager()
+	function __construct()
 	{
 		$this->objResponse = NULL;
 		$this->aDebugMessages = array();
--- a/intranet/xajax/xajax_core/xajaxRequest.inc.php
+++ b/intranet/xajax/xajax_core/xajaxRequest.inc.php
@@ -312,7 +312,7 @@
 		aVariables - (associative array, optional):  An array of variable name, 
 			value pairs that will be passed to <xajaxCustomRequest->setVariable>
 	*/
-	function xajaxCustomRequest($sScript)
+	function __construct($sScript)
 	{
 		$this->aVariables = array();
 		$this->sScript = $sScript;
--- a/intranet/xajax/xajax_core/xajax.inc.php
+++ b/intranet/xajax/xajax_core/xajax.inc.php
@@ -1,4 +1,5 @@
 <?php
+require_once __DIR__ . '/../../core/legacy-date-format.php';
 /*
 	File: xajax.inc.php
 
@@ -566,7 +567,7 @@
 							fwrite(
 								$fH, 
 								$this->objLanguageManager->getText('LOGHDR:01')
-								. strftime("%b %e %Y %I:%M:%S %p") 
+								. prowinch_format_legacy_date("%b %e %Y %I:%M:%S %p") 
 								. $this->objLanguageManager->getText('LOGHDR:02')
 								. $sErrorMessage 
 								. $this->objLanguageManager->getText('LOGHDR:03')
--- a/intranet/xajax/xajax_core/xajaxResponse.inc.php
+++ b/intranet/xajax/xajax_core/xajaxResponse.inc.php
@@ -1806,7 +1806,7 @@
 	var $sCharacterEncoding;
 	var $bOutputEntities;
 	
-	function xajaxCustomResponse($sContentType)
+	function __construct($sContentType)
 	{
 		$this->sOutput = '';
 		$this->sContentType = $sContentType;
--- a/intranet/xajax/xajax_core/plugin_layer/xajaxDefaultIncludePlugin.inc.php
+++ b/intranet/xajax/xajax_core/plugin_layer/xajaxDefaultIncludePlugin.inc.php
@@ -45,7 +45,7 @@
 	var $sLanguage;
 	var $nResponseQueueSize;
 
-	function xajaxIncludeClientScriptPlugin()
+	function __construct()
 	{
 		$this->sJsURI = '';
 		$this->aJsFiles = array();
--- a/intranet/xajax/xajax_controls/misc.inc.php
+++ b/intranet/xajax/xajax_controls/misc.inc.php
@@ -36,9 +36,9 @@
 
 class clsObject extends xajaxControlContainer
 {
-	function clsObject($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControlContainer::xajaxControlContainer('object', $aConfiguration);
+		xajaxControlContainer::__construct('object', $aConfiguration);
 
 		$this->sClass = '%block';
 		$this->sEndTag = 'required';
@@ -47,9 +47,9 @@
 
 class clsParam extends xajaxControl
 {
-	function clsParam($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControl::xajaxControl('param', $aConfiguration);
+		xajaxControl::__construct('param', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -57,14 +57,14 @@
 
 class clsAnchor extends xajaxControlContainer
 {
-	function clsAnchor($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		if (false == isset($aConfiguration['attributes']))
 			$aConfiguration['attributes'] = array();
 		if (false == isset($aConfiguration['attributes']['href']))
 			$aConfiguration['attributes']['href'] = '#';
 		
-		xajaxControlContainer::xajaxControlContainer('a', $aConfiguration);
+		xajaxControlContainer::__construct('a', $aConfiguration);
 
 		$this->sClass = '%inline';
 		$this->sEndTag = 'required';
@@ -78,9 +78,9 @@
 
 class clsImg extends xajaxControl
 {
-	function clsImg($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControl::xajaxControl('img', $aConfiguration);
+		xajaxControl::__construct('img', $aConfiguration);
 
 		$this->sClass = '%inline';
 	}
@@ -88,9 +88,9 @@
 
 class clsButton extends xajaxControlContainer
 {
-	function clsButton($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControlContainer::xajaxControlContainer('button', $aConfiguration);
+		xajaxControlContainer::__construct('button', $aConfiguration);
 
 		$this->sClass = '%inline';
 	}
@@ -98,9 +98,9 @@
 
 class clsArea extends xajaxControl
 {
-	function clsArea($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControl::xajaxControl('area', $aConfiguration);
+		xajaxControl::__construct('area', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -108,9 +108,9 @@
 
 class clsMap extends xajaxControlContainer
 {
-	function clsMap($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControlContainer::xajaxControlContainer('map', $aConfiguration);
+		xajaxControlContainer::__construct('map', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
--- a/intranet/xajax/xajax_controls/content.inc.php
+++ b/intranet/xajax/xajax_controls/content.inc.php
@@ -34,9 +34,12 @@
 
 class clsLiteral extends xajaxControl
 {
-	function clsLiteral($sText)
-	{
-		xajaxControl::xajaxControl('CDATA');
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $sText;
+
+	function __construct($sText)
+	{
+		xajaxControl::__construct('CDATA');
 
 		$this->sClass = '%inline';
 		$this->sText = $sText;
@@ -50,9 +53,9 @@
 
 class clsBr extends xajaxControl
 {
-	function clsBr($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('br', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('br', $aConfiguration);
 		
 		$this->sClass = '%inline';
 		$this->sEndTag = 'optional';
@@ -61,9 +64,9 @@
 
 class clsHr extends xajaxControl
 {
-	function clsHr($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('hr', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('hr', $aConfiguration);
 		
 		$this->sClass = '%inline';
 		$this->sEndTag = 'optional';
@@ -72,9 +75,9 @@
 
 class clsInlineContainer extends xajaxControlContainer
 {
-	function clsInlineContainer($sTag, $aConfiguration)
-	{
-		xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
+	function __construct($sTag, $aConfiguration)
+	{
+		xajaxControlContainer::__construct($sTag, $aConfiguration);
 		
 		$this->sClass = '%inline';
 		$this->sEndTag = 'required';
@@ -83,160 +86,160 @@
 
 class clsSub extends clsInlineContainer
 {
-	function clsSub($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('sub', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('sub', $aConfiguration);
 	}
 }
 
 class clsSup extends xajaxControlContainer
 {
-	function clsSup($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('sup', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('sup', $aConfiguration);
 	}
 }
 
 class clsEm extends clsInlineContainer
 {
-	function clsEm($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('em', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('em', $aConfiguration);
 	}
 }
 
 class clsStrong extends clsInlineContainer
 {
-	function clsStrong($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('strong', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('strong', $aConfiguration);
 	}
 }
 
 class clsCite extends clsInlineContainer
 {
-	function clsCite($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('cite', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('cite', $aConfiguration);
 	}
 }
 
 class clsDfn extends clsInlineContainer
 {
-	function clsDfn($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('dfn', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('dfn', $aConfiguration);
 	}
 }
 
 class clsCode extends clsInlineContainer
 {
-	function clsCode($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('code', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('code', $aConfiguration);
 	}
 }
 
 class clsSamp extends clsInlineContainer
 {
-	function clsSamp($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('samp', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('samp', $aConfiguration);
 	}
 }
 
 class clsKbd extends clsInlineContainer
 {
-	function clsKbd($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('kbd', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('kbd', $aConfiguration);
 	}
 }
 
 class clsVar extends clsInlineContainer
 {
-	function clsVar($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('var', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('var', $aConfiguration);
 	}
 }
 
 class clsAbbr extends clsInlineContainer
 {
-	function clsAbbr($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('abbr', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('abbr', $aConfiguration);
 	}
 }
 
 class clsAcronym extends clsInlineContainer
 {
-	function clsAcronym($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('acronym', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('acronym', $aConfiguration);
 	}
 }
 
 class clsTt extends clsInlineContainer
 {
-	function clsTt($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('tt', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('tt', $aConfiguration);
 	}
 }
 
 class clsItalic extends clsInlineContainer
 {
-	function clsItalic($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('i', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('i', $aConfiguration);
 	}
 }
 
 class clsBold extends clsInlineContainer
 {
-	function clsBold($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('b', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('b', $aConfiguration);
 	}
 }
 
 class clsBig extends clsInlineContainer
 {
-	function clsBig($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('big', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('big', $aConfiguration);
 	}
 }
 
 
 class clsSmall extends clsInlineContainer
 {
-	function clsSmall($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('small', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('small', $aConfiguration);
 	}
 }
 
 class clsIns extends clsInlineContainer
 {
-	function clsIns($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('ins', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('ins', $aConfiguration);
 	}
 }
 
 class clsDel extends clsInlineContainer
 {
-	function clsDel($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('del', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('del', $aConfiguration);
 	}
 }
 
 class clsHeadline extends xajaxControlContainer
 {
-	function clsHeadline($sType, $aConfiguration=array())
+	function __construct($sType, $aConfiguration=array())
 	{
 		if (0 < strpos($sType, '123456'))
 			trigger_error('Invalid type for headline control; should be 1,2,3,4,5 or 6.'
@@ -244,7 +247,7 @@
 				E_USER_ERROR
 				);
 		
-		xajaxControlContainer::xajaxControlContainer('h' . $sType, $aConfiguration);
+		xajaxControlContainer::__construct('h' . $sType, $aConfiguration);
 
 		$this->sClass = '%inline';
 	}
@@ -252,32 +255,32 @@
 
 class clsAddress extends clsInlineContainer
 {
-	function clsAddress($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('address', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('address', $aConfiguration);
 	}
 }
 
 class clsParagraph extends clsInlineContainer
 {
-	function clsParagraph($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('p', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('p', $aConfiguration);
 	}
 }
 
 class clsBlockquote extends clsInlineContainer
 {
-	function clsBlockquote($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('blockquote', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('blockquote', $aConfiguration);
 	}
 }
 
 class clsPre extends clsInlineContainer
 {
-	function clsPre($aConfiguration=array())
-	{
-		clsInlineContainer::clsInlineContainer('pre', $aConfiguration);
-	}
-}
+	function __construct($aConfiguration=array())
+	{
+		clsInlineContainer::__construct('pre', $aConfiguration);
+	}
+}
--- a/intranet/xajax/xajax_controls/group.inc.php
+++ b/intranet/xajax/xajax_controls/group.inc.php
@@ -34,11 +34,14 @@
 
 class clsList extends xajaxControlContainer
 {
-	function clsList($sTag, $aConfiguration=array())
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $eventAddItem;
+
+	function __construct($sTag, $aConfiguration=array())
 	{
 		$this->clearEvent_AddItem();
 			
-		xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
+		xajaxControlContainer::__construct($sTag, $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -72,7 +75,7 @@
 	
 	function &_onAddItem($mItem, $mConfiguration)
 	{
-		$objItem =& new clsLI(array(
+		$objItem = new clsLI(array(
 			'child' => new clsLiteral($mItem)
 			));
 		return $objItem;
@@ -81,25 +84,25 @@
 
 class clsUL extends clsList
 {
-	function clsUL($aConfiguration=array())
-	{
-		clsList::clsList('ul', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsList::__construct('ul', $aConfiguration);
 	}
 }
 
 class clsOL extends clsList
 {
-	function clsOL($aConfiguration=array())
-	{
-		clsList::clsList('ol', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsList::__construct('ol', $aConfiguration);
 	}
 }
 
 class clsLI extends xajaxControlContainer
 {
-	function clsLI($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('li', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('li', $aConfiguration);
 
 		$this->sClass = '%flow';
 		$this->sEndTag = 'optional';
@@ -108,9 +111,9 @@
 
 class clsDl extends xajaxControlContainer
 {
-	function clsDl($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('dl', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('dl', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -118,9 +121,9 @@
 
 class clsDt extends xajaxControlContainer
 {
-	function clsDt($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('dt', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('dt', $aConfiguration);
 
 		$this->sClass = '%block';
 		$this->sEndTag = 'optional';
@@ -129,9 +132,9 @@
 
 class clsDd extends xajaxControlContainer
 {
-	function clsDd($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('dd', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('dd', $aConfiguration);
 
 		$this->sClass = '%flow';
 		$this->sEndTag = 'optional';
@@ -143,12 +146,12 @@
 	var $eventAddRow;
 	var $eventAddRowCell;
 	
-	function clsTableRowContainer($sTag, $aConfiguration=array())
+	function __construct($sTag, $aConfiguration=array())
 	{
 		$this->clearEvent_AddRow();
 		$this->clearEvent_AddRowCell();
 			
-		xajaxControlContainer::xajaxControlContainer($sTag, $aConfiguration);
+		xajaxControlContainer::__construct($sTag, $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -194,7 +197,7 @@
 	
 	function &_onAddRow($aCells, $mConfiguration=null)
 	{
-		$objTableRow =& new clsTr();
+		$objTableRow = new clsTr();
 		if (null != $this->eventAddRowCell)
 			$objTableRow->setEvent_AddCell($this->eventAddRowCell);
 		$objTableRow->addCells($aCells, $mConfiguration);
@@ -226,7 +229,7 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTable($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		$this->clearEvent_AddHeader();
 		$this->clearEvent_AddHeaderRow();
@@ -238,7 +241,7 @@
 		$this->clearEvent_AddFooterRow();
 		$this->clearEvent_AddFooterRowCell();
 		
-		xajaxControlContainer::xajaxControlContainer('table', $aConfiguration);
+		xajaxControlContainer::__construct('table', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -374,7 +377,7 @@
 	
 	function &_onAddHeader($aRows, $mConfiguration)
 	{
-		$objTableHeader =& new clsThead();
+		$objTableHeader = new clsThead();
 		if (null != $this->eventAddHeaderRow)
 			$objTableHeader->setEvent_AddRow($this->eventAddHeaderRow);
 		if (null != $this->eventAddHeaderRowCell)
@@ -384,7 +387,7 @@
 	}
 	function &_onAddBody($aRows, $mConfiguration)
 	{
-		$objTableBody =& new clsTbody();
+		$objTableBody = new clsTbody();
 		if (null != $this->eventAddBodyRow)
 			$objTableBody->setEvent_AddRow($this->eventAddBodyRow);
 		if (null != $this->eventAddBodyRowCell)
@@ -394,7 +397,7 @@
 	}
 	function &_onAddFooter($aRows, $mConfiguration)
 	{
-		$objTableFooter =& new clsTfoot();
+		$objTableFooter = new clsTfoot();
 		if (null != $this->eventAddFooterRow)
 			$objTableFooter->setEvent_AddRow($this->eventAddFooterRow);
 		if (null != $this->eventAddFooterRowCell)
@@ -406,9 +409,9 @@
 
 class clsCaption extends xajaxControlContainer
 {
-	function clsCaption($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('caption', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('caption', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -416,9 +419,9 @@
 
 class clsColgroup extends xajaxControlContainer
 {
-	function clsColgroup($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('colgroup', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('colgroup', $aConfiguration);
 
 		$this->sClass = '%block';
 		$this->sEndTag = 'optional';
@@ -427,9 +430,9 @@
 
 class clsCol extends xajaxControl
 {
-	function clsCol($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('col');
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('col');
 
 		$this->sClass = '%block';
 	}
@@ -445,9 +448,9 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsThead($aConfiguration=array())
-	{
-		clsTableRowContainer::clsTableRowContainer('thead', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsTableRowContainer::__construct('thead', $aConfiguration);
 	}
 }
 
@@ -461,9 +464,9 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTbody($aConfiguration=array())
-	{
-		clsTableRowContainer::clsTableRowContainer('tbody', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsTableRowContainer::__construct('tbody', $aConfiguration);
 	}
 }
 
@@ -477,9 +480,9 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTfoot($aConfiguration=array())
-	{
-		clsTableRowContainer::clsTableRowContainer('tfoot', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		clsTableRowContainer::__construct('tfoot', $aConfiguration);
 	}
 }
 
@@ -495,11 +498,11 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTr($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		$this->clearEvent_AddCell();
 			
-		xajaxControlContainer::xajaxControlContainer('tr', $aConfiguration);
+		xajaxControlContainer::__construct('tr', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -551,9 +554,9 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTd($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('td', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('td', $aConfiguration);
 
 		$this->sClass = '%flow';
 	}
@@ -569,9 +572,9 @@
 		
 		Constructs and initializes an instance of the class.
 	*/
-	function clsTh($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('th', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('th', $aConfiguration);
 
 		$this->sClass = '%flow';
 	}
--- a/intranet/xajax/xajax_controls/document.inc.php
+++ b/intranet/xajax/xajax_controls/document.inc.php
@@ -35,7 +35,7 @@
 
 class clsDocument extends xajaxControlContainer
 {
-	function clsDocument($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		if (isset($aConfiguration['attributes']))
 			trigger_error(
@@ -43,7 +43,7 @@
 				. $this->backtrace(),
 				E_USER_ERROR);
 		
-		xajaxControlContainer::xajaxControlContainer('DOCUMENT', $aConfiguration);
+		xajaxControlContainer::__construct('DOCUMENT', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -72,7 +72,7 @@
 	var $sValidation;
 	var $sEncoding;
 	
-	function clsDocType($sFormat=null, $sVersion=null, $sValidation=null, $sEncoding='UTF-8')
+	function __construct($sFormat=null, $sVersion=null, $sValidation=null, $sEncoding='UTF-8')
 	{
 		if (null === $sFormat && false == defined('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT'))
 			trigger_error('You must specify a doctype format.', E_USER_ERROR);
@@ -88,7 +88,7 @@
 		if (null === $sValidation)
 			$sValidation = XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION;
 			
-		xajaxControlContainer::xajaxControlContainer('DOCTYPE', array());
+		xajaxControlContainer::__construct('DOCTYPE', array());
 		
 		$this->sText = '<'.'!DOCTYPE html PUBLIC "-//W3C//DTD ';
 		$this->sText .= $sFormat;
@@ -154,9 +154,9 @@
 
 class clsHtml extends xajaxControlContainer
 {
-	function clsHtml($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('html', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('html', $aConfiguration);
 
 		$this->sClass = '%block';
 		$this->sEndTag = 'optional';
@@ -167,13 +167,13 @@
 {
 	var $objXajax;
 	
-	function clsHead($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		$this->objXajax = null;
 		if (isset($aConfiguration['xajax']))
 			$this->setXajax($aConfiguration['xajax']);
 			
-		xajaxControlContainer::xajaxControlContainer('head', $aConfiguration);
+		xajaxControlContainer::__construct('head', $aConfiguration);
 
 		$this->sClass = '%block';
 		$this->sEndTag = 'optional';
@@ -195,9 +195,9 @@
 
 class clsBody extends xajaxControlContainer
 {
-	function clsBody($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('body', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('body', $aConfiguration);
 		
 		$this->sClass = '%block';
 		$this->sEndTag = 'optional';
@@ -206,9 +206,9 @@
 
 class clsScript extends xajaxControlContainer
 {
-	function clsScript($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('script', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('script', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -216,9 +216,9 @@
 
 class clsStyle extends xajaxControlContainer
 {
-	function clsStyle($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('style', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('style', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -226,9 +226,9 @@
 
 class clsLink extends xajaxControl
 {
-	function clsLink($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('link', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('link', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -236,9 +236,9 @@
 
 class clsMeta extends xajaxControl
 {
-	function clsMeta($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('meta', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('meta', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -246,9 +246,9 @@
 
 class clsTitle extends xajaxControlContainer
 {
-	function clsTitle($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('title', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('title', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -264,9 +264,9 @@
 
 class clsBase extends xajaxControl
 {
-	function clsBase($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('base', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('base', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -274,9 +274,9 @@
 
 class clsNoscript extends xajaxControlContainer
 {
-	function clsNoscript($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('noscript', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('noscript', $aConfiguration);
 
 		$this->sClass = '%flow';
 	}
@@ -284,9 +284,9 @@
 
 class clsIframe extends xajaxControlContainer
 {
-	function clsIframe($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('iframe', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('iframe', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -294,9 +294,9 @@
 
 class clsFrameset extends xajaxControlContainer
 {
-	function clsFrameset($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('frameset', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('frameset', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -304,9 +304,9 @@
 
 class clsFrame extends xajaxControl
 {
-	function clsFrame($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('frame', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('frame', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -314,9 +314,9 @@
 
 class clsNoframes extends xajaxControlContainer
 {
-	function clsNoframes($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('noframes', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('noframes', $aConfiguration);
 
 		$this->sClass = '%flow';
 	}
--- a/intranet/xajax/xajax_controls/validate_HTML401TRANSITIONAL.inc.php
+++ b/intranet/xajax/xajax_controls/validate_HTML401TRANSITIONAL.inc.php
@@ -809,7 +809,7 @@
 	var $aAttributes;
 	var $aRequiredAttributes;
 	
-	function clsValidator()
+	function __construct()
 	{
 		global $aTags;
 		global $aAttributes;
--- a/intranet/xajax/xajax_controls/structure.inc.php
+++ b/intranet/xajax/xajax_controls/structure.inc.php
@@ -27,9 +27,9 @@
 
 class clsDiv extends xajaxControlContainer
 {
-	function clsDiv($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControlContainer::xajaxControlContainer('div', $aConfiguration);
+		xajaxControlContainer::__construct('div', $aConfiguration);
 
 		$this->sClass = '%block';
 	}
@@ -37,9 +37,9 @@
 
 class clsSpan extends xajaxControlContainer
 {
-	function clsSpan($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
-		xajaxControlContainer::xajaxControlContainer('span', $aConfiguration);
+		xajaxControlContainer::__construct('span', $aConfiguration);
 
 		$this->sClass = '%inline';
 	}
--- a/intranet/xajax/xajax_controls/validate_XHTML10TRANSITIONAL.inc.php
+++ b/intranet/xajax/xajax_controls/validate_XHTML10TRANSITIONAL.inc.php
@@ -839,7 +839,7 @@
 	var $aAttributes;
 	var $aRequiredAttributes;
 	
-	function clsValidator()
+	function __construct()
 	{
 		global $aTags;
 		global $aAttributes;
--- a/intranet/xajax/xajax_controls/form.inc.php
+++ b/intranet/xajax/xajax_controls/form.inc.php
@@ -35,7 +35,7 @@
 
 class clsForm extends xajaxControlContainer
 {
-	function clsForm($aConfiguration=array())
+	function __construct($aConfiguration=array())
 	{
 		if (false == isset($aConfiguration['attributes']))
 			$aConfiguration['attributes'] = array();
@@ -44,15 +44,15 @@
 		if (false == isset($aConfiguration['attributes']['action']))
 			$aConfiguration['attributes']['action'] = '#';
 
-		xajaxControlContainer::xajaxControlContainer('form', $aConfiguration);
+		xajaxControlContainer::__construct('form', $aConfiguration);
 	}
 }
 
 class clsInput extends xajaxControl
 {
-	function clsInput($aConfiguration=array())
-	{
-		xajaxControl::xajaxControl('input', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControl::__construct('input', $aConfiguration);
 	}
 }
 
@@ -62,18 +62,18 @@
 	var $sWhere;
 	var $objBreak;
 	
-	function clsInputWithLabel($sLabel, $sWhere, $aConfiguration=array())
-	{
-		clsInput::clsInput($aConfiguration);
-		
-		$this->objLabel =& new clsLabel(array(
+	function __construct($sLabel, $sWhere, $aConfiguration=array())
+	{
+		clsInput::__construct($aConfiguration);
+		
+		$this->objLabel = new clsLabel(array(
 			'child' => new clsLiteral($sLabel)
 			));
 		$this->objLabel->setControl($this);
 		
 		$this->sWhere = $sWhere;
 		
-		$this->objBreak =& new clsBr();
+		$this->objBreak = new clsBr();
 	}
 	
 	function printHTML($sIndent='')
@@ -108,9 +108,9 @@
 		Construct and initialize an instance of the class.  See <xajaxControlContainer>
 		for details regarding the aConfiguration parameter.
 	*/
-	function clsSelect($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('select', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('select', $aConfiguration);
 	}
 	
 	/*
@@ -125,7 +125,7 @@
 	*/
 	function addOption($sValue, $sText)
 	{
-		$optionNew =& new clsOption();
+		$optionNew = new clsOption();
 		$optionNew->setValue($sValue);
 		$optionNew->setText($sText);
 		$this->addChild($optionNew);
@@ -163,9 +163,9 @@
 */
 class clsOptionGroup extends xajaxControlContainer
 {
-	function clsOptionGroup($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('optgroup', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('optgroup', $aConfiguration);
 	}
 	
 	/*
@@ -180,7 +180,7 @@
 	*/
 	function addOption($sValue, $sText)
 	{
-		$optionNew =& new clsOption();
+		$optionNew = new clsOption();
 		$optionNew->setValue($sValue);
 		$optionNew->setText($sText);
 		$this->addChild($optionNew);
@@ -226,9 +226,9 @@
 		Constructs and initializes an instance of this class.  See <xajaxControlContainer>
 		for more information regarding the aConfiguration parameter.
 	*/
-	function clsOption($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('option', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('option', $aConfiguration);
 	}
 	
 	/*
@@ -257,9 +257,9 @@
 
 class clsTextArea extends xajaxControlContainer
 {
-	function clsTextArea($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('textarea', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('textarea', $aConfiguration);
 		
 		$this->sClass = '%block';
 	}
@@ -269,9 +269,9 @@
 {
 	var $objFor;
 
-	function clsLabel($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('label', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('label', $aConfiguration);
 	}
 
 	function setControl(&$objControl)
@@ -295,9 +295,9 @@
 
 class clsFieldset extends xajaxControlContainer
 {
-	function clsFieldset($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('fieldset', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('fieldset', $aConfiguration);
 		
 		$this->sClass = '%block';
 	}
@@ -305,9 +305,9 @@
 
 class clsLegend extends xajaxControlContainer
 {
-	function clsLegend($aConfiguration=array())
-	{
-		xajaxControlContainer::xajaxControlContainer('legend', $aConfiguration);
+	function __construct($aConfiguration=array())
+	{
+		xajaxControlContainer::__construct('legend', $aConfiguration);
 		
 		$this->sClass = '%inline';
 	}
--- a/intranet/xajax/xajax_plugins/response/googleMap.inc.php
+++ b/intranet/xajax/xajax_plugins/response/googleMap.inc.php
@@ -22,6 +22,9 @@
 */
 class clsGoogleMap extends xajaxResponsePlugin
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $sGoogleSiteKey;
+
 	/*
 		String: sJavascriptURI
 		
@@ -52,7 +55,7 @@
 		
 		Constructs and initializes an instance of the table updater class.
 	*/
-	function clsGoogleMap()
+	function __construct()
 	{
 		$this->sJavascriptURI = '';
 		$this->bInlineScript = true;
--- a/intranet/xajax/xajax_plugins/response/tableUpdater.inc.php
+++ b/intranet/xajax/xajax_plugins/response/tableUpdater.inc.php
@@ -61,7 +61,7 @@
 		
 		Constructs and initializes an instance of the table updater class.
 	*/
-	function clsTableUpdater()
+	function __construct()
 	{
 		$this->sDefer = '';
 		$this->sJavascriptURI = '';
--- a/intranet/xajax/examples/signup/signup.server.php
+++ b/intranet/xajax/examples/signup/signup.server.php
@@ -101,7 +101,7 @@
 		$objResponse->alert("Please enter your last name.");
 		$bError = true;
 	}
-	if (!eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??????0-9]+(-[a-z??????0-9]+)*(\.[a-z??????0-9-]+)*(\.[a-z]{2,4})$", $aFormValues['email']))
+	if (!preg_match("~^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??????0-9]+(-[a-z??????0-9]+)*(\.[a-z??????0-9-]+)*(\.[a-z]{2,4})$~i", $aFormValues['email']))
 	{
 		$objResponse->alert("Please enter a valid email address.");
 		$bError = true;
--- a/intranet/xajax/examples/thewall/thewall.server.php
+++ b/intranet/xajax/examples/thewall/thewall.server.php
@@ -72,7 +72,7 @@
 		
 		Builds the <html> output and sets the <isValid> indicator.
 	*/
-	function graffiti($sHandle, $sWords)
+	function __construct($sHandle, $sWords)
 	{
 		if (trim($sHandle) == "" || trim($sWords) == "")
 		{
--- a/intranet/tcpdf/tcpdf_parser.php
+++ b/intranet/tcpdf/tcpdf_parser.php
@@ -104,13 +104,13 @@
 			$this->Error('Empty PDF data.');
 		}
 		// find the pdf header starting position
-		if (($trimpos = strpos($data, '%PDF-')) === FALSE) {
+		if (($trimpos = strpos(($data ?? ''), '%PDF-')) === FALSE) {
 			$this->Error('Invalid PDF data: missing %PDF header.');
 		}
 		// get PDF content string
-		$this->pdfdata = substr($data, $trimpos);
+		$this->pdfdata = substr(($data ?? ''), $trimpos);
 		// get length
-		$pdflen = strlen($this->pdfdata);
+		$pdflen = strlen(($this->pdfdata ?? ''));
 		// set configuration parameters
 		$this->setConfig($cfg);
 		// get xref and trailer data
@@ -169,25 +169,25 @@
 	protected function getXrefData($offset=0, $xref=array()) {
 		if ($offset == 0) {
 			// find last startxref
-			if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
+			if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', ($this->pdfdata ?? ''), $matches, PREG_SET_ORDER, $offset) == 0) {
 				$this->Error('Unable to find startxref');
 			}
 			$matches = array_pop($matches);
 			$startxref = $matches[1];
-		} elseif (strpos($this->pdfdata, 'xref', $offset) == $offset) {
+		} elseif (strpos(($this->pdfdata ?? ''), 'xref', $offset) == $offset) {
 			// Already pointing at the xref table
 			$startxref = $offset;
-		} elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
+		} elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', ($this->pdfdata ?? ''), $matches, PREG_OFFSET_CAPTURE, $offset)) {
 			// Cross-Reference Stream object
 			$startxref = $offset;
-		} elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
+		} elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', ($this->pdfdata ?? ''), $matches, PREG_OFFSET_CAPTURE, $offset)) {
 			// startxref found
 			$startxref = $matches[1][0];
 		} else {
 			$this->Error('Unable to find startxref');
 		}
 		// check xref position
-		if (strpos($this->pdfdata, 'xref', $startxref) == $startxref) {
+		if (strpos(($this->pdfdata ?? ''), 'xref', $startxref) == $startxref) {
 			// Cross-Reference
 			$xref = $this->decodeXref($startxref, $xref);
 		} else {
@@ -215,12 +215,12 @@
 		// initialize object number
 		$obj_num = 0;
 		// search for cross-reference entries or subsection
-		while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
+		while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', ($this->pdfdata ?? ''), $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
 			if ($matches[0][1] != $offset) {
 				// we are on another section
 				break;
 			}
-			$offset += strlen($matches[0][0]);
+			$offset += strlen(($matches[0][0] ?? ''));
 			if ($matches[3][0] == 'n') {
 				// create unique object index: [object number]_[generation number]
 				$index = $obj_num.'_'.intval($matches[2][0]);
@@ -238,31 +238,31 @@
 			}
 		}
 		// get trailer data
-		if (preg_match('/trailer[\s]*<<(.*)>>/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
+		if (preg_match('/trailer[\s]*<<(.*)>>/isU', ($this->pdfdata ?? ''), $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
 			$trailer_data = $matches[1][0];
 			if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
 				// get only the last updated version
 				$xref['trailer'] = array();
 				// parse trailer_data
-				if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
+				if (preg_match('/Size[\s]+([0-9]+)/i', ($trailer_data ?? ''), $matches) > 0) {
 					$xref['trailer']['size'] = intval($matches[1]);
 				}
-				if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
+				if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', ($trailer_data ?? ''), $matches) > 0) {
 					$xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]);
 				}
-				if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
+				if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', ($trailer_data ?? ''), $matches) > 0) {
 					$xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
 				}
-				if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
+				if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', ($trailer_data ?? ''), $matches) > 0) {
 					$xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
 				}
-				if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) {
+				if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', ($trailer_data ?? ''), $matches) > 0) {
 					$xref['trailer']['id'] = array();
 					$xref['trailer']['id'][0] = $matches[1];
 					$xref['trailer']['id'][1] = $matches[2];
 				}
 			}
-			if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
+			if (preg_match('/Prev[\s]+([0-9]+)/i', ($trailer_data ?? ''), $matches) > 0) {
 				// get previous xref
 				$xref = $this->getXrefData(intval($matches[1]), $xref);
 			}
@@ -516,9 +516,9 @@
 				// name object
 				$objtype = $char;
 				++$offset;
-				if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) {
+				if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', (substr(($this->pdfdata ?? ''), $offset, 256) ?? ''), $matches) == 1) {
 					$objval = $matches[1]; // unescaped value
-					$offset += strlen($objval);
+					$offset += strlen(($objval ?? ''));
 				}
 				break;
 			}
@@ -531,10 +531,10 @@
 				if ($char == '(') {
 					$open_bracket = 1;
 					while ($open_bracket > 0) {
-						if (!isset($this->pdfdata{$strpos})) {
+						if (!isset($this->pdfdata[$strpos])) {
 							break;
 						}
-						$ch = $this->pdfdata{$strpos};
+						$ch = $this->pdfdata[$strpos];
 						switch ($ch) {
 							case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
 								// skip next character
@@ -552,7 +552,7 @@
 						}
 						++$strpos;
 					}
-					$objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1));
+					$objval = substr(($this->pdfdata ?? ''), $offset, ($strpos - $offset - 1));
 					$offset = $strpos;
 				}
 				break;
@@ -578,7 +578,7 @@
 			}
 			case '<':   // \x3C LESS-THAN SIGN
 			case '>': { // \x3E GREATER-THAN SIGN
-				if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
+				if (isset($this->pdfdata[($offset + 1)]) AND ($this->pdfdata[($offset + 1)] == $char)) {
 					// dictionary object
 					$objtype = $char.$char;
 					$offset += 2;
@@ -598,65 +598,65 @@
 					// hexadecimal string object
 					$objtype = $char;
 					++$offset;
-					if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', substr($this->pdfdata, $offset), $matches) == 1)) {
+					if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', (substr(($this->pdfdata ?? ''), $offset) ?? ''), $matches) == 1)) {
 						// remove white space characters
-						$objval = strtr($matches[1], "\x09\x0a\x0c\x0d\x20", '');
-						$offset += strlen($matches[0]);
-					} elseif (($endpos = strpos($this->pdfdata, '>', $offset)) !== FALSE) {
+						$objval = strtr(($matches[1] ?? ''), "\x09\x0a\x0c\x0d\x20", '');
+						$offset += strlen(($matches[0] ?? ''));
+					} elseif (($endpos = strpos(($this->pdfdata ?? ''), '>', $offset)) !== FALSE) {
 						$offset = $endpos + 1;
                     }
 				}
 				break;
 			}
 			default: {
-				if (substr($this->pdfdata, $offset, 6) == 'endobj') {
+				if (substr(($this->pdfdata ?? ''), $offset, 6) == 'endobj') {
 					// indirect object
 					$objtype = 'endobj';
 					$offset += 6;
-				} elseif (substr($this->pdfdata, $offset, 4) == 'null') {
+				} elseif (substr(($this->pdfdata ?? ''), $offset, 4) == 'null') {
 					// null object
 					$objtype = 'null';
 					$offset += 4;
 					$objval = 'null';
-				} elseif (substr($this->pdfdata, $offset, 4) == 'true') {
+				} elseif (substr(($this->pdfdata ?? ''), $offset, 4) == 'true') {
 					// boolean true object
 					$objtype = 'boolean';
 					$offset += 4;
 					$objval = 'true';
-				} elseif (substr($this->pdfdata, $offset, 5) == 'false') {
+				} elseif (substr(($this->pdfdata ?? ''), $offset, 5) == 'false') {
 					// boolean false object
 					$objtype = 'boolean';
 					$offset += 5;
 					$objval = 'false';
-				} elseif (substr($this->pdfdata, $offset, 6) == 'stream') {
+				} elseif (substr(($this->pdfdata ?? ''), $offset, 6) == 'stream') {
 					// start stream object
 					$objtype = 'stream';
 					$offset += 6;
-					if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) {
-						$offset += strlen($matches[0]);
-						if (preg_match('/(endstream)[\x09\x0a\x0c\x0d\x20]/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) {
-							$objval = substr($this->pdfdata, $offset, $matches[0][1]);
+					if (preg_match('/^([\r]?[\n])/isU', (substr(($this->pdfdata ?? ''), $offset) ?? ''), $matches) == 1) {
+						$offset += strlen(($matches[0] ?? ''));
+						if (preg_match('/(endstream)[\x09\x0a\x0c\x0d\x20]/isU', (substr(($this->pdfdata ?? ''), $offset) ?? ''), $matches, PREG_OFFSET_CAPTURE) == 1) {
+							$objval = substr(($this->pdfdata ?? ''), $offset, $matches[0][1]);
 							$offset += $matches[1][1];
 						}
 					}
-				} elseif (substr($this->pdfdata, $offset, 9) == 'endstream') {
+				} elseif (substr(($this->pdfdata ?? ''), $offset, 9) == 'endstream') {
 					// end stream object
 					$objtype = 'endstream';
 					$offset += 9;
-				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
+				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', (substr(($this->pdfdata ?? ''), $offset, 33) ?? ''), $matches) == 1) {
 					// indirect object reference
 					$objtype = 'objref';
-					$offset += strlen($matches[0]);
+					$offset += strlen(($matches[0] ?? ''));
 					$objval = intval($matches[1]).'_'.intval($matches[2]);
-				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
+				} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', (substr(($this->pdfdata ?? ''), $offset, 33) ?? ''), $matches) == 1) {
 					// object start
 					$objtype = 'obj';
 					$objval = intval($matches[1]).'_'.intval($matches[2]);
-					$offset += strlen ($matches[0]);
+					$offset += strlen (($matches[0] ?? ''));
 				} elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
 					// numeric object
 					$objtype = 'numeric';
-					$objval = substr($this->pdfdata, $offset, $numlen);
+					$objval = substr(($this->pdfdata ?? ''), $offset, $numlen);
 					$offset += $numlen;
 				}
 				break;
@@ -675,20 +675,20 @@
 	 * @since 1.0.000 (2011-05-24)
 	 */
 	protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
-		$obj = explode('_', $obj_ref);
-		if (($obj === false) OR (count($obj) != 2)) {
+		$obj = explode('_', ($obj_ref ?? ''));
+		if (($obj === false) OR (count(($obj ?? [])) != 2)) {
 			$this->Error('Invalid object reference: '.$obj);
 			return;
 		}
 		$objref = $obj[0].' '.$obj[1].' obj';
 		// ignore leading zeros
 		$offset += strspn($this->pdfdata, '0', $offset);
-		if (strpos($this->pdfdata, $objref, $offset) != $offset) {
+		if (strpos(($this->pdfdata ?? ''), ($objref ?? ''), $offset) != $offset) {
 			// an indirect reference to an undefined object shall be considered a reference to the null object
 			return array('null', 'null', $offset);
 		}
 		// starting position of object content
-		$offset += strlen($objref);
+		$offset += strlen(($objref ?? ''));
 		// get array of object content
 		$objdata = array();
 		$i = 0; // object main index
@@ -742,7 +742,7 @@
 	 */
 	protected function decodeStream($sdic, $stream) {
 		// get stream length and filters
-		$slength = strlen($stream);
+		$slength = strlen(($stream ?? ''));
 		if ($slength <= 0) {
 			return array('', array());
 		}
@@ -753,7 +753,7 @@
 					// get declared stream length
 					$declength = intval($sdic[($k + 1)][1]);
 					if ($declength < $slength) {
-						$stream = substr($stream, 0, $declength);
+						$stream = substr(($stream ?? ''), 0, $declength);
 						$slength = $declength;
 					}
 				} elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) {
--- a/intranet/tcpdf/tcpdf_barcodes_2d.php
+++ b/intranet/tcpdf/tcpdf_barcodes_2d.php
@@ -92,7 +92,7 @@
 		header('Pragma: public');
 		header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
 		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
-		header('Content-Disposition: inline; filename="'.md5($code).'.svg";');
+		header('Content-Disposition: inline; filename="'.md5(($code ?? '')).'.svg";');
 		//header('Content-Length: '.strlen($code));
 		echo $code;
 	}
@@ -111,7 +111,7 @@
 		$svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n";
 		$svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n";
 		$svg .= '<svg width="'.round(($this->barcode_array['num_cols'] * $w), 3).'" height="'.round(($this->barcode_array['num_rows'] * $h), 3).'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n";
-		$svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n";
+		$svg .= "\t".'<desc>'.strtr(($this->barcode_array['code'] ?? ''), ($repstr ?? '')).'</desc>'."\n";
 		$svg .= "\t".'<g id="elements" fill="'.$color.'" stroke="none">'."\n";
 		// print barcode elements
 		$y = 0;
@@ -197,10 +197,10 @@
 		if (function_exists('imagecreate')) {
 			// GD library
 			$imagick = false;
-			$png = imagecreate($width, $height);
+			$png = imagecreate((int) ($width), (int) ($height));
 			$bgcol = imagecolorallocate($png, 255, 255, 255);
 			imagecolortransparent($png, $bgcol);
-			$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
+			$fgcol = imagecolorallocate($png, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]));
 		} elseif (extension_loaded('imagick')) {
 			$imagick = true;
 			$bgcol = new imagickpixel('rgb(255,255,255');
@@ -224,7 +224,7 @@
 					if ($imagick) {
 						$bar->rectangle($x, $y, ($x + $w - 1), ($y + $h - 1));
 					} else {
-						imagefilledrectangle($png, $x, $y, ($x + $w - 1), ($y + $h - 1), $fgcol);
+						imagefilledrectangle($png, (int) ($x), (int) ($y), ((int) ($x + $w - 1)), ((int) ($y + $h - 1)), (int) ($fgcol));
 					}
 				}
 				$x += $w;
@@ -250,8 +250,8 @@
  	 * @return array
 	 */
 	public function setBarcode($code, $type) {
-		$mode = explode(',', $type);
-		$qrtype = strtoupper($mode[0]);
+		$mode = explode(',', ($type ?? ''));
+		$qrtype = strtoupper(($mode[0] ?? ''));
 		switch ($qrtype) {
 			case 'DATAMATRIX': { // DATAMATRIX (ISO/IEC 16022)
 				require_once(dirname(__FILE__).'/include/barcodes/datamatrix.php');
@@ -277,12 +277,12 @@
 				if (isset($mode[3]) AND ($mode[3] !== '') AND isset($mode[4]) AND ($mode[4] !== '') AND isset($mode[5]) AND ($mode[5] !== '')) {
 					$macro['segment_total'] = intval($mode[3]);
 					$macro['segment_index'] = intval($mode[4]);
-					$macro['file_id'] = strtr($mode[5], "\xff", ',');
+					$macro['file_id'] = strtr(($mode[5] ?? ''), "\xff", ',');
 					for ($i = 0; $i < 7; ++$i) {
 						$o = $i + 6;
 						if (isset($mode[$o]) AND ($mode[$o] !== '')) {
 							// add option
-							$macro['option_'.$i] = strtr($mode[$o], "\xff", ',');
+							$macro['option_'.$i] = strtr(($mode[$o] ?? ''), "\xff", ',');
 						}
 					}
 				}
@@ -296,7 +296,7 @@
 				if (!isset($mode[1]) OR (!in_array($mode[1],array('L','M','Q','H')))) {
 					$mode[1] = 'L'; // Ddefault: Low error correction
 				}
-				$qrcode = new QRcode($code, strtoupper($mode[1]));
+				$qrcode = new QRcode($code, strtoupper(($mode[1] ?? '')));
 				$this->barcode_array = $qrcode->getBarcodeArray();
 				$this->barcode_array['code'] = $code;
 				break;
@@ -304,23 +304,23 @@
 			case 'RAW':
 			case 'RAW2': { // RAW MODE
 				// remove spaces
-				$code = preg_replace('/[\s]*/si', '', $code);
-				if (strlen($code) < 3) {
+				$code = preg_replace('/[\s]*/si', '', ($code ?? ''));
+				if (strlen(($code ?? '')) < 3) {
 					break;
 				}
 				if ($qrtype == 'RAW') {
 					// comma-separated rows
-					$rows = explode(',', $code);
+					$rows = explode(',', ($code ?? ''));
 				} else { // RAW2
 					// rows enclosed in square parentheses
-					$code = substr($code, 1, -1);
-					$rows = explode('][', $code);
-				}
-				$this->barcode_array['num_rows'] = count($rows);
-				$this->barcode_array['num_cols'] = strlen($rows[0]);
+					$code = substr(($code ?? ''), 1, -1);
+					$rows = explode('][', ($code ?? ''));
+				}
+				$this->barcode_array['num_rows'] = count(($rows ?? []));
+				$this->barcode_array['num_cols'] = strlen(($rows[0] ?? ''));
 				$this->barcode_array['bcode'] = array();
 				foreach ($rows as $r) {
-					$this->barcode_array['bcode'][] = str_split($r, 1);
+					$this->barcode_array['bcode'][] = str_split(($r ?? ''), 1);
 				}
 				$this->barcode_array['code'] = $code;
 				break;
--- a/intranet/tcpdf/tcpdf.php
+++ b/intranet/tcpdf/tcpdf.php
@@ -134,7 +134,11 @@
  * @IgnoreAnnotation("public")
  * @IgnoreAnnotation("pre")
  */
+#[\AllowDynamicProperties]
 class TCPDF {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $parser;
+
 
 	// Protected properties
 
@@ -1846,7 +1850,7 @@
 		}
 		// set file ID for trailer
 		$serformat = (is_array($format) ? json_encode($format) : $format);
-		$this->file_id = md5(TCPDF_STATIC::getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding));
+		$this->file_id = md5((TCPDF_STATIC::getRandomSeed('TCPDF'.$orientation.$unit.$serformat.$encoding) ?? ''));
 		$this->font_obj_ids = array();
 		$this->page_obj_id = array();
 		$this->form_obj_id = array();
@@ -2008,7 +2012,7 @@
 	 * @since 3.0.015 (2008-06-06)
 	 */
 	public function setPageUnit($unit) {
-		$unit = strtolower($unit);
+		$unit = strtolower(($unit ?? ''));
 		//Set scale factor
 		switch ($unit) {
 			// points
@@ -2253,7 +2257,7 @@
 		if (empty($orientation)) {
 			$orientation = $default_orientation;
 		} else {
-			$orientation = strtoupper($orientation[0]);
+			$orientation = strtoupper(($orientation[0] ?? ''));
 		}
 		if (in_array($orientation, $valid_orientations) AND ($orientation != $default_orientation)) {
 			$this->CurOrientation = $orientation;
@@ -2321,7 +2325,7 @@
 	 */
 	public function setSpacesRE($re='/[^\S\xa0]/') {
 		$this->re_spaces = $re;
-		$re_parts = explode('/', $re);
+		$re_parts = explode('/', ($re ?? ''));
 		// get pattern parts
 		$this->re_space = array();
 		if (isset($re_parts[1]) AND !empty($re_parts[1])) {
@@ -2372,7 +2376,7 @@
 	 */
 	public function setTempRTL($mode) {
 		$newmode = false;
-		switch (strtoupper($mode)) {
+		switch (strtoupper(($mode ?? ''))) {
 			case 'LTR':
 			case 'L': {
 				if ($this->rtl) {
@@ -2717,7 +2721,7 @@
 		}
 		if (is_string($brd)) {
 			// convert string to array
-			$slen = strlen($brd);
+			$slen = strlen(($brd ?? ''));
 			$newbrd = array();
 			for ($i = 0; $i < $slen; ++$i) {
 				$newbrd[$brd[$i]] = true;
@@ -2762,16 +2766,16 @@
 				}
 			}
 			// correct internal cell padding if required to avoid overlap between text and lines
-			if ((strpos($border,'T') !== false) AND ($this->cell_padding['T'] < $adj)) {
+			if ((strpos(($border ?? ''),'T') !== false) AND ($this->cell_padding['T'] < $adj)) {
 				$this->cell_padding['T'] = $adj;
 			}
-			if ((strpos($border,'R') !== false) AND ($this->cell_padding['R'] < $adj)) {
+			if ((strpos(($border ?? ''),'R') !== false) AND ($this->cell_padding['R'] < $adj)) {
 				$this->cell_padding['R'] = $adj;
 			}
-			if ((strpos($border,'B') !== false) AND ($this->cell_padding['B'] < $adj)) {
+			if ((strpos(($border ?? ''),'B') !== false) AND ($this->cell_padding['B'] < $adj)) {
 				$this->cell_padding['B'] = $adj;
 			}
-			if ((strpos($border,'L') !== false) AND ($this->cell_padding['L'] < $adj)) {
+			if ((strpos(($border ?? ''),'L') !== false) AND ($this->cell_padding['L'] < $adj)) {
 				$this->cell_padding['L'] = $adj;
 			}
 		}
@@ -3714,7 +3718,7 @@
 	 */
 	public function AddSpotColor($name, $c, $m, $y, $k) {
 		if (!isset($this->spot_colors[$name])) {
-			$i = (1 + count($this->spot_colors));
+			$i = (1 + count(($this->spot_colors ?? [])));
 			$this->spot_colors[$name] = array('C' => $c, 'M' => $m, 'Y' => $y, 'K' => $k, 'name' => $name, 'i' => $i);
 		}
 	}
@@ -3937,7 +3941,7 @@
 		}
 		switch ($type) {
 			case 'draw': {
-				$pdfcolor .= strtoupper($suffix);
+				$pdfcolor .= strtoupper(($suffix ?? ''));
 				$this->DrawColor = $pdfcolor;
 				$this->strokecolor = $intcolor;
 				break;
@@ -4133,9 +4137,9 @@
 	 */
 	public function GetNumChars($s) {
 		if ($this->isUnicodeFont()) {
-			return count(TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont));
-		}
-		return strlen($s);
+			return count((TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont) ?? []));
+		}
+		return strlen(($s ?? ''));
 	}
 
 	/**
@@ -4146,8 +4150,8 @@
 	protected function getFontsList() {
 		if (($fontsdir = opendir(TCPDF_FONTS::_getfontpath())) !== false) {
 			while (($file = readdir($fontsdir)) !== false) {
-				if (substr($file, -4) == '.php') {
-					array_push($this->fontlist, strtolower(basename($file, '.php')));
+				if (substr(($file ?? ''), -4) == '.php') {
+					array_push($this->fontlist, strtolower((basename($file, '.php') ?? '')));
 				}
 			}
 			closedir($fontsdir);
@@ -4182,16 +4186,16 @@
 			}
 		}
 		// move embedded styles on $style
-		if (substr($family, -1) == 'I') {
+		if (substr(($family ?? ''), -1) == 'I') {
 			$style .= 'I';
-			$family = substr($family, 0, -1);
-		}
-		if (substr($family, -1) == 'B') {
+			$family = substr(($family ?? ''), 0, -1);
+		}
+		if (substr(($family ?? ''), -1) == 'B') {
 			$style .= 'B';
-			$family = substr($family, 0, -1);
+			$family = substr(($family ?? ''), 0, -1);
 		}
 		// normalize family name
-		$family = strtolower($family);
+		$family = strtolower(($family ?? ''));
 		if ((!$this->isunicode) AND ($family == 'arial')) {
 			$family = 'helvetica';
 		}
@@ -4202,32 +4206,32 @@
 			// all fonts must be embedded
 			$family = 'pdfa'.$family;
 		}
-		$tempstyle = strtoupper($style);
+		$tempstyle = strtoupper(($style ?? ''));
 		$style = '';
 		// underline
-		if (strpos($tempstyle, 'U') !== false) {
+		if (strpos(($tempstyle ?? ''), 'U') !== false) {
 			$this->underline = true;
 		} else {
 			$this->underline = false;
 		}
 		// line-through (deleted)
-		if (strpos($tempstyle, 'D') !== false) {
+		if (strpos(($tempstyle ?? ''), 'D') !== false) {
 			$this->linethrough = true;
 		} else {
 			$this->linethrough = false;
 		}
 		// overline
-		if (strpos($tempstyle, 'O') !== false) {
+		if (strpos(($tempstyle ?? ''), 'O') !== false) {
 			$this->overline = true;
 		} else {
 			$this->overline = false;
 		}
 		// bold
-		if (strpos($tempstyle, 'B') !== false) {
+		if (strpos(($tempstyle ?? ''), 'B') !== false) {
 			$style .= 'B';
 		}
 		// oblique
-		if (strpos($tempstyle, 'I') !== false) {
+		if (strpos(($tempstyle ?? ''), 'I') !== false) {
 			$style .= 'I';
 		}
 		$bistyle = $style;
@@ -4258,12 +4262,12 @@
 		// search and include font file
 		if (TCPDF_STATIC::empty_string($fontfile) OR (!@TCPDF_STATIC::file_exists($fontfile))) {
 			// build a standard filenames for specified font
-			$tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php';
+			$tmp_fontfile = str_replace(' ', '', ($family ?? '')).strtolower(($style ?? '')).'.php';
 			$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
 			if (TCPDF_STATIC::empty_string($fontfile)) {
 				$missing_style = true;
 				// try to remove the style part
-				$tmp_fontfile = str_replace(' ', '', $family).'.php';
+				$tmp_fontfile = str_replace(' ', '', ($family ?? '')).'.php';
 				$fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir);
 			}
 		}
@@ -4338,7 +4342,7 @@
 			$styles = array('' => '', 'B' => ',Bold', 'I' => ',Italic', 'BI' => ',BoldItalic');
 			$name .= $styles[$bistyle];
 			// artificial bold
-			if (strpos($bistyle, 'B') !== false) {
+			if (strpos(($bistyle ?? ''), 'B') !== false) {
 				if (isset($desc['StemV'])) {
 					// from normal to bold
 					$desc['StemV'] = round($desc['StemV'] * 1.75);
@@ -4348,7 +4352,7 @@
 				}
 			}
 			// artificial italic
-			if (strpos($bistyle, 'I') !== false) {
+			if (strpos(($bistyle ?? ''), 'I') !== false) {
 				if (isset($desc['ItalicAngle'])) {
 					$desc['ItalicAngle'] -= 11;
 				} else {
@@ -4375,7 +4379,7 @@
 		if (isset($diff) AND (!empty($diff))) {
 			//Search existing encodings
 			$d = 0;
-			$nb = count($this->diffs);
+			$nb = count(($this->diffs ?? []));
 			for ($i=1; $i <= $nb; ++$i) {
 				if ($this->diffs[$i] == $diff) {
 					$d = $i;
@@ -4459,7 +4463,7 @@
 		$this->FontSize = $size / $this->k;
 		// calculate some font metrics
 		if (isset($this->CurrentFont['desc']['FontBBox'])) {
-			$bbox = explode(' ', substr($this->CurrentFont['desc']['FontBBox'], 1, -1));
+			$bbox = explode(' ', (substr(($this->CurrentFont['desc']['FontBBox'] ?? ''), 1, -1) ?? ''));
 			$font_height = ((intval($bbox[3]) - intval($bbox[1])) * $size / 1000);
 		} else {
 			$font_height = $size * 1.219;
@@ -4495,7 +4499,7 @@
 	public function getFontBBox() {
 		$fbbox = array();
 		if (isset($this->CurrentFont['desc']['FontBBox'])) {
-			$tmpbbox = explode(' ', substr($this->CurrentFont['desc']['FontBBox'], 1, -1));
+			$tmpbbox = explode(' ', (substr(($this->CurrentFont['desc']['FontBBox'] ?? ''), 1, -1) ?? ''));
 			$fbbox = array_map(array($this,'getAbsFontMeasure'), $tmpbbox);
 		} else {
 			// Find max width
@@ -4682,7 +4686,7 @@
 	 */
 	public function AddLink() {
 		// create a new internal link
-		$n = count($this->links) + 1;
+		$n = count(($this->links ?? [])) + 1;
 		$this->links[$n] = array('p' => 0, 'y' => 0, 'f' => false);
 		return $n;
 	}
@@ -4699,7 +4703,7 @@
 	public function SetLink($link, $y=0, $page=-1) {
 		$fixed = false;
 		if (!empty($page) AND ($page[0] == '*')) {
-			$page = intval(substr($page, 1));
+			$page = intval(substr(($page ?? ''), 1));
 			// this page number will not be changed when moving/add/deleting pages
 			$fixed = true;
 		}
@@ -4759,7 +4763,7 @@
 		// recalculate coordinates to account for graphic transformations
 		if (isset($this->transfmatrix) AND !empty($this->transfmatrix)) {
 			for ($i=$this->transfmatrix_key; $i > 0; --$i) {
-				$maxid = count($this->transfmatrix[$i]) - 1;
+				$maxid = count(($this->transfmatrix[$i] ?? [])) - 1;
 				for ($j=$maxid; $j >= 0; --$j) {
 					$ctm = $this->transfmatrix[$i][$j];
 					if (isset($ctm['a'])) {
@@ -4841,7 +4845,7 @@
 		foreach ($this->embeddedfiles as $filename => $filedata) {
 			$data = TCPDF_STATIC::fileGetContents($filedata['file']);
 			if ($data !== FALSE) {
-				$rawsize = strlen($data);
+				$rawsize = strlen(($data ?? ''));
 				if ($rawsize > 0) {
 					// update name tree
 					$this->efnames[$filename] = $filedata['f'].' 0 R';
@@ -4858,7 +4862,7 @@
 					}
 					$stream = $this->_getrawstream($data, $filedata['n']);
 					$out = $this->_getobj($filedata['n'])."\n";
-					$out .= '<< /Type /EmbeddedFile'.$filter.' /Length '.strlen($stream).' /Params <</Size '.$rawsize.'>> >>';
+					$out .= '<< /Type /EmbeddedFile'.$filter.' /Length '.strlen(($stream ?? '')).' /Params <</Size '.$rawsize.'>> >>';
 					$out .= ' stream'."\n".$stream."\n".'endstream';
 					$out .= "\n".'endobj';
 					$this->_out($out);
@@ -5062,7 +5066,7 @@
 	 */
 	protected function getCellCode($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M') {
 		// replace 'NO-BREAK SPACE' (U+00A0) character with a simple space
-		$txt = str_replace(TCPDF_FONTS::unichr(160, $this->isunicode), ' ', $txt);
+		$txt = str_replace((TCPDF_FONTS::unichr(160, $this->isunicode) ?? ''), ' ', ($txt ?? ''));
 		$prev_cell_margin = $this->cell_margin;
 		$prev_cell_padding = $this->cell_padding;
 		$txt = TCPDF_STATIC::removeSHY($txt, $this->isunicode);
@@ -5203,7 +5207,7 @@
 		}
 		$s = '';
 		// fill and borders
-		if (is_string($border) AND (strlen($border) == 4)) {
+		if (is_string($border) AND (strlen(($border ?? '')) == 4)) {
 			// full border
 			$border = 1;
 		}
@@ -5233,7 +5237,7 @@
 					// replace thai chars (if any)
 					if (defined('K_THAI_TOPCHARS') AND (K_THAI_TOPCHARS == true)) {
 						// number of chars
-						$numchars = count($unicode);
+						$numchars = count(($unicode ?? []));
 						// po pla, for far, for fan
 						$longtail = array(0x0e1b, 0x0e1d, 0x0e1f);
 						// do chada, to patak
@@ -5372,7 +5376,7 @@
 			if (($align == 'J') AND ($ns > 0)) {
 				if ($this->isUnicodeFont()) {
 					// get string width without spaces
-					$width = $this->GetStringWidth(str_replace(' ', '', $txt));
+					$width = $this->GetStringWidth(str_replace(' ', '', ($txt ?? '')));
 					// calculate average space width
 					$spacewidth = -1000 * ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns?$ns:1) / ($this->FontSize?$this->FontSize:1);
 					if ($this->font_stretching != 100) {
@@ -5380,7 +5384,7 @@
 						$spacewidth /= ($this->font_stretching / 100);
 					}
 					// set word position to be used with TJ operator
-					$txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%F', $spacewidth).' (', $txt2);
+					$txt2 = str_replace(chr(0).chr(32), ') '.sprintf('%F', $spacewidth).' (', ($txt2 ?? ''));
 					$unicode_justification = true;
 				} else {
 					// get string width
@@ -5397,7 +5401,7 @@
 				$width = $w - $this->cell_padding['L'] - $this->cell_padding['R'];
 			}
 			// replace carriage return characters
-			$txt2 = str_replace("\r", ' ', $txt2);
+			$txt2 = str_replace("\r", ' ', ($txt2 ?? ''));
 			switch ($align) {
 				case 'C': {
 					$dx = ($w - $width) / 2;
@@ -5447,7 +5451,7 @@
 						// x space to skip
 						if ($spacewidth != 0) {
 							// justification shift
-							$xshift += (count(array_keys($uniarr, 32)) * $spw);
+							$xshift += (count((array_keys($uniarr, 32) ?? [])) * $spw);
 						}
 						$xshift += $this->GetArrStringWidth($uniarr); // + shift justification
 					} else {
@@ -5576,7 +5580,7 @@
 		$yeB = $yeL;
 		if (is_string($brd)) {
 			// convert string to array
-			$slen = strlen($brd);
+			$slen = strlen(($brd ?? ''));
 			$newbrd = array();
 			for ($i = 0; $i < $slen; ++$i) {
 				$newbrd[$brd[$i]] = array('cap' => 'square', 'join' => 'miter');
@@ -5638,63 +5642,63 @@
 				}
 			}
 			// draw borders by case
-			if (strlen($border) == 4) {
+			if (strlen(($border ?? '')) == 4) {
 				$s .= sprintf('%F %F %F %F re S ', $xT, $yT, ($w * $k), (-$h * $k));
-			} elseif (strlen($border) == 3) {
-				if (strpos($border,'B') === false) { // LTR
+			} elseif (strlen(($border ?? '')) == 3) {
+				if (strpos(($border ?? ''),'B') === false) { // LTR
 					$s .= sprintf('%F %F m ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= 'S ';
-				} elseif (strpos($border,'L') === false) { // TRB
+				} elseif (strpos(($border ?? ''),'L') === false) { // TRB
 					$s .= sprintf('%F %F m ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= 'S ';
-				} elseif (strpos($border,'T') === false) { // RBL
+				} elseif (strpos(($border ?? ''),'T') === false) { // RBL
 					$s .= sprintf('%F %F m ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= 'S ';
-				} elseif (strpos($border,'R') === false) { // BLT
+				} elseif (strpos(($border ?? ''),'R') === false) { // BLT
 					$s .= sprintf('%F %F m ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= 'S ';
 				}
-			} elseif (strlen($border) == 2) {
-				if ((strpos($border,'L') !== false) AND (strpos($border,'T') !== false)) { // LT
+			} elseif (strlen(($border ?? '')) == 2) {
+				if ((strpos(($border ?? ''),'L') !== false) AND (strpos(($border ?? ''),'T') !== false)) { // LT
 					$s .= sprintf('%F %F m ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= 'S ';
-				} elseif ((strpos($border,'T') !== false) AND (strpos($border,'R') !== false)) { // TR
+				} elseif ((strpos(($border ?? ''),'T') !== false) AND (strpos(($border ?? ''),'R') !== false)) { // TR
 					$s .= sprintf('%F %F m ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= 'S ';
-				} elseif ((strpos($border,'R') !== false) AND (strpos($border,'B') !== false)) { // RB
+				} elseif ((strpos(($border ?? ''),'R') !== false) AND (strpos(($border ?? ''),'B') !== false)) { // RB
 					$s .= sprintf('%F %F m ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= 'S ';
-				} elseif ((strpos($border,'B') !== false) AND (strpos($border,'L') !== false)) { // BL
+				} elseif ((strpos(($border ?? ''),'B') !== false) AND (strpos(($border ?? ''),'L') !== false)) { // BL
 					$s .= sprintf('%F %F m ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= 'S ';
-				} elseif ((strpos($border,'L') !== false) AND (strpos($border,'R') !== false)) { // LR
+				} elseif ((strpos(($border ?? ''),'L') !== false) AND (strpos(($border ?? ''),'R') !== false)) { // LR
 					$s .= sprintf('%F %F m ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= 'S ';
 					$s .= sprintf('%F %F m ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= 'S ';
-				} elseif ((strpos($border,'T') !== false) AND (strpos($border,'B') !== false)) { // TB
+				} elseif ((strpos(($border ?? ''),'T') !== false) AND (strpos(($border ?? ''),'B') !== false)) { // TB
 					$s .= sprintf('%F %F m ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= 'S ';
@@ -5703,19 +5707,19 @@
 					$s .= 'S ';
 				}
 			} else { // strlen($border) == 1
-				if (strpos($border,'L') !== false) { // L
+				if (strpos(($border ?? ''),'L') !== false) { // L
 					$s .= sprintf('%F %F m ', $xL, $yL);
 					$s .= sprintf('%F %F l ', $xT, $yT);
 					$s .= 'S ';
-				} elseif (strpos($border,'T') !== false) { // T
+				} elseif (strpos(($border ?? ''),'T') !== false) { // T
 					$s .= sprintf('%F %F m ', $xT, $yT);
 					$s .= sprintf('%F %F l ', $xR, $yR);
 					$s .= 'S ';
-				} elseif (strpos($border,'R') !== false) { // R
+				} elseif (strpos(($border ?? ''),'R') !== false) { // R
 					$s .= sprintf('%F %F m ', $xR, $yR);
 					$s .= sprintf('%F %F l ', $xB, $yB);
 					$s .= 'S ';
-				} elseif (strpos($border,'B') !== false) { // B
+				} elseif (strpos(($border ?? ''),'B') !== false) { // B
 					$s .= sprintf('%F %F m ', $xB, $yB);
 					$s .= sprintf('%F %F l ', $xL, $yL);
 					$s .= 'S ';
@@ -6033,7 +6037,7 @@
 				} // end for each column
 			}
 			if ($cborder OR $fill) {
-				$offsetlen = strlen($ccode);
+				$offsetlen = strlen(($ccode ?? ''));
 				// draw border and fill
 				if ($this->inxobj) {
 					// we are inside an XObject template
@@ -6046,8 +6050,8 @@
 						$this->xobjects[$this->xobjid]['intmrk'] += $offsetlen;
 					}
 					$pagebuff = $this->xobjects[$this->xobjid]['outdata'];
-					$pstart = substr($pagebuff, 0, $pagemark);
-					$pend = substr($pagebuff, $pagemark);
+					$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+					$pend = substr(($pagebuff ?? ''), $pagemark);
 					$this->xobjects[$this->xobjid]['outdata'] = $pstart.$ccode.$pend;
 				} else {
 					if (end($this->transfmrk[$this->page]) !== false) {
@@ -6062,8 +6066,8 @@
 						$this->intmrk[$this->page] += $offsetlen;
 					}
 					$pagebuff = $this->getPageBuffer($this->page);
-					$pstart = substr($pagebuff, 0, $pagemark);
-					$pend = substr($pagebuff, $pagemark);
+					$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+					$pend = substr(($pagebuff ?? ''), $pagemark);
 					$this->setPageBuffer($this->page, $pstart.$ccode.$pend);
 				}
 			}
@@ -6153,18 +6157,18 @@
 		$sum = 0;
 		$chars = TCPDF_FONTS::utf8Bidi(TCPDF_FONTS::UTF8StringToArray($txt, $this->isunicode, $this->CurrentFont), $txt, $this->tmprtl, $this->isunicode, $this->CurrentFont);
 		$charsWidth = $this->GetArrStringWidth($chars, '', '', 0, true);
-		$length = count($chars);
+		$length = count(($chars ?? []));
 		$lastSeparator = -1;
 		for ($i = 0; $i < $length; ++$i) {
 			$c = $chars[$i];
 			$charWidth = $charsWidth[$i];
 			if (($c != 160)
 					AND (($c == 173)
-						OR preg_match($this->re_spaces, TCPDF_FONTS::unichr($c, $this->isunicode))
+						OR preg_match(($this->re_spaces ?? ''), (TCPDF_FONTS::unichr($c, $this->isunicode) ?? ''))
 						OR (($c == 45)
 							AND ($i > 0) AND ($i < ($length - 1))
-							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], TCPDF_FONTS::unichr($chars[($i - 1)], $this->isunicode))
-							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
+							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], (TCPDF_FONTS::unichr($chars[($i - 1)], $this->isunicode) ?? ''))
+							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], (TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode) ?? ''))
 						)
 					)
 				) {
@@ -6277,7 +6281,7 @@
 	public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0, $wadj=0, $margin='') {
 		// check page for no-write regions and adapt page margins if necessary
 		list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y);
-		if (strlen($txt) == 0) {
+		if (strlen(($txt ?? '')) == 0) {
 			// fix empty text
 			$txt = ' ';
 		}
@@ -6286,15 +6290,15 @@
 			$margin = $this->cell_margin;
 		}
 		// remove carriage returns
-		$s = str_replace("\r", '', $txt);
+		$s = str_replace("\r", '', ($txt ?? ''));
 		// check if string contains arabic text
-		if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $s)) {
+		if (preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC ?? ''), ($s ?? ''))) {
 			$arabic = true;
 		} else {
 			$arabic = false;
 		}
 		// check if string contains RTL text
-		if ($arabic OR ($this->tmprtl == 'R') OR preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $s)) {
+		if ($arabic OR ($this->tmprtl == 'R') OR preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL ?? ''), ($s ?? ''))) {
 			$rtlmode = true;
 		} else {
 			$rtlmode = false;
@@ -6305,12 +6309,12 @@
 		$chars = TCPDF_FONTS::UTF8StringToArray($s, $this->isunicode, $this->CurrentFont);
 		// calculate maximum width for a single character on string
 		$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);
-		array_walk($chrw, array($this, 'getRawCharWidth'));
+		// GetArrStringWidth already returns the character widths.
 		$maxchwidth = max($chrw);
 		// get array of chars
 		$uchars = TCPDF_FONTS::UTF8ArrayToUniArray($chars, $this->isunicode);
 		// get the number of characters
-		$nb = count($chars);
+		$nb = count(($chars ?? []));
 		// replacement for SHY character (minus symbol)
 		$shy_replacement = 45;
 		$shy_replacement_char = TCPDF_FONTS::unichr($shy_replacement, $this->isunicode);
@@ -6425,11 +6429,11 @@
 				// \p{Lo} is needed because Chinese characters are packed next to each other without spaces in between.
 				if (($c != 160)
 					AND (($c == 173)
-						OR preg_match($this->re_spaces, TCPDF_FONTS::unichr($c, $this->isunicode))
+						OR preg_match(($this->re_spaces ?? ''), (TCPDF_FONTS::unichr($c, $this->isunicode) ?? ''))
 						OR (($c == 45)
 							AND ($i < ($nb - 1))
-							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], TCPDF_FONTS::unichr($pc, $this->isunicode))
-							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode))
+							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], (TCPDF_FONTS::unichr($pc, $this->isunicode) ?? ''))
+							AND @preg_match('/[\p{L}]/'.$this->re_space['m'], (TCPDF_FONTS::unichr($chars[($i + 1)], $this->isunicode) ?? ''))
 						)
 					)
 				) {
@@ -6837,11 +6841,11 @@
 		// check if we are passing an image as file or string
 		if ($file[0] === '@') {
 			// image from string
-			$imgdata = substr($file, 1);
+			$imgdata = substr(($file ?? ''), 1);
 		} else { // image file
 			if ($file[0] === '*') {
 				// image as external stream
-				$file = substr($file, 1);
+				$file = substr(($file ?? ''), 1);
 				$exurl = $file;
 			}
 			// check if file exist and it is valid
@@ -6853,7 +6857,7 @@
 					// get existing image data
 					$info = $this->getImageBuffer($file);
 					$imsize = array($info['w'], $info['h']);
-				} elseif (strpos($file, '__tcpdf_'.$this->file_id.'_img') === FALSE) {
+				} elseif (strpos(($file ?? ''), '__tcpdf_'.$this->file_id.'_img') === FALSE) {
 					$imgdata = TCPDF_STATIC::fileGetContents($file);
 				}
 			}
@@ -6886,7 +6890,7 @@
 			}
 		}
 		// file hash
-		$filehash = md5($file);
+		$filehash = md5(($file ?? ''));
 		// get original image width and height in pixels
 		list($pixw, $pixh) = $imsize;
 		// calculate image width and height on document
@@ -6899,7 +6903,7 @@
 		} elseif ($h <= 0) {
 			$h = $w * $pixh / $pixw;
 		} elseif (($fitbox !== false) AND ($w > 0) AND ($h > 0)) {
-			if (strlen($fitbox) !== 2) {
+			if (strlen(($fitbox ?? '')) !== 2) {
 				// set default alignment
 				$fitbox = '--';
 			}
@@ -6912,7 +6916,7 @@
 				// height difference
 				$hdiff = ($oldh - $h);
 				// vertical alignment
-				switch (strtoupper($fitbox[1])) {
+				switch (strtoupper(($fitbox[1] ?? ''))) {
 					case 'T': {
 						break;
 					}
@@ -6933,7 +6937,7 @@
 				// width difference
 				$wdiff = ($oldw - $w);
 				// horizontal alignment
-				switch (strtoupper($fitbox[0])) {
+				switch (strtoupper(($fitbox[0] ?? ''))) {
 					case 'L': {
 						if ($this->rtl) {
 							$x -= $wdiff;
@@ -6976,14 +6980,14 @@
 			$newimage = false;
 			// get existing image data
 			$info = $this->getImageBuffer($file);
-			if (strpos($file, '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE) {
+			if (strpos(($file ?? ''), '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE) {
 				// check if the newer image is larger
 				$oldsize = ($info['w'] * $info['h']);
 				if ((($oldsize < $newsize) AND ($resize)) OR (($oldsize < $pixsize) AND (!$resize))) {
 					$newimage = true;
 				}
 			}
-		} elseif (($ismask === false) AND ($imgmask === false) AND (strpos($file, '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE)) {
+		} elseif (($ismask === false) AND ($imgmask === false) AND (strpos(($file ?? ''), '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE)) {
 			// create temp image file (without alpha channel)
 			$tempfile_plain = K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_imgmask_plain_'.$filehash;
 			// create temp alpha file
@@ -7007,7 +7011,7 @@
 		}
 		if ($newimage) {
 			//First use of image, get info
-			$type = strtolower($type);
+			$type = strtolower(($type ?? ''));
 			if ($type == '') {
 				$type = TCPDF_IMAGES::getImageFileType($file, $imsize);
 			} elseif ($type == 'jpg') {
@@ -7023,7 +7027,7 @@
 			if ((method_exists('TCPDF_IMAGES', $mtd)) AND (!($resize AND (function_exists($gdfunction) OR extension_loaded('imagick'))))) {
 				// TCPDF image functions
 				$info = TCPDF_IMAGES::$mtd($file);
-				if (($ismask === false) AND ($imgmask === false) AND (strpos($file, '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE)
+				if (($ismask === false) AND ($imgmask === false) AND (strpos(($file ?? ''), '__tcpdf_'.$this->file_id.'_imgmask_') === FALSE)
 					AND (($info === 'pngalpha') OR (isset($info['trns']) AND !empty($info['trns'])))) {
 					return $this->ImagePngAlpha($file, $x, $y, $pixw, $pixh, $w, $h, 'PNG', $link, $align, $resize, $dpi, $palign, $filehash);
 				}
@@ -7034,11 +7038,11 @@
 					$img = $gdfunction($file);
 					if ($img !== false) {
 						if ($resize) {
-							$imgr = imagecreatetruecolor($neww, $newh);
+							$imgr = imagecreatetruecolor((int) ($neww), (int) ($newh));
 							if (($type == 'gif') OR ($type == 'png')) {
 								$imgr = TCPDF_IMAGES::setGDImageTransparency($imgr, $img);
 							}
-							imagecopyresampled($imgr, $img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
+							imagecopyresampled($imgr, $img, 0, 0, 0, 0, (int) ($neww), (int) ($newh), (int) ($pixw), (int) ($pixh));
 							$img = $imgr;
 						}
 						if (($type == 'gif') OR ($type == 'png')) {
@@ -7058,7 +7062,7 @@
 					if ($type == 'svg') {
 						if ($file[0] === '@') {
 							// image from string
-							$svgimg = substr($file, 1);
+							$svgimg = substr(($file ?? ''), 1);
 						} else {
 							// get SVG file content
 							$svgimg = TCPDF_STATIC::fileGetContents($file);
@@ -7066,32 +7070,32 @@
 						if ($svgimg !== FALSE) {
 							// get width and height
 							$regs = array();
-							if (preg_match('/<svg([^\>]*)>/si', $svgimg, $regs)) {
+							if (preg_match('/<svg([^\>]*)>/si', ($svgimg ?? ''), $regs)) {
 								$svgtag = $regs[1];
 								$tmp = array();
-								if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
+								if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', ($svgtag ?? ''), $tmp)) {
 									$ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
 									$owu = sprintf('%F', ($ow * $dpi / 72)).$this->pdfunit;
-									$svgtag = preg_replace('/[\s]+width[\s]*=[\s]*"[^"]*"/si', ' width="'.$owu.'"', $svgtag, 1);
+									$svgtag = preg_replace('/[\s]+width[\s]*=[\s]*"[^"]*"/si', ' width="'.$owu.'"', ($svgtag ?? ''), 1);
 								} else {
 									$ow = $w;
 								}
 								$tmp = array();
-								if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $svgtag, $tmp)) {
+								if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', ($svgtag ?? ''), $tmp)) {
 									$oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
 									$ohu = sprintf('%F', ($oh * $dpi / 72)).$this->pdfunit;
-									$svgtag = preg_replace('/[\s]+height[\s]*=[\s]*"[^"]*"/si', ' height="'.$ohu.'"', $svgtag, 1);
+									$svgtag = preg_replace('/[\s]+height[\s]*=[\s]*"[^"]*"/si', ' height="'.$ohu.'"', ($svgtag ?? ''), 1);
 								} else {
 									$oh = $h;
 								}
 								$tmp = array();
-								if (!preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $svgtag, $tmp)) {
+								if (!preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', ($svgtag ?? ''), $tmp)) {
 									$vbw = ($ow * $this->imgscale * $this->k);
 									$vbh = ($oh * $this->imgscale * $this->k);
 									$vbox = sprintf(' viewBox="0 0 %F %F" ', $vbw, $vbh);
 									$svgtag = $vbox.$svgtag;
 								}
-								$svgimg = preg_replace('/<svg([^\>]*)>/si', '<svg'.$svgtag.'>', $svgimg, 1);
+								$svgimg = preg_replace('/<svg([^\>]*)>/si', '<svg'.$svgtag.'>', ($svgimg ?? ''), 1);
 							}
 							$img->readImageBlob($svgimg);
 						}
@@ -7239,7 +7243,7 @@
 	protected function ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $filehash='') {
 		// create temp images
 		if (empty($filehash)) {
-			$filehash = md5($file);
+			$filehash = md5(($file ?? ''));
 		}
 		// create temp image file (without alpha channel)
 		$tempfile_plain = K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_imgmask_plain_'.$filehash;
@@ -7283,25 +7287,25 @@
 			try {
 				// generate images
 				$img = imagecreatefrompng($file);
-				$imgalpha = imagecreate($wpx, $hpx);
+				$imgalpha = imagecreate((int) ($wpx), (int) ($hpx));
 				// generate gray scale palette (0 -> 255)
 				for ($c = 0; $c < 256; ++$c) {
-					ImageColorAllocate($imgalpha, $c, $c, $c);
+					ImageColorAllocate($imgalpha, (int) ($c), (int) ($c), (int) ($c));
 				}
 				// extract alpha channel
 				for ($xpx = 0; $xpx < $wpx; ++$xpx) {
 					for ($ypx = 0; $ypx < $hpx; ++$ypx) {
-						$color = imagecolorat($img, $xpx, $ypx);
+						$color = imagecolorat($img, (int) ($xpx), (int) ($ypx));
 						// get and correct gamma color
 						$alpha = $this->getGDgamma($img, $color);
-						imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
+						imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), (int) ($alpha));
 					}
 				}
 				imagepng($imgalpha, $tempfile_alpha);
 				imagedestroy($imgalpha);
 				// extract image without alpha channel
-				$imgplain = imagecreatetruecolor($wpx, $hpx);
-				imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
+				$imgplain = imagecreatetruecolor((int) ($wpx), (int) ($hpx));
+				imagecopy($imgplain, $img, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
 				imagepng($imgplain, $tempfile_plain);
 				imagedestroy($imgplain);
 				$parsed = true;
@@ -7332,13 +7336,13 @@
 	 */
 	protected function getGDgamma($img, $c) {
 		if (!isset($this->gdgammacache['#'.$c])) {
-			$colors = imagecolorsforindex($img, $c);
+			$colors = imagecolorsforindex($img, (int) ($c));
 			// GD alpha is only 7 bit (0 -> 127)
 			$this->gdgammacache['#'.$c] = (((127 - $colors['alpha']) / 127) * 255);
 			// correct gamma
 			$this->gdgammacache['#'.$c] = (pow(($this->gdgammacache['#'.$c] / 255), 2.2) * 255);
 			// store the latest values on cache to improve performances
-			if (count($this->gdgammacache) > 8) {
+			if (count(($this->gdgammacache ?? [])) > 8) {
 				// remove one element from the cache array
 				array_shift($this->gdgammacache);
 			}
@@ -7556,37 +7560,37 @@
 		if (is_bool($dest)) {
 			$dest = $dest ? 'D' : 'F';
 		}
-		$dest = strtoupper($dest);
+		$dest = strtoupper(($dest ?? ''));
 		if ($dest[0] != 'F') {
-			$name = preg_replace('/[\s]+/', '_', $name);
-			$name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $name);
+			$name = preg_replace('/[\s]+/', '_', ($name ?? ''));
+			$name = preg_replace('/[^a-zA-Z0-9_\.-]/', '', ($name ?? ''));
 		}
 		if ($this->sign) {
 			// *** apply digital signature to the document ***
 			// get the document content
 			$pdfdoc = $this->getBuffer();
 			// remove last newline
-			$pdfdoc = substr($pdfdoc, 0, -1);
+			$pdfdoc = substr(($pdfdoc ?? ''), 0, -1);
 			// remove filler space
-			$byterange_string_len = strlen(TCPDF_STATIC::$byterange_string);
+			$byterange_string_len = strlen((TCPDF_STATIC::$byterange_string ?? ''));
 			// define the ByteRange
 			$byte_range = array();
 			$byte_range[0] = 0;
-			$byte_range[1] = strpos($pdfdoc, TCPDF_STATIC::$byterange_string) + $byterange_string_len + 10;
+			$byte_range[1] = strpos(($pdfdoc ?? ''), (TCPDF_STATIC::$byterange_string ?? '')) + $byterange_string_len + 10;
 			$byte_range[2] = $byte_range[1] + $this->signature_max_length + 2;
-			$byte_range[3] = strlen($pdfdoc) - $byte_range[2];
-			$pdfdoc = substr($pdfdoc, 0, $byte_range[1]).substr($pdfdoc, $byte_range[2]);
+			$byte_range[3] = strlen(($pdfdoc ?? '')) - $byte_range[2];
+			$pdfdoc = substr(($pdfdoc ?? ''), 0, $byte_range[1]).substr(($pdfdoc ?? ''), $byte_range[2]);
 			// replace the ByteRange
 			$byterange = sprintf('/ByteRange[0 %u %u %u]', $byte_range[1], $byte_range[2], $byte_range[3]);
-			$byterange .= str_repeat(' ', ($byterange_string_len - strlen($byterange)));
-			$pdfdoc = str_replace(TCPDF_STATIC::$byterange_string, $byterange, $pdfdoc);
+			$byterange .= str_repeat(' ', ($byterange_string_len - strlen(($byterange ?? ''))));
+			$pdfdoc = str_replace((TCPDF_STATIC::$byterange_string ?? ''), ($byterange ?? ''), ($pdfdoc ?? ''));
 			// write the document to a temporary folder
 			$tempdoc = TCPDF_STATIC::getObjFilename('doc', $this->file_id);
 			$f = TCPDF_STATIC::fopenLocal($tempdoc, 'wb');
 			if (!$f) {
 				$this->Error('Unable to create temporary file: '.$tempdoc);
 			}
-			$pdfdoc_length = strlen($pdfdoc);
+			$pdfdoc_length = strlen(($pdfdoc ?? ''));
 			fwrite($f, $pdfdoc, $pdfdoc_length);
 			fclose($f);
 			// get digital signature via openssl library
@@ -7597,22 +7601,22 @@
 				openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED, $this->signature_data['extracerts']);
 			}
 			// read signature
-			$signature = file_get_contents($tempsign);
+			$signature = file_get_contents(($tempsign ?? ''));
 			// extract signature
-			$signature = substr($signature, $pdfdoc_length);
-			$signature = substr($signature, (strpos($signature, "%%EOF\n\n------") + 13));
-			$tmparr = explode("\n\n", $signature);
+			$signature = substr(($signature ?? ''), $pdfdoc_length);
+			$signature = substr(($signature ?? ''), (strpos(($signature ?? ''), "%%EOF\n\n------") + 13));
+			$tmparr = explode("\n\n", ($signature ?? ''));
 			$signature = $tmparr[1];
 			// decode signature
-			$signature = base64_decode(trim($signature));
+			$signature = base64_decode((trim(($signature ?? '')) ?? ''));
 			// add TSA timestamp to signature
 			$signature = $this->applyTSA($signature);
 			// convert signature to hex
 			$signature = current(unpack('H*', $signature));
-			$signature = str_pad($signature, $this->signature_max_length, '0');
+			$signature = str_pad(($signature ?? ''), $this->signature_max_length, '0');
 			// Add signature to the document
-			$this->buffer = substr($pdfdoc, 0, $byte_range[1]).'<'.$signature.'>'.substr($pdfdoc, $byte_range[1]);
-			$this->bufferlen = strlen($this->buffer);
+			$this->buffer = substr(($pdfdoc ?? ''), 0, $byte_range[1]).'<'.$signature.'>'.substr(($pdfdoc ?? ''), $byte_range[1]);
+			$this->bufferlen = strlen(($this->buffer ?? ''));
 		}
 		switch($dest) {
 			case 'I': {
@@ -7653,7 +7657,7 @@
 				header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
 				header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
 				// force download dialog
-				if (strpos(php_sapi_name(), 'cgi') === false) {
+				if (strpos((php_sapi_name() ?? ''), 'cgi') === false) {
 					header('Content-Type: application/force-download');
 					header('Content-Type: application/octet-stream', false);
 					header('Content-Type: application/download', false);
@@ -7686,7 +7690,7 @@
 					header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
 					header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
 					header('Content-Disposition: inline; filename="'.basename($name).'"');
-					TCPDF_STATIC::sendOutputData(file_get_contents($name), filesize($name));
+					TCPDF_STATIC::sendOutputData(file_get_contents(($name ?? '')), filesize($name));
 				} elseif ($dest == 'FD') {
 					// send headers to browser
 					if (ob_get_contents()) {
@@ -7701,7 +7705,7 @@
 					header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
 					header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
 					// force download dialog
-					if (strpos(php_sapi_name(), 'cgi') === false) {
+					if (strpos((php_sapi_name() ?? ''), 'cgi') === false) {
 						header('Content-Type: application/force-download');
 						header('Content-Type: application/octet-stream', false);
 						header('Content-Type: application/download', false);
@@ -7712,7 +7716,7 @@
 					// use the Content-Disposition header to supply a recommended filename
 					header('Content-Disposition: attachment; filename="'.basename($name).'"');
 					header('Content-Transfer-Encoding: binary');
-					TCPDF_STATIC::sendOutputData(file_get_contents($name), filesize($name));
+					TCPDF_STATIC::sendOutputData(file_get_contents(($name ?? '')), filesize($name));
 				}
 				break;
 			}
@@ -7723,7 +7727,7 @@
 				$retval .= 'Content-Transfer-Encoding: base64'."\r\n";
 				$retval .= 'Content-Disposition: attachment;'."\r\n";
 				$retval .= ' filename="'.$name.'"'."\r\n\r\n";
-				$retval .= chunk_split(base64_encode($this->getBuffer()), 76, "\r\n");
+				$retval .= chunk_split(base64_encode(($this->getBuffer() ?? '')), 76, "\r\n");
 				return $retval;
 			}
 			case 'S': {
@@ -7843,16 +7847,16 @@
 		foreach ($aliases as $type => $alias) {
 			foreach ($alias as $a) {
 				// find position of compensation factor
-				$startnum = (strpos($a, ':') + 1);
-				$a = substr($a, 0, $startnum);
-				if (($pos = strpos($page, $a)) !== false) {
+				$startnum = (strpos(($a ?? ''), ':') + 1);
+				$a = substr(($a ?? ''), 0, $startnum);
+				if (($pos = strpos(($page ?? ''), ($a ?? ''))) !== false) {
 					// end of alias
-					$endnum = strpos($page, '}', $pos);
+					$endnum = strpos(($page ?? ''), '}', $pos);
 					// string to be replaced
-					$aa = substr($page, $pos, ($endnum - $pos + 1));
+					$aa = substr(($page ?? ''), $pos, ($endnum - $pos + 1));
 					// get compensation factor
-					$ratio = substr($page, ($pos + $startnum), ($endnum - $pos - $startnum));
-					$ratio = preg_replace('/[^0-9\.]/', '', $ratio);
+					$ratio = substr(($page ?? ''), ($pos + $startnum), ($endnum - $pos - $startnum));
+					$ratio = preg_replace('/[^0-9\.]/', '', ($ratio ?? ''));
 					$ratio = floatval($ratio);
 					if ($type == 'u') {
 						$chrdiff = floor(($diff + 12) * $ratio);
@@ -7862,7 +7866,7 @@
 						$chrdiff = floor(($diff + 11) * $ratio);
 						$shift = str_repeat(' ', $chrdiff);
 					}
-					$page = str_replace($aa, $shift, $page);
+					$page = str_replace(($aa ?? ''), ($shift ?? ''), ($page ?? ''));
 				}
 			}
 		}
@@ -7903,7 +7907,7 @@
 		for ($n = 1; $n <= $num_pages; ++$n) {
 			// get current page
 			$temppage = $this->getPageBuffer($n);
-			$pagelen = strlen($temppage);
+			$pagelen = strlen(($temppage ?? ''));
 			// set replacements for total pages number
 			$pnpa = TCPDF_STATIC::formatPageNumber(($this->starting_page_number + $n - 1));
 			$pnpu = TCPDF_FONTS::UTF8ToUTF16BE($pnpa, false, $this->isunicode, $this->CurrentFont);
@@ -7940,7 +7944,7 @@
 			// replace right shift alias
 			$temppage = $this->replaceRightShiftPageNumAliases($temppage, $pnalias[4], max($pdiff, $gdiff));
 			// replace EPS marker
-			$temppage = str_replace($this->epsmarker, '', $temppage);
+			$temppage = str_replace(($this->epsmarker ?? ''), '', ($temppage ?? ''));
 			//Page
 			$this->page_obj_id[$n] = $this->_newobj();
 			$out = '<<';
@@ -8028,7 +8032,7 @@
 			$p = ($this->compress) ? gzcompress($temppage) : $temppage;
 			$this->_newobj();
 			$p = $this->_getrawstream($p);
-			$this->_out('<<'.$filter.'/Length '.strlen($p).'>> stream'."\n".$p."\n".'endstream'."\n".'endobj');
+			$this->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).'>> stream'."\n".$p."\n".'endstream'."\n".'endobj');
 		}
 		//Pages root
 		$out = $this->_getobj(1)."\n";
@@ -8166,7 +8170,7 @@
 						$fval = 0;
 						if (is_array($pl['opt']['f'])) {
 							foreach ($pl['opt']['f'] as $f) {
-								switch (strtolower($f)) {
+								switch (strtolower(($f ?? ''))) {
 									case 'invisible': {
 										$fval += 1 << 0;
 										break;
@@ -8232,7 +8236,7 @@
 						if (is_array($pl['opt']['ap'])) {
 							foreach ($pl['opt']['ap'] as $apmode => $apdef) {
 								// $apmode can be: n = normal; r = rollover; d = down;
-								$annots .= ' /'.strtoupper($apmode);
+								$annots .= ' /'.strtoupper(($apmode ?? ''));
 								if (is_array($apdef)) {
 									$annots .= ' <<';
 									foreach ($apdef as $apstate => $stream) {
@@ -8272,7 +8276,7 @@
 						$annots .= ' >>';
 					} else {
 						$annots .= ' /Border [';
-						if (isset($pl['opt']['border']) AND (count($pl['opt']['border']) >= 3)) {
+						if (isset($pl['opt']['border']) AND (count(($pl['opt']['border'] ?? [])) >= 3)) {
 							$annots .= intval($pl['opt']['border'][0]).' ';
 							$annots .= intval($pl['opt']['border'][1]).' ';
 							$annots .= intval($pl['opt']['border'][2]);
@@ -8307,7 +8311,7 @@
 					//$annots .= ' /StructParent ';
 					//$annots .= ' /OC ';
 					$markups = array('text', 'freetext', 'line', 'square', 'circle', 'polygon', 'polyline', 'highlight', 'underline', 'squiggly', 'strikeout', 'stamp', 'caret', 'ink', 'fileattachment', 'sound');
-					if (in_array(strtolower($pl['opt']['subtype']), $markups)) {
+					if (in_array(strtolower(($pl['opt']['subtype'] ?? '')), $markups)) {
 						// this is a markup type
 						if (isset($pl['opt']['t']) AND is_string($pl['opt']['t'])) {
 							$annots .= ' /T '.$this->_textstring($pl['opt']['t'], $annot_obj_id);
@@ -8330,10 +8334,10 @@
 					}
 					$lineendings = array('Square', 'Circle', 'Diamond', 'OpenArrow', 'ClosedArrow', 'None', 'Butt', 'ROpenArrow', 'RClosedArrow', 'Slash');
 					// Annotation types
-					switch (strtolower($pl['opt']['subtype'])) {
+					switch (strtolower(($pl['opt']['subtype'] ?? ''))) {
 						case 'text': {
 							if (isset($pl['opt']['open'])) {
-								$annots .= ' /Open '. (strtolower($pl['opt']['open']) == 'true' ? 'true' : 'false');
+								$annots .= ' /Open '. (strtolower(($pl['opt']['open'] ?? '')) == 'true' ? 'true' : 'false');
 							}
 							$iconsapp = array('Comment', 'Help', 'Insert', 'Key', 'NewParagraph', 'Note', 'Paragraph');
 							if (isset($pl['opt']['name']) AND in_array($pl['opt']['name'], $iconsapp)) {
@@ -8368,25 +8372,25 @@
 							if (is_string($pl['txt']) && !empty($pl['txt'])) {
 								if ($pl['txt'][0] == '#') {
 									// internal destination
-									$annots .= ' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($pl['txt'], 1));
+									$annots .= ' /Dest /'.TCPDF_STATIC::encodeNameObject(substr(($pl['txt'] ?? ''), 1));
 								} elseif ($pl['txt'][0] == '%') {
 									// embedded PDF file
-									$filename = basename(substr($pl['txt'], 1));
+									$filename = basename(substr(($pl['txt'] ?? ''), 1));
 									$annots .= ' /A << /S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($n - 1).' /A '.$this->embeddedfiles[$filename]['a'].' >> >>';
 								} elseif ($pl['txt'][0] == '*') {
 									// embedded generic file
-									$filename = basename(substr($pl['txt'], 1));
+									$filename = basename(substr(($pl['txt'] ?? ''), 1));
 									$jsa = 'var D=event.target.doc;var MyData=D.dataObjects;for (var i in MyData) if (MyData[i].path=="'.$filename.'") D.exportDataObject( { cName : MyData[i].name, nLaunch : 2});';
 									$annots .= ' /A << /S /JavaScript /JS '.$this->_textstring($jsa, $annot_obj_id).'>>';
 								} else {
 									$parsedUrl = parse_url($pl['txt']);
-									if (empty($parsedUrl['scheme']) AND (strtolower(substr($parsedUrl['path'], -4)) == '.pdf')) {
+									if (empty($parsedUrl['scheme']) AND (strtolower((substr(($parsedUrl['path'] ?? ''), -4) ?? '')) == '.pdf')) {
 										// relative link to a PDF file
 										$dest = '[0 /Fit]'; // default page 0
 										if (!empty($parsedUrl['fragment'])) {
 											// check for named destination
-											$tmp = explode('=', $parsedUrl['fragment']);
-											$dest = '('.((count($tmp) == 2) ? $tmp[1] : $tmp[0]).')';
+											$tmp = explode('=', ($parsedUrl['fragment'] ?? ''));
+											$dest = '('.((count(($tmp ?? [])) == 2) ? $tmp[1] : $tmp[0]).')';
 										}
 										$annots .= ' /A <</S /GoToR /D '.$dest.' /F '.$this->_datastring($this->unhtmlentities($parsedUrl['path']), $annot_obj_id).' /NewWindow true>>';
 									} else {
@@ -8739,7 +8743,7 @@
 	 * @since 4.8.001 (2009-09-09)
 	 */
 	protected function _putAPXObject($w=0, $h=0, $stream='') {
-		$stream = trim($stream);
+		$stream = trim(($stream ?? ''));
 		$out = $this->_getobj()."\n";
 		$this->xobjects['AX'.$this->n] = array('n' => $this->n);
 		$out .= '<<';
@@ -8755,7 +8759,7 @@
 		$out .= ' /Matrix [1 0 0 1 0 0]';
 		$out .= ' /Resources 2 0 R';
 		$stream = $this->_getrawstream($stream);
-		$out .= ' /Length '.strlen($stream);
+		$out .= ' /Length '.strlen(($stream ?? ''));
 		$out .= ' >>';
 		$out .= ' stream'."\n".$stream."\n".'endstream';
 		$out .= "\n".'endobj';
@@ -8781,17 +8785,17 @@
 			// search and get font file to embedd
 			$fontfile = TCPDF_FONTS::getFontFullPath($file, $info['fontdir']);
 			if (!TCPDF_STATIC::empty_string($fontfile)) {
-				$font = file_get_contents($fontfile);
-				$compressed = (substr($file, -2) == '.z');
+				$font = file_get_contents(($fontfile ?? ''));
+				$compressed = (substr(($file ?? ''), -2) == '.z');
 				if ((!$compressed) AND (isset($info['length2']))) {
-					$header = (ord($font[0]) == 128);
+					$header = (ord(($font[0] ?? '')) == 128);
 					if ($header) {
 						// strip first binary header
-						$font = substr($font, 6);
-					}
-					if ($header AND (ord($font[$info['length1']]) == 128)) {
+						$font = substr(($font ?? ''), 6);
+					}
+					if ($header AND (ord(($font[$info['length1']] ?? '')) == 128)) {
 						// strip second binary header
-						$font = substr($font, 0, $info['length1']).substr($font, ($info['length1'] + 6));
+						$font = substr(($font ?? ''), 0, $info['length1']).substr(($font ?? ''), ($info['length1'] + 6));
 					}
 				} elseif ($info['subset'] AND ((!$compressed) OR ($compressed AND function_exists('gzcompress')))) {
 					if ($compressed) {
@@ -8807,7 +8811,7 @@
 					// rebuild a font subset
 					$font = TCPDF_FONTS::_getTrueTypeFontSubset($font, $subsetchars);
 					// calculate new font length
-					$info['length1'] = strlen($font);
+					$info['length1'] = strlen(($font ?? ''));
 					if ($compressed) {
 						// recompress font
 						$font = gzcompress($font);
@@ -8816,7 +8820,7 @@
 				$this->_newobj();
 				$this->FontFiles[$file]['n'] = $this->n;
 				$stream = $this->_getrawstream($font);
-				$out = '<< /Length '.strlen($stream);
+				$out = '<< /Length '.strlen(($stream ?? ''));
 				if ($compressed) {
 					$out .= ' /Filter /FlateDecode';
 				}
@@ -8843,7 +8847,7 @@
 				$out .= ' /Subtype /Type1';
 				$out .= ' /BaseFont /'.$name;
 				$out .= ' /Name /F'.$font['i'];
-				if ((strtolower($name) != 'symbol') AND (strtolower($name) != 'zapfdingbats')) {
+				if ((strtolower(($name ?? '')) != 'symbol') AND (strtolower(($name ?? '')) != 'zapfdingbats')) {
 					$out .= ' /Encoding /WinAnsiEncoding';
 				}
 				if ($k == 'helvetica') {
@@ -8903,7 +8907,7 @@
 				$this->_out($s);
 			} else {
 				// additional types
-				$mtd = '_put'.strtolower($type);
+				$mtd = '_put'.strtolower(($type ?? ''));
 				if (!method_exists($this, $mtd)) {
 					$this->Error('Unsupported font type: '.$type);
 				}
@@ -8925,7 +8929,7 @@
 		if ($font['subset']) {
 			// change name for font subsetting
 			$subtag = sprintf('%06u', $font['i']);
-			$subtag = strtr($subtag, '0123456789', 'ABCDEFGHIJ');
+			$subtag = strtr(($subtag ?? ''), '0123456789', 'ABCDEFGHIJ');
 			$fontname .= $subtag.'+';
 		}
 		$fontname .= $font['name'];
@@ -8949,7 +8953,7 @@
 		$stream = ($this->compress) ? gzcompress($stream) : $stream;
 		$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
 		$stream = $this->_getrawstream($stream);
-		$this->_out('<<'.$filter.'/Length '.strlen($stream).'>> stream'."\n".$stream."\n".'endstream'."\n".'endobj');
+		$this->_out('<<'.$filter.'/Length '.strlen(($stream ?? '')).'>> stream'."\n".$stream."\n".'endstream'."\n".'endobj');
 		// CIDFontType2
 		// A CIDFont whose glyph descriptions are based on TrueType font technology
 		$oid = $this->_newobj();
@@ -8995,15 +8999,15 @@
 			// Embed CIDToGIDMap
 			// A specification of the mapping from CIDs to glyph indices
 			// search and get CTG font file to embedd
-			$ctgfile = strtolower($font['ctg']);
+			$ctgfile = strtolower(($font['ctg'] ?? ''));
 			// search and get ctg font file to embedd
 			$fontfile = TCPDF_FONTS::getFontFullPath($ctgfile, $fontdir);
 			if (TCPDF_STATIC::empty_string($fontfile)) {
 				$this->Error('Font file not found: '.$ctgfile);
 			}
-			$stream = $this->_getrawstream(file_get_contents($fontfile));
-			$out = '<< /Length '.strlen($stream).'';
-			if (substr($fontfile, -2) == '.z') { // check file extension
+			$stream = $this->_getrawstream(file_get_contents(($fontfile ?? '')));
+			$out = '<< /Length '.strlen(($stream ?? '')).'';
+			if (substr(($fontfile ?? ''), -2) == '.z') { // check file extension
 				// Decompresses data encoded using the public-domain
 				// zlib/deflate compression method, reproducing the
 				// original text or binary data
@@ -9137,7 +9141,7 @@
 				$out .= ' /ColorSpace [/ICCBased '.($this->n + 1).' 0 R]';
 			} elseif ($info['cs'] == 'Indexed') {
 				// Indexed Colour Space
-				$out .= ' /ColorSpace [/Indexed /DeviceRGB '.((strlen($info['pal']) / 3) - 1).' '.($this->n + 1).' 0 R]';
+				$out .= ' /ColorSpace [/Indexed /DeviceRGB '.((strlen(($info['pal'] ?? '')) / 3) - 1).' '.($this->n + 1).' 0 R]';
 			} else {
 				// Device Colour Space
 				$out .= ' /ColorSpace /'.$info['cs'];
@@ -9168,7 +9172,7 @@
 				}
 				if (isset($info['trns']) AND is_array($info['trns'])) {
 					$trns = '';
-					$count_info = count($info['trns']);
+					$count_info = count(($info['trns'] ?? []));
 					if ($info['cs'] == 'Indexed') {
 						$maxval =(pow(2, $info['bpc']) - 1);
 						for ($i = 0; $i < $count_info; ++$i) {
@@ -9195,7 +9199,7 @@
 					}
 				}
 				$stream = $this->_getrawstream($info['data']);
-				$out .= ' /Length '.strlen($stream).' >>';
+				$out .= ' /Length '.strlen(($stream ?? '')).' >>';
 				$out .= ' stream'."\n".$stream."\n".'endstream';
 			}
 			$out .= "\n".'endobj';
@@ -9205,13 +9209,13 @@
 				$this->_newobj();
 				$icc = ($this->compress) ? gzcompress($info['icc']) : $info['icc'];
 				$icc = $this->_getrawstream($icc);
-				$this->_out('<</N '.$info['ch'].' /Alternate /'.$info['cs'].' '.$filter.'/Length '.strlen($icc).'>> stream'."\n".$icc."\n".'endstream'."\n".'endobj');
+				$this->_out('<</N '.$info['ch'].' /Alternate /'.$info['cs'].' '.$filter.'/Length '.strlen(($icc ?? '')).'>> stream'."\n".$icc."\n".'endstream'."\n".'endobj');
 			} elseif ($info['cs'] == 'Indexed') {
 				// colour palette
 				$this->_newobj();
 				$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
 				$pal = $this->_getrawstream($pal);
-				$this->_out('<<'.$filter.'/Length '.strlen($pal).'>> stream'."\n".$pal."\n".'endstream'."\n".'endobj');
+				$this->_out('<<'.$filter.'/Length '.strlen(($pal ?? '')).'>> stream'."\n".$pal."\n".'endstream'."\n".'endobj');
 			}
 		}
 	}
@@ -9226,7 +9230,7 @@
 	protected function _putxobjects() {
 		foreach ($this->xobjects as $key => $data) {
 			if (isset($data['outdata'])) {
-				$stream = str_replace($this->epsmarker, '', trim($data['outdata']));
+				$stream = str_replace(($this->epsmarker ?? ''), '', (trim(($data['outdata'] ?? '')) ?? ''));
 				$out = $this->_getobj($data['n'])."\n";
 				$out .= '<<';
 				$out .= ' /Type /XObject';
@@ -9312,7 +9316,7 @@
 					$out .= ' >>';
 				}
 				$stream = $this->_getrawstream($stream, $data['n']);
-				$out .= ' /Length '.strlen($stream);
+				$out .= ' /Length '.strlen(($stream ?? ''));
 				$out .= ' >>';
 				$out .= ' stream'."\n".$stream."\n".'endstream';
 				$out .= "\n".'endobj';
@@ -9330,7 +9334,7 @@
 		foreach ($this->spot_colors as $name => $color) {
 			$this->_newobj();
 			$this->spot_colors[$name]['n'] = $this->n;
-			$out = '[/Separation /'.str_replace(' ', '#20', $name);
+			$out = '[/Separation /'.str_replace(' ', '#20', ($name ?? ''));
 			$out .= ' /DeviceCMYK <<';
 			$out .= ' /Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0]';
 			$out .= ' '.sprintf('/C1 [%F %F %F %F] ', ($color['C'] / 100), ($color['M'] / 100), ($color['Y'] / 100), ($color['K'] / 100));
@@ -9542,15 +9546,15 @@
 		$xmp .= "\t\t".'</rdf:Description>'."\n";
 		// convert doc creation date format
 		$dcdate = TCPDF_STATIC::getFormattedDate($this->doc_creation_timestamp);
-		$doccreationdate = substr($dcdate, 0, 4).'-'.substr($dcdate, 4, 2).'-'.substr($dcdate, 6, 2);
-		$doccreationdate .= 'T'.substr($dcdate, 8, 2).':'.substr($dcdate, 10, 2).':'.substr($dcdate, 12, 2);
-		$doccreationdate .= substr($dcdate, 14, 3).':'.substr($dcdate, 18, 2);
+		$doccreationdate = substr(($dcdate ?? ''), 0, 4).'-'.substr(($dcdate ?? ''), 4, 2).'-'.substr(($dcdate ?? ''), 6, 2);
+		$doccreationdate .= 'T'.substr(($dcdate ?? ''), 8, 2).':'.substr(($dcdate ?? ''), 10, 2).':'.substr(($dcdate ?? ''), 12, 2);
+		$doccreationdate .= substr(($dcdate ?? ''), 14, 3).':'.substr(($dcdate ?? ''), 18, 2);
 		$doccreationdate = TCPDF_STATIC::_escapeXML($doccreationdate);
 		// convert doc modification date format
 		$dmdate = TCPDF_STATIC::getFormattedDate($this->doc_modification_timestamp);
-		$docmoddate = substr($dmdate, 0, 4).'-'.substr($dmdate, 4, 2).'-'.substr($dmdate, 6, 2);
-		$docmoddate .= 'T'.substr($dmdate, 8, 2).':'.substr($dmdate, 10, 2).':'.substr($dmdate, 12, 2);
-		$docmoddate .= substr($dmdate, 14, 3).':'.substr($dmdate, 18, 2);
+		$docmoddate = substr(($dmdate ?? ''), 0, 4).'-'.substr(($dmdate ?? ''), 4, 2).'-'.substr(($dmdate ?? ''), 6, 2);
+		$docmoddate .= 'T'.substr(($dmdate ?? ''), 8, 2).':'.substr(($dmdate ?? ''), 10, 2).':'.substr(($dmdate ?? ''), 12, 2);
+		$docmoddate .= substr(($dmdate ?? ''), 14, 3).':'.substr(($dmdate ?? ''), 18, 2);
 		$docmoddate = TCPDF_STATIC::_escapeXML($docmoddate);
 		$xmp .= "\t\t".'<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">'."\n";
 		$xmp .= "\t\t\t".'<xmp:CreateDate>'.$doccreationdate.'</xmp:CreateDate>'."\n";
@@ -9563,7 +9567,7 @@
 		$xmp .= "\t\t\t".'<pdf:Producer>'.TCPDF_STATIC::_escapeXML(TCPDF_STATIC::getTCPDFProducer()).'</pdf:Producer>'."\n";
 		$xmp .= "\t\t".'</rdf:Description>'."\n";
 		$xmp .= "\t\t".'<rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">'."\n";
-		$uuid = 'uuid:'.substr($this->file_id, 0, 8).'-'.substr($this->file_id, 8, 4).'-'.substr($this->file_id, 12, 4).'-'.substr($this->file_id, 16, 4).'-'.substr($this->file_id, 20, 12);
+		$uuid = 'uuid:'.substr(($this->file_id ?? ''), 0, 8).'-'.substr(($this->file_id ?? ''), 8, 4).'-'.substr(($this->file_id ?? ''), 12, 4).'-'.substr(($this->file_id ?? ''), 16, 4).'-'.substr(($this->file_id ?? ''), 20, 12);
 		$xmp .= "\t\t\t".'<xmpMM:DocumentID>'.$uuid.'</xmpMM:DocumentID>'."\n";
 		$xmp .= "\t\t\t".'<xmpMM:InstanceID>'.$uuid.'</xmpMM:InstanceID>'."\n";
 		$xmp .= "\t\t".'</rdf:Description>'."\n";
@@ -9631,7 +9635,7 @@
 		$xmp .= $this->custom_xmp;
 		$xmp .= '</x:xmpmeta>'."\n";
 		$xmp .= '<?xpacket end="w"?>';
-		$out = '<< /Type /Metadata /Subtype /XML /Length '.strlen($xmp).' >> stream'."\n".$xmp."\n".'endstream'."\n".'endobj';
+		$out = '<< /Type /Metadata /Subtype /XML /Length '.strlen(($xmp ?? '')).' >> stream'."\n".$xmp."\n".'endstream'."\n".'endobj';
 		// restore previous isunicode value
 		$this->isunicode = $prev_isunicode;
 		$this->encrypted = $prev_encrypted;
@@ -9657,7 +9661,7 @@
 				$icc = gzcompress($icc);
 			}
 			$icc = $this->_getrawstream($icc);
-			$this->_out('<</N 3 '.$filter.'/Length '.strlen($icc).'>> stream'."\n".$icc."\n".'endstream'."\n".'endobj');
+			$this->_out('<</N 3 '.$filter.'/Length '.strlen(($icc ?? '')).'>> stream'."\n".$icc."\n".'endstream'."\n".'endobj');
 		}
 		// start catalog
 		$oid = $this->_newobj();
@@ -9688,7 +9692,7 @@
 		if (isset($this->PageMode) AND (!TCPDF_STATIC::empty_string($this->PageMode))) {
 			$out .= ' /PageMode /'.$this->PageMode;
 		}
-		if (count($this->outlines) > 0) {
+		if (count(($this->outlines ?? [])) > 0) {
 			$out .= ' /Outlines '.$this->OutlineRoot.' 0 R';
 			$out .= ' /PageMode /UseOutlines';
 		}
@@ -9890,7 +9894,7 @@
 			foreach ($vp['PrintPageRange'] as $k => $v) {
 				$PrintPageRangeNum .= ' '.($v - 1).'';
 			}
-			$out .= ' /PrintPageRange ['.substr($PrintPageRangeNum,1).']';
+			$out .= ' /PrintPageRange ['.substr(($PrintPageRangeNum ?? ''),1).']';
 		}
 		if (isset($vp['NumCopies'])) {
 			$out .= ' /NumCopies '.intval($vp['NumCopies']);
@@ -10275,8 +10279,8 @@
 			} elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
 				// puts data before page footer
 				$pagebuff = $this->getPageBuffer($this->page);
-				$page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
-				$footer = substr($pagebuff, -$this->footerlen[$this->page]);
+				$page = substr(($pagebuff ?? ''), 0, -$this->footerlen[$this->page]);
+				$footer = substr(($pagebuff ?? ''), -$this->footerlen[$this->page]);
 				$this->setPageBuffer($this->page, $page.$s."\n".$footer);
 				// update footer position
 				$this->footerpos[$this->page] += strlen($s."\n");
@@ -10371,10 +10375,10 @@
 	public function addHtmlLink($url, $name, $fill=false, $firstline=false, $color='', $style=-1, $firstblock=false) {
 		if (isset($url[1]) AND ($url[0] == '#') AND is_numeric($url[1])) {
 			// convert url to internal link
-			$lnkdata = explode(',', $url);
+			$lnkdata = explode(',', ($url ?? ''));
 			if (isset($lnkdata[0]) ) {
-				$page = substr($lnkdata[0], 1);
-				if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
+				$page = substr(($lnkdata[0] ?? ''), 1);
+				if (isset($lnkdata[1]) AND (strlen(($lnkdata[1] ?? '')) > 0)) {
 					$lnky = floatval($lnkdata[1]);
 				} else {
 					$lnky = 0;
@@ -10422,7 +10426,7 @@
 	 * @public
 	 */
 	public function unhtmlentities($text_to_convert) {
-		return @html_entity_decode($text_to_convert, ENT_QUOTES, $this->encoding);
+		return @html_entity_decode(($text_to_convert ?? ''), ENT_QUOTES, $this->encoding);
 	}
 
 	// ENCRYPTION METHODS ----------------------------------
@@ -10442,8 +10446,8 @@
 			// AES padding
 			$objkey .= "\x73\x41\x6C\x54"; // sAlT
 		}
-		$objkey = substr(TCPDF_STATIC::_md5_16($objkey), 0, (($this->encryptdata['Length'] / 8) + 5));
-		$objkey = substr($objkey, 0, 16);
+		$objkey = substr((TCPDF_STATIC::_md5_16($objkey) ?? ''), 0, (($this->encryptdata['Length'] / 8) + 5));
+		$objkey = substr(($objkey ?? ''), 0, 16);
 		return $objkey;
 	}
 
@@ -10610,22 +10614,22 @@
 		} elseif ($this->encryptdata['mode'] < 3) { // RC4-128, AES-128
 			$tmp = TCPDF_STATIC::_md5_16(TCPDF_STATIC::$enc_padding.$this->encryptdata['fileid']);
 			$enc = TCPDF_STATIC::_RC4($this->encryptdata['key'], $tmp, $this->last_enc_key, $this->last_enc_key_c);
-			$len = strlen($tmp);
+			$len = strlen(($tmp ?? ''));
 			for ($i = 1; $i <= 19; ++$i) {
 				$ek = '';
 				for ($j = 0; $j < $len; ++$j) {
-					$ek .= chr(ord($this->encryptdata['key'][$j]) ^ $i);
+					$ek .= chr((int) (ord(($this->encryptdata['key'][$j] ?? '')) ^ $i));
 				}
 				$enc = TCPDF_STATIC::_RC4($ek, $enc, $this->last_enc_key, $this->last_enc_key_c);
 			}
 			$enc .= str_repeat("\x00", 16);
-			return substr($enc, 0, 32);
+			return substr(($enc ?? ''), 0, 32);
 		} elseif ($this->encryptdata['mode'] == 3) { // AES-256
 			$seed = TCPDF_STATIC::_md5_16(TCPDF_STATIC::getRandomSeed());
 			// User Validation Salt
-			$this->encryptdata['UVS'] = substr($seed, 0, 8);
+			$this->encryptdata['UVS'] = substr(($seed ?? ''), 0, 8);
 			// User Key Salt
-			$this->encryptdata['UKS'] = substr($seed, 8, 16);
+			$this->encryptdata['UKS'] = substr(($seed ?? ''), 8, 16);
 			return hash('sha256', $this->encryptdata['user_password'].$this->encryptdata['UVS'], true).$this->encryptdata['UVS'].$this->encryptdata['UKS'];
 		}
 	}
@@ -10657,14 +10661,14 @@
 					$tmp = TCPDF_STATIC::_md5_16($tmp);
 				}
 			}
-			$owner_key = substr($tmp, 0, ($this->encryptdata['Length'] / 8));
+			$owner_key = substr(($tmp ?? ''), 0, ($this->encryptdata['Length'] / 8));
 			$enc = TCPDF_STATIC::_RC4($owner_key, $this->encryptdata['user_password'], $this->last_enc_key, $this->last_enc_key_c);
 			if ($this->encryptdata['mode'] > 0) {
-				$len = strlen($owner_key);
+				$len = strlen(($owner_key ?? ''));
 				for ($i = 1; $i <= 19; ++$i) {
 					$ek = '';
 					for ($j = 0; $j < $len; ++$j) {
-						$ek .= chr(ord($owner_key[$j]) ^ $i);
+						$ek .= chr((int) (ord(($owner_key[$j] ?? '')) ^ $i));
 					}
 					$enc = TCPDF_STATIC::_RC4($ek, $enc, $this->last_enc_key, $this->last_enc_key_c);
 				}
@@ -10673,9 +10677,9 @@
 		} elseif ($this->encryptdata['mode'] == 3) { // AES-256
 			$seed = TCPDF_STATIC::_md5_16(TCPDF_STATIC::getRandomSeed());
 			// Owner Validation Salt
-			$this->encryptdata['OVS'] = substr($seed, 0, 8);
+			$this->encryptdata['OVS'] = substr(($seed ?? ''), 0, 8);
 			// Owner Key Salt
-			$this->encryptdata['OKS'] = substr($seed, 8, 16);
+			$this->encryptdata['OKS'] = substr(($seed ?? ''), 8, 16);
 			return hash('sha256', $this->encryptdata['owner_password'].$this->encryptdata['OVS'].$this->encryptdata['U'], true).$this->encryptdata['OVS'].$this->encryptdata['OKS'];
 		}
 	}
@@ -10706,7 +10710,7 @@
 		foreach ($psw_array as $c) {
 			$psw .= TCPDF_FONTS::unichr($c, $this->isunicode);
 		}
-		return substr($psw, 0, 127);
+		return substr(($psw ?? ''), 0, 127);
 	}
 
 	/**
@@ -10720,7 +10724,7 @@
 		if (!$this->encryptdata['pubkey']) { // standard mode
 			if ($this->encryptdata['mode'] == 3) { // AES-256
 				// generate 256 bit random key
-				$this->encryptdata['key'] = substr(hash('sha256', TCPDF_STATIC::getRandomSeed(), true), 0, $keybytelen);
+				$this->encryptdata['key'] = substr((hash('sha256', (TCPDF_STATIC::getRandomSeed() ?? ''), true) ?? ''), 0, $keybytelen);
 				// truncate passwords
 				$this->encryptdata['user_password'] = $this->_fixAES256Password($this->encryptdata['user_password']);
 				$this->encryptdata['owner_password'] = $this->_fixAES256Password($this->encryptdata['owner_password']);
@@ -10757,10 +10761,10 @@
 				$tmp = TCPDF_STATIC::_md5_16($this->encryptdata['user_password'].$this->encryptdata['O'].$permissions.$this->encryptdata['fileid']);
 				if ($this->encryptdata['mode'] > 0) {
 					for ($i = 0; $i < 50; ++$i) {
-						$tmp = TCPDF_STATIC::_md5_16(substr($tmp, 0, $keybytelen));
-					}
-				}
-				$this->encryptdata['key'] = substr($tmp, 0, $keybytelen);
+						$tmp = TCPDF_STATIC::_md5_16(substr(($tmp ?? ''), 0, $keybytelen));
+					}
+				}
+				$this->encryptdata['key'] = substr(($tmp ?? ''), 0, $keybytelen);
 				// Compute U value
 				$this->encryptdata['U'] = $this->_Uvalue();
 				// Compute P value
@@ -10768,7 +10772,7 @@
 			}
 		} else { // Public-Key mode
 			// random 20-byte seed
-			$seed = sha1(TCPDF_STATIC::getRandomSeed(), true);
+			$seed = sha1((TCPDF_STATIC::getRandomSeed() ?? ''), true);
 			$recipient_bytes = '';
 			foreach ($this->encryptdata['pubkeys'] as $pubkey) {
 				// for each public certificate
@@ -10787,7 +10791,7 @@
 				if (!$f) {
 					$this->Error('Unable to create temporary key file: '.$tempkeyfile);
 				}
-				$envelope_length = strlen($envelope);
+				$envelope_length = strlen(($envelope ?? ''));
 				fwrite($f, $envelope, $envelope_length);
 				fclose($f);
 				$tempencfile = TCPDF_STATIC::getObjFilename('enc', $this->file_id);
@@ -10795,14 +10799,14 @@
 					$this->Error('Unable to encrypt the file: '.$tempkeyfile);
 				}
 				// read encryption signature
-				$signature = file_get_contents($tempencfile, false, null, $envelope_length);
+				$signature = file_get_contents(($tempencfile ?? ''), (false ?? false), null, $envelope_length);
 				// extract signature
-				$signature = substr($signature, strpos($signature, 'Content-Disposition'));
-				$tmparr = explode("\n\n", $signature);
-				$signature = trim($tmparr[1]);
+				$signature = substr(($signature ?? ''), strpos(($signature ?? ''), 'Content-Disposition'));
+				$tmparr = explode("\n\n", ($signature ?? ''));
+				$signature = trim(($tmparr[1] ?? ''));
 				unset($tmparr);
 				// decode signature
-				$signature = base64_decode($signature);
+				$signature = base64_decode(($signature ?? ''));
 				// convert signature to hex
 				$hexsignature = current(unpack('H*', $signature));
 				// store signature on recipients array
@@ -10812,9 +10816,9 @@
 			}
 			// calculate encryption key
 			if ($this->encryptdata['mode'] == 3) { // AES-256
-				$this->encryptdata['key'] = substr(hash('sha256', $seed.$recipient_bytes, true), 0, $keybytelen);
+				$this->encryptdata['key'] = substr((hash('sha256', $seed.$recipient_bytes, true) ?? ''), 0, $keybytelen);
 			} else { // RC4-40, RC4-128, AES-128
-				$this->encryptdata['key'] = substr(sha1($seed.$recipient_bytes, true), 0, $keybytelen);
+				$this->encryptdata['key'] = substr((sha1($seed.$recipient_bytes, true) ?? ''), 0, $keybytelen);
 			}
 		}
 	}
@@ -10862,14 +10866,11 @@
 			$this->encryptdata['StrF'] = 'StdCF';
 		}
 		if ($mode > 1) { // AES
-			if (!extension_loaded('openssl') && !extension_loaded('mcrypt')) {
-				$this->Error('AES encryption requires openssl or mcrypt extension (http://www.php.net/manual/en/mcrypt.requirements.php).');
+			if (!extension_loaded('openssl')) {
+				$this->Error('AES encryption requires the OpenSSL extension.');
 			}
 			if (extension_loaded('openssl') && !in_array('aes-256-cbc', openssl_get_cipher_methods())) {
 				$this->Error('AES encryption requires openssl/aes-256-cbc cypher.');
-			}
-			if (extension_loaded('mcrypt') && mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) === false) {
-				$this->Error('AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
 			}
 			if (($mode == 3) AND !function_exists('hash')) {
 				// the Hash extension requires no external libraries and is enabled by default as of PHP 5.1.2.
@@ -10877,7 +10878,7 @@
 			}
 		}
 		if ($owner_pass === null) {
-			$owner_pass = md5(TCPDF_STATIC::getRandomSeed());
+			$owner_pass = md5((TCPDF_STATIC::getRandomSeed() ?? ''));
 		}
 		$this->encryptdata['user_password'] = $user_pass;
 		$this->encryptdata['owner_password'] = $owner_pass;
@@ -10946,7 +10947,7 @@
 		$this->_outSaveGraphicsState();
 		if ($this->inxobj) {
 			// we are inside an XObject template
-			$this->xobjects[$this->xobjid]['transfmrk'][] = strlen($this->xobjects[$this->xobjid]['outdata']);
+			$this->xobjects[$this->xobjid]['transfmrk'][] = strlen(($this->xobjects[$this->xobjid]['outdata'] ?? ''));
 		} else {
 			$this->transfmrk[$this->page][] = $this->pagelen[$this->page];
 		}
@@ -11253,7 +11254,7 @@
 			// we are inside an XObject template
 			if (end($this->xobjects[$this->xobjid]['transfmrk']) !== false) {
 				$key = key($this->xobjects[$this->xobjid]['transfmrk']);
-				$this->xobjects[$this->xobjid]['transfmrk'][$key] = strlen($this->xobjects[$this->xobjid]['outdata']);
+				$this->xobjects[$this->xobjid]['transfmrk'][$key] = strlen(($this->xobjects[$this->xobjid]['outdata'] ?? ''));
 			}
 		} elseif (end($this->transfmrk[$this->page]) !== false) {
 			$key = key($this->transfmrk[$this->page]);
@@ -11343,8 +11344,8 @@
 		if (isset($style['dash'])) {
 			$dash_string = '';
 			if ($style['dash']) {
-				if (preg_match('/^.+,/', $style['dash']) > 0) {
-					$tab = explode(',', $style['dash']);
+				if (preg_match('/^.+,/', ($style['dash'] ?? '')) > 0) {
+					$tab = explode(',', ($style['dash'] ?? ''));
 				} else {
 					$tab = array($style['dash']);
 				}
@@ -11512,7 +11513,7 @@
 		if (empty($style)) {
 			$style = 'S';
 		}
-		if (!(strpos($style, 'F') === false) AND !empty($fill_color)) {
+		if (!(strpos(($style ?? ''), 'F') === false) AND !empty($fill_color)) {
 			// set background color
 			$this->SetFillColorArray($fill_color);
 		}
@@ -11536,7 +11537,7 @@
 		if (!empty($border_style)) {
 			$border_style2 = array();
 			foreach ($border_style as $line => $value) {
-				$length = strlen($line);
+				$length = strlen(($line ?? ''));
 				for ($i = 0; $i < $length; ++$i) {
 					$border_style2[$line[$i]] = $value;
 				}
@@ -11580,7 +11581,7 @@
 		if ($this->state != 2) {
 			return;
 		}
-		if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
+		if (!(false === strpos(($style ?? ''), 'F')) AND isset($fill_color)) {
 			$this->SetFillColorArray($fill_color);
 		}
 		$op = TCPDF_STATIC::getPathPaintOperator($style);
@@ -11610,7 +11611,7 @@
 		if ($this->state != 2) {
 			return;
 		}
-		if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
+		if (!(false === strpos(($style ?? ''), 'F')) AND isset($fill_color)) {
 			$this->SetFillColorArray($fill_color);
 		}
 		$op = TCPDF_STATIC::getPathPaintOperator($style);
@@ -11653,7 +11654,7 @@
 		if (TCPDF_STATIC::empty_string($ry) OR ($ry == 0)) {
 			$ry = $rx;
 		}
-		if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
+		if (!(false === strpos(($style ?? ''), 'F')) AND isset($fill_color)) {
 			$this->SetFillColorArray($fill_color);
 		}
 		$op = TCPDF_STATIC::getPathPaintOperator($style);
@@ -11859,7 +11860,7 @@
 		if ($this->state != 2) {
 			return;
 		}
-		$nc = count($p); // number of coordinates
+		$nc = count(($p ?? [])); // number of coordinates
 		$np = $nc / 2; // number of points
 		if ($closed) {
 			// close polygon by adding the first 2 points at the end (one line)
@@ -11872,7 +11873,7 @@
 			}
 			$nc += 4;
 		}
-		if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
+		if (!(false === strpos(($style ?? ''), 'F')) AND isset($fill_color)) {
 			$this->SetFillColorArray($fill_color);
 		}
 		$op = TCPDF_STATIC::getPathPaintOperator($style);
@@ -12075,7 +12076,7 @@
 			return;
 		}
 		// Rounded
-		if (!(false === strpos($style, 'F')) AND isset($fill_color)) {
+		if (!(false === strpos(($style ?? ''), 'F')) AND isset($fill_color)) {
 			$this->SetFillColorArray($fill_color);
 		}
 		$op = TCPDF_STATIC::getPathPaintOperator($style);
@@ -12222,7 +12223,7 @@
 		}
 		$fixed = false;
 		if (!empty($page) AND ($page[0] == '*')) {
-			$page = intval(substr($page, 1));
+			$page = intval(substr(($page ?? ''), 1));
 			// this page number will not be changed when moving/add/deleting pages
 			$fixed = true;
 		}
@@ -12325,7 +12326,7 @@
 		}
 		$fixed = false;
 		if (!empty($page) AND ($page[0] == '*')) {
-			$page = intval(substr($page, 1));
+			$page = intval(substr(($page ?? ''), 1));
 			// this page number will not be changed when moving/add/deleting pages
 			$fixed = true;
 		}
@@ -12335,7 +12336,7 @@
 				return;
 			}
 		}
-		$this->outlines[] = array('t' => $txt, 'l' => $level, 'x' => $x, 'y' => $y, 'p' => $page, 'f' => $fixed, 's' => strtoupper($style), 'c' => $color, 'u' => $link);
+		$this->outlines[] = array('t' => $txt, 'l' => $level, 'x' => $x, 'y' => $y, 'p' => $page, 'f' => $fixed, 's' => strtoupper(($style ?? '')), 'c' => $color, 'u' => $link);
 	}
 
 	/**
@@ -12362,7 +12363,7 @@
 	 * @since 2.1.002 (2008-02-12)
 	 */
 	protected function _putbookmarks() {
-		$nb = count($this->outlines);
+		$nb = count(($this->outlines ?? []));
 		if ($nb == 0) {
 			return;
 		}
@@ -12398,9 +12399,9 @@
 		foreach ($this->outlines as $i => $o) {
 			$oid = $this->_newobj();
 			// covert HTML title to string
-			$title = preg_replace($nltags, "\n", $o['t']);
-			$title = preg_replace("/[\r]+/si", '', $title);
-			$title = preg_replace("/[\n]+/si", "\n", $title);
+			$title = preg_replace(($nltags ?? ''), "\n", ($o['t'] ?? ''));
+			$title = preg_replace("/[\r]+/si", '', ($title ?? ''));
+			$title = preg_replace("/[\n]+/si", "\n", ($title ?? ''));
 			$title = strip_tags($title);
 			$title = $this->stringTrim($title);
 			$out = '<</Title '.$this->_textstring($title, $oid);
@@ -12422,14 +12423,14 @@
 				if (is_string($o['u'])) {
 					if ($o['u'][0] == '#') {
 						// internal destination
-						$out .= ' /Dest /'.TCPDF_STATIC::encodeNameObject(substr($o['u'], 1));
+						$out .= ' /Dest /'.TCPDF_STATIC::encodeNameObject(substr(($o['u'] ?? ''), 1));
 					} elseif ($o['u'][0] == '%') {
 						// embedded PDF file
-						$filename = basename(substr($o['u'], 1));
+						$filename = basename(substr(($o['u'] ?? ''), 1));
 						$out .= ' /A <</S /GoToE /D [0 /Fit] /NewWindow true /T << /R /C /P '.($o['p'] - 1).' /A '.$this->embeddedfiles[$filename]['a'].' >> >>';
 					} elseif ($o['u'][0] == '*') {
 						// embedded generic file
-						$filename = basename(substr($o['u'], 1));
+						$filename = basename(substr(($o['u'] ?? ''), 1));
 						$jsa = 'var D=event.target.doc;var MyData=D.dataObjects;for (var i in MyData) if (MyData[i].path=="'.$filename.'") D.exportDataObject( { cName : MyData[i].name, nLaunch : 2});';
 						$out .= ' /A <</S /JavaScript /JS '.$this->_textstring($jsa, $oid).'>>';
 					} else {
@@ -12451,17 +12452,17 @@
 			$style = 0;
 			if (!empty($o['s'])) {
 				// bold
-				if (strpos($o['s'], 'B') !== false) {
+				if (strpos(($o['s'] ?? ''), 'B') !== false) {
 					$style |= 2;
 				}
 				// oblique
-				if (strpos($o['s'], 'I') !== false) {
+				if (strpos(($o['s'] ?? ''), 'I') !== false) {
 					$style |= 1;
 				}
 			}
 			$out .= sprintf(' /F %d', $style);
 			// set bookmark color
-			if (isset($o['c']) AND is_array($o['c']) AND (count($o['c']) == 3)) {
+			if (isset($o['c']) AND is_array($o['c']) AND (count(($o['c'] ?? [])) == 3)) {
 				$color = array_values($o['c']);
 				$out .= sprintf(' /C [%F %F %F]', ($color[0] / 255), ($color[1] / 255), ($color[2] / 255));
 			} else {
@@ -12520,7 +12521,7 @@
 		if ($this->pdfa_mode OR (empty($this->javascript) AND empty($this->js_objects))) {
 			return;
 		}
-		if (strpos($this->javascript, 'this.addField') > 0) {
+		if (strpos(($this->javascript ?? ''), 'this.addField') > 0) {
 			if (!$this->ur['enabled']) {
 				//$this->setUserRights();
 			}
@@ -12584,7 +12585,7 @@
 		$this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%u,[%F,%F,%F,%F]);", $name, $type, $this->PageNo()-1, $x*$k, ($this->h-$y)*$k+1, ($x+$w)*$k, ($this->h-$y-$h)*$k+1)."\n";
 		$this->javascript .= 'f'.$name.'.textSize='.$this->FontSizePt.";\n";
 		foreach($prop as $key => $val) {
-			if (strcmp(substr($key, -5), 'Color') == 0) {
+			if (strcmp(substr(($key ?? ''), -5), 'Color') == 0) {
 				$val = TCPDF_COLORS::_JScolor($val);
 			} else {
 				$val = "'".$val."'";
@@ -12882,7 +12883,7 @@
 					$s .= ',[\''.addslashes($value).'\',\''.addslashes($value).'\']';
 				}
 			}
-			$this->javascript .= 'f'.$name.'.setItems('.substr($s, 1).');'."\n";
+			$this->javascript .= 'f'.$name.'.setItems('.substr(($s ?? ''), 1).');'."\n";
 			return;
 		}
 		// get default style
@@ -12968,7 +12969,7 @@
 					$s .= ',[\''.addslashes($value).'\',\''.addslashes($value).'\']';
 				}
 			}
-			$this->javascript .= 'f'.$name.'.setItems('.substr($s, 1).');'."\n";
+			$this->javascript .= 'f'.$name.'.setItems('.substr(($s ?? ''), 1).');'."\n";
 			return;
 		}
 		// get default style
@@ -13418,10 +13419,10 @@
 		$this->sig_obj_id = $this->n; // signature widget
 		++$this->n; // signature object ($this->sig_obj_id + 1)
 		$this->signature_data = array();
-		if (strlen($signing_cert) == 0) {
+		if (strlen(($signing_cert ?? '')) == 0) {
 			$this->Error('Please provide a certificate file and password!');
 		}
-		if (strlen($private_key) == 0) {
+		if (strlen(($private_key ?? '')) == 0) {
 			$private_key = $signing_cert;
 		}
 		$this->signature_data['signcert'] = $signing_cert;
@@ -13516,7 +13517,7 @@
 		if (!function_exists('curl_init')) {
 			$this->Error('Please enable cURL PHP extension!');
 		}
-		if (strlen($tsa_host) == 0) {
+		if (strlen(($tsa_host ?? '')) == 0) {
 			$this->Error('Please specify the host of Time Stamping Authority (TSA)!');
 		}
 		$this->tsa_data['tsa_host'] = $tsa_host;
@@ -13723,11 +13724,11 @@
 		if ($this->state != 2) {
 			return;
 		}
-		$layer = sprintf('LYR%03d', (count($this->pdflayers) + 1));
+		$layer = sprintf('LYR%03d', (count(($this->pdflayers ?? [])) + 1));
 		if (empty($name)) {
 			$name = $layer;
 		} else {
-			$name = preg_replace('/[^a-zA-Z0-9_\-]/', '', $name);
+			$name = preg_replace('/[^a-zA-Z0-9_\-]/', '', ($name ?? ''));
 		}
 		$this->pdflayers[] = array('layer' => $layer, 'name' => $name, 'print' => $print, 'view' => $view, 'lock' => $lock);
 		$this->openMarkedContent = true;
@@ -13807,7 +13808,7 @@
 				return $i;
 			}
 		}
-		$n = (count($this->extgstates) + 1);
+		$n = (count(($this->extgstates ?? [])) + 1);
 		$this->extgstates[$n] = array('parms' => $parms);
 		if ($this->inxobj) {
 			// we are inside an XObject template
@@ -13917,7 +13918,7 @@
 		}
 		if ($bm[0] == '/') {
 			// remove trailing slash
-			$bm = substr($bm, 1);
+			$bm = substr(($bm ?? ''), 1);
 		}
 		if (!in_array($bm, array('Normal', 'Multiply', 'Screen', 'Overlay', 'Darken', 'Lighten', 'ColorDodge', 'ColorBurn', 'HardLight', 'SoftLight', 'Difference', 'Exclusion', 'Hue', 'Saturation', 'Color', 'Luminosity'))) {
 			$bm = 'Normal';
@@ -14023,21 +14024,21 @@
 	 * @public
 	 */
 	public function colorRegistrationBar($x, $y, $w, $h, $transition=true, $vertical=false, $colors='A,R,G,B,C,M,Y,K') {
-		if (strpos($colors, 'ALLSPOT') !== false) {
+		if (strpos(($colors ?? ''), 'ALLSPOT') !== false) {
 			// expand spot colors
 			$spot_colors = '';
 			foreach ($this->spot_colors as $spot_color_name => $v) {
 				$spot_colors .= ','.$spot_color_name;
 			}
 			if (!empty($spot_colors)) {
-				$spot_colors = substr($spot_colors, 1);
-				$colors = str_replace('ALLSPOT', $spot_colors, $colors);
+				$spot_colors = substr(($spot_colors ?? ''), 1);
+				$colors = str_replace('ALLSPOT', ($spot_colors ?? ''), ($colors ?? ''));
 			} else {
-				$colors = str_replace('ALLSPOT', 'NONE', $colors);
-			}
-		}
-		$bars = explode(',', $colors);
-		$numbars = count($bars); // number of bars to print
+				$colors = str_replace('ALLSPOT', 'NONE', ($colors ?? ''));
+			}
+		}
+		$bars = explode(',', ($colors ?? ''));
+		$numbars = count(($bars ?? [])); // number of bars to print
 		if ($numbars <= 0) {
 			return;
 		}
@@ -14164,20 +14165,20 @@
 	 */
 	public function cropMark($x, $y, $w, $h, $type='T,R,B,L', $color=array(100,100,100,100,'All')) {
 		$this->SetLineStyle(array('width' => (0.5 / $this->k), 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $color));
-		$type = strtoupper($type);
-		$type = preg_replace('/[^A-Z\-\,]*/', '', $type);
+		$type = strtoupper(($type ?? ''));
+		$type = preg_replace('/[^A-Z\-\,]*/', '', ($type ?? ''));
 		// split type in single components
-		$type = str_replace('-', ',', $type);
-		$type = str_replace('TL', 'T,L', $type);
-		$type = str_replace('TR', 'T,R', $type);
-		$type = str_replace('BL', 'F,L', $type);
-		$type = str_replace('BR', 'F,R', $type);
-		$type = str_replace('A', 'T,L', $type);
-		$type = str_replace('B', 'T,R', $type);
-		$type = str_replace('T,RO', 'BO', $type);
-		$type = str_replace('C', 'F,L', $type);
-		$type = str_replace('D', 'F,R', $type);
-		$crops = explode(',', strtoupper($type));
+		$type = str_replace('-', ',', ($type ?? ''));
+		$type = str_replace('TL', 'T,L', ($type ?? ''));
+		$type = str_replace('TR', 'T,R', ($type ?? ''));
+		$type = str_replace('BL', 'F,L', ($type ?? ''));
+		$type = str_replace('BR', 'F,R', ($type ?? ''));
+		$type = str_replace('A', 'T,L', ($type ?? ''));
+		$type = str_replace('B', 'T,R', ($type ?? ''));
+		$type = str_replace('T,RO', 'BO', ($type ?? ''));
+		$type = str_replace('C', 'F,L', ($type ?? ''));
+		$type = str_replace('D', 'F,R', ($type ?? ''));
+		$crops = explode(',', (strtoupper(($type ?? '')) ?? ''));
 		// remove duplicates
 		$crops = array_unique($crops);
 		$dw = ($w / 4); // horizontal space to leave before the intersection point
@@ -14350,7 +14351,7 @@
 			return;
 		}
 		$this->Clip($x, $y, $w, $h);
-		$n = count($this->gradients) + 1;
+		$n = count(($this->gradients ?? [])) + 1;
 		$this->gradients[$n] = array();
 		$this->gradients[$n]['type'] = 6; //coons patch mesh
 		$this->gradients[$n]['coords'] = array();
@@ -14393,10 +14394,10 @@
 		$bpcd = 65535; //16 bits per coordinate
 		//build the data stream
 		$this->gradients[$n]['stream'] = '';
-		$count_patch = count($patch_array);
+		$count_patch = count(($patch_array ?? []));
 		for ($i=0; $i < $count_patch; ++$i) {
-			$this->gradients[$n]['stream'] .= chr($patch_array[$i]['f']); //start with the edge flag as 8 bit
-			$count_points = count($patch_array[$i]['points']);
+			$this->gradients[$n]['stream'] .= chr((int) ($patch_array[$i]['f'])); //start with the edge flag as 8 bit
+			$count_points = count(($patch_array[$i]['points'] ?? []));
 			for ($j=0; $j < $count_points; ++$j) {
 				//each point as 16 bit
 				$patch_array[$i]['points'][$j] = (($patch_array[$i]['points'][$j] - $coords_min) / ($coords_max - $coords_min)) * $bpcd;
@@ -14406,15 +14407,15 @@
 				if ($patch_array[$i]['points'][$j] > $bpcd) {
 					$patch_array[$i]['points'][$j] = $bpcd;
 				}
-				$this->gradients[$n]['stream'] .= chr(floor($patch_array[$i]['points'][$j] / 256));
-				$this->gradients[$n]['stream'] .= chr(floor($patch_array[$i]['points'][$j] % 256));
-			}
-			$count_cols = count($patch_array[$i]['colors']);
+				$this->gradients[$n]['stream'] .= chr((int) (floor($patch_array[$i]['points'][$j] / 256)));
+				$this->gradients[$n]['stream'] .= chr((int) (floor($patch_array[$i]['points'][$j] % 256)));
+			}
+			$count_cols = count(($patch_array[$i]['colors'] ?? []));
 			for ($j=0; $j < $count_cols; ++$j) {
 				//each color component as 8 bit
-				$this->gradients[$n]['stream'] .= chr($patch_array[$i]['colors'][$j]['r']);
-				$this->gradients[$n]['stream'] .= chr($patch_array[$i]['colors'][$j]['g']);
-				$this->gradients[$n]['stream'] .= chr($patch_array[$i]['colors'][$j]['b']);
+				$this->gradients[$n]['stream'] .= chr((int) ($patch_array[$i]['colors'][$j]['r']));
+				$this->gradients[$n]['stream'] .= chr((int) ($patch_array[$i]['colors'][$j]['g']));
+				$this->gradients[$n]['stream'] .= chr((int) ($patch_array[$i]['colors'][$j]['b']));
 			}
 		}
 		//paint the gradient
@@ -14468,7 +14469,7 @@
 		if ($this->pdfa_mode OR ($this->state != 2)) {
 			return;
 		}
-		$n = count($this->gradients) + 1;
+		$n = count(($this->gradients ?? [])) + 1;
 		$this->gradients[$n] = array();
 		$this->gradients[$n]['type'] = $type;
 		$this->gradients[$n]['coords'] = $coords;
@@ -14476,7 +14477,7 @@
 		$this->gradients[$n]['colors'] = array();
 		$this->gradients[$n]['transparency'] = false;
 		// color space
-		$numcolspace = count($stops[0]['color']);
+		$numcolspace = count(($stops[0]['color'] ?? []));
 		$bcolor = array_values($background);
 		switch($numcolspace) {
 			case 5:   // SPOT
@@ -14502,7 +14503,7 @@
 				break;
 			}
 		}
-		$num_stops = count($stops);
+		$num_stops = count(($stops ?? []));
 		$last_stop_id = $num_stops - 1;
 		foreach ($stops as $key => $stop) {
 			$this->gradients[$n]['colors'][$key] = array();
@@ -14575,7 +14576,7 @@
 		if ($this->pdfa_mode) {
 			return;
 		}
-		$idt = count($this->gradients); //index for transparency gradients
+		$idt = count(($this->gradients ?? [])); //index for transparency gradients
 		foreach ($this->gradients as $id => $grad) {
 			if (($grad['type'] == 2) OR ($grad['type'] == 3)) {
 				$fc = $this->_newobj();
@@ -14586,7 +14587,7 @@
 				$bounds = '';
 				$encode = '';
 				$i = 1;
-				$num_cols = count($grad['colors']);
+				$num_cols = count(($grad['colors'] ?? []));
 				$lastcols = $num_cols - 1;
 				for ($i = 1; $i < $num_cols; ++$i) {
 					$functions .= ($fc + $i).' 0 R ';
@@ -14595,9 +14596,9 @@
 					}
 					$encode .= '0 1 ';
 				}
-				$out .= ' /Functions ['.trim($functions).']';
-				$out .= ' /Bounds ['.trim($bounds).']';
-				$out .= ' /Encode ['.trim($encode).']';
+				$out .= ' /Functions ['.trim(($functions ?? '')).']';
+				$out .= ' /Bounds ['.trim(($bounds ?? '')).']';
+				$out .= ' /Encode ['.trim(($encode ?? '')).']';
 				$out .= ' >>';
 				$out .= "\n".'endobj';
 				$this->_out($out);
@@ -14621,13 +14622,13 @@
 					$out .= ' /Domain [0 1]';
 					$functions = '';
 					$i = 1;
-					$num_cols = count($grad['colors']);
+					$num_cols = count(($grad['colors'] ?? []));
 					for ($i = 1; $i < $num_cols; ++$i) {
 						$functions .= ($ft + $i).' 0 R ';
 					}
-					$out .= ' /Functions ['.trim($functions).']';
-					$out .= ' /Bounds ['.trim($bounds).']';
-					$out .= ' /Encode ['.trim($encode).']';
+					$out .= ' /Functions ['.trim(($functions ?? '')).']';
+					$out .= ' /Bounds ['.trim(($bounds ?? '')).']';
+					$out .= ' /Encode ['.trim(($encode ?? '')).']';
 					$out .= ' >>';
 					$out .= "\n".'endobj';
 					$this->_out($out);
@@ -14679,15 +14680,15 @@
 				$out .= ' /Decode[0 1 0 1 0 1 0 1 0 1]';
 				$out .= ' /BitsPerFlag 8';
 				$stream = $this->_getrawstream($grad['stream']);
-				$out .= ' /Length '.strlen($stream);
+				$out .= ' /Length '.strlen(($stream ?? ''));
 				$out .= ' >>';
 				$out .= ' stream'."\n".$stream."\n".'endstream';
 			}
 			$out .= "\n".'endobj';
 			$this->_out($out);
 			if ($grad['transparency']) {
-				$shading_transparency = preg_replace('/\/ColorSpace \/[^\s]+/si', '/ColorSpace /DeviceGray', $out);
-				$shading_transparency = preg_replace('/\/Function [0-9]+ /si', '/Function '.$ft.' ', $shading_transparency);
+				$shading_transparency = preg_replace('/\/ColorSpace \/[^\s]+/si', '/ColorSpace /DeviceGray', ($out ?? ''));
+				$shading_transparency = preg_replace('/\/Function [0-9]+ /si', '/Function '.$ft.' ', ($shading_transparency ?? ''));
 			}
 			$this->gradients[$id]['id'] = $this->n;
 			// set pattern object
@@ -14723,7 +14724,7 @@
 				}
 				$stream = $this->_getrawstream($stream);
 				$out = '<< /Type /XObject /Subtype /Form /FormType 1'.$filter;
-				$out .= ' /Length '.strlen($stream);
+				$out .= ' /Length '.strlen(($stream ?? ''));
 				$rect = sprintf('%F %F', $this->wPt, $this->hPt);
 				$out .= ' /BBox [0 0 '.$rect.']';
 				$out .= ' /Group << /Type /Group /S /Transparency /CS /DeviceGray >>';
@@ -14846,7 +14847,7 @@
 		list($x, $y) = $this->checkPageRegions($h, $x, $y);
 		$k = $this->k;
 		if ($file[0] === '@') { // image from string
-			$data = substr($file, 1);
+			$data = substr(($file ?? ''), 1);
 		} else { // EPS/AI file
 			$data = TCPDF_STATIC::fileGetContents($file);
 		}
@@ -14855,11 +14856,11 @@
 		}
 		$regs = array();
 		// EPS/AI compatibility check (only checks files created by Adobe Illustrator!)
-		preg_match("/%%Creator:([^\r\n]+)/", $data, $regs); # find Creator
-		if (count($regs) > 1) {
-			$version_str = trim($regs[1]); # e.g. "Adobe Illustrator(R) 8.0"
-			if (strpos($version_str, 'Adobe Illustrator') !== false) {
-				$versexp = explode(' ', $version_str);
+		preg_match("/%%Creator:([^\r\n]+)/", ($data ?? ''), $regs); # find Creator
+		if (count(($regs ?? [])) > 1) {
+			$version_str = trim(($regs[1] ?? '')); # e.g. "Adobe Illustrator(R) 8.0"
+			if (strpos(($version_str ?? ''), 'Adobe Illustrator') !== false) {
+				$versexp = explode(' ', ($version_str ?? ''));
 				$version = (float)array_pop($versexp);
 				if ($version >= 9) {
 					$this->Error('This version of Adobe Illustrator file is not supported: '.$file);
@@ -14867,31 +14868,31 @@
 			}
 		}
 		// strip binary bytes in front of PS-header
-		$start = strpos($data, '%!PS-Adobe');
+		$start = strpos(($data ?? ''), '%!PS-Adobe');
 		if ($start > 0) {
-			$data = substr($data, $start);
+			$data = substr(($data ?? ''), $start);
 		}
 		// find BoundingBox params
-		preg_match("/%%BoundingBox:([^\r\n]+)/", $data, $regs);
-		if (count($regs) > 1) {
-			list($x1, $y1, $x2, $y2) = explode(' ', trim($regs[1]));
+		preg_match("/%%BoundingBox:([^\r\n]+)/", ($data ?? ''), $regs);
+		if (count(($regs ?? [])) > 1) {
+			list($x1, $y1, $x2, $y2) = explode(' ', (trim(($regs[1] ?? '')) ?? ''));
 		} else {
 			$this->Error('No BoundingBox found in EPS/AI file: '.$file);
 		}
-		$start = strpos($data, '%%EndSetup');
+		$start = strpos(($data ?? ''), '%%EndSetup');
 		if ($start === false) {
-			$start = strpos($data, '%%EndProlog');
+			$start = strpos(($data ?? ''), '%%EndProlog');
 		}
 		if ($start === false) {
-			$start = strpos($data, '%%BoundingBox');
-		}
-		$data = substr($data, $start);
-		$end = strpos($data, '%%PageTrailer');
+			$start = strpos(($data ?? ''), '%%BoundingBox');
+		}
+		$data = substr(($data ?? ''), $start);
+		$end = strpos(($data ?? ''), '%%PageTrailer');
 		if ($end===false) {
-			$end = strpos($data, 'showpage');
+			$end = strpos(($data ?? ''), 'showpage');
 		}
 		if ($end) {
-			$data = substr($data, 0, $end);
+			$data = substr(($data ?? ''), 0, $end);
 		}
 		// calculate image width and height on document
 		if (($w <= 0) AND ($h <= 0)) {
@@ -14953,29 +14954,29 @@
 			$this->_out(sprintf('%F %F %F %F %F %F cm', $scale_x, 0, 0, $scale_y, $x1 * (1 - $scale_x), $y2 * (1 - $scale_y)));
 		}
 		// handle pc/unix/mac line endings
-		$lines = preg_split('/[\r\n]+/si', $data, -1, PREG_SPLIT_NO_EMPTY);
+		$lines = preg_split('/[\r\n]+/si', ($data ?? ''), -1, PREG_SPLIT_NO_EMPTY);
 		$u=0;
-		$cnt = count($lines);
+		$cnt = count(($lines ?? []));
 		for ($i=0; $i < $cnt; ++$i) {
 			$line = $lines[$i];
 			if (($line == '') OR ($line[0] == '%')) {
 				continue;
 			}
-			$len = strlen($line);
+			$len = strlen(($line ?? ''));
 			// check for spot color names
 			$color_name = '';
-			if (strcasecmp('x', substr(trim($line), -1)) == 0) {
-				if (preg_match('/\([^\)]*\)/', $line, $matches) > 0) {
+			if (strcasecmp('x', substr((trim(($line ?? '')) ?? ''), -1)) == 0) {
+				if (preg_match('/\([^\)]*\)/', ($line ?? ''), $matches) > 0) {
 					// extract spot color name
 					$color_name = $matches[0];
 					// remove color name from string
-					$line = str_replace(' '.$color_name, '', $line);
+					$line = str_replace(' '.$color_name, '', ($line ?? ''));
 					// remove pharentesis from color name
-					$color_name = substr($color_name, 1, -1);
-				}
-			}
-			$chunks = explode(' ', $line);
-			$cmd = trim(array_pop($chunks));
+					$color_name = substr(($color_name ?? ''), 1, -1);
+				}
+			}
+			$chunks = explode(' ', ($line ?? ''));
+			$cmd = trim((array_pop($chunks) ?? ''));
 			// RGB
 			if (($cmd == 'Xa') OR ($cmd == 'XA')) {
 				$b = array_pop($chunks);
@@ -15062,7 +15063,7 @@
 					if ($skip) {
 						break;
 					}
-					$line[($len - 1)] = strtolower($cmd);
+					$line[($len - 1)] = strtolower(($cmd ?? ''));
 					$this->_out($line);
 					break;
 				}
@@ -15192,7 +15193,7 @@
 	 * @public
 	 */
 	public function write1DBarcode($code, $type, $x='', $y='', $w='', $h='', $xres='', $style=array(), $align='') {
-		if (TCPDF_STATIC::empty_string(trim($code))) {
+		if (TCPDF_STATIC::empty_string(trim(($code ?? '')))) {
 			return;
 		}
 		require_once(dirname(__FILE__).'/tcpdf_barcodes_1d.php');
@@ -15511,7 +15512,7 @@
 	 * @public
 	 */
 	public function write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style=array(), $align='', $distort=false) {
-		if (TCPDF_STATIC::empty_string(trim($code))) {
+		if (TCPDF_STATIC::empty_string(trim(($code ?? '')))) {
 			return;
 		}
 		require_once(dirname(__FILE__).'/tcpdf_barcodes_2d.php');
@@ -15858,7 +15859,7 @@
 	 * @since 5.7.000 (2010-08-02)
 	 */
 	protected function getCSSBorderDashStyle($style) {
-		switch (strtolower($style)) {
+		switch (strtolower(($style ?? ''))) {
 			case 'none':
 			case 'hidden': {
 				$dash = -1;
@@ -15894,9 +15895,9 @@
 	 * @since 5.7.000 (2010-08-02)
 	 */
 	protected function getCSSBorderStyle($cssborder) {
-		$bprop = preg_split('/[\s]+/', trim($cssborder));
+		$bprop = preg_split('/[\s]+/', (trim(($cssborder ?? '')) ?? ''));
 		$border = array(); // value to be returned
-		switch (count($bprop)) {
+		switch (count(($bprop ?? []))) {
 			case 3: {
 				$width = $bprop[0];
 				$style = $bprop[1];
@@ -15945,9 +15946,9 @@
 	 * @since 5.9.000 (2010-10-04)
 	 */
 	public function getCSSPadding($csspadding, $width=0) {
-		$padding = preg_split('/[\s]+/', trim($csspadding));
+		$padding = preg_split('/[\s]+/', (trim(($csspadding ?? '')) ?? ''));
 		$cell_padding = array(); // value to be returned
-		switch (count($padding)) {
+		switch (count(($padding ?? []))) {
 			case 4: {
 				$cell_padding['T'] = $padding[0];
 				$cell_padding['R'] = $padding[1];
@@ -15999,9 +16000,9 @@
 	 * @since 5.9.000 (2010-10-04)
 	 */
 	public function getCSSMargin($cssmargin, $width=0) {
-		$margin = preg_split('/[\s]+/', trim($cssmargin));
+		$margin = preg_split('/[\s]+/', (trim(($cssmargin ?? '')) ?? ''));
 		$cell_margin = array(); // value to be returned
-		switch (count($margin)) {
+		switch (count(($margin ?? []))) {
 			case 4: {
 				$cell_margin['T'] = $margin[0];
 				$cell_margin['R'] = $margin[1];
@@ -16037,10 +16038,10 @@
 		if ($width == 0) {
 			$width = $this->w - $this->lMargin - $this->rMargin;
 		}
-		$cell_margin['T'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', $cell_margin['T']), $width, 'px', false);
-		$cell_margin['R'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', $cell_margin['R']), $width, 'px', false);
-		$cell_margin['B'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', $cell_margin['B']), $width, 'px', false);
-		$cell_margin['L'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', $cell_margin['L']), $width, 'px', false);
+		$cell_margin['T'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', ($cell_margin['T'] ?? '')), $width, 'px', false);
+		$cell_margin['R'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', ($cell_margin['R'] ?? '')), $width, 'px', false);
+		$cell_margin['B'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', ($cell_margin['B'] ?? '')), $width, 'px', false);
+		$cell_margin['L'] = $this->getHTMLUnitToUnits(str_replace('auto', '0', ($cell_margin['L'] ?? '')), $width, 'px', false);
 		return $cell_margin;
 	}
 
@@ -16053,9 +16054,9 @@
 	 * @since 5.9.010 (2010-10-27)
 	 */
 	public function getCSSBorderMargin($cssbspace, $width=0) {
-		$space = preg_split('/[\s]+/', trim($cssbspace));
+		$space = preg_split('/[\s]+/', (trim(($cssbspace ?? '')) ?? ''));
 		$border_spacing = array(); // value to be returned
-		switch (count($space)) {
+		switch (count(($space ?? []))) {
 			case 2: {
 				$border_spacing['H'] = $space[0];
 				$border_spacing['V'] = $space[1];
@@ -16088,7 +16089,7 @@
 	 */
 	protected function getCSSFontSpacing($spacing, $parent=0) {
 		$val = 0; // value to be returned
-		$spacing = trim($spacing);
+		$spacing = trim(($spacing ?? ''));
 		switch ($spacing) {
 			case 'normal': {
 				$val = 0;
@@ -16119,7 +16120,7 @@
 	 */
 	protected function getCSSFontStretching($stretch, $parent=100) {
 		$val = 100; // value to be returned
-		$stretch = trim($stretch);
+		$stretch = trim(($stretch ?? ''));
 		switch ($stretch) {
 			case 'ultra-condensed': {
 				$val = 40;
@@ -16248,28 +16249,28 @@
 		$css = array();
 		// get CSS array defined at previous call
 		$matches = array();
-		if (preg_match_all('/<cssarray>([^\<]*)<\/cssarray>/isU', $html, $matches) > 0) {
+		if (preg_match_all('/<cssarray>([^\<]*)<\/cssarray>/isU', ($html ?? ''), $matches) > 0) {
 			if (isset($matches[1][0])) {
 				$css = array_merge($css, json_decode($this->unhtmlentities($matches[1][0]), true));
 			}
-			$html = preg_replace('/<cssarray>(.*?)<\/cssarray>/isU', '', $html);
+			$html = preg_replace('/<cssarray>(.*?)<\/cssarray>/isU', '', ($html ?? ''));
 		}
 		// extract external CSS files
 		$matches = array();
-		if (preg_match_all('/<link([^\>]*)>/isU', $html, $matches) > 0) {
+		if (preg_match_all('/<link([^\>]*)>/isU', ($html ?? ''), $matches) > 0) {
 			foreach ($matches[1] as $key => $link) {
 				$type = array();
-				if (preg_match('/type[\s]*=[\s]*"text\/css"/', $link, $type)) {
+				if (preg_match('/type[\s]*=[\s]*"text\/css"/', ($link ?? ''), $type)) {
 					$type = array();
-					preg_match('/media[\s]*=[\s]*"([^"]*)"/', $link, $type);
+					preg_match('/media[\s]*=[\s]*"([^"]*)"/', ($link ?? ''), $type);
 					// get 'all' and 'print' media, other media types are discarded
 					// (all, braille, embossed, handheld, print, projection, screen, speech, tty, tv)
 					if (empty($type) OR (isset($type[1]) AND (($type[1] == 'all') OR ($type[1] == 'print')))) {
 						$type = array();
-						if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) {
+						if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', ($link ?? ''), $type) > 0) {
 							// read CSS data file
-							$cssdata = TCPDF_STATIC::fileGetContents(trim($type[1]));
-							if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) {
+							$cssdata = TCPDF_STATIC::fileGetContents(trim(($type[1] ?? '')));
+							if (($cssdata !== FALSE) AND (strlen(($cssdata ?? '')) > 0)) {
 								$css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata));
 							}
 						}
@@ -16279,10 +16280,10 @@
 		}
 		// extract style tags
 		$matches = array();
-		if (preg_match_all('/<style([^\>]*)>([^\<]*)<\/style>/isU', $html, $matches) > 0) {
+		if (preg_match_all('/<style([^\>]*)>([^\<]*)<\/style>/isU', ($html ?? ''), $matches) > 0) {
 			foreach ($matches[1] as $key => $media) {
 				$type = array();
-				preg_match('/media[\s]*=[\s]*"([^"]*)"/', $media, $type);
+				preg_match('/media[\s]*=[\s]*"([^"]*)"/', ($media ?? ''), $type);
 				// get 'all' and 'print' media, other media types are discarded
 				// (all, braille, embossed, handheld, print, projection, screen, speech, tty, tv)
 				if (empty($type) OR (isset($type[1]) AND (($type[1] == 'all') OR ($type[1] == 'print')))) {
@@ -16292,101 +16293,101 @@
 			}
 		}
 		// create a special tag to contain the CSS array (used for table content)
-		$csstagarray = '<cssarray>'.htmlentities(json_encode($css)).'</cssarray>';
+		$csstagarray = '<cssarray>'.htmlentities((json_encode($css) ?? '')).'</cssarray>';
 		// remove head and style blocks
-		$html = preg_replace('/<head([^\>]*)>(.*?)<\/head>/siU', '', $html);
-		$html = preg_replace('/<style([^\>]*)>([^\<]*)<\/style>/isU', '', $html);
+		$html = preg_replace('/<head([^\>]*)>(.*?)<\/head>/siU', '', ($html ?? ''));
+		$html = preg_replace('/<style([^\>]*)>([^\<]*)<\/style>/isU', '', ($html ?? ''));
 		// define block tags
 		$blocktags = array('blockquote','br','dd','dl','div','dt','h1','h2','h3','h4','h5','h6','hr','li','ol','p','pre','ul','tcpdf','table','tr','td');
 		// define self-closing tags
 		$selfclosingtags = array('area','base','basefont','br','hr','input','img','link','meta');
 		// remove all unsupported tags (the line below lists all supported tags)
-		$html = strip_tags($html, '<marker/><a><b><blockquote><body><br><br/><dd><del><div><dl><dt><em><font><form><h1><h2><h3><h4><h5><h6><hr><hr/><i><img><input><label><li><ol><option><p><pre><s><select><small><span><strike><strong><sub><sup><table><tablehead><tcpdf><td><textarea><th><thead><tr><tt><u><ul>');
+		$html = strip_tags($html, '<marker><a><b><blockquote><body><br><br><dd><del><div><dl><dt><em><font><form><h1><h2><h3><h4><h5><h6><hr><hr><i><img><input><label><li><ol><option><p><pre><s><select><small><span><strike><strong><sub><sup><table><tablehead><tcpdf><td><textarea><th><thead><tr><tt><u><ul>');
 		//replace some blank characters
-		$html = preg_replace('/<pre/', '<xre', $html); // preserve pre tag
-		$html = preg_replace('/<(table|tr|td|th|tcpdf|blockquote|dd|div|dl|dt|form|h1|h2|h3|h4|h5|h6|br|hr|li|ol|ul|p)([^\>]*)>[\n\r\t]+/', '<\\1\\2>', $html);
-		$html = preg_replace('@(\r\n|\r)@', "\n", $html);
+		$html = preg_replace('/<pre/', '<xre', ($html ?? '')); // preserve pre tag
+		$html = preg_replace('/<(table|tr|td|th|tcpdf|blockquote|dd|div|dl|dt|form|h1|h2|h3|h4|h5|h6|br|hr|li|ol|ul|p)([^\>]*)>[\n\r\t]+/', '<\\1\\2>', ($html ?? ''));
+		$html = preg_replace('@(\r\n|\r)@', "\n", ($html ?? ''));
 		$repTable = array("\t" => ' ', "\0" => ' ', "\x0B" => ' ', "\\" => "\\\\");
-		$html = strtr($html, $repTable);
+		$html = strtr(($html ?? ''), ($repTable ?? ''));
 		$offset = 0;
-		while (($offset < strlen($html)) AND ($pos = strpos($html, '</pre>', $offset)) !== false) {
-			$html_a = substr($html, 0, $offset);
-			$html_b = substr($html, $offset, ($pos - $offset + 6));
-			while (preg_match("'<xre([^\>]*)>(.*?)\n(.*?)</pre>'si", $html_b)) {
+		while (($offset < strlen(($html ?? ''))) AND ($pos = strpos(($html ?? ''), '</pre>', $offset)) !== false) {
+			$html_a = substr(($html ?? ''), 0, $offset);
+			$html_b = substr(($html ?? ''), $offset, ($pos - $offset + 6));
+			while (preg_match("'<xre([^\>]*)>(.*?)\n(.*?)</pre>'si", ($html_b ?? ''))) {
 				// preserve newlines on <pre> tag
-				$html_b = preg_replace("'<xre([^\>]*)>(.*?)\n(.*?)</pre>'si", "<xre\\1>\\2<br />\\3</pre>", $html_b);
-			}
-			while (preg_match("'<xre([^\>]*)>(.*?)".$this->re_space['p']."(.*?)</pre>'".$this->re_space['m'], $html_b)) {
+				$html_b = preg_replace("'<xre([^\>]*)>(.*?)\n(.*?)</pre>'si", "<xre\\1>\\2<br />\\3</pre>", ($html_b ?? ''));
+			}
+			while (preg_match("'<xre([^\>]*)>(.*?)".$this->re_space['p']."(.*?)</pre>'".$this->re_space['m'], ($html_b ?? ''))) {
 				// preserve spaces on <pre> tag
-				$html_b = preg_replace("'<xre([^\>]*)>(.*?)".$this->re_space['p']."(.*?)</pre>'".$this->re_space['m'], "<xre\\1>\\2&nbsp;\\3</pre>", $html_b);
-			}
-			$html = $html_a.$html_b.substr($html, $pos + 6);
+				$html_b = preg_replace("'<xre([^\>]*)>(.*?)".$this->re_space['p']."(.*?)</pre>'".$this->re_space['m'], "<xre\\1>\\2&nbsp;\\3</pre>", ($html_b ?? ''));
+			}
+			$html = $html_a.$html_b.substr(($html ?? ''), $pos + 6);
 			$offset = strlen($html_a.$html_b);
 		}
 		$offset = 0;
-		while (($offset < strlen($html)) AND ($pos = strpos($html, '</textarea>', $offset)) !== false) {
-			$html_a = substr($html, 0, $offset);
-			$html_b = substr($html, $offset, ($pos - $offset + 11));
-			while (preg_match("'<textarea([^\>]*)>(.*?)\n(.*?)</textarea>'si", $html_b)) {
+		while (($offset < strlen(($html ?? ''))) AND ($pos = strpos(($html ?? ''), '</textarea>', $offset)) !== false) {
+			$html_a = substr(($html ?? ''), 0, $offset);
+			$html_b = substr(($html ?? ''), $offset, ($pos - $offset + 11));
+			while (preg_match("'<textarea([^\>]*)>(.*?)\n(.*?)</textarea>'si", ($html_b ?? ''))) {
 				// preserve newlines on <textarea> tag
-				$html_b = preg_replace("'<textarea([^\>]*)>(.*?)\n(.*?)</textarea>'si", "<textarea\\1>\\2<TBR>\\3</textarea>", $html_b);
-				$html_b = preg_replace("'<textarea([^\>]*)>(.*?)[\"](.*?)</textarea>'si", "<textarea\\1>\\2''\\3</textarea>", $html_b);
-			}
-			$html = $html_a.$html_b.substr($html, $pos + 11);
+				$html_b = preg_replace("'<textarea([^\>]*)>(.*?)\n(.*?)</textarea>'si", "<textarea\\1>\\2<TBR>\\3</textarea>", ($html_b ?? ''));
+				$html_b = preg_replace("'<textarea([^\>]*)>(.*?)[\"](.*?)</textarea>'si", "<textarea\\1>\\2''\\3</textarea>", ($html_b ?? ''));
+			}
+			$html = $html_a.$html_b.substr(($html ?? ''), $pos + 11);
 			$offset = strlen($html_a.$html_b);
 		}
-		$html = preg_replace('/([\s]*)<option/si', '<option', $html);
-		$html = preg_replace('/<\/option>([\s]*)/si', '</option>', $html);
+		$html = preg_replace('/([\s]*)<option/si', '<option', ($html ?? ''));
+		$html = preg_replace('/<\/option>([\s]*)/si', '</option>', ($html ?? ''));
 		$offset = 0;
-		while (($offset < strlen($html)) AND ($pos = strpos($html, '</option>', $offset)) !== false) {
-			$html_a = substr($html, 0, $offset);
-			$html_b = substr($html, $offset, ($pos - $offset + 9));
-			while (preg_match("'<option([^\>]*)>(.*?)</option>'si", $html_b)) {
-				$html_b = preg_replace("'<option([\s]+)value=\"([^\"]*)\"([^\>]*)>(.*?)</option>'si", "\\2#!TaB!#\\4#!NwL!#", $html_b);
-				$html_b = preg_replace("'<option([^\>]*)>(.*?)</option>'si", "\\2#!NwL!#", $html_b);
-			}
-			$html = $html_a.$html_b.substr($html, $pos + 9);
+		while (($offset < strlen(($html ?? ''))) AND ($pos = strpos(($html ?? ''), '</option>', $offset)) !== false) {
+			$html_a = substr(($html ?? ''), 0, $offset);
+			$html_b = substr(($html ?? ''), $offset, ($pos - $offset + 9));
+			while (preg_match("'<option([^\>]*)>(.*?)</option>'si", ($html_b ?? ''))) {
+				$html_b = preg_replace("'<option([\s]+)value=\"([^\"]*)\"([^\>]*)>(.*?)</option>'si", "\\2#!TaB!#\\4#!NwL!#", ($html_b ?? ''));
+				$html_b = preg_replace("'<option([^\>]*)>(.*?)</option>'si", "\\2#!NwL!#", ($html_b ?? ''));
+			}
+			$html = $html_a.$html_b.substr(($html ?? ''), $pos + 9);
 			$offset = strlen($html_a.$html_b);
 		}
-		if (preg_match("'</select'si", $html)) {
-			$html = preg_replace("'<select([^\>]*)>'si", "<select\\1 opt=\"", $html);
-			$html = preg_replace("'#!NwL!#</select>'si", "\" />", $html);
-		}
-		$html = str_replace("\n", ' ', $html);
+		if (preg_match("'</select'si", ($html ?? ''))) {
+			$html = preg_replace("'<select([^\>]*)>'si", "<select\\1 opt=\"", ($html ?? ''));
+			$html = preg_replace("'#!NwL!#</select>'si", "\" />", ($html ?? ''));
+		}
+		$html = str_replace("\n", ' ', ($html ?? ''));
 		// restore textarea newlines
-		$html = str_replace('<TBR>', "\n", $html);
+		$html = str_replace('<TBR>', "\n", ($html ?? ''));
 		// remove extra spaces from code
-		$html = preg_replace('/[\s]+<\/(table|tr|ul|ol|dl)>/', '</\\1>', $html);
-		$html = preg_replace('/'.$this->re_space['p'].'+<\/(td|th|li|dt|dd)>/'.$this->re_space['m'], '</\\1>', $html);
-		$html = preg_replace('/[\s]+<(tr|td|th|li|dt|dd)/', '<\\1', $html);
-		$html = preg_replace('/'.$this->re_space['p'].'+<(ul|ol|dl|br)/'.$this->re_space['m'], '<\\1', $html);
-		$html = preg_replace('/<\/(table|tr|td|th|blockquote|dd|dt|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|ul|p)>[\s]+</', '</\\1><', $html);
-		$html = preg_replace('/<\/(td|th)>/', '<marker style="font-size:0"/></\\1>', $html);
-		$html = preg_replace('/<\/table>([\s]*)<marker style="font-size:0"\/>/', '</table>', $html);
-		$html = preg_replace('/'.$this->re_space['p'].'+<img/'.$this->re_space['m'], chr(32).'<img', $html);
-		$html = preg_replace('/<img([^\>]*)>[\s]+([^\<])/xi', '<img\\1>&nbsp;\\2', $html);
-		$html = preg_replace('/<img([^\>]*)>/xi', '<img\\1><span><marker style="font-size:0"/></span>', $html);
-		$html = preg_replace('/<xre/', '<pre', $html); // restore pre tag
-		$html = preg_replace('/<textarea([^\>]*)>([^\<]*)<\/textarea>/xi', '<textarea\\1 value="\\2" />', $html);
-		$html = preg_replace('/<li([^\>]*)><\/li>/', '<li\\1>&nbsp;</li>', $html);
-		$html = preg_replace('/<li([^\>]*)>'.$this->re_space['p'].'*<img/'.$this->re_space['m'], '<li\\1><font size="1">&nbsp;</font><img', $html);
-		$html = preg_replace('/<([^\>\/]*)>[\s]/', '<\\1>&nbsp;', $html); // preserve some spaces
-		$html = preg_replace('/[\s]<\/([^\>]*)>/', '&nbsp;</\\1>', $html); // preserve some spaces
-		$html = preg_replace('/<su([bp])/', '<zws/><su\\1', $html); // fix sub/sup alignment
-		$html = preg_replace('/<\/su([bp])>/', '</su\\1><zws/>', $html); // fix sub/sup alignment
-		$html = preg_replace('/'.$this->re_space['p'].'+/'.$this->re_space['m'], chr(32), $html); // replace multiple spaces with a single space
+		$html = preg_replace('/[\s]+<\/(table|tr|ul|ol|dl)>/', '</\\1>', ($html ?? ''));
+		$html = preg_replace('/'.$this->re_space['p'].'+<\/(td|th|li|dt|dd)>/'.$this->re_space['m'], '</\\1>', ($html ?? ''));
+		$html = preg_replace('/[\s]+<(tr|td|th|li|dt|dd)/', '<\\1', ($html ?? ''));
+		$html = preg_replace('/'.$this->re_space['p'].'+<(ul|ol|dl|br)/'.$this->re_space['m'], '<\\1', ($html ?? ''));
+		$html = preg_replace('/<\/(table|tr|td|th|blockquote|dd|dt|dl|div|dt|h1|h2|h3|h4|h5|h6|hr|li|ol|ul|p)>[\s]+</', '</\\1><', ($html ?? ''));
+		$html = preg_replace('/<\/(td|th)>/', '<marker style="font-size:0"/></\\1>', ($html ?? ''));
+		$html = preg_replace('/<\/table>([\s]*)<marker style="font-size:0"\/>/', '</table>', ($html ?? ''));
+		$html = preg_replace('/'.$this->re_space['p'].'+<img/'.$this->re_space['m'], chr(32).'<img', ($html ?? ''));
+		$html = preg_replace('/<img([^\>]*)>[\s]+([^\<])/xi', '<img\\1>&nbsp;\\2', ($html ?? ''));
+		$html = preg_replace('/<img([^\>]*)>/xi', '<img\\1><span><marker style="font-size:0"/></span>', ($html ?? ''));
+		$html = preg_replace('/<xre/', '<pre', ($html ?? '')); // restore pre tag
+		$html = preg_replace('/<textarea([^\>]*)>([^\<]*)<\/textarea>/xi', '<textarea\\1 value="\\2" />', ($html ?? ''));
+		$html = preg_replace('/<li([^\>]*)><\/li>/', '<li\\1>&nbsp;</li>', ($html ?? ''));
+		$html = preg_replace('/<li([^\>]*)>'.$this->re_space['p'].'*<img/'.$this->re_space['m'], '<li\\1><font size="1">&nbsp;</font><img', ($html ?? ''));
+		$html = preg_replace('/<([^\>\/]*)>[\s]/', '<\\1>&nbsp;', ($html ?? '')); // preserve some spaces
+		$html = preg_replace('/[\s]<\/([^\>]*)>/', '&nbsp;</\\1>', ($html ?? '')); // preserve some spaces
+		$html = preg_replace('/<su([bp])/', '<zws/><su\\1', ($html ?? '')); // fix sub/sup alignment
+		$html = preg_replace('/<\/su([bp])>/', '</su\\1><zws/>', ($html ?? '')); // fix sub/sup alignment
+		$html = preg_replace('/'.$this->re_space['p'].'+/'.$this->re_space['m'], (chr(32) ?? ''), ($html ?? '')); // replace multiple spaces with a single space
 		// trim string
 		$html = $this->stringTrim($html);
 		// fix br tag after li
-		$html = preg_replace('/<li><br([^\>]*)>/', '<li> <br\\1>', $html);
+		$html = preg_replace('/<li><br([^\>]*)>/', '<li> <br\\1>', ($html ?? ''));
 		// fix first image tag alignment
-		$html = preg_replace('/^<img/', '<span style="font-size:0"><br /></span> <img', $html, 1);
+		$html = preg_replace('/^<img/', '<span style="font-size:0"><br /></span> <img', ($html ?? ''), 1);
 		// pattern for generic tag
 		$tagpattern = '/(<[^>]+>)/';
 		// explodes the string
-		$a = preg_split($tagpattern, $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+		$a = preg_split(($tagpattern ?? ''), ($html ?? ''), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
 		// count elements
-		$maxel = count($a);
+		$maxel = count(($a ?? []));
 		$elkey = 0;
 		$key = 0;
 		// create an array of elements
@@ -16425,12 +16426,12 @@
 			$dom[$key] = array();
 			$element = $a[$elkey];
 			$dom[$key]['elkey'] = $elkey;
-			if (preg_match($tagpattern, $element)) {
+			if (preg_match(($tagpattern ?? ''), ($element ?? ''))) {
 				// html tag
-				$element = substr($element, 1, -1);
+				$element = substr(($element ?? ''), 1, -1);
 				// get tag name
-				preg_match('/[\/]?([a-zA-Z0-9]*)/', $element, $tag);
-				$tagname = strtolower($tag[1]);
+				preg_match('/[\/]?([a-zA-Z0-9]*)/', ($element ?? ''), $tag);
+				$tagname = strtolower(($tag[1] ?? ''));
 				// check if we are inside a table header
 				if ($tagname == 'thead') {
 					if ($element[0] == '/') {
@@ -16483,10 +16484,10 @@
 						}
 						$key = $i;
 						// mark nested tables
-						$dom[($dom[$key]['parent'])]['content'] = str_replace('<table', '<table nested="true"', $dom[($dom[$key]['parent'])]['content']);
+						$dom[($dom[$key]['parent'])]['content'] = str_replace('<table', '<table nested="true"', ($dom[($dom[$key]['parent'])]['content'] ?? ''));
 						// remove thead sections from nested tables
-						$dom[($dom[$key]['parent'])]['content'] = str_replace('<thead>', '', $dom[($dom[$key]['parent'])]['content']);
-						$dom[($dom[$key]['parent'])]['content'] = str_replace('</thead>', '', $dom[($dom[$key]['parent'])]['content']);
+						$dom[($dom[$key]['parent'])]['content'] = str_replace('<thead>', '', ($dom[($dom[$key]['parent'])]['content'] ?? ''));
+						$dom[($dom[$key]['parent'])]['content'] = str_replace('</thead>', '', ($dom[($dom[$key]['parent'])]['content'] ?? ''));
 					}
 					// store header rows on a new table
 					if (($dom[$key]['value'] == 'tr') AND ($dom[($dom[$key]['parent'])]['thead'] === true)) {
@@ -16504,14 +16505,14 @@
 					}
 					if (($dom[$key]['value'] == 'table') AND (!TCPDF_STATIC::empty_string($dom[($dom[$key]['parent'])]['thead']))) {
 						// remove the nobr attributes from the table header
-						$dom[($dom[$key]['parent'])]['thead'] = str_replace(' nobr="true"', '', $dom[($dom[$key]['parent'])]['thead']);
+						$dom[($dom[$key]['parent'])]['thead'] = str_replace(' nobr="true"', '', ($dom[($dom[$key]['parent'])]['thead'] ?? ''));
 						$dom[($dom[$key]['parent'])]['thead'] .= '</tablehead>';
 					}
 				} else {
 					// *** opening or self-closing html tag
 					$dom[$key]['opening'] = true;
 					$dom[$key]['parent'] = end($level);
-					if ((substr($element, -1, 1) == '/') OR (in_array($dom[$key]['value'], $selfclosingtags))) {
+					if ((substr(($element ?? ''), -1, 1) == '/') OR (in_array($dom[$key]['value'], $selfclosingtags))) {
 						// self-closing tag
 						$dom[$key]['self'] = true;
 					} else {
@@ -16544,10 +16545,10 @@
 						$dom[$key]['dir'] = $dom[$parentkey]['dir'];
 					}
 					// get attributes
-					preg_match_all('/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', $element, $attr_array, PREG_PATTERN_ORDER);
+					preg_match_all('/([^=\s]*)[\s]*=[\s]*"([^"]*)"/', ($element ?? ''), $attr_array, PREG_PATTERN_ORDER);
 					$dom[$key]['attribute'] = array(); // reset attribute array
                     foreach($attr_array[1] as $id => $name) {
-                        $dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
+                        $dom[$key]['attribute'][strtolower(($name ?? ''))] = $attr_array[2][$id];
                     }
 					if (!empty($css)) {
 						// merge CSS style to current style
@@ -16557,11 +16558,11 @@
 					// split style attributes
 					if (isset($dom[$key]['attribute']['style']) AND !empty($dom[$key]['attribute']['style'])) {
 						// get style attributes
-						preg_match_all('/([^;:\s]*):([^;]*)/', $dom[$key]['attribute']['style'], $style_array, PREG_PATTERN_ORDER);
+						preg_match_all('/([^;:\s]*):([^;]*)/', ($dom[$key]['attribute']['style'] ?? ''), $style_array, PREG_PATTERN_ORDER);
 						$dom[$key]['style'] = array(); // reset style attribute array
                         foreach($style_array[1] as $id => $name) {
                             // in case of duplicate attribute the last replace the previous
-                            $dom[$key]['style'][strtolower($name)] = trim($style_array[2][$id]);
+                            $dom[$key]['style'][strtolower(($name ?? ''))] = trim(($style_array[2][$id] ?? ''));
                         }
 						// --- get some style attributes ---
 						// text direction
@@ -16570,7 +16571,7 @@
 						}
 						// display
 						if (isset($dom[$key]['style']['display'])) {
-							$dom[$key]['hide'] = (trim(strtolower($dom[$key]['style']['display'])) == 'none');
+							$dom[$key]['hide'] = (trim((strtolower(($dom[$key]['style']['display'] ?? '')) ?? '')) == 'none');
 						}
 						// font family
 						if (isset($dom[$key]['style']['font-family'])) {
@@ -16578,7 +16579,7 @@
 						}
 						// list-style-type
 						if (isset($dom[$key]['style']['list-style-type'])) {
-							$dom[$key]['listtype'] = trim(strtolower($dom[$key]['style']['list-style-type']));
+							$dom[$key]['listtype'] = trim((strtolower(($dom[$key]['style']['list-style-type'] ?? '')) ?? ''));
 							if ($dom[$key]['listtype'] == 'inherit') {
 								$dom[$key]['listtype'] = $dom[$parentkey]['listtype'];
 							}
@@ -16596,7 +16597,7 @@
 						}
 						// font size
 						if (isset($dom[$key]['style']['font-size'])) {
-							$fsize = trim($dom[$key]['style']['font-size']);
+							$fsize = trim(($dom[$key]['style']['font-size'] ?? ''));
 							$dom[$key]['fontsize'] = $this->getHTMLFontUnits($fsize, $dom[0]['fontsize'], $dom[$parentkey]['fontsize'], 'pt');
 						}
 						// font-stretch
@@ -16609,7 +16610,7 @@
 						}
 						// line-height (internally is the cell height ratio)
 						if (isset($dom[$key]['style']['line-height'])) {
-							$lineheight = trim($dom[$key]['style']['line-height']);
+							$lineheight = trim(($dom[$key]['style']['line-height'] ?? ''));
 							switch ($lineheight) {
 								// A normal line height. This is default
 								case 'normal': {
@@ -16625,7 +16626,7 @@
 										$lineheight = ($lineheight * 100).'%';
 									}
 									$dom[$key]['line-height'] = $this->getHTMLUnitToUnits($lineheight, 1, '%', true);
-									if (substr($lineheight, -1) !== '%') {
+									if (substr(($lineheight ?? ''), -1) !== '%') {
 										if ($dom[$key]['fontsize'] <= 0) {
 											$dom[$key]['line-height'] = 1;
 										} else {
@@ -16637,15 +16638,15 @@
 						}
 						// font style
 						if (isset($dom[$key]['style']['font-weight'])) {
-							if (strtolower($dom[$key]['style']['font-weight'][0]) == 'n') {
-								if (strpos($dom[$key]['fontstyle'], 'B') !== false) {
-									$dom[$key]['fontstyle'] = str_replace('B', '', $dom[$key]['fontstyle']);
+							if (strtolower(($dom[$key]['style']['font-weight'][0] ?? '')) == 'n') {
+								if (strpos(($dom[$key]['fontstyle'] ?? ''), 'B') !== false) {
+									$dom[$key]['fontstyle'] = str_replace('B', '', ($dom[$key]['fontstyle'] ?? ''));
 								}
-							} elseif (strtolower($dom[$key]['style']['font-weight'][0]) == 'b') {
+							} elseif (strtolower(($dom[$key]['style']['font-weight'][0] ?? '')) == 'b') {
 								$dom[$key]['fontstyle'] .= 'B';
 							}
 						}
-						if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style'][0]) == 'i')) {
+						if (isset($dom[$key]['style']['font-style']) AND (strtolower(($dom[$key]['style']['font-style'][0] ?? '')) == 'i')) {
 							$dom[$key]['fontstyle'] .= 'I';
 						}
 						// font color
@@ -16660,9 +16661,9 @@
 						}
 						// text-decoration
 						if (isset($dom[$key]['style']['text-decoration'])) {
-							$decors = explode(' ', strtolower($dom[$key]['style']['text-decoration']));
+							$decors = explode(' ', (strtolower(($dom[$key]['style']['text-decoration'] ?? '')) ?? ''));
 							foreach ($decors as $dec) {
-								$dec = trim($dec);
+								$dec = trim(($dec ?? ''));
 								if (!TCPDF_STATIC::empty_string($dec)) {
 									if ($dec[0] == 'u') {
 										// underline
@@ -16689,7 +16690,7 @@
 						}
 						// check for text alignment
 						if (isset($dom[$key]['style']['text-align'])) {
-							$dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align'][0]);
+							$dom[$key]['align'] = strtoupper(($dom[$key]['style']['text-align'][0] ?? ''));
 						}
 						// check for CSS border properties
 						if (isset($dom[$key]['style']['border'])) {
@@ -16699,7 +16700,7 @@
 							}
 						}
 						if (isset($dom[$key]['style']['border-color'])) {
-							$brd_colors = preg_split('/[\s]+/', trim($dom[$key]['style']['border-color']));
+							$brd_colors = preg_split('/[\s]+/', (trim(($dom[$key]['style']['border-color'] ?? '')) ?? ''));
 							if (isset($brd_colors[3])) {
 								$dom[$key]['border']['L']['color'] = TCPDF_COLORS::convertHTMLColorToDec($brd_colors[3], $this->spot_colors);
 							}
@@ -16714,7 +16715,7 @@
 							}
 						}
 						if (isset($dom[$key]['style']['border-width'])) {
-							$brd_widths = preg_split('/[\s]+/', trim($dom[$key]['style']['border-width']));
+							$brd_widths = preg_split('/[\s]+/', (trim(($dom[$key]['style']['border-width'] ?? '')) ?? ''));
 							if (isset($brd_widths[3])) {
 								$dom[$key]['border']['L']['width'] = $this->getCSSBorderWidth($brd_widths[3]);
 							}
@@ -16729,7 +16730,7 @@
 							}
 						}
 						if (isset($dom[$key]['style']['border-style'])) {
-							$brd_styles = preg_split('/[\s]+/', trim($dom[$key]['style']['border-style']));
+							$brd_styles = preg_split('/[\s]+/', (trim(($dom[$key]['style']['border-style'] ?? '')) ?? ''));
 							if (isset($brd_styles[3]) AND ($brd_styles[3]!='none')) {
 								$dom[$key]['border']['L']['cap'] = 'square';
 								$dom[$key]['border']['L']['join'] = 'miter';
@@ -16803,7 +16804,7 @@
 						}
 						foreach ($cellside as $psk => $psv) {
 							if (isset($dom[$key]['style']['margin-'.$psv])) {
-								$dom[$key]['margin'][$psk] = $this->getHTMLUnitToUnits(str_replace('auto', '0', $dom[$key]['style']['margin-'.$psv]), 0, 'px', false);
+								$dom[$key]['margin'][$psk] = $this->getHTMLUnitToUnits(str_replace('auto', '0', ($dom[$key]['style']['margin-'.$psv] ?? '')), 0, 'px', false);
 							}
 						}
 						// check for CSS border-spacing properties
@@ -16836,7 +16837,7 @@
 						}
 					}
 					if (isset($dom[$key]['attribute']['display'])) {
-						$dom[$key]['hide'] = (trim(strtolower($dom[$key]['attribute']['display'])) == 'none');
+						$dom[$key]['hide'] = (trim((strtolower(($dom[$key]['attribute']['display'] ?? '')) ?? '')) == 'none');
 					}
 					if (isset($dom[$key]['attribute']['border']) AND ($dom[$key]['attribute']['border'] != 0)) {
 						$borderstyle = $this->getCSSBorderStyle($dom[$key]['attribute']['border'].' solid black');
@@ -16854,9 +16855,9 @@
 						if (isset($dom[$key]['attribute']['size'])) {
 							if ($key > 0) {
 								if ($dom[$key]['attribute']['size'][0] == '+') {
-									$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] + intval(substr($dom[$key]['attribute']['size'], 1));
+									$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] + intval(substr(($dom[$key]['attribute']['size'] ?? ''), 1));
 								} elseif ($dom[$key]['attribute']['size'][0] == '-') {
-									$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] - intval(substr($dom[$key]['attribute']['size'], 1));
+									$dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] - intval(substr(($dom[$key]['attribute']['size'] ?? ''), 1));
 								} else {
 									$dom[$key]['fontsize'] = intval($dom[$key]['attribute']['size']);
 								}
@@ -16897,10 +16898,10 @@
 					if (($dom[$key]['value'] == 'pre') OR ($dom[$key]['value'] == 'tt')) {
 						$dom[$key]['fontname'] = $this->default_monospaced_font;
 					}
-					if (!empty($dom[$key]['value']) AND ($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) {
+					if (!empty($dom[$key]['value']) AND ($dom[$key]['value'][0] == 'h') AND (intval($dom[$key]['value'][1]) > 0) AND (intval($dom[$key]['value'][1]) < 7)) {
 						// headings h1, h2, h3, h4, h5, h6
 						if (!isset($dom[$key]['attribute']['size']) AND !isset($dom[$key]['style']['font-size'])) {
-							$headsize = (4 - intval($dom[$key]['value']{1})) * 2;
+							$headsize = (4 - intval($dom[$key]['value'][1])) * 2;
 							$dom[$key]['fontsize'] = $dom[0]['fontsize'] + $headsize;
 						}
 						if (!isset($dom[$key]['style']['font-weight'])) {
@@ -16962,7 +16963,7 @@
 					}
 					// check for text alignment
 					if (isset($dom[$key]['attribute']['align']) AND (!TCPDF_STATIC::empty_string($dom[$key]['attribute']['align'])) AND ($dom[$key]['value'] !== 'img')) {
-						$dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align'][0]);
+						$dom[$key]['align'] = strtoupper(($dom[$key]['attribute']['align'][0] ?? ''));
 					}
 					// check for text rendering mode (the following attributes do not exist in HTML)
 					if (isset($dom[$key]['attribute']['stroke'])) {
@@ -17002,15 +17003,15 @@
 					} elseif (!$this->isunicode) {
 						switch ($dom[$dom[$key]['parent']]['text-transform']) {
 							case 'capitalize': {
-								$element = ucwords(strtolower($element));
+								$element = ucwords((strtolower(($element ?? '')) ?? ''));
 								break;
 							}
 							case 'uppercase': {
-								$element = strtoupper($element);
+								$element = strtoupper(($element ?? ''));
 								break;
 							}
 							case 'lowercase': {
-								$element = strtolower($element);
+								$element = strtolower(($element ?? ''));
 								break;
 							}
 						}
@@ -17046,7 +17047,7 @@
 	 * @public static
 	 */
 	protected function getHashForTCPDFtagParams($data) {
-		return md5(strlen($data).$this->file_id.$data);
+		return md5(strlen(($data ?? '')).$this->file_id.$data);
 	}
 
 	/**
@@ -17056,7 +17057,7 @@
 	 * @public static
 	 */
 	public function serializeTCPDFtagParameters($data) {
-		$encoded = urlencode(json_encode($data));
+		$encoded = urlencode((json_encode($data) ?? ''));
 		return $this->getHashForTCPDFtagParams($encoded).$encoded;
 	}
 
@@ -17067,12 +17068,12 @@
 	 * @protected static
 	 */
 	protected function unserializeTCPDFtagParameters($data) {
-		$hash = substr($data, 0, 32);
-		$encoded = substr($data, 32);
+		$hash = substr(($data ?? ''), 0, 32);
+		$encoded = substr(($data ?? ''), 32);
 		if ($hash != $this->getHashForTCPDFtagParams($encoded)) {
 			$this->Error('Invalid parameters');
 		}
-		return json_decode(urldecode($encoded), true);
+		return json_decode(urldecode(($encoded ?? '')), true);
 	}
 
 	/**
@@ -17146,15 +17147,15 @@
 		$this->premode = false;
 		if ($this->inxobj) {
 			// we are inside an XObject template
-			$pask = count($this->xobjects[$this->xobjid]['annotations']);
+			$pask = count(($this->xobjects[$this->xobjid]['annotations'] ?? []));
 		} elseif (isset($this->PageAnnots[$this->page])) {
-			$pask = count($this->PageAnnots[$this->page]);
+			$pask = count(($this->PageAnnots[$this->page] ?? []));
 		} else {
 			$pask = 0;
 		}
 		if ($this->inxobj) {
 			// we are inside an XObject template
-			$startlinepos = strlen($this->xobjects[$this->xobjid]['outdata']);
+			$startlinepos = strlen(($this->xobjects[$this->xobjid]['outdata'] ?? ''));
 		} elseif (!$this->InFooter) {
 			if (isset($this->footerlen[$this->page])) {
 				$this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
@@ -17204,7 +17205,7 @@
 			$this->resetLastH();
 		}
 		$dom = $this->getHtmlDomArray($html);
-		$maxel = count($dom);
+		$maxel = count(($dom ?? []));
 		$key = 0;
 		while ($key < $maxel) {
 			if ($dom[$key]['tag'] AND $dom[$key]['opening'] AND $dom[$key]['hide']) {
@@ -17378,14 +17379,14 @@
 							}
 							// line to be moved one page forward
 							$pagebuff = $this->getPageBuffer($startlinepage);
-							$linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
-							$tstart = substr($pagebuff, 0, $startlinepos);
-							$tend = substr($this->getPageBuffer($startlinepage), $curpos);
+							$linebeg = substr(($pagebuff ?? ''), $startlinepos, ($curpos - $startlinepos));
+							$tstart = substr(($pagebuff ?? ''), 0, $startlinepos);
+							$tend = substr(($this->getPageBuffer($startlinepage) ?? ''), $curpos);
 							// remove line from previous page
 							$this->setPageBuffer($startlinepage, $tstart.''.$tend);
 							$pagebuff = $this->getPageBuffer($this->page);
-							$tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
-							$tend = substr($pagebuff, $this->cntmrk[$this->page]);
+							$tstart = substr(($pagebuff ?? ''), 0, $this->cntmrk[$this->page]);
+							$tend = substr(($pagebuff ?? ''), $this->cntmrk[$this->page]);
 							// add line start to current page
 							$yshift = ($minstartliney - $this->y);
 							if ($fontaligned) {
@@ -17395,7 +17396,7 @@
 							$this->setPageBuffer($this->page, $tstart."\nq\n".$try."\n".$linebeg."\nQ\n".$tend);
 							// shift the annotations and links
 							if (isset($this->PageAnnots[$this->page])) {
-								$next_pask = count($this->PageAnnots[$this->page]);
+								$next_pask = count(($this->PageAnnots[$this->page] ?? []));
 							} else {
 								$next_pask = 0;
 							}
@@ -17404,7 +17405,7 @@
 									if ($pak >= $pask) {
 										$this->PageAnnots[$this->page][] = $pac;
 										unset($this->PageAnnots[$startlinepage][$pak]);
-										$npak = count($this->PageAnnots[$this->page]) - 1;
+										$npak = count(($this->PageAnnots[$this->page] ?? [])) - 1;
 										$this->PageAnnots[$this->page][$npak]['y'] -= $yshift;
 									}
 								}
@@ -17446,21 +17447,21 @@
 								}
 								// line to be moved one page forward
 								$pagebuff = $this->getPageBuffer($startlinepage);
-								$linebeg = substr($pagebuff, $startlinepos, ($curpos - $startlinepos));
-								$tstart = substr($pagebuff, 0, $startlinepos);
-								$tend = substr($this->getPageBuffer($startlinepage), $curpos);
+								$linebeg = substr(($pagebuff ?? ''), $startlinepos, ($curpos - $startlinepos));
+								$tstart = substr(($pagebuff ?? ''), 0, $startlinepos);
+								$tend = substr(($this->getPageBuffer($startlinepage) ?? ''), $curpos);
 								// remove line start from previous page
 								$this->setPageBuffer($startlinepage, $tstart.''.$tend);
 								$pagebuff = $this->getPageBuffer($this->page);
-								$tstart = substr($pagebuff, 0, $this->cntmrk[$this->page]);
-								$tend = substr($pagebuff, $this->cntmrk[$this->page]);
+								$tstart = substr(($pagebuff ?? ''), 0, $this->cntmrk[$this->page]);
+								$tend = substr(($pagebuff ?? ''), $this->cntmrk[$this->page]);
 								// add line start to current page
 								$yshift = ($minstartliney - $this->y);
 								$try = sprintf('1 0 0 1 0 %F cm', ($yshift * $this->k));
 								$this->setPageBuffer($this->page, $tstart."\nq\n".$try."\n".$linebeg."\nQ\n".$tend);
 								// shift the annotations and links
 								if (isset($this->PageAnnots[$this->page])) {
-									$next_pask = count($this->PageAnnots[$this->page]);
+									$next_pask = count(($this->PageAnnots[$this->page] ?? []));
 								} else {
 									$next_pask = 0;
 								}
@@ -17469,7 +17470,7 @@
 										if ($pak >= $pask) {
 											$this->PageAnnots[$this->page][] = $pac;
 											unset($this->PageAnnots[$startlinepage][$pak]);
-											$npak = count($this->PageAnnots[$this->page]) - 1;
+											$npak = count(($this->PageAnnots[$this->page] ?? [])) - 1;
 											$this->PageAnnots[$this->page][$npak]['y'] -= $yshift;
 										}
 									}
@@ -17488,7 +17489,7 @@
 								}
 								if (($dom[$key]['value'] != 'sup') AND ($dom[$key]['value'] != 'sub')) {
 									$current_line_align_data = array($key, $minstartliney, $maxbottomliney);
-									if (isset($line_align_data) AND (($line_align_data[0] == ($key - 1)) OR (($line_align_data[0] == ($key - 2)) AND (isset($dom[($key - 1)])) AND (preg_match('/^([\s]+)$/', $dom[($key - 1)]['value']) > 0)))) {
+									if (isset($line_align_data) AND (($line_align_data[0] == ($key - 1)) OR (($line_align_data[0] == ($key - 2)) AND (isset($dom[($key - 1)])) AND (preg_match('/^([\s]+)$/', ($dom[($key - 1)]['value'] ?? '')) > 0)))) {
 										$minstartliney = min($this->y, $line_align_data[1]);
 										$maxbottomliney = max(($this->y + $this->getCellHeight($fontsize / $this->k)), $line_align_data[2]);
 									} else {
@@ -17547,7 +17548,7 @@
 				}
 			}
 			// align lines
-			if ($this->newline AND (strlen($dom[$key]['value']) > 0) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) {
+			if ($this->newline AND (strlen(($dom[$key]['value'] ?? '')) > 0) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) {
 				$newline = true;
 				$fontaligned = false;
 				// we are at the beginning of a new line
@@ -17561,21 +17562,21 @@
 					$linew = abs($this->endlinex - $startlinex);
 					if ($this->inxobj) {
 						// we are inside an XObject template
-						$pstart = substr($this->xobjects[$this->xobjid]['outdata'], 0, $startlinepos);
+						$pstart = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), 0, $startlinepos);
 						if (isset($opentagpos)) {
 							$midpos = $opentagpos;
 						} else {
 							$midpos = 0;
 						}
 						if ($midpos > 0) {
-							$pmid = substr($this->xobjects[$this->xobjid]['outdata'], $startlinepos, ($midpos - $startlinepos));
-							$pend = substr($this->xobjects[$this->xobjid]['outdata'], $midpos);
+							$pmid = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $startlinepos, ($midpos - $startlinepos));
+							$pend = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $midpos);
 						} else {
-							$pmid = substr($this->xobjects[$this->xobjid]['outdata'], $startlinepos);
+							$pmid = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $startlinepos);
 							$pend = '';
 						}
 					} else {
-						$pstart = substr($this->getPageBuffer($startlinepage), 0, $startlinepos);
+						$pstart = substr(($this->getPageBuffer($startlinepage) ?? ''), 0, $startlinepos);
 						if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
 							$this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
 							$midpos = min($opentagpos, $this->footerpos[$startlinepage]);
@@ -17588,10 +17589,10 @@
 							$midpos = 0;
 						}
 						if ($midpos > 0) {
-							$pmid = substr($this->getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
-							$pend = substr($this->getPageBuffer($startlinepage), $midpos);
+							$pmid = substr(($this->getPageBuffer($startlinepage) ?? ''), $startlinepos, ($midpos - $startlinepos));
+							$pend = substr(($this->getPageBuffer($startlinepage) ?? ''), $midpos);
 						} else {
-							$pmid = substr($this->getPageBuffer($startlinepage), $startlinepos);
+							$pmid = substr(($this->getPageBuffer($startlinepage) ?? ''), $startlinepos);
 							$pend = '';
 						}
 					}
@@ -17622,10 +17623,10 @@
 									$spacelen = 1;
 								}
 								if ($pos1 == $pos2) {
-									$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
-									if (substr($pmid, $pos1, 4) == '[()]') {
+									$pmid = substr(($pmid ?? ''), 0, ($pos1 + 2)).substr(($pmid ?? ''), ($pos1 + 2 + $spacelen));
+									if (substr(($pmid ?? ''), $pos1, 4) == '[()]') {
 										$linew -= $one_space_width;
-									} elseif ($pos1 == strpos($pmid, '[(')) {
+									} elseif ($pos1 == strpos(($pmid ?? ''), '[(')) {
 										$no = 1;
 									}
 								}
@@ -17643,7 +17644,7 @@
 									$spacelen = 1;
 								}
 								if ($pos1 == $pos2) {
-									$pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
+									$pmid = substr(($pmid ?? ''), 0, ($pos1 - $spacelen)).substr(($pmid ?? ''), $pos1);
 									$linew -= $one_space_width;
 								}
 							}
@@ -17670,16 +17671,16 @@
 							$ns = 0; // number of spaces
 							$pmidtemp = $pmid;
 							// escape special characters
-							$pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmidtemp);
-							$pmidtemp = preg_replace('/[\\\][\)]/x', '\\#!#CP#!#', $pmidtemp);
+							$pmidtemp = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', ($pmidtemp ?? ''));
+							$pmidtemp = preg_replace('/[\\\][\)]/x', '\\#!#CP#!#', ($pmidtemp ?? ''));
 							// search spaces
-							if (preg_match_all('/\[\(([^\)]*)\)\]/x', $pmidtemp, $lnstring, PREG_PATTERN_ORDER)) {
+							if (preg_match_all('/\[\(([^\)]*)\)\]/x', ($pmidtemp ?? ''), $lnstring, PREG_PATTERN_ORDER)) {
 								$spacestr = $this->getSpaceString();
-								$maxkk = count($lnstring[1]) - 1;
+								$maxkk = count(($lnstring[1] ?? [])) - 1;
 								for ($kk=0; $kk <= $maxkk; ++$kk) {
 									// restore special characters
-									$lnstring[1][$kk] = str_replace('#!#OP#!#', '(', $lnstring[1][$kk]);
-									$lnstring[1][$kk] = str_replace('#!#CP#!#', ')', $lnstring[1][$kk]);
+									$lnstring[1][$kk] = str_replace('#!#OP#!#', '(', ($lnstring[1][$kk] ?? ''));
+									$lnstring[1][$kk] = str_replace('#!#CP#!#', ')', ($lnstring[1][$kk] ?? ''));
 									// store number of spaces on the strings
 									$lnstring[2][$kk] = substr_count($lnstring[1][$kk], $spacestr);
 									// count total spaces on line
@@ -17710,14 +17711,14 @@
 								if ($this->isRTLTextDir()) {
 									$textpos = $this->wPt;
 								}
-								while (preg_match('/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', $pmid, $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
+								while (preg_match('/([0-9\.\+\-]*)[\s](Td|cm|m|l|c|re)[\s]/x', ($pmid ?? ''), $strpiece, PREG_OFFSET_CAPTURE, $offset) == 1) {
 									// check if we are inside a string section '[( ... )]'
-									$stroffset = strpos($pmid, '[(', $offset);
+									$stroffset = strpos(($pmid ?? ''), '[(', $offset);
 									if (($stroffset !== false) AND ($stroffset <= $strpiece[2][1])) {
 										// set offset to the end of string section
-										$offset = strpos($pmid, ')]', $stroffset);
+										$offset = strpos(($pmid ?? ''), ')]', $stroffset);
 										while (($offset !== false) AND ($pmid[($offset - 1)] == '\\')) {
-											$offset = strpos($pmid, ')]', ($offset + 1));
+											$offset = strpos(($pmid ?? ''), ')]', ($offset + 1));
 										}
 										if ($offset === false) {
 											$this->Error('HTML Justification: malformed PDF code.');
@@ -17729,21 +17730,21 @@
 									} else {
 										$spacew = ($spacewidth * $ns);
 									}
-									$offset = $strpiece[2][1] + strlen($strpiece[2][0]);
-									$epsposend = strpos($pmid, $this->epsmarker.'Q', $offset);
+									$offset = $strpiece[2][1] + strlen(($strpiece[2][0] ?? ''));
+									$epsposend = strpos(($pmid ?? ''), $this->epsmarker.'Q', $offset);
 									if ($epsposend !== null) {
 										$epsposend += strlen($this->epsmarker.'Q');
-										$epsposbeg = strpos($pmid, 'q'.$this->epsmarker, $offset);
+										$epsposbeg = strpos(($pmid ?? ''), 'q'.$this->epsmarker, $offset);
 										if ($epsposbeg === null) {
-											$epsposbeg = strpos($pmid, 'q'.$this->epsmarker, ($prev_epsposbeg - 6));
+											$epsposbeg = strpos(($pmid ?? ''), 'q'.$this->epsmarker, ($prev_epsposbeg - 6));
 											$prev_epsposbeg = $epsposbeg;
 										}
 										if (($epsposbeg > 0) AND ($epsposend > 0) AND ($offset > $epsposbeg) AND ($offset < $epsposend)) {
 											// shift EPS images
 											$trx = sprintf('1 0 0 1 %F 0 cm', $spacew);
-											$pmid_b = substr($pmid, 0, $epsposbeg);
-											$pmid_m = substr($pmid, $epsposbeg, ($epsposend - $epsposbeg));
-											$pmid_e = substr($pmid, $epsposend);
+											$pmid_b = substr(($pmid ?? ''), 0, $epsposbeg);
+											$pmid_m = substr(($pmid ?? ''), $epsposbeg, ($epsposend - $epsposbeg));
+											$pmid_e = substr(($pmid ?? ''), $epsposend);
 											$pmid = $pmid_b."\nq\n".$trx."\n".$pmid_m."\nQ\n".$pmid_e;
 											$offset = $epsposend;
 											continue;
@@ -17757,7 +17758,7 @@
 										case 'm':
 										case 'l': {
 											// get current X position
-											preg_match('/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x', $pmid, $xmatches);
+											preg_match('/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x', ($pmid ?? ''), $xmatches);
 											if (!isset($xmatches[1])) {
 												break;
 											}
@@ -17771,9 +17772,9 @@
 												++$strcount;
 											}
 											// justify block
-											if (preg_match('/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x', $pmid, $pmatch) == 1) {
+											if (preg_match('/([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s]('.$strpiece[2][0].')([\s]*)/x', ($pmid ?? ''), $pmatch) == 1) {
 												$newpmid = sprintf('%F',(floatval($pmatch[1]) + $spacew)).' '.$pmatch[2].' x*#!#*x'.$pmatch[3].$pmatch[4];
-												$pmid = str_replace($pmatch[0], $newpmid, $pmid);
+												$pmid = str_replace(($pmatch[0] ?? ''), ($newpmid ?? ''), ($pmid ?? ''));
 												unset($pmatch, $newpmid);
 											}
 											break;
@@ -17784,7 +17785,7 @@
 												$this->lispacer = '';
 												break;
 											}
-											preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', $pmid, $xmatches);
+											preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', ($pmid ?? ''), $xmatches);
 											if (!isset($xmatches[1])) {
 												break;
 											}
@@ -17816,29 +17817,29 @@
 													}
 												}
 											}
-											if (preg_match('/('.$xmatches[1].')[\s]('.$xmatches[2].')[\s]('.$xmatches[3].')[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', $pmid, $pmatch) == 1) {
+											if (preg_match('/('.$xmatches[1].')[\s]('.$xmatches[2].')[\s]('.$xmatches[3].')[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', ($pmid ?? ''), $pmatch) == 1) {
 												$newx = sprintf('%F',(floatval($pmatch[1]) + $x_diff));
 												$neww = sprintf('%F',(floatval($pmatch[3]) + $w_diff));
 												$newpmid = $newx.' '.$pmatch[2].' '.$neww.' '.$pmatch[4].' x*#!#*x'.$pmatch[5].$pmatch[6];
-												$pmid = str_replace($pmatch[0], $newpmid, $pmid);
+												$pmid = str_replace(($pmatch[0] ?? ''), ($newpmid ?? ''), ($pmid ?? ''));
 												unset($pmatch, $newpmid, $newx, $neww);
 											}
 											break;
 										}
 										case 'c': {
 											// get current X position
-											preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](c)([\s]*)/x', $pmid, $xmatches);
+											preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](c)([\s]*)/x', ($pmid ?? ''), $xmatches);
 											if (!isset($xmatches[1])) {
 												break;
 											}
 											$currentxpos = $xmatches[1];
 											// justify block
-											if (preg_match('/('.$xmatches[1].')[\s]('.$xmatches[2].')[\s]('.$xmatches[3].')[\s]('.$xmatches[4].')[\s]('.$xmatches[5].')[\s]('.$strpiece[1][0].')[\s](c)([\s]*)/x', $pmid, $pmatch) == 1) {
+											if (preg_match('/('.$xmatches[1].')[\s]('.$xmatches[2].')[\s]('.$xmatches[3].')[\s]('.$xmatches[4].')[\s]('.$xmatches[5].')[\s]('.$strpiece[1][0].')[\s](c)([\s]*)/x', ($pmid ?? ''), $pmatch) == 1) {
 												$newx1 = sprintf('%F',(floatval($pmatch[1]) + $spacew));
 												$newx2 = sprintf('%F',(floatval($pmatch[3]) + $spacew));
 												$newx3 = sprintf('%F',(floatval($pmatch[5]) + $spacew));
 												$newpmid = $newx1.' '.$pmatch[2].' '.$newx2.' '.$pmatch[4].' '.$newx3.' '.$pmatch[6].' x*#!#*x'.$pmatch[7].$pmatch[8];
-												$pmid = str_replace($pmatch[0], $newpmid, $pmid);
+												$pmid = str_replace(($pmatch[0] ?? ''), ($newpmid ?? ''), ($pmid ?? ''));
 												unset($pmatch, $newpmid, $newx1, $newx2, $newx3);
 											}
 											break;
@@ -17875,7 +17876,7 @@
 									}
 								} // end of while
 								// remove markers
-								$pmid = str_replace('x*#!#*x', '', $pmid);
+								$pmid = str_replace('x*#!#*x', '', ($pmid ?? ''));
 								if ($this->isUnicodeFont()) {
 									// multibyte characters
 									$spacew = $spacewidthu;
@@ -17885,17 +17886,17 @@
 									}
 									// escape special characters
 									$pos = 0;
-									$pmid = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', $pmid);
-									$pmid = preg_replace('/[\\\][\)]/x', '\\#!#CP#!#', $pmid);
-									if (preg_match_all('/\[\(([^\)]*)\)\]/x', $pmid, $pamatch) > 0) {
+									$pmid = preg_replace('/[\\\][\(]/x', '\\#!#OP#!#', ($pmid ?? ''));
+									$pmid = preg_replace('/[\\\][\)]/x', '\\#!#CP#!#', ($pmid ?? ''));
+									if (preg_match_all('/\[\(([^\)]*)\)\]/x', ($pmid ?? ''), $pamatch) > 0) {
 										foreach($pamatch[0] as $pk => $pmatch) {
 											$replace = $pamatch[1][$pk];
-											$replace = str_replace('#!#OP#!#', '(', $replace);
-											$replace = str_replace('#!#CP#!#', ')', $replace);
-											$newpmid = '[('.str_replace(chr(0).chr(32), ') '.sprintf('%F', $spacew).' (', $replace).')]';
-											$pos = strpos($pmid, $pmatch, $pos);
+											$replace = str_replace('#!#OP#!#', '(', ($replace ?? ''));
+											$replace = str_replace('#!#CP#!#', ')', ($replace ?? ''));
+											$newpmid = '[('.str_replace(chr(0).chr(32), ') '.sprintf('%F', $spacew).' (', ($replace ?? '')).')]';
+											$pos = strpos(($pmid ?? ''), ($pmatch ?? ''), $pos);
 											if ($pos !== FALSE) {
-												$pmid = substr_replace($pmid, $newpmid, $pos, strlen($pmatch));
+												$pmid = substr_replace(($pmid ?? ''), ($newpmid ?? ''), $pos, strlen(($pmatch ?? '')));
 											}
 											++$pos;
 										}
@@ -17915,7 +17916,7 @@
 										$spacewidth /= ($this->font_stretching / 100);
 									}
 									$rs = sprintf('%F Tw', $spacewidth);
-									$pmid = preg_replace("/\[\(/x", $rs.' [(', $pmid);
+									$pmid = preg_replace("/\[\(/x", $rs.' [(', ($pmid ?? ''));
 									if ($this->inxobj) {
 										// we are inside an XObject template
 										$this->xobjects[$this->xobjid]['outdata'] = $pstart."\n".$pmid."\nBT 0 Tw ET\n".$pend;
@@ -17931,7 +17932,7 @@
 						// shift the line
 						$trx = sprintf('1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
 						$pstart .= "\nq\n".$trx."\n".$pmid."\nQ\n";
-						$endlinepos = strlen($pstart);
+						$endlinepos = strlen(($pstart ?? ''));
 						if ($this->inxobj) {
 							// we are inside an XObject template
 							$this->xobjects[$this->xobjid]['outdata'] = $pstart.$pend;
@@ -17974,7 +17975,7 @@
 				} else {
 					if ($this->inxobj) {
 						// we are inside an XObject template
-						$startlinepos = strlen($this->xobjects[$this->xobjid]['outdata']);
+						$startlinepos = strlen(($this->xobjects[$this->xobjid]['outdata'] ?? ''));
 					} elseif (!$this->InFooter) {
 						if (isset($this->footerlen[$this->page])) {
 							$this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
@@ -17989,7 +17990,7 @@
 				unset($endlinepos);
 				$plalign = $lalign;
 				if (isset($this->PageAnnots[$this->page])) {
-					$pask = count($this->PageAnnots[$this->page]);
+					$pask = count(($this->PageAnnots[$this->page] ?? []));
 				} else {
 					$pask = 0;
 				}
@@ -18130,7 +18131,7 @@
 						// skip row-spanned cells started on the previous rows
 						if (isset($dom[$table_el]['rowspans'])) {
 							$rsk = 0;
-							$rskmax = count($dom[$table_el]['rowspans']);
+							$rskmax = count(($dom[$table_el]['rowspans'] ?? []));
 							while ($rsk < $rskmax) {
 								$trwsp = $dom[$table_el]['rowspans'][$rsk];
 								$rsstartx = $trwsp['startx'];
@@ -18272,7 +18273,7 @@
 						if (!isset($opentagpos)) {
 							if ($this->inxobj) {
 								// we are inside an XObject template
-								$opentagpos = strlen($this->xobjects[$this->xobjid]['outdata']);
+								$opentagpos = strlen(($this->xobjects[$this->xobjid]['outdata'] ?? ''));
 							} elseif (!$this->InFooter) {
 								if (isset($this->footerlen[$this->page])) {
 									$this->footerpos[$this->page] = $this->pagelen[$this->page] - $this->footerlen[$this->page];
@@ -18295,7 +18296,7 @@
 						$startlinepage = $this->page;
 					}
 				}
-			} elseif (strlen($dom[$key]['value']) > 0) {
+			} elseif (strlen(($dom[$key]['value'] ?? '')) > 0) {
 				// print list-item
 				if (!TCPDF_STATIC::empty_string($this->lispacer) AND ($this->lispacer != '^')) {
 					$this->SetFont($pfontname, $pfontstyle, $pfontsize);
@@ -18317,22 +18318,22 @@
 				}
 				// text
 				$this->htmlvspace = 0;
-				$isRTLString = preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $dom[$key]['value']) || preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $dom[$key]['value']);
+				$isRTLString = preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL ?? ''), ($dom[$key]['value'] ?? '')) || preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC ?? ''), ($dom[$key]['value'] ?? ''));
 				if ((!$this->premode) AND $this->isRTLTextDir() AND !$isRTLString) {
 					// reverse spaces order
 					$lsp = ''; // left spaces
 					$rsp = ''; // right spaces
-					if (preg_match('/^('.$this->re_space['p'].'+)/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
+					if (preg_match('/^('.$this->re_space['p'].'+)/'.$this->re_space['m'], ($dom[$key]['value'] ?? ''), $matches)) {
 						$lsp = $matches[1];
 					}
-					if (preg_match('/('.$this->re_space['p'].'+)$/'.$this->re_space['m'], $dom[$key]['value'], $matches)) {
+					if (preg_match('/('.$this->re_space['p'].'+)$/'.$this->re_space['m'], ($dom[$key]['value'] ?? ''), $matches)) {
 						$rsp = $matches[1];
 					}
 					$dom[$key]['value'] = $rsp.$this->stringTrim($dom[$key]['value']).$lsp;
 				}
 				if ($newline) {
 					if (!$this->premode) {
-						$prelen = strlen($dom[$key]['value']);
+						$prelen = strlen(($dom[$key]['value'] ?? ''));
 						if ($this->isRTLTextDir() AND !$isRTLString) {
 							// right trim except non-breaking space
 							$dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']);
@@ -18340,7 +18341,7 @@
 							// left trim except non-breaking space
 							$dom[$key]['value'] = $this->stringLeftTrim($dom[$key]['value']);
 						}
-						$postlen = strlen($dom[$key]['value']);
+						$postlen = strlen(($dom[$key]['value'] ?? ''));
 						if (($postlen == 0) AND ($prelen > 0)) {
 							$dom[$key]['trimmed_space'] = true;
 						}
@@ -18350,7 +18351,7 @@
 				} else {
 					$firstblock = false;
 					// replace empty multiple spaces string with a single space
-					$dom[$key]['value'] = preg_replace('/^'.$this->re_space['p'].'+$/'.$this->re_space['m'], chr(32), $dom[$key]['value']);
+					$dom[$key]['value'] = preg_replace('/^'.$this->re_space['p'].'+$/'.$this->re_space['m'], (chr(32) ?? ''), ($dom[$key]['value'] ?? ''));
 				}
 				$strrest = '';
 				if ($this->rtl) {
@@ -18411,7 +18412,7 @@
 						if (($wadj > 0) AND (($strlinelen + $wadj) >= $cwa)) {
 							$wadj = 0;
 							$nextstr = TCPDF_STATIC::pregSplit('/'.$this->re_space['p'].'/', $this->re_space['m'], $dom[$key]['value']);
-							$numblks = count($nextstr);
+							$numblks = count(($nextstr ?? []));
 							if ($numblks > 1) {
 								// try to split on blank spaces
 								$wadj = ($cwa - $strlinelen + $this->GetStringWidth($nextstr[($numblks - 1)]));
@@ -18444,7 +18445,7 @@
 					}
 				}
 				$this->textindent = 0;
-				if (strlen($strrest) > 0) {
+				if (strlen(($strrest ?? '')) > 0) {
 					// store the remaining string on the previous $key position
 					$this->newline = true;
 					if ($strrest == $dom[$key]['value']) {
@@ -18512,21 +18513,21 @@
 			$linew = abs($this->endlinex - $startlinex);
 			if ($this->inxobj) {
 				// we are inside an XObject template
-				$pstart = substr($this->xobjects[$this->xobjid]['outdata'], 0, $startlinepos);
+				$pstart = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), 0, $startlinepos);
 				if (isset($opentagpos)) {
 					$midpos = $opentagpos;
 				} else {
 					$midpos = 0;
 				}
 				if ($midpos > 0) {
-					$pmid = substr($this->xobjects[$this->xobjid]['outdata'], $startlinepos, ($midpos - $startlinepos));
-					$pend = substr($this->xobjects[$this->xobjid]['outdata'], $midpos);
+					$pmid = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $startlinepos, ($midpos - $startlinepos));
+					$pend = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $midpos);
 				} else {
-					$pmid = substr($this->xobjects[$this->xobjid]['outdata'], $startlinepos);
+					$pmid = substr(($this->xobjects[$this->xobjid]['outdata'] ?? ''), $startlinepos);
 					$pend = '';
 				}
 			} else {
-				$pstart = substr($this->getPageBuffer($startlinepage), 0, $startlinepos);
+				$pstart = substr(($this->getPageBuffer($startlinepage) ?? ''), 0, $startlinepos);
 				if (isset($opentagpos) AND isset($this->footerlen[$startlinepage]) AND (!$this->InFooter)) {
 					$this->footerpos[$startlinepage] = $this->pagelen[$startlinepage] - $this->footerlen[$startlinepage];
 					$midpos = min($opentagpos, $this->footerpos[$startlinepage]);
@@ -18539,10 +18540,10 @@
 					$midpos = 0;
 				}
 				if ($midpos > 0) {
-					$pmid = substr($this->getPageBuffer($startlinepage), $startlinepos, ($midpos - $startlinepos));
-					$pend = substr($this->getPageBuffer($startlinepage), $midpos);
+					$pmid = substr(($this->getPageBuffer($startlinepage) ?? ''), $startlinepos, ($midpos - $startlinepos));
+					$pend = substr(($this->getPageBuffer($startlinepage) ?? ''), $midpos);
 				} else {
-					$pmid = substr($this->getPageBuffer($startlinepage), $startlinepos);
+					$pmid = substr(($this->getPageBuffer($startlinepage) ?? ''), $startlinepos);
 					$pend = '';
 				}
 			}
@@ -18570,10 +18571,10 @@
 							$spacelen = 1;
 						}
 						if ($pos1 == $pos2) {
-							$pmid = substr($pmid, 0, ($pos1 + 2)).substr($pmid, ($pos1 + 2 + $spacelen));
-							if (substr($pmid, $pos1, 4) == '[()]') {
+							$pmid = substr(($pmid ?? ''), 0, ($pos1 + 2)).substr(($pmid ?? ''), ($pos1 + 2 + $spacelen));
+							if (substr(($pmid ?? ''), $pos1, 4) == '[()]') {
 								$linew -= $one_space_width;
-							} elseif ($pos1 == strpos($pmid, '[(')) {
+							} elseif ($pos1 == strpos(($pmid ?? ''), '[(')) {
 								$no = 1;
 							}
 						}
@@ -18591,7 +18592,7 @@
 							$spacelen = 1;
 						}
 						if ($pos1 == $pos2) {
-							$pmid = substr($pmid, 0, ($pos1 - $spacelen)).substr($pmid, $pos1);
+							$pmid = substr(($pmid ?? ''), 0, ($pos1 - $spacelen)).substr(($pmid ?? ''), $pos1);
 							$linew -= $one_space_width;
 						}
 					}
@@ -18615,7 +18616,7 @@
 				// shift the line
 				$trx = sprintf('1 0 0 1 %F %F cm', ($t_x * $this->k), ($yshift * $this->k));
 				$pstart .= "\nq\n".$trx."\n".$pmid."\nQ\n";
-				$endlinepos = strlen($pstart);
+				$endlinepos = strlen(($pstart ?? ''));
 				if ($this->inxobj) {
 					// we are inside an XObject template
 					$this->xobjects[$this->xobjid]['outdata'] = $pstart.$pend;
@@ -18695,7 +18696,7 @@
 			}
 			if (isset($this->tagvspaces[$tag['value']][0]['n'])) {
 				$on = $this->tagvspaces[$tag['value']][0]['n'];
-			} elseif (preg_match('/[h][0-9]/', $tag['value']) > 0) {
+			} elseif (preg_match('/[h][0-9]/', ($tag['value'] ?? '')) > 0) {
 				$on = 0.6;
 			} else {
 				$on = 1;
@@ -18727,7 +18728,7 @@
 			}
 			if (isset($this->tagvspaces[$tag['value']][1]['n'])) {
 				$cn = $this->tagvspaces[$tag['value']][1]['n'];
-			} elseif (preg_match('/[h][0-9]/', $tag['value']) > 0) {
+			} elseif (preg_match('/[h][0-9]/', ($tag['value'] ?? '')) > 0) {
 				$cn = 0.6;
 			} else {
 				$cn = 1;
@@ -18823,27 +18824,27 @@
 				$imgsrc = $tag['attribute']['src'];
 				if ($imgsrc[0] === '@') {
 					// data stream
-					$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
+					$imgsrc = '@'.base64_decode((substr(($imgsrc ?? ''), 1) ?? ''));
 					$type = '';
 				} else {
 					if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
 						// fix image path
-						$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
+						$findroot = strpos(($imgsrc ?? ''), ($_SERVER['DOCUMENT_ROOT'] ?? ''));
 						if (($findroot === false) OR ($findroot > 1)) {
-							if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
-								$imgsrc = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$imgsrc;
+							if (substr(($_SERVER['DOCUMENT_ROOT'] ?? ''), -1) == '/') {
+								$imgsrc = substr(($_SERVER['DOCUMENT_ROOT'] ?? ''), 0, -1).$imgsrc;
 							} else {
 								$imgsrc = $_SERVER['DOCUMENT_ROOT'].$imgsrc;
 							}
 						}
-						$imgsrc = urldecode($imgsrc);
+						$imgsrc = urldecode(($imgsrc ?? ''));
 						$testscrtype = @parse_url($imgsrc);
 						if (empty($testscrtype['query'])) {
 							// convert URL to server path
-							$imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc);
-						} elseif (preg_match('|^https?://|', $imgsrc) !== 1) {
+							$imgsrc = str_replace((K_PATH_URL ?? ''), (K_PATH_MAIN ?? ''), ($imgsrc ?? ''));
+						} elseif (preg_match('|^https?://|', ($imgsrc ?? '')) !== 1) {
 							// convert URL to server path
-							$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
+							$imgsrc = str_replace((K_PATH_MAIN ?? ''), (K_PATH_URL ?? ''), ($imgsrc ?? ''));
 						}
 					}
 					// get image type
@@ -18885,13 +18886,13 @@
 					$imglink = $this->HREF['url'];
 					if ($imglink[0] == '#') {
 						// convert url to internal link
-						$lnkdata = explode(',', $imglink);
+						$lnkdata = explode(',', ($imglink ?? ''));
 						if (isset($lnkdata[0])) {
-							$page = intval(substr($lnkdata[0], 1));
+							$page = intval(substr(($lnkdata[0] ?? ''), 1));
 							if (empty($page) OR ($page <= 0)) {
 								$page = $this->page;
 							}
-							if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) {
+							if (isset($lnkdata[1]) AND (strlen(($lnkdata[1] ?? '')) > 0)) {
 								$lnky = floatval($lnkdata[1]);
 							} else {
 								$lnky = 0;
@@ -19287,11 +19288,11 @@
 				}
 				$w = 0;
 				if (isset($tag['attribute']['opt']) AND !TCPDF_STATIC::empty_string($tag['attribute']['opt'])) {
-					$options = explode('#!NwL!#', $tag['attribute']['opt']);
+					$options = explode('#!NwL!#', ($tag['attribute']['opt'] ?? ''));
 					$values = array();
 					foreach ($options as $val) {
-						if (strpos($val, '#!TaB!#') !== false) {
-							$opts = explode('#!TaB!#', $val);
+						if (strpos(($val ?? ''), '#!TaB!#') !== false) {
+							$opts = explode('#!TaB!#', ($val ?? ''));
 							$values[] = $opts;
 							$w = max($w, $this->GetStringWidth($opts[1]));
 						} else {
@@ -19388,7 +19389,7 @@
 			}
 			if (isset($this->tagvspaces[$tag['value']][1]['n'])) {
 				$cn = $this->tagvspaces[$tag['value']][1]['n'];
-			} elseif (preg_match('/[h][0-9]/', $tag['value']) > 0) {
+			} elseif (preg_match('/[h][0-9]/', ($tag['value'] ?? '')) > 0) {
 				$cn = 0.6;
 			} else {
 				$cn = 1;
@@ -19534,13 +19535,13 @@
 					$table_el = $dom[($dom[$key]['parent'])];
 				}
 				// for each row
-				if (count($table_el['trids']) > 0) {
+				if (count(($table_el['trids'] ?? [])) > 0) {
 					unset($xmax);
 				}
 				foreach ($table_el['trids'] as $j => $trkey) {
 					$parent = $dom[$trkey];
 					if (!isset($xmax)) {
-						$xmax = $parent['cellpos'][(count($parent['cellpos']) - 1)]['endx'];
+						$xmax = $parent['cellpos'][(count(($parent['cellpos'] ?? [])) - 1)]['endx'];
 					}
 					// for each cell on the row
 					foreach ($parent['cellpos'] as $k => $cellpos) {
@@ -19695,7 +19696,7 @@
 								} // end for each column
 							}
 							if (!empty($cborder) OR !empty($fill)) {
-								$offsetlen = strlen($ccode);
+								$offsetlen = strlen(($ccode ?? ''));
 								// draw border and fill
 								if ($this->inxobj) {
 									// we are inside an XObject template
@@ -19708,8 +19709,8 @@
 										$this->xobjects[$this->xobjid]['intmrk'] += $offsetlen;
 									}
 									$pagebuff = $this->xobjects[$this->xobjid]['outdata'];
-									$pstart = substr($pagebuff, 0, $pagemark);
-									$pend = substr($pagebuff, $pagemark);
+									$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+									$pend = substr(($pagebuff ?? ''), $pagemark);
 									$this->xobjects[$this->xobjid]['outdata'] = $pstart.$ccode.$pend;
 								} else {
 									// draw border and fill
@@ -19722,8 +19723,8 @@
 										$pagemark = $this->intmrk[$this->page];
 									}
 									$pagebuff = $this->getPageBuffer($this->page);
-									$pstart = substr($pagebuff, 0, $pagemark);
-									$pend = substr($pagebuff, $pagemark);
+									$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+									$pend = substr(($pagebuff ?? ''), $pagemark);
 									$this->setPageBuffer($this->page, $pstart.$ccode.$pend);
 								}
 							}
@@ -19753,8 +19754,8 @@
 					if (($this->page == ($this->numpages - 1)) AND ($this->pageopen[$this->numpages])) {
 						$plendiff = ($this->pagelen[$this->numpages] - $this->emptypagemrk[$this->numpages]);
 						if (($plendiff > 0) AND ($plendiff < 60)) {
-							$pagediff = substr($this->getPageBuffer($this->numpages), $this->emptypagemrk[$this->numpages], $plendiff);
-							if (substr($pagediff, 0, 5) == 'BT /F') {
+							$pagediff = substr(($this->getPageBuffer($this->numpages) ?? ''), $this->emptypagemrk[$this->numpages], $plendiff);
+							if (substr(($pagediff ?? ''), 0, 5) == 'BT /F') {
 								// the difference is only a font setting
 								$plendiff = 0;
 							}
@@ -20103,7 +20104,7 @@
 				} // end for each column
 			}
 			if ($cborder OR $fill) {
-				$offsetlen = strlen($ccode);
+				$offsetlen = strlen(($ccode ?? ''));
 				// draw border and fill
 				if ($this->inxobj) {
 					// we are inside an XObject template
@@ -20116,8 +20117,8 @@
 						$this->xobjects[$this->xobjid]['intmrk'] += $offsetlen;
 					}
 					$pagebuff = $this->xobjects[$this->xobjid]['outdata'];
-					$pstart = substr($pagebuff, 0, $pagemark);
-					$pend = substr($pagebuff, $pagemark);
+					$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+					$pend = substr(($pagebuff ?? ''), $pagemark);
 					$this->xobjects[$this->xobjid]['outdata'] = $pstart.$ccode.$pend;
 				} else {
 					if (end($this->transfmrk[$this->page]) !== false) {
@@ -20129,8 +20130,8 @@
 						$pagemark = $this->intmrk[$this->page];
 					}
 					$pagebuff = $this->getPageBuffer($this->page);
-					$pstart = substr($pagebuff, 0, $pagemark);
-					$pend = substr($pagebuff, $pagemark);
+					$pstart = substr(($pagebuff ?? ''), 0, $pagemark);
+					$pend = substr(($pagebuff ?? ''), $pagemark);
 					$this->setPageBuffer($this->page, $pstart.$ccode.$pend);
 					$this->bordermrk[$this->page] += $offsetlen;
 					$this->cntmrk[$this->page] += $offsetlen;
@@ -20157,11 +20158,11 @@
 	 */
 	public function setLIsymbol($symbol='!') {
 		// check for custom image symbol
-		if (substr($symbol, 0, 4) == 'img|') {
+		if (substr(($symbol ?? ''), 0, 4) == 'img|') {
 			$this->lisymbol = $symbol;
 			return;
 		}
-		$symbol = strtolower($symbol);
+		$symbol = strtolower(($symbol ?? ''));
 		$valid_symbols = array('!', '#', 'disc', 'circle', 'square', '1', 'decimal', 'decimal-leading-zero', 'i', 'lower-roman', 'I', 'upper-roman', 'a', 'lower-alpha', 'lower-latin', 'A', 'upper-alpha', 'upper-latin', 'lower-greek');
 		if (in_array($symbol, $valid_symbols)) {
 			$this->lisymbol = $symbol;
@@ -20279,9 +20280,9 @@
 		}
 		if (is_numeric($htmlval)) {
 			$value = floatval($htmlval);
-		} elseif (preg_match('/([0-9\.\-\+]+)/', $htmlval, $mnum)) {
+		} elseif (preg_match('/([0-9\.\-\+]+)/', ($htmlval ?? ''), $mnum)) {
 			$value = floatval($mnum[1]);
-			if (preg_match('/([a-z%]+)/', $htmlval, $munit)) {
+			if (preg_match('/([a-z%]+)/', ($htmlval ?? ''), $munit)) {
 				if (in_array($munit[1], $supportedunits)) {
 					$unit = $munit[1];
 				}
@@ -20372,9 +20373,9 @@
 		} elseif ($listtype == '#') {
 			// set default list type for ordered list
 			$listtype = 'decimal';
-		} elseif (substr($listtype, 0, 4) == 'img|') {
+		} elseif (substr(($listtype ?? ''), 0, 4) == 'img|') {
 			// custom image type ('img|type|width|height|image.ext')
-			$img = explode('|', $listtype);
+			$img = explode('|', ($listtype ?? ''));
 			$listtype = 'img';
 		}
 		switch ($listtype) {
@@ -20426,7 +20427,7 @@
 				} else {
 					$this->x -= $lspace;
 				}
-				$imgtype = strtolower($img[1]);
+				$imgtype = strtolower(($img[1] ?? ''));
 				$prev_y = $this->y;
 				switch ($imgtype) {
 					case 'svg': {
@@ -20460,7 +20461,7 @@
 			}
 			case 'i':
 			case 'lower-roman': {
-				$textitem = strtolower(TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]));
+				$textitem = strtolower((TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]) ?? ''));
 				break;
 			}
 			case 'I':
@@ -20471,13 +20472,13 @@
 			case 'a':
 			case 'lower-alpha':
 			case 'lower-latin': {
-				$textitem = chr(97 + $this->listcount[$this->listnum] - 1);
+				$textitem = chr((int) (97 + $this->listcount[$this->listnum] - 1));
 				break;
 			}
 			case 'A':
 			case 'upper-alpha':
 			case 'upper-latin': {
-				$textitem = chr(65 + $this->listcount[$this->listnum] - 1);
+				$textitem = chr((int) (65 + $this->listcount[$this->listnum] - 1));
 				break;
 			}
 			case 'lower-greek': {
@@ -20694,7 +20695,7 @@
 	 * @since 4.5.000 (2009-01-02)
 	 */
 	protected function setBuffer($data) {
-		$this->bufferlen += strlen($data);
+		$this->bufferlen += strlen(($data ?? ''));
 		$this->buffer .= $data;
 	}
 
@@ -20705,7 +20706,7 @@
 	 * @since 5.5.000 (2010-06-22)
 	 */
 	protected function replaceBuffer($data) {
-		$this->bufferlen = strlen($data);
+		$this->bufferlen = strlen(($data ?? ''));
 		$this->buffer = $data;
 	}
 
@@ -20734,9 +20735,9 @@
 			$this->pages[$page] = $data;
 		}
 		if ($append AND isset($this->pagelen[$page])) {
-			$this->pagelen[$page] += strlen($data);
+			$this->pagelen[$page] += strlen(($data ?? ''));
 		} else {
-			$this->pagelen[$page] = strlen($data);
+			$this->pagelen[$page] = strlen(($data ?? ''));
 		}
 	}
 
@@ -20999,7 +21000,7 @@
 		// adjust javascript
 		$jfrompage = $frompage;
 		$jtopage = $topage;
-		if (preg_match_all('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
+		if (preg_match_all('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', ($this->javascript ?? ''), $pamatch) > 0) {
 			foreach($pamatch[0] as $pk => $pmatch) {
 				$pagenum = intval($pamatch[3][$pk]) + 1;
 				if (($pagenum >= $jtopage) AND ($pagenum < $jfrompage)) {
@@ -21011,7 +21012,7 @@
 				}
 				--$newpage;
 				$newjs = "this.addField(\'".$pamatch[1][$pk]."\',\'".$pamatch[2][$pk]."\',".$newpage;
-				$this->javascript = str_replace($pmatch, $newjs, $this->javascript);
+				$this->javascript = str_replace(($pmatch ?? ''), ($newjs ?? ''), ($this->javascript ?? ''));
 			}
 			unset($pamatch);
 		}
@@ -21187,7 +21188,7 @@
 		}
 		// adjust javascript
 		$jpage = $page;
-		if (preg_match_all('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', $this->javascript, $pamatch) > 0) {
+		if (preg_match_all('/this\.addField\(\'([^\']*)\',\'([^\']*)\',([0-9]+)/', ($this->javascript ?? ''), $pamatch) > 0) {
 			foreach($pamatch[0] as $pk => $pmatch) {
 				$pagenum = intval($pamatch[3][$pk]) + 1;
 				if ($pagenum >= $jpage) {
@@ -21199,7 +21200,7 @@
 				}
 				--$newpage;
 				$newjs = "this.addField(\'".$pamatch[1][$pk]."\',\'".$pamatch[2][$pk]."\',".$newpage;
-				$this->javascript = str_replace($pmatch, $newjs, $this->javascript);
+				$this->javascript = str_replace(($pmatch ?? ''), ($newjs ?? ''), ($this->javascript ?? ''));
 			}
 			unset($pamatch);
 		}
@@ -21404,7 +21405,7 @@
 				$numfills = 0;
 			}
 			if ($numfills > 0) {
-				$rowfill = str_repeat($filler, $numfills);
+				$rowfill = str_repeat(($filler ?? ''), $numfills);
 			} else {
 				$rowfill = '';
 			}
@@ -21456,22 +21457,22 @@
 					$nu = TCPDF_FONTS::UTF8ToUTF16BE($na, false, $this->isunicode, $this->CurrentFont);
 					// replace aliases with numbers
 					foreach ($pnalias['u'] as $u) {
-						$sfill = str_repeat($filler, max(0, (strlen($u) - strlen($nu.' '))));
+						$sfill = str_repeat(($filler ?? ''), max(0, (strlen(($u ?? '')) - strlen($nu.' '))));
 						if ($this->rtl) {
 							$nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(' '.$sfill, false, $this->isunicode, $this->CurrentFont);
 						} else {
 							$nr = TCPDF_FONTS::UTF8ToUTF16BE($sfill.' ', false, $this->isunicode, $this->CurrentFont).$nu;
 						}
-						$temppage = str_replace($u, $nr, $temppage);
+						$temppage = str_replace(($u ?? ''), ($nr ?? ''), ($temppage ?? ''));
 					}
 					foreach ($pnalias['a'] as $a) {
-						$sfill = str_repeat($filler, max(0, (strlen($a) - strlen($na.' '))));
+						$sfill = str_repeat(($filler ?? ''), max(0, (strlen(($a ?? '')) - strlen($na.' '))));
 						if ($this->rtl) {
 							$nr = $na.' '.$sfill;
 						} else {
 							$nr = $sfill.' '.$na;
 						}
-						$temppage = str_replace($a, $nr, $temppage);
+						$temppage = str_replace(($a ?? ''), ($nr ?? ''), ($temppage ?? ''));
 					}
 				}
 				// save changes
@@ -21541,8 +21542,8 @@
 				$maxpage = max($maxpage, $outline['p']);
 			}
 			// replace templates with current values
-			$row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
-			$row = str_replace('#TOC_PAGE_NUMBER#', $pagenum, $row);
+			$row = str_replace('#TOC_DESCRIPTION#', ($outline['t'] ?? ''), ($row ?? ''));
+			$row = str_replace('#TOC_PAGE_NUMBER#', ($pagenum ?? ''), ($row ?? ''));
 			// add link to page
 			$row = '<a href="#'.$outline['p'].','.$outline['y'].'">'.$row.'</a>';
 			// write bookmark entry
@@ -21593,7 +21594,7 @@
 					// replace aliases with numbers
 					foreach ($pnalias['u'] as $u) {
 						if ($correct_align) {
-							$sfill = str_repeat($filler, (strlen($u) - strlen($nu.' ')));
+							$sfill = str_repeat(($filler ?? ''), (strlen(($u ?? '')) - strlen($nu.' ')));
 							if ($this->rtl) {
 								$nr = $nu.TCPDF_FONTS::UTF8ToUTF16BE(' '.$sfill, false, $this->isunicode, $this->CurrentFont);
 							} else {
@@ -21602,11 +21603,11 @@
 						} else {
 							$nr = $nu;
 						}
-						$temppage = str_replace($u, $nr, $temppage);
+						$temppage = str_replace(($u ?? ''), ($nr ?? ''), ($temppage ?? ''));
 					}
 					foreach ($pnalias['a'] as $a) {
 						if ($correct_align) {
-							$sfill = str_repeat($filler, (strlen($a) - strlen($na.' ')));
+							$sfill = str_repeat(($filler ?? ''), (strlen(($a ?? '')) - strlen($na.' ')));
 							if ($this->rtl) {
 								$nr = $na.' '.$sfill;
 							} else {
@@ -21615,7 +21616,7 @@
 						} else {
 							$nr = $na;
 						}
-						$temppage = str_replace($a, $nr, $temppage);
+						$temppage = str_replace(($a ?? ''), ($nr ?? ''), ($temppage ?? ''));
 					}
 				}
 				// save changes
@@ -21739,7 +21740,7 @@
 	 */
 	public function setColumnsArray($columns) {
 		$this->columns = $columns;
-		$this->num_columns = count($columns);
+		$this->num_columns = count(($columns ?? []));
 		$this->current_column = 0;
 		$this->column_start_page = $this->page;
 		$this->selectColumn(0);
@@ -21969,19 +21970,19 @@
 	 */
 	protected function hyphenateWord($word, $patterns, $dictionary=array(), $leftmin=1, $rightmin=2, $charmin=1, $charmax=8) {
 		$hyphenword = array(); // hyphens positions
-		$numchars = count($word);
+		$numchars = count(($word ?? []));
 		if ($numchars <= $charmin) {
 			return $word;
 		}
 		$word_string = TCPDF_FONTS::UTF8ArrSubString($word, '', '', $this->isunicode);
 		// some words will be returned as-is
 		$pattern = '/^([a-zA-Z0-9_\.\-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/';
-		if (preg_match($pattern, $word_string) > 0) {
+		if (preg_match(($pattern ?? ''), ($word_string ?? '')) > 0) {
 			// email
 			return $word;
 		}
 		$pattern = '/(([a-zA-Z0-9\-]+\.)?)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/';
-		if (preg_match($pattern, $word_string) > 0) {
+		if (preg_match(($pattern ?? ''), ($word_string ?? '')) > 0) {
 			// URL
 			return $word;
 		}
@@ -21995,10 +21996,10 @@
 		for ($pos = 0; $pos < $maxpos; ++$pos) {
 			$imax = min(($tmpnumchars - $pos), $charmax);
 			for ($i = 1; $i <= $imax; ++$i) {
-				$subword = strtolower(TCPDF_FONTS::UTF8ArrSubString($tmpword, $pos, ($pos + $i), $this->isunicode));
+				$subword = strtolower((TCPDF_FONTS::UTF8ArrSubString($tmpword, $pos, ($pos + $i), $this->isunicode) ?? ''));
 				if (isset($patterns[$subword])) {
 					$pattern = TCPDF_FONTS::UTF8StringToArray($patterns[$subword], $this->isunicode, $this->CurrentFont);
-					$pattern_length = count($pattern);
+					$pattern_length = count(($pattern ?? []));
 					$digits = 1;
 					for ($j = 0; $j < $pattern_length; ++$j) {
 						// check if $pattern[$j] is a number = hyphenation level (only numbers from 1 to 5 are valid)
@@ -22071,10 +22072,10 @@
 					$word = array();
 				}
 				$txtarr[] = $char;
-				if (chr($char) == '<') {
+				if (chr((int) ($char)) == '<') {
 					// we are inside an HTML tag
 					$intag = true;
-				} elseif ($intag AND (chr($char) == '>')) {
+				} elseif ($intag AND (chr((int) ($char)) == '>')) {
 					// end of HTML tag
 					$intag = false;
 					// check for style tag
@@ -22151,7 +22152,7 @@
 	 * @since 5.8.000 (2010-08-11)
 	 */
 	public function stringLeftTrim($str, $replace='') {
-		return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], $replace, $str);
+		return preg_replace('/^'.$this->re_space['p'].'+/'.$this->re_space['m'], ($replace ?? ''), ($str ?? ''));
 	}
 
 	/**
@@ -22164,7 +22165,7 @@
 	 * @since 5.8.000 (2010-08-11)
 	 */
 	public function stringRightTrim($str, $replace='') {
-		return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], $replace, $str);
+		return preg_replace('/'.$this->re_space['p'].'+$/'.$this->re_space['m'], ($replace ?? ''), ($str ?? ''));
 	}
 
 	/**
@@ -22203,16 +22204,16 @@
 	 */
 	public function getFontFamilyName($fontfamily) {
 		// remove spaces and symbols
-		$fontfamily = preg_replace('/[^a-z0-9_\,]/', '', strtolower($fontfamily));
+		$fontfamily = preg_replace('/[^a-z0-9_\,]/', '', (strtolower(($fontfamily ?? '')) ?? ''));
 		// extract all font names
-		$fontslist = preg_split('/[,]/', $fontfamily);
+		$fontslist = preg_split('/[,]/', ($fontfamily ?? ''));
 		// find first valid font name
 		foreach ($fontslist as $font) {
 			// replace font variations
-			$font = preg_replace('/regular$/', '', $font);
-			$font = preg_replace('/italic$/', 'I', $font);
-			$font = preg_replace('/oblique$/', 'I', $font);
-			$font = preg_replace('/bold([I]?)$/', 'B\\1', $font);
+			$font = preg_replace('/regular$/', '', ($font ?? ''));
+			$font = preg_replace('/italic$/', 'I', ($font ?? ''));
+			$font = preg_replace('/oblique$/', 'I', ($font ?? ''));
+			$font = preg_replace('/bold([I]?)$/', 'B\\1', ($font ?? ''));
 			// replace common family names and core fonts
 			$pattern = array();
 			$replacement = array();
@@ -22222,8 +22223,8 @@
 			$replacement[] = 'helvetica';
 			$pattern[] = '/^monospace/';
 			$replacement[] = 'courier';
-			$font = preg_replace($pattern, $replacement, $font);
-			if (in_array(strtolower($font), $this->fontlist) OR in_array($font, $this->fontkeys)) {
+			$font = preg_replace(($pattern ?? ''), ($replacement ?? ''), ($font ?? ''));
+			if (in_array(strtolower(($font ?? '')), $this->fontlist) OR in_array($font, $this->fontkeys)) {
 				return $font;
 			}
 		}
@@ -22713,7 +22714,7 @@
 		}
 		if ($file[0] === '@') { // image from string
 			$this->svgdir = '';
-			$svgdata = substr($file, 1);
+			$svgdata = substr(($file ?? ''), 1);
 		} else { // SVG file
 			$this->svgdir = dirname($file);
 			$svgdata = TCPDF_STATIC::fileGetContents($file);
@@ -22738,28 +22739,28 @@
 		$aspect_ratio_ms = 'meet';
 		$regs = array();
 		// get original image width and height
-		preg_match('/<svg([^\>]*)>/si', $svgdata, $regs);
+		preg_match('/<svg([^\>]*)>/si', ($svgdata ?? ''), $regs);
 		if (isset($regs[1]) AND !empty($regs[1])) {
 			$tmp = array();
-			if (preg_match('/[\s]+x[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
+			if (preg_match('/[\s]+x[\s]*=[\s]*"([^"]*)"/si', ($regs[1] ?? ''), $tmp)) {
 				$ox = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit, false);
 			}
 			$tmp = array();
-			if (preg_match('/[\s]+y[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
+			if (preg_match('/[\s]+y[\s]*=[\s]*"([^"]*)"/si', ($regs[1] ?? ''), $tmp)) {
 				$oy = $this->getHTMLUnitToUnits($tmp[1], 0, $this->svgunit, false);
 			}
 			$tmp = array();
-			if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
+			if (preg_match('/[\s]+width[\s]*=[\s]*"([^"]*)"/si', ($regs[1] ?? ''), $tmp)) {
 				$ow = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
 			}
 			$tmp = array();
-			if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
+			if (preg_match('/[\s]+height[\s]*=[\s]*"([^"]*)"/si', ($regs[1] ?? ''), $tmp)) {
 				$oh = $this->getHTMLUnitToUnits($tmp[1], 1, $this->svgunit, false);
 			}
 			$tmp = array();
 			$view_box = array();
-			if (preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', $regs[1], $tmp)) {
-				if (count($tmp) == 5) {
+			if (preg_match('/[\s]+viewBox[\s]*=[\s]*"[\s]*([0-9\.\-]+)[\s]+([0-9\.\-]+)[\s]+([0-9\.]+)[\s]+([0-9\.]+)[\s]*"/si', ($regs[1] ?? ''), $tmp)) {
+				if (count(($tmp ?? [])) == 5) {
 					array_shift($tmp);
 					foreach ($tmp as $key => $val) {
 						$view_box[$key] = $this->getHTMLUnitToUnits($val, 0, $this->svgunit, false);
@@ -22769,9 +22770,9 @@
 				}
 				// get aspect ratio
 				$tmp = array();
-				if (preg_match('/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', $regs[1], $tmp)) {
-					$aspect_ratio = preg_split('/[\s]+/si', $tmp[1]);
-					switch (count($aspect_ratio)) {
+				if (preg_match('/[\s]+preserveAspectRatio[\s]*=[\s]*"([^"]*)"/si', ($regs[1] ?? ''), $tmp)) {
+					$aspect_ratio = preg_split('/[\s]+/si', ($tmp[1] ?? ''));
+					switch (count(($aspect_ratio ?? []))) {
 						case 3: {
 							$aspect_ratio_align = $aspect_ratio[1];
 							$aspect_ratio_ms = $aspect_ratio[2];
@@ -22879,7 +22880,7 @@
 				}
 			}
 			// correct X alignment
-			switch (substr($aspect_ratio_align, 1, 3)) {
+			switch (substr(($aspect_ratio_align ?? ''), 1, 3)) {
 				case 'Min': {
 					// do nothing
 					break;
@@ -22895,7 +22896,7 @@
 				}
 			}
 			// correct Y alignment
-			switch (substr($aspect_ratio_align, 5)) {
+			switch (substr(($aspect_ratio_align ?? ''), 5)) {
 				case 'Min': {
 					// do nothing
 					break;
@@ -23063,7 +23064,7 @@
 		}
 		// clip-path
 		$regs = array();
-		if (preg_match('/url\([\s]*\#([^\)]*)\)/si', $svgstyle['clip-path'], $regs)) {
+		if (preg_match('/url\([\s]*\#([^\)]*)\)/si', ($svgstyle['clip-path'] ?? ''), $regs)) {
 			$clip_path = $this->svgclippaths[$regs[1]];
 			foreach ($clip_path as $cp) {
 				$this->startSVGElementHandler('clip-path', $cp['name'], $cp['attribs'], $cp['tm']);
@@ -23080,7 +23081,7 @@
 		$text_color = TCPDF_COLORS::convertHTMLColorToDec($svgstyle['text-color'], $this->spot_colors);
 		$this->SetTextColorArray($text_color);
 		// clip
-		if (preg_match('/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', $svgstyle['clip'], $regs)) {
+		if (preg_match('/rect\(([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)[\s]*([a-z0-9\-\.]*)\)/si', ($svgstyle['clip'] ?? ''), $regs)) {
 			$top = (isset($regs[1])?$this->getHTMLUnitToUnits($regs[1], 0, $this->svgunit, false):0);
 			$right = (isset($regs[2])?$this->getHTMLUnitToUnits($regs[2], 0, $this->svgunit, false):0);
 			$bottom = (isset($regs[3])?$this->getHTMLUnitToUnits($regs[3], 0, $this->svgunit, false):0);
@@ -23098,7 +23099,7 @@
 		}
 		// fill
 		$regs = array();
-		if (preg_match('/url\([\s]*\#([^\)]*)\)/si', $svgstyle['fill'], $regs)) {
+		if (preg_match('/url\([\s]*\#([^\)]*)\)/si', ($svgstyle['fill'] ?? ''), $regs)) {
 			// gradient
 			$gradient = $this->svggradients[$regs[1]];
 			if (isset($gradient['xref'])) {
@@ -23118,7 +23119,7 @@
 			//set clipping area
 			if (!empty($clip_function) AND method_exists($this, $clip_function)) {
 				$bbox = call_user_func_array(array($this, $clip_function), $clip_params);
-				if ((!isset($gradient['type']) OR ($gradient['type'] != 3)) AND is_array($bbox) AND (count($bbox) == 4)) {
+				if ((!isset($gradient['type']) OR ($gradient['type'] != 3)) AND is_array($bbox) AND (count(($bbox ?? [])) == 4)) {
 					list($x, $y, $w, $h) = $bbox;
 				}
 			}
@@ -23197,7 +23198,7 @@
 				$cy -= $h;
 			}
 			$this->_out(sprintf('%F 0 0 %F %F %F cm', ($w * $this->k), ($h * $this->k), ($x * $this->k), ($cy * $this->k)));
-			if (count($gradient['stops']) > 1) {
+			if (count(($gradient['stops'] ?? [])) > 1) {
 				$this->Gradient($gradient['type'], $gradient['coords'], $gradient['stops'], array(), false);
 			}
 		} elseif ($svgstyle['fill'] != 'none') {
@@ -23216,7 +23217,7 @@
 		if ($svgstyle['stroke'] != 'none') {
 			if ($svgstyle['stroke-opacity'] != 1) {
 				$this->setAlpha($svgstyle['stroke-opacity'], 'Normal', $this->alpha['ca'], false);
-			} elseif (preg_match('/rgba\(\d+%?,\s*\d+%?,\s*\d+%?,\s*(\d+(?:\.\d+)?)\)/i', $svgstyle['stroke'], $rgba_matches)) {
+			} elseif (preg_match('/rgba\(\d+%?,\s*\d+%?,\s*\d+%?,\s*(\d+(?:\.\d+)?)\)/i', ($svgstyle['stroke'] ?? ''), $rgba_matches)) {
 				$this->setAlpha($rgba_matches[1], 'Normal', $this->alpha['ca'], false);
 			}
 			$stroke_style = array(
@@ -23234,33 +23235,33 @@
 		// font
 		$regs = array();
 		if (!empty($svgstyle['font'])) {
-			if (preg_match('/font-family[\s]*:[\s]*([^\;\"]*)/si', $svgstyle['font'], $regs)) {
+			if (preg_match('/font-family[\s]*:[\s]*([^\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
 				$font_family = $this->getFontFamilyName($regs[1]);
 			} else {
 				$font_family = $svgstyle['font-family'];
 			}
-			if (preg_match('/font-size[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
-				$font_size = trim($regs[1]);
+			if (preg_match('/font-size[\s]*:[\s]*([^\s\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
+				$font_size = trim(($regs[1] ?? ''));
 			} else {
 				$font_size = $svgstyle['font-size'];
 			}
-			if (preg_match('/font-style[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
-				$font_style = trim($regs[1]);
+			if (preg_match('/font-style[\s]*:[\s]*([^\s\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
+				$font_style = trim(($regs[1] ?? ''));
 			} else {
 				$font_style = $svgstyle['font-style'];
 			}
-			if (preg_match('/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
-				$font_weight = trim($regs[1]);
+			if (preg_match('/font-weight[\s]*:[\s]*([^\s\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
+				$font_weight = trim(($regs[1] ?? ''));
 			} else {
 				$font_weight = $svgstyle['font-weight'];
 			}
-			if (preg_match('/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
-				$font_stretch = trim($regs[1]);
+			if (preg_match('/font-stretch[\s]*:[\s]*([^\s\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
+				$font_stretch = trim(($regs[1] ?? ''));
 			} else {
 				$font_stretch = $svgstyle['font-stretch'];
 			}
-			if (preg_match('/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', $svgstyle['font'], $regs)) {
-				$font_spacing = trim($regs[1]);
+			if (preg_match('/letter-spacing[\s]*:[\s]*([^\s\;\"]*)/si', ($svgstyle['font'] ?? ''), $regs)) {
+				$font_spacing = trim(($regs[1] ?? ''));
 			} else {
 				$font_spacing = $svgstyle['letter-spacing'];
 			}
@@ -23297,10 +23298,10 @@
 				break;
 			}
 			case 'normal': {
-				if ((substr($font_family, -1) == 'I') AND (substr($font_family, -2, 1) == 'B')) {
-					$font_family = substr($font_family, 0, -2).'I';
-				} elseif (substr($font_family, -1) == 'B') {
-					$font_family = substr($font_family, 0, -1);
+				if ((substr(($font_family ?? ''), -1) == 'I') AND (substr(($font_family ?? ''), -2, 1) == 'B')) {
+					$font_family = substr(($font_family ?? ''), 0, -2).'I';
+				} elseif (substr(($font_family ?? ''), -1) == 'B') {
+					$font_family = substr(($font_family ?? ''), 0, -1);
 				}
 				break;
 			}
@@ -23357,8 +23358,8 @@
 			return;
 		}
 		$paths = array();
-		$d = preg_replace('/([0-9ACHLMQSTVZ])([\-\+])/si', '\\1 \\2', $d);
-		preg_match_all('/([ACHLMQSTVZ])[\s]*([^ACHLMQSTVZ\"]*)/si', $d, $paths, PREG_SET_ORDER);
+		$d = preg_replace('/([0-9ACHLMQSTVZ])([\-\+])/si', '\\1 \\2', ($d ?? ''));
+		preg_match_all('/([ACHLMQSTVZ])[\s]*([^ACHLMQSTVZ\"]*)/si', ($d ?? ''), $paths, PREG_SET_ORDER);
 		$x = 0;
 		$y = 0;
 		$x1 = 0;
@@ -23375,8 +23376,8 @@
 		// draw curve pieces
 		foreach ($paths as $key => $val) {
 			// get curve type
-			$cmd = trim($val[1]);
-			if (strtolower($cmd) == $cmd) {
+			$cmd = trim(($val[1] ?? ''));
+			if (strtolower(($cmd ?? '')) == $cmd) {
 				// use relative coordinated instead of absolute
 				$relcoord = true;
 				$xoffset = $x;
@@ -23389,7 +23390,7 @@
 			$params = array();
 			if (isset($val[2])) {
 				// get curve parameters
-				$rawparams = preg_split('/([\,\s]+)/si', trim($val[2]));
+				$rawparams = preg_split('/([\,\s]+)/si', (trim(($val[2] ?? '')) ?? ''));
 				$params = array();
 				foreach ($rawparams as $ck => $cp) {
 					$params[$ck] = $this->getHTMLUnitToUnits($cp, 0, $this->svgunit, false);
@@ -23402,7 +23403,7 @@
 			// store current origin point
 			$x0 = $x;
 			$y0 = $y;
-			switch (strtoupper($cmd)) {
+			switch (strtoupper(($cmd ?? ''))) {
 				case 'M': { // moveto
 					foreach ($params as $ck => $cp) {
 						if (($ck % 2) == 0) {
@@ -23513,7 +23514,7 @@
 					foreach ($params as $ck => $cp) {
 						$params[$ck] = $cp;
 						if ((($ck + 1) % 4) == 0) {
-							if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) == 'C') OR (strtoupper($paths[($key - 1)][1]) == 'S'))) {
+							if (($key > 0) AND ((strtoupper(($paths[($key - 1)][1] ?? '')) == 'C') OR (strtoupper(($paths[($key - 1)][1] ?? '')) == 'S'))) {
 								$x1 = (2 * $x) - $x2;
 								$y1 = (2 * $y) - $y2;
 							} else {
@@ -23567,7 +23568,7 @@
 					foreach ($params as $ck => $cp) {
 						$params[$ck] = $cp;
 						if (($ck % 2) != 0) {
-							if (($key > 0) AND ((strtoupper($paths[($key - 1)][1]) == 'Q') OR (strtoupper($paths[($key - 1)][1]) == 'T'))) {
+							if (($key > 0) AND ((strtoupper(($paths[($key - 1)][1] ?? '')) == 'Q') OR (strtoupper(($paths[($key - 1)][1] ?? '')) == 'T'))) {
 								$x1 = (2 * $x) - $x1;
 								$y1 = (2 * $y) - $y1;
 							} else {
@@ -23669,7 +23670,7 @@
 									$angf += 360;
 								}
 								$pie = false;
-								if (($key == 0) AND (isset($paths[($key + 1)][1])) AND (trim($paths[($key + 1)][1]) == 'z')) {
+								if (($key == 0) AND (isset($paths[($key + 1)][1])) AND (trim(($paths[($key + 1)][1] ?? '')) == 'z')) {
 									$pie = true;
 								}
 								list($axmin, $aymin, $axmax, $aymax) = $this->_outellipticalarc($cx, $cy, $rx, $ry, $ang, $angs, $angf, $pie, 2, false, ($fs == 0), true);
@@ -23705,8 +23706,8 @@
 	 * @protected
 	 */
 	protected function removeTagNamespace($name) {
-		if(strpos($name, ':') !== false) {
-			$parts = explode(':', $name);
+		if(strpos(($name ?? ''), ':') !== false) {
+			$parts = explode(':', ($name ?? ''));
 			return $parts[(sizeof($parts) - 1)];
 		}
 		return $name;
@@ -23738,7 +23739,7 @@
 			if (end($this->svgdefs) !== FALSE) {
 				$last_svgdefs_id = key($this->svgdefs);
 				if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) {
-					$attribs['id'] = 'DF_'.(count($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements']) + 1);
+					$attribs['id'] = 'DF_'.(count(($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'] ?? [])) + 1);
 					$this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
 					return;
 				}
@@ -23751,9 +23752,9 @@
 			$clipping = true;
 		}
 		// get styling properties
-		$prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))]; // previous style
+		$prev_svgstyle = $this->svgstyles[max(0,(count(($this->svgstyles ?? [])) - 1))]; // previous style
 		$svgstyle = $this->svgstyles[0]; // set default style
-		if ($clipping AND !isset($attribs['fill']) AND (!isset($attribs['style']) OR (!preg_match('/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval)))) {
+		if ($clipping AND !isset($attribs['fill']) AND (!isset($attribs['style']) OR (!preg_match('/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', ($attribs['style'] ?? ''), $attrval)))) {
 			// default fill attribute for clipping
 			$attribs['fill'] = 'none';
 		}
@@ -23776,7 +23777,7 @@
 			} elseif (isset($attribs['style']) AND !TCPDF_STATIC::empty_string($attribs['style'])) {
 				// CSS style syntax
 				$attrval = array();
-				if (preg_match('/[;\"\s]{1}'.$key.'[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval) AND isset($attrval[1])) {
+				if (preg_match('/[;\"\s]{1}'.$key.'[\s]*:[\s]*([^;\"]*)/si', ($attribs['style'] ?? ''), $attrval) AND isset($attrval[1])) {
 					if ($attrval[1] == 'inherit') {
 						$svgstyle[$key] = $val;
 					} else {
@@ -23813,7 +23814,7 @@
 				}
 				$this->svgclipmode = true;
 				if (!isset($attribs['id'])) {
-					$attribs['id'] = 'CP_'.(count($this->svgcliptm) + 1);
+					$attribs['id'] = 'CP_'.(count(($this->svgcliptm ?? [])) + 1);
 				}
 				$this->svgclipid = $attribs['id'];
 				$this->svgclippaths[$this->svgclipid] = array();
@@ -23845,7 +23846,7 @@
 				// parse viewbox, calculate extra transformation matrix
 				if (isset($attribs['viewBox'])) {
 					$tmp = array();
-					preg_match_all("/[0-9]+/", $attribs['viewBox'], $tmp);
+					preg_match_all("/[0-9]+/", ($attribs['viewBox'] ?? ''), $tmp);
 					$tmp = $tmp[0];
 					if (sizeof($tmp) == 4) {
 						$vx = $tmp[0];
@@ -23861,11 +23862,11 @@
 							if($attribs['preserveAspectRatio'] == 'none') {
 								$fit = 'none';
 							} else {
-								preg_match_all('/[a-zA-Z]+/', $attribs['preserveAspectRatio'], $tmp);
+								preg_match_all('/[a-zA-Z]+/', ($attribs['preserveAspectRatio'] ?? ''), $tmp);
 								$tmp = $tmp[0];
-								if ((sizeof($tmp) == 2) AND (strlen($tmp[0]) == 8) AND (in_array($tmp[1], array('meet', 'slice', 'none')))) {
-									$aspectX = substr($tmp[0], 0, 4);
-									$aspectY = substr($tmp[0], 4, 4);
+								if ((sizeof($tmp) == 2) AND (strlen(($tmp[0] ?? '')) == 8) AND (in_array($tmp[1], array('meet', 'slice', 'none')))) {
+									$aspectX = substr(($tmp[0] ?? ''), 0, 4);
+									$aspectY = substr(($tmp[0] ?? ''), 4, 4);
 									$fit = $tmp[1];
 								}
 							}
@@ -23916,7 +23917,7 @@
 					break;
 				}
 				if (!isset($attribs['id'])) {
-					$attribs['id'] = 'GR_'.(count($this->svggradients) + 1);
+					$attribs['id'] = 'GR_'.(count(($this->svggradients ?? [])) + 1);
 				}
 				$this->svggradientid = $attribs['id'];
 				$this->svggradients[$this->svggradientid] = array();
@@ -23929,10 +23930,10 @@
 				}
 				//$attribs['spreadMethod']
 				if (((!isset($attribs['x1'])) AND (!isset($attribs['y1'])) AND (!isset($attribs['x2'])) AND (!isset($attribs['y2'])))
-					OR ((isset($attribs['x1']) AND (substr($attribs['x1'], -1) == '%'))
-						OR (isset($attribs['y1']) AND (substr($attribs['y1'], -1) == '%'))
-						OR (isset($attribs['x2']) AND (substr($attribs['x2'], -1) == '%'))
-						OR (isset($attribs['y2']) AND (substr($attribs['y2'], -1) == '%')))) {
+					OR ((isset($attribs['x1']) AND (substr(($attribs['x1'] ?? ''), -1) == '%'))
+						OR (isset($attribs['y1']) AND (substr(($attribs['y1'] ?? ''), -1) == '%'))
+						OR (isset($attribs['x2']) AND (substr(($attribs['x2'] ?? ''), -1) == '%'))
+						OR (isset($attribs['y2']) AND (substr(($attribs['y2'] ?? ''), -1) == '%')))) {
 					$this->svggradients[$this->svggradientid]['mode'] = 'percentage';
 				} else {
 					$this->svggradients[$this->svggradientid]['mode'] = 'measure';
@@ -23947,7 +23948,7 @@
 				$this->svggradients[$this->svggradientid]['coords'] = array($x1, $y1, $x2, $y2);
 				if (isset($attribs['xlink:href']) AND !empty($attribs['xlink:href'])) {
 					// gradient is defined on another place
-					$this->svggradients[$this->svggradientid]['xref'] = substr($attribs['xlink:href'], 1);
+					$this->svggradients[$this->svggradientid]['xref'] = substr(($attribs['xlink:href'] ?? ''), 1);
 				}
 				break;
 			}
@@ -23956,7 +23957,7 @@
 					break;
 				}
 				if (!isset($attribs['id'])) {
-					$attribs['id'] = 'GR_'.(count($this->svggradients) + 1);
+					$attribs['id'] = 'GR_'.(count(($this->svggradients ?? [])) + 1);
 				}
 				$this->svggradientid = $attribs['id'];
 				$this->svggradients[$this->svggradientid] = array();
@@ -23969,8 +23970,8 @@
 				}
 				//$attribs['spreadMethod']
 				if (((!isset($attribs['cx'])) AND (!isset($attribs['cy'])))
-					OR ((isset($attribs['cx']) AND (substr($attribs['cx'], -1) == '%'))
-					OR (isset($attribs['cy']) AND (substr($attribs['cy'], -1) == '%')))) {
+					OR ((isset($attribs['cx']) AND (substr(($attribs['cx'] ?? ''), -1) == '%'))
+					OR (isset($attribs['cy']) AND (substr(($attribs['cy'] ?? ''), -1) == '%')))) {
 					$this->svggradients[$this->svggradientid]['mode'] = 'percentage';
 				} elseif (isset($attribs['r']) AND is_numeric($attribs['r']) AND ($attribs['r']) <= 1) {
 					$this->svggradients[$this->svggradientid]['mode'] = 'ratio';
@@ -23988,14 +23989,14 @@
 				$this->svggradients[$this->svggradientid]['coords'] = array($cx, $cy, $fx, $fy, $r);
 				if (isset($attribs['xlink:href']) AND !empty($attribs['xlink:href'])) {
 					// gradient is defined on another place
-					$this->svggradients[$this->svggradientid]['xref'] = substr($attribs['xlink:href'], 1);
+					$this->svggradients[$this->svggradientid]['xref'] = substr(($attribs['xlink:href'] ?? ''), 1);
 				}
 				break;
 			}
 			case 'stop': {
 				// gradient stops
-				if (substr($attribs['offset'], -1) == '%') {
-					$offset = floatval(substr($attribs['offset'], -1)) / 100;
+				if (substr(($attribs['offset'] ?? ''), -1) == '%') {
+					$offset = floatval(substr(($attribs['offset'] ?? ''), -1)) / 100;
 				} else {
 					$offset = floatval($attribs['offset']);
 					if ($offset > 1) {
@@ -24013,7 +24014,7 @@
 					break;
 				}
 				if (isset($attribs['d'])) {
-					$d = trim($attribs['d']);
+					$d = trim(($attribs['d'] ?? ''));
 					if (!empty($d)) {
 						$x = (isset($attribs['x'])?$attribs['x']:0);
 						$y = (isset($attribs['y'])?$attribs['y']:0);
@@ -24139,10 +24140,10 @@
 					break;
 				}
 				$points = (isset($attribs['points'])?$attribs['points']:'0 0');
-				$points = trim($points);
+				$points = trim(($points ?? ''));
 				// note that point may use a complex syntax not covered here
-				$points = preg_split('/[\,\s]+/si', $points);
-				if (count($points) < 4) {
+				$points = preg_split('/[\,\s]+/si', ($points ?? ''));
+				if (count(($points ?? [])) < 4) {
 					break;
 				}
 				$p = array();
@@ -24207,9 +24208,9 @@
 					$this->StartTransform();
 					$this->SVGTransform($tm);
 					$obstyle = $this->setSVGStyles($svgstyle, $prev_svgstyle, $x, $y, $w, $h);
-					if (preg_match('/^data:image\/[^;]+;base64,/', $img, $m) > 0) {
+					if (preg_match('/^data:image\/[^;]+;base64,/', ($img ?? ''), $m) > 0) {
 						// embedded image encoded as base64
-						$img = '@'.base64_decode(substr($img, strlen($m[0])));
+						$img = '@'.base64_decode((substr(($img ?? ''), strlen(($m[0] ?? ''))) ?? ''));
 					} else {
 						// fix image path
 						if (!TCPDF_STATIC::empty_string($this->svgdir) AND (($img[0] == '.') OR (basename($img) == $img))) {
@@ -24217,23 +24218,23 @@
 							$img = $this->svgdir.'/'.$img;
 						}
 						if (($img[0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
-							$findroot = strpos($img, $_SERVER['DOCUMENT_ROOT']);
+							$findroot = strpos(($img ?? ''), ($_SERVER['DOCUMENT_ROOT'] ?? ''));
 							if (($findroot === false) OR ($findroot > 1)) {
-								if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
-									$img = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$img;
+								if (substr(($_SERVER['DOCUMENT_ROOT'] ?? ''), -1) == '/') {
+									$img = substr(($_SERVER['DOCUMENT_ROOT'] ?? ''), 0, -1).$img;
 								} else {
 									$img = $_SERVER['DOCUMENT_ROOT'].$img;
 								}
 							}
 						}
-						$img = urldecode($img);
+						$img = urldecode(($img ?? ''));
 						$testscrtype = @parse_url($img);
 						if (empty($testscrtype['query'])) {
 							// convert URL to server path
-							$img = str_replace(K_PATH_URL, K_PATH_MAIN, $img);
-						} elseif (preg_match('|^https?://|', $img) !== 1) {
+							$img = str_replace((K_PATH_URL ?? ''), (K_PATH_MAIN ?? ''), ($img ?? ''));
+						} elseif (preg_match('|^https?://|', ($img ?? '')) !== 1) {
 							// convert server path to URL
-							$img = str_replace(K_PATH_MAIN, K_PATH_URL, $img);
+							$img = str_replace((K_PATH_MAIN ?? ''), (K_PATH_URL ?? ''), ($img ?? ''));
 						}
 					}
 					// get image type
@@ -24334,7 +24335,7 @@
 			// use
 			case 'use': {
 				if (isset($attribs['xlink:href']) AND !empty($attribs['xlink:href'])) {
-					$svgdefid = substr($attribs['xlink:href'], 1);
+					$svgdefid = substr(($attribs['xlink:href'] ?? ''), 1);
 					if (isset($this->svgdefs[$svgdefid])) {
 						$use = $this->svgdefs[$svgdefid];
 						if (isset($attribs['xlink:href'])) {
--- a/intranet/tcpdf/tcpdf_import.php
+++ b/intranet/tcpdf/tcpdf_import.php
@@ -67,7 +67,7 @@
 	 */
 	public function importPDF($filename) {
 		// load document
-		$rawdata = file_get_contents($filename);
+		$rawdata = file_get_contents(($filename ?? ''));
 		if ($rawdata === false) {
 			$this->Error('Unable to get the content of the file: '.$filename);
 		}
--- a/intranet/tcpdf/tcpdf_barcodes_1d.php
+++ b/intranet/tcpdf/tcpdf_barcodes_1d.php
@@ -98,7 +98,7 @@
 		header('Pragma: public');
 		header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
 		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
-		header('Content-Disposition: inline; filename="'.md5($code).'.svg";');
+		header('Content-Disposition: inline; filename="'.md5(($code ?? '')).'.svg";');
 		//header('Content-Length: '.strlen($code));
 		echo $code;
 	}
@@ -117,7 +117,7 @@
 		$svg = '<'.'?'.'xml version="1.0" standalone="no"'.'?'.'>'."\n";
 		$svg .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n";
 		$svg .= '<svg width="'.round(($this->barcode_array['maxw'] * $w), 3).'" height="'.$h.'" version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n";
-		$svg .= "\t".'<desc>'.strtr($this->barcode_array['code'], $repstr).'</desc>'."\n";
+		$svg .= "\t".'<desc>'.strtr(($this->barcode_array['code'] ?? ''), ($repstr ?? '')).'</desc>'."\n";
 		$svg .= "\t".'<g id="bars" fill="'.$color.'" stroke="none">'."\n";
 		// print bars
 		$x = 0;
@@ -196,10 +196,10 @@
 		if (function_exists('imagecreate')) {
 			// GD library
 			$imagick = false;
-			$png = imagecreate($width, $height);
+			$png = imagecreate((int) ($width), (int) ($height));
 			$bgcol = imagecolorallocate($png, 255, 255, 255);
 			imagecolortransparent($png, $bgcol);
-			$fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
+			$fgcol = imagecolorallocate($png, (int) ($color[0]), (int) ($color[1]), (int) ($color[2]));
 		} elseif (extension_loaded('imagick')) {
 			$imagick = true;
 			$bgcol = new imagickpixel('rgb(255,255,255');
@@ -222,7 +222,7 @@
 				if ($imagick) {
 					$bar->rectangle($x, $y, ($x + $bw - 1), ($y + $bh - 1));
 				} else {
-					imagefilledrectangle($png, $x, $y, ($x + $bw - 1), ($y + $bh - 1), $fgcol);
+					imagefilledrectangle($png, (int) ($x), (int) ($y), ((int) ($x + $bw - 1)), ((int) ($y + $bh - 1)), (int) ($fgcol));
 				}
 			}
 			$x += $bw;
@@ -247,7 +247,7 @@
  	 * @public
 	 */
 	public function setBarcode($code, $type) {
-		switch (strtoupper($type)) {
+		switch (strtoupper(($type ?? ''))) {
 			case 'C39': { // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
 				$arrcode = $this->barcode_code39($code, false, false);
 				break;
@@ -435,7 +435,7 @@
 		$chr['+'] = '131113131';
 		$chr['%'] = '111313131';
 		$chr['*'] = '131131311';
-		$code = strtoupper($code);
+		$code = strtoupper(($code ?? ''));
 		if ($extended) {
 			// extended mode
 			$code = $this->encode_code39_ext($code);
@@ -451,9 +451,9 @@
 		$code = '*'.$code.'*';
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
-			$char = $code{$i};
+			$char = $code[$i];
 			if(!isset($chr[$char])) {
 				// invalid character
 				return false;
@@ -464,7 +464,7 @@
 				} else {
 					$t = false; // space
 				}
-				$w = $chr[$char]{$j};
+				$w = $chr[$char][$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -518,12 +518,12 @@
 			chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P',
 			chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
 		$code_ext = '';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
-			if (ord($code{$i}) > 127) {
+			if (ord(($code[$i] ?? '')) > 127) {
 				return false;
 			}
-			$code_ext .= $encode[$code{$i}];
+			$code_ext .= $encode[$code[$i]];
 		}
 		return $code_ext;
 	}
@@ -541,9 +541,9 @@
 			'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
 		$sum = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
-			$k = array_keys($chars, $code{$i});
+			$k = array_keys($chars, $code[$i]);
 			$sum += $k[0];
 		}
 		$j = ($sum % 43);
@@ -606,7 +606,7 @@
 		$chr[130] = '122211'; // (+)
 		$chr[131] = '312111'; // (%)
 		$chr[42] = '111141'; // start-stop
-		$code = strtoupper($code);
+		$code = strtoupper(($code ?? ''));
 		$encode = array(
 			chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
 			chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
@@ -641,12 +641,12 @@
 			chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
 			chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
 		$code_ext = '';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
-			if (ord($code{$i}) > 127) {
+			if (ord(($code[$i] ?? '')) > 127) {
 				return false;
 			}
-			$code_ext .= $encode[$code{$i}];
+			$code_ext .= $encode[$code[$i]];
 		}
 		// checksum
 		$code_ext .= $this->checksum_code93($code_ext);
@@ -654,9 +654,9 @@
 		$code = '*'.$code_ext.'*';
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
-			$char = ord($code{$i});
+			$char = ord(($code[$i] ?? ''));
 			if(!isset($chr[$char])) {
 				// invalid character
 				return false;
@@ -667,7 +667,7 @@
 				} else {
 					$t = false; // space
 				}
-				$w = $chr[$char]{$j};
+				$w = $chr[$char][$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -693,13 +693,13 @@
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%',
 			'<', '=', '>', '?');
 		// translate special characters
-		$code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?');
-		$len = strlen($code);
+		$code = strtr(($code ?? ''), chr(128).chr(131).chr(129).chr(130), '<=>?');
+		$len = strlen(($code ?? ''));
 		// calculate check digit C
 		$p = 1;
 		$check = 0;
 		for ($i = ($len - 1); $i >= 0; --$i) {
-			$k = array_keys($chars, $code{$i});
+			$k = array_keys($chars, $code[$i]);
 			$check += ($k[0] * $p);
 			++$p;
 			if ($p > 20) {
@@ -713,7 +713,7 @@
 		$p = 1;
 		$check = 0;
 		for ($i = $len; $i >= 0; --$i) {
-			$k = array_keys($chars, $code{$i});
+			$k = array_keys($chars, $code[$i]);
 			$check += ($k[0] * $p);
 			++$p;
 			if ($p > 15) {
@@ -724,7 +724,7 @@
 		$k = $chars[$check];
 		$checksum = $c.$k;
 		// resto respecial characters
-		$checksum = strtr($checksum, '<=>?', chr(128).chr(131).chr(129).chr(130));
+		$checksum = strtr(($checksum ?? ''), '<=>?', chr(128).chr(131).chr(129).chr(130));
 		return $checksum;
 	}
 
@@ -735,14 +735,14 @@
 	 * @protected
 	 */
 	protected function checksum_s25($code) {
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		$sum = 0;
 		for ($i = 0; $i < $len; $i+=2) {
-			$sum += $code{$i};
+			$sum += $code[$i];
 		}
 		$sum *= 3;
 		for ($i = 1; $i < $len; $i+=2) {
-			$sum += ($code{$i});
+			$sum += ($code[$i]);
 		}
 		$r = $sum % 10;
 		if($r > 0) {
@@ -779,11 +779,11 @@
 		$chr['F'] = '110110110110';
 		if ($checksum) {
 			// add checksum
-			$clen = strlen($code);
+			$clen = strlen(($code ?? ''));
 			$p = 2;
 			$check = 0;
 			for ($i = ($clen - 1); $i >= 0; --$i) {
-				$check += (hexdec($code{$i}) * $p);
+				$check += (hexdec($code[$i]) * $p);
 				++$p;
 				if ($p > 7) {
 					$p = 2;
@@ -796,9 +796,9 @@
 			$code .= $check;
 		}
 		$seq = '110'; // left guard
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
-			$digit = $code{$i};
+			$digit = $code[$i];
 			if (!isset($chr[$digit])) {
 				// invalid character
 				return false;
@@ -834,14 +834,14 @@
 			// add checksum
 			$code .= $this->checksum_s25($code);
 		}
-		if((strlen($code) % 2) != 0) {
+		if((strlen(($code ?? '')) % 2) != 0) {
 			// add leading zero if code-length is odd
 			$code = '0'.$code;
 		}
 		$seq = '11011010';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
-			$digit = $code{$i};
+			$digit = $code[$i];
 			if (!isset($chr[$digit])) {
 				// invalid character
 				return false;
@@ -862,13 +862,13 @@
 	 * @protected
 	 */
 	protected function binseq_to_array($seq, $bararray) {
-		$len = strlen($seq);
+		$len = strlen(($seq ?? ''));
 		$w = 0;
 		$k = 0;
 		for ($i = 0; $i < $len; ++$i) {
 			$w += 1;
-			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
-				if ($seq{$i} == '1') {
+			if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq[$i] != $seq[($i+1)]))) {
+				if ($seq[$i] == '1') {
 					$t = true; // bar
 				} else {
 					$t = false; // space
@@ -908,37 +908,37 @@
 			// add checksum
 			$code .= $this->checksum_s25($code);
 		}
-		if((strlen($code) % 2) != 0) {
+		if((strlen(($code ?? '')) % 2) != 0) {
 			// add leading zero if code-length is odd
 			$code = '0'.$code;
 		}
 		// add start and stop codes
-		$code = 'AA'.strtolower($code).'ZA';
+		$code = 'AA'.strtolower(($code ?? '')).'ZA';
 
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; $i = ($i + 2)) {
-			$char_bar = $code{$i};
-			$char_space = $code{$i+1};
+			$char_bar = $code[$i];
+			$char_space = $code[$i+1];
 			if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
 				// invalid character
 				return false;
 			}
 			// create a bar-space sequence
 			$seq = '';
-			$chrlen = strlen($chr[$char_bar]);
+			$chrlen = strlen(($chr[$char_bar] ?? ''));
 			for ($s = 0; $s < $chrlen; $s++){
-				$seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
-			}
-			$seqlen = strlen($seq);
+				$seq .= $chr[$char_bar][$s] . $chr[$char_space][$s];
+			}
+			$seqlen = strlen(($seq ?? ''));
 			for ($j = 0; $j < $seqlen; ++$j) {
 				if (($j % 2) == 0) {
 					$t = true; // bar
 				} else {
 					$t = false; // space
 				}
-				$w = $seq{$j};
+				$w = $seq[$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -1080,17 +1080,17 @@
 		// array of symbols
 		$code_data = array();
 		// length of the code
-		$len = strlen($code);
-		switch(strtoupper($type)) {
+		$len = strlen(($code ?? ''));
+		switch(strtoupper(($type ?? ''))) {
 			case 'A': { // MODE A
 				$startid = 103;
 				for ($i = 0; $i < $len; ++$i) {
-					$char = $code{$i};
-					$char_id = ord($char);
+					$char = $code[$i];
+					$char_id = ord(($char ?? ''));
 					if (($char_id >= 241) AND ($char_id <= 244)) {
 						$code_data[] = $fnc_a[$char_id];
 					} elseif (($char_id >= 0) AND ($char_id <= 95)) {
-						$code_data[] = strpos($keys_a, $char);
+						$code_data[] = strpos(($keys_a ?? ''), ($char ?? ''));
 					} else {
 						return false;
 					}
@@ -1100,12 +1100,12 @@
 			case 'B': { // MODE B
 				$startid = 104;
 				for ($i = 0; $i < $len; ++$i) {
-					$char = $code{$i};
-					$char_id = ord($char);
+					$char = $code[$i];
+					$char_id = ord(($char ?? ''));
 					if (($char_id >= 241) AND ($char_id <= 244)) {
 						$code_data[] = $fnc_b[$char_id];
 					} elseif (($char_id >= 32) AND ($char_id <= 127)) {
-						$code_data[] = strpos($keys_b, $char);
+						$code_data[] = strpos(($keys_b ?? ''), ($char ?? ''));
 					} else {
 						return false;
 					}
@@ -1114,9 +1114,9 @@
 			}
 			case 'C': { // MODE C
 				$startid = 105;
-				if (ord($code[0]) == 241) {
+				if (ord(($code[0] ?? '')) == 241) {
 					$code_data[] = 102;
-					$code = substr($code, 1);
+					$code = substr(($code ?? ''), 1);
 					--$len;
 				}
 				if (($len % 2) != 0) {
@@ -1124,8 +1124,8 @@
 					return false;
 				}
 				for ($i = 0; $i < $len; $i+=2) {
-					$chrnum = $code{$i}.$code{$i+1};
-					if (preg_match('/([0-9]{2})/', $chrnum) > 0) {
+					$chrnum = $code[$i].$code[$i+1];
+					if (preg_match('/([0-9]{2})/', ($chrnum ?? '')) > 0) {
 						$code_data[] = intval($chrnum);
 					} else {
 						return false;
@@ -1138,26 +1138,26 @@
 				$sequence = array();
 				// get numeric sequences (if any)
 				$numseq = array();
-				preg_match_all('/([0-9]{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
+				preg_match_all('/([0-9]{4,})/', ($code ?? ''), $numseq, PREG_OFFSET_CAPTURE);
 				if (isset($numseq[1]) AND !empty($numseq[1])) {
 					$end_offset = 0;
 					foreach ($numseq[1] as $val) {
 						$offset = $val[1];
 						if ($offset > $end_offset) {
 							// non numeric sequence
-							$sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset, ($offset - $end_offset))));
+							$sequence = array_merge($sequence, $this->get128ABsequence(substr(($code ?? ''), $end_offset, ($offset - $end_offset))));
 						}
 						// numeric sequence
-						$slen = strlen($val[0]);
+						$slen = strlen(($val[0] ?? ''));
 						if (($slen % 2) != 0) {
 							// the length must be even
 							--$slen;
 						}
-						$sequence[] = array('C', substr($code, $offset, $slen), $slen);
+						$sequence[] = array('C', substr(($code ?? ''), $offset, $slen), $slen);
 						$end_offset = $offset + $slen;
 					}
 					if ($end_offset < $len) {
-						$sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset)));
+						$sequence = array_merge($sequence, $this->get128ABsequence(substr(($code ?? ''), $end_offset)));
 					}
 				} else {
 					// text code (non C mode)
@@ -1180,19 +1180,19 @@
 								}
 							}
 							for ($i = 0; $i < $seq[2]; ++$i) {
-								$char = $seq[1]{$i};
-								$char_id = ord($char);
+								$char = $seq[1][$i];
+								$char_id = ord(($char ?? ''));
 								if (($char_id >= 241) AND ($char_id <= 244)) {
 									$code_data[] = $fnc_a[$char_id];
 								} else {
-									$code_data[] = strpos($keys_a, $char);
+									$code_data[] = strpos(($keys_a ?? ''), ($char ?? ''));
 								}
 							}
 							break;
 						}
 						case 'B': {
 							if ($key == 0) {
-								$tmpchr = ord($seq[1][0]);
+								$tmpchr = ord(($seq[1][0] ?? ''));
 								if (($seq[2] == 1) AND ($tmpchr >= 241) AND ($tmpchr <= 244) AND isset($sequence[($key + 1)]) AND ($sequence[($key + 1)][0] != 'B')) {
 									switch ($sequence[($key + 1)][0]) {
 										case 'A': {
@@ -1223,12 +1223,12 @@
 								}
 							}
 							for ($i = 0; $i < $seq[2]; ++$i) {
-								$char = $seq[1]{$i};
-								$char_id = ord($char);
+								$char = $seq[1][$i];
+								$char_id = ord(($char ?? ''));
 								if (($char_id >= 241) AND ($char_id <= 244)) {
 									$code_data[] = $fnc_b[$char_id];
 								} else {
-									$code_data[] = strpos($keys_b, $char);
+									$code_data[] = strpos(($keys_b ?? ''), ($char ?? ''));
 								}
 							}
 							break;
@@ -1240,7 +1240,7 @@
 								$code_data[] = 99;
 							}
 							for ($i = 0; $i < $seq[2]; $i+=2) {
-								$chrnum = $seq[1]{$i}.$seq[1]{$i+1};
+								$chrnum = $seq[1][$i].$seq[1][$i+1];
 								$code_data[] = intval($chrnum);
 							}
 							break;
@@ -1271,7 +1271,7 @@
 				} else {
 					$t = false; // space
 				}
-				$w = $seq{$j};
+				$w = $seq[$j];
 				$bararray['bcode'][] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 			}
@@ -1286,26 +1286,26 @@
 	 * @protected
 	 */
 	protected function get128ABsequence($code) {
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		$sequence = array();
 		// get A sequences (if any)
 		$numseq = array();
-		preg_match_all('/([\0-\31])/', $code, $numseq, PREG_OFFSET_CAPTURE);
+		preg_match_all('/([\0-\31])/', ($code ?? ''), $numseq, PREG_OFFSET_CAPTURE);
 		if (isset($numseq[1]) AND !empty($numseq[1])) {
 			$end_offset = 0;
 			foreach ($numseq[1] as $val) {
 				$offset = $val[1];
 				if ($offset > $end_offset) {
 					// B sequence
-					$sequence[] = array('B', substr($code, $end_offset, ($offset - $end_offset)), ($offset - $end_offset));
+					$sequence[] = array('B', substr(($code ?? ''), $end_offset, ($offset - $end_offset)), ($offset - $end_offset));
 				}
 				// A sequence
-				$slen = strlen($val[0]);
-				$sequence[] = array('A', substr($code, $offset, $slen), $slen);
+				$slen = strlen(($val[0] ?? ''));
+				$sequence[] = array('A', substr(($code ?? ''), $offset, $slen), $slen);
 				$end_offset = $offset + $slen;
 			}
 			if ($end_offset < $len) {
-				$sequence[] = array('B', substr($code, $end_offset), ($len - $end_offset));
+				$sequence[] = array('B', substr(($code ?? ''), $end_offset), ($len - $end_offset));
 			}
 		} else {
 			// only B sequence
@@ -1332,19 +1332,19 @@
 		}
 		$data_len = $len - 1;
 		//Padding
-		$code = str_pad($code, $data_len, '0', STR_PAD_LEFT);
-		$code_len = strlen($code);
+		$code = str_pad(($code ?? ''), $data_len, '0', STR_PAD_LEFT);
+		$code_len = strlen(($code ?? ''));
 		// calculate check digit
 		$sum_a = 0;
 		for ($i = 1; $i < $data_len; $i+=2) {
-			$sum_a += $code{$i};
+			$sum_a += $code[$i];
 		}
 		if ($len > 12) {
 			$sum_a *= 3;
 		}
 		$sum_b = 0;
 		for ($i = 0; $i < $data_len; $i+=2) {
-			$sum_b += ($code{$i});
+			$sum_b += ($code[$i]);
 		}
 		if ($len < 13) {
 			$sum_b *= 3;
@@ -1356,7 +1356,7 @@
 		if ($code_len == $data_len) {
 			// add check digit
 			$code .= $r;
-		} elseif ($r !== intval($code{$data_len})) {
+		} elseif ($r !== intval($code[$data_len])) {
 			// wrong checkdigit
 			return false;
 		}
@@ -1367,23 +1367,23 @@
 		}
 		if ($upce) {
 			// convert UPC-A to UPC-E
-			$tmp = substr($code, 4, 3);
+			$tmp = substr(($code ?? ''), 4, 3);
 			if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
 				// manufacturer code ends in 000, 100, or 200
-				$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
+				$upce_code = substr(($code ?? ''), 2, 2).substr(($code ?? ''), 9, 3).substr(($code ?? ''), 4, 1);
 			} else {
-				$tmp = substr($code, 5, 2);
+				$tmp = substr(($code ?? ''), 5, 2);
 				if ($tmp == '00') {
 					// manufacturer code ends in 00
-					$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
+					$upce_code = substr(($code ?? ''), 2, 3).substr(($code ?? ''), 10, 2).'3';
 				} else {
-					$tmp = substr($code, 6, 1);
+					$tmp = substr(($code ?? ''), 6, 1);
 					if ($tmp == '0') {
 						// manufacturer code ends in 0
-						$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
+						$upce_code = substr(($code ?? ''), 2, 4).substr(($code ?? ''), 11, 1).'4';
 					} else {
 						// manufacturer code does not end in zero
-						$upce_code = substr($code, 2, 5).substr($code, 11, 1);
+						$upce_code = substr(($code ?? ''), 2, 5).substr(($code ?? ''), 11, 1);
 					}
 				}
 			}
@@ -1467,7 +1467,7 @@
 			$bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 			$p = $upce_parities[$code[1]][$r];
 			for ($i = 0; $i < 6; ++$i) {
-				$seq .= $codes[$p[$i]][$upce_code{$i}];
+				$seq .= $codes[$p[$i]][$upce_code[$i]];
 			}
 			$seq .= '010101'; // right guard bar
 		} else {
@@ -1475,26 +1475,26 @@
 			$half_len = intval(ceil($len / 2));
 			if ($len == 8) {
 				for ($i = 0; $i < $half_len; ++$i) {
-					$seq .= $codes['A'][$code{$i}];
+					$seq .= $codes['A'][$code[$i]];
 				}
 			} else {
 				$p = $parities[$code[0]];
 				for ($i = 1; $i < $half_len; ++$i) {
-					$seq .= $codes[$p[$i-1]][$code{$i}];
+					$seq .= $codes[$p[$i-1]][$code[$i]];
 				}
 			}
 			$seq .= '01010'; // center guard bar
 			for ($i = $half_len; $i < $len; ++$i) {
-				$seq .= $codes['C'][$code{$i}];
+				$seq .= $codes['C'][$code[$i]];
 			}
 			$seq .= '101'; // right guard bar
 		}
-		$clen = strlen($seq);
+		$clen = strlen(($seq ?? ''));
 		$w = 0;
 		for ($i = 0; $i < $clen; ++$i) {
 			$w += 1;
-			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
-				if ($seq{$i} == '1') {
+			if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq[$i] != $seq[($i+1)]))) {
+				if ($seq[$i] == '1') {
 					$t = true; // bar
 				} else {
 					$t = false; // space
@@ -1519,7 +1519,7 @@
 	 */
 	protected function barcode_eanext($code, $len=5) {
 		//Padding
-		$code = str_pad($code, $len, '0', STR_PAD_LEFT);
+		$code = str_pad(($code ?? ''), $len, '0', STR_PAD_LEFT);
 		// calculate check digit
 		if ($len == 2) {
 			$r = $code % 4;
@@ -1578,7 +1578,7 @@
 		$seq .= $codes[$p[0]][$code[0]];
 		for ($i = 1; $i < $len; ++$i) {
 			$seq .= '01'; // separator
-			$seq .= $codes[$p[$i]][$code{$i}];
+			$seq .= $codes[$p[$i]][$code[$i]];
 		}
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		return $this->binseq_to_array($seq, $bararray);
@@ -1623,27 +1623,27 @@
 		}
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
 		$k = 0;
-		$code = str_replace('-', '', $code);
-		$code = str_replace(' ', '', $code);
-		$len = strlen($code);
+		$code = str_replace('-', '', ($code ?? ''));
+		$code = str_replace(' ', '', ($code ?? ''));
+		$len = strlen(($code ?? ''));
 		// calculate checksum
 		$sum = 0;
 		for ($i = 0; $i < $len; ++$i) {
-			$sum += intval($code{$i});
+			$sum += intval($code[$i]);
 		}
 		$chkd = ($sum % 10);
 		if($chkd > 0) {
 			$chkd = (10 - $chkd);
 		}
 		$code .= $chkd;
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		// start bar
 		$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
 		$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
 		$bararray['maxw'] += 2;
 		for ($i = 0; $i < $len; ++$i) {
 			for ($j = 0; $j < 5; ++$j) {
-				$h = $barlen[$code{$i}][$j];
+				$h = $barlen[$code[$i]][$j];
 				$p = floor(1 / $h);
 				$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
 				$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
@@ -1710,8 +1710,8 @@
 			'Y' => array(2,1,4,3),
 			'Z' => array(2,2,3,3)
 		);
-		$code = strtoupper($code);
-		$len = strlen($code);
+		$code = strtoupper(($code ?? ''));
+		$len = strlen(($code ?? ''));
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
 		if ($notkix) {
 			// table for checksum calculation (row,col)
@@ -1756,8 +1756,8 @@
 			$row = 0;
 			$col = 0;
 			for ($i = 0; $i < $len; ++$i) {
-				$row += $checktable[$code{$i}][0];
-				$col += $checktable[$code{$i}][1];
+				$row += $checktable[$code[$i]][0];
+				$col += $checktable[$code[$i]][1];
 			}
 			$row %= 6;
 			$col %= 6;
@@ -1774,7 +1774,7 @@
 		}
 		for ($i = 0; $i < $len; ++$i) {
 			for ($j = 0; $j < 4; ++$j) {
-				switch ($barmode[$code{$i}][$j]) {
+				switch ($barmode[$code[$i]][$j]) {
 					case 1: {
 						$p = 0;
 						$h = 2;
@@ -1843,20 +1843,20 @@
 		$k = 0;
 		$w = 0;
 		$seq = '';
-		$code = 'A'.strtoupper($code).'A';
-		$len = strlen($code);
+		$code = 'A'.strtoupper(($code ?? '')).'A';
+		$len = strlen(($code ?? ''));
 		for ($i = 0; $i < $len; ++$i) {
-			if (!isset($chr[$code{$i}])) {
+			if (!isset($chr[$code[$i]])) {
 				return false;
 			}
-			$seq = $chr[$code{$i}];
+			$seq = $chr[$code[$i]];
 			for ($j = 0; $j < 8; ++$j) {
 				if (($j % 2) == 0) {
 					$t = true; // bar
 				} else {
 					$t = false; // space
 				}
-				$w = $seq{$j};
+				$w = $seq[$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -1891,12 +1891,12 @@
 		$k = 0;
 		$w = 0;
 		$seq = '';
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		// calculate check digit C
 		$p = 1;
 		$check = 0;
 		for ($i = ($len - 1); $i >= 0; --$i) {
-			$digit = $code{$i};
+			$digit = $code[$i];
 			if ($digit == '-') {
 				$dval = 10;
 			} else {
@@ -1918,7 +1918,7 @@
 			$p = 1;
 			$check = 0;
 			for ($i = $len; $i >= 0; --$i) {
-				$digit = $code{$i};
+				$digit = $code[$i];
 				if ($digit == '-') {
 					$dval = 10;
 				} else {
@@ -1937,17 +1937,17 @@
 		$code = 'S'.$code.'S';
 		$len += 3;
 		for ($i = 0; $i < $len; ++$i) {
-			if (!isset($chr[$code{$i}])) {
+			if (!isset($chr[$code[$i]])) {
 				return false;
 			}
-			$seq = $chr[$code{$i}];
+			$seq = $chr[$code[$i]];
 			for ($j = 0; $j < 6; ++$j) {
 				if (($j % 2) == 0) {
 					$t = true; // bar
 				} else {
 					$t = false; // space
 				}
-				$w = $seq{$j};
+				$w = $seq[$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -1976,7 +1976,7 @@
 			}
 			$code /= 2;
 		}
-		$seq = substr($seq, 0, -2);
+		$seq = substr(($seq ?? ''), 0, -2);
 		$seq = strrev($seq);
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		return $this->binseq_to_array($seq, $bararray);
@@ -2014,9 +2014,9 @@
 		$seq = strrev($seq);
 		$k = 0;
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
-		$len = strlen($seq);
+		$len = strlen(($seq ?? ''));
 		for ($i = 0; $i < $len; ++$i) {
-			switch ($seq{$i}) {
+			switch ($seq[$i]) {
 				case '1': {
 					$p = 1;
 					$h = 1;
@@ -2056,7 +2056,7 @@
 		$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
 		$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
 		$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
-		$code_arr = explode('-', $code);
+		$code_arr = explode('-', ($code ?? ''));
 		$tracking_number = $code_arr[0];
 		if (isset($code_arr[1])) {
 			$routing_code = $code_arr[1];
@@ -2064,7 +2064,7 @@
 			$routing_code = '';
 		}
 		// Conversion of Routing Code
-		switch (strlen($routing_code)) {
+		switch (strlen(($routing_code ?? ''))) {
 			case 0: {
 				$binary_code = 0;
 				break;
@@ -2090,20 +2090,20 @@
 		$binary_code = bcadd($binary_code, $tracking_number[0]);
 		$binary_code = bcmul($binary_code, 5);
 		$binary_code = bcadd($binary_code, $tracking_number[1]);
-		$binary_code .= substr($tracking_number, 2, 18);
+		$binary_code .= substr(($tracking_number ?? ''), 2, 18);
 		// convert to hexadecimal
 		$binary_code = $this->dec_to_hex($binary_code);
 		// pad to get 13 bytes
-		$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
+		$binary_code = str_pad(($binary_code ?? ''), 26, '0', STR_PAD_LEFT);
 		// convert string to array of bytes
 		$binary_code_arr = chunk_split($binary_code, 2, "\r");
-		$binary_code_arr = substr($binary_code_arr, 0, -1);
-		$binary_code_arr = explode("\r", $binary_code_arr);
+		$binary_code_arr = substr(($binary_code_arr ?? ''), 0, -1);
+		$binary_code_arr = explode("\r", ($binary_code_arr ?? ''));
 		// calculate frame check sequence
 		$fcs = $this->imb_crc11fcs($binary_code_arr);
 		// exclude first 2 bits from first byte
 		$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
-		$binary_code_102bit = $first_byte.substr($binary_code, 2);
+		$binary_code_102bit = $first_byte.substr(($binary_code ?? ''), 2);
 		// convert binary data to codewords
 		$codewords = array();
 		$data = $this->hex_to_dec($binary_code_102bit);
@@ -2177,10 +2177,10 @@
 	 * @protected
 	 */
 	protected function barcode_imb_pre($code) {
-		if (!preg_match('/^[fadtFADT]{65}$/', $code) == 1) {
+		if (!preg_match('/^[fadtFADT]{65}$/', ($code ?? '')) == 1) {
 			return false;
 		}
-		$characters = str_split(strtolower($code), 1);
+		$characters = str_split((strtolower(($code ?? '')) ?? ''), 1);
 		// build bars
 		$k = 0;
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
@@ -2236,7 +2236,7 @@
 			if($number == 0) {
 				array_push($hex, '0');
 			} else {
-				array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
+				array_push($hex, strtoupper((dechex(bcmod($number, '16')) ?? '')));
 				$number = bcdiv($number, '16', 0);
 			}
 		}
@@ -2253,9 +2253,9 @@
 	public function hex_to_dec($hex) {
 		$dec = 0;
 		$bitval = 1;
-		$len = strlen($hex);
+		$len = strlen(($hex ?? ''));
 		for($pos = ($len - 1); $pos >= 0; --$pos) {
-			$dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
+			$dec = bcadd($dec, bcmul(hexdec($hex[$pos]), $bitval));
 			$bitval = bcmul($bitval, 16);
 		}
 		return $dec;
--- a/intranet/tcpdf/tools/tcpdf_addfont.php
+++ b/intranet/tcpdf/tools/tcpdf_addfont.php
@@ -188,7 +188,7 @@
 		case 'o':
 		case 'outpath': {
 			$options['outpath'] = realpath($val);
-			if (substr($options['outpath'], -1) != '/') {
+			if (substr(($options['outpath'] ?? ''), -1) != '/') {
 				$options['outpath'] .= '/';
 			}
 			break;
@@ -215,7 +215,7 @@
 		}
 		case 'i':
 		case 'fonts': {
-			$options['fonts'] = explode(',', $val);
+			$options['fonts'] = explode(',', ($val ?? ''));
 			break;
 		}
 		case 'h':
--- a/intranet/tcpdf/include/tcpdf_static.php
+++ b/intranet/tcpdf/include/tcpdf_static.php
@@ -140,7 +140,7 @@
 			define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
 		}
 		if (PHP_VERSION_ID < 50300) {
-			@set_magic_quotes_runtime($mqr);
+			@false;
 		}
 	}
 
@@ -156,7 +156,7 @@
 			define('PHP_VERSION_ID', (($version[0] * 10000) + ($version[2] * 100) + $version[4]));
 		}
 		if (PHP_VERSION_ID < 50300) {
-			return @get_magic_quotes_runtime();
+			return @false;
 		}
 		return 0;
 	}
@@ -170,7 +170,7 @@
 	 */
 	public static function isValidURL($url) {
 		$headers = @get_headers($url);
-    	return (strpos($headers[0], '200') !== false);
+    	return (strpos(($headers[0] ?? ''), '200') !== false);
 	}
 
 	/**
@@ -191,9 +191,9 @@
 	 * @public static
 	 */
 	public static function removeSHY($txt='', $unicode=true) {
-		$txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', $txt);
+		$txt = preg_replace('/([\\xc2]{1}[\\xad]{1})/', '', ($txt ?? ''));
 		if (!$unicode) {
-			$txt = preg_replace('/([\\xad]{1})/', '', $txt);
+			$txt = preg_replace('/([\\xad]{1})/', '', ($txt ?? ''));
 		}
 		return $txt;
 	}
@@ -217,7 +217,7 @@
 		}
 		if (is_string($brd)) {
 			// convert string to array
-			$slen = strlen($brd);
+			$slen = strlen(($brd ?? ''));
 			$newbrd = array();
 			for ($i = 0; $i < $slen; ++$i) {
 				$newbrd[$brd[$i]] = array('cap' => 'square', 'join' => 'miter');
@@ -227,10 +227,10 @@
 		foreach ($brd as $border => $style) {
 			switch ($position) {
 				case 'start': {
-					if (strpos($border, 'B') !== false) {
+					if (strpos(($border ?? ''), 'B') !== false) {
 						// remove bottom line
-						$newkey = str_replace('B', '', $border);
-						if (strlen($newkey) > 0) {
+						$newkey = str_replace('B', '', ($border ?? ''));
+						if (strlen(($newkey ?? '')) > 0) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -238,19 +238,19 @@
 					break;
 				}
 				case 'middle': {
-					if (strpos($border, 'B') !== false) {
+					if (strpos(($border ?? ''), 'B') !== false) {
 						// remove bottom line
-						$newkey = str_replace('B', '', $border);
-						if (strlen($newkey) > 0) {
+						$newkey = str_replace('B', '', ($border ?? ''));
+						if (strlen(($newkey ?? '')) > 0) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
 						$border = $newkey;
 					}
-					if (strpos($border, 'T') !== false) {
+					if (strpos(($border ?? ''), 'T') !== false) {
 						// remove bottom line
-						$newkey = str_replace('T', '', $border);
-						if (strlen($newkey) > 0) {
+						$newkey = str_replace('T', '', ($border ?? ''));
+						if (strlen(($newkey ?? '')) > 0) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -258,10 +258,10 @@
 					break;
 				}
 				case 'end': {
-					if (strpos($border, 'T') !== false) {
+					if (strpos(($border ?? ''), 'T') !== false) {
 						// remove bottom line
-						$newkey = str_replace('T', '', $border);
-						if (strlen($newkey) > 0) {
+						$newkey = str_replace('T', '', ($border ?? ''));
+						if (strlen(($newkey ?? '')) > 0) {
 							$brd[$newkey] = $style;
 						}
 						unset($brd[$border]);
@@ -281,7 +281,7 @@
 	 * @public static
 	 */
 	public static function empty_string($str) {
-		return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
+		return (is_null($str) OR (is_string($str) AND (strlen(($str ?? '')) == 0)));
 	}
 
 	/**
@@ -293,7 +293,7 @@
 	 * @public static
 	 */
 	public static function getObjFilename($type='tmp', $file_id='') {
-		return tempnam(K_PATH_CACHE, '__tcpdf_'.$file_id.'_'.$type.'_'.md5(TCPDF_STATIC::getRandomSeed()).'_');
+		return tempnam(K_PATH_CACHE, '__tcpdf_'.$file_id.'_'.$type.'_'.md5((TCPDF_STATIC::getRandomSeed() ?? '')).'_');
 	}
 
 	/**
@@ -304,7 +304,7 @@
 	 */
 	public static function _escape($s) {
 		// the chr(13) substitution fixes the Bugs item #1421290.
-		return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
+		return strtr(($s ?? ''), array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
 	}
 
 	/**
@@ -316,7 +316,7 @@
 	 */
 	public static function _escapeXML($str) {
 		$replaceTable = array("\0" => '', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;');
-		$str = strtr($str, $replaceTable);
+		$str = strtr(($str ?? ''), ($replaceTable ?? ''));
 		return $str;
 	}
 
@@ -361,8 +361,8 @@
 	public static function replacePageNumAliases($page, $replace, $diff=0) {
 		foreach ($replace as $rep) {
 			foreach ($rep[3] as $a) {
-				if (strpos($page, $a) !== false) {
-					$page = str_replace($a, $rep[0], $page);
+				if (strpos(($page ?? ''), ($a ?? '')) !== false) {
+					$page = str_replace(($a ?? ''), ($rep[0] ?? ''), ($page ?? ''));
 					$diff += ($rep[2] - $rep[1]);
 				}
 			}
@@ -380,7 +380,7 @@
 	public static function getTimestamp($date) {
 		if (($date[0] == 'D') AND ($date[1] == ':')) {
 			// remove date prefix if present
-			$date = substr($date, 2);
+			$date = substr(($date ?? ''), 2);
 		}
 		return strtotime($date);
 	}
@@ -393,7 +393,7 @@
 	 * @public static
 	 */
 	public static function getFormattedDate($time) {
-		return substr_replace(date('YmdHisO', intval($time)), '\'', (0 - 2), 0).'\'';
+		return substr_replace((date('YmdHisO', intval($time)) ?? ''), '\'', (0 - 2), 0).'\'';
 	}
 
 	/**
@@ -409,7 +409,7 @@
 		if (function_exists('posix_getpid')) {
 			$rnd .= posix_getpid();
 		}
-		if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
+		if (function_exists('openssl_random_pseudo_bytes') AND (strtoupper((substr((PHP_OS ?? ''), 0, 3) ?? '')) !== 'WIN')) {
 			// this is not used on windows systems because it is very slow for a know bug
 			$rnd .= openssl_random_pseudo_bytes(512);
 		} else {
@@ -428,12 +428,12 @@
 	 * @public static
 	 */
 	public static function _md5_16($str) {
-		return pack('H*', md5($str));
+		return pack('H*', md5(($str ?? '')));
 	}
 
 	/**
 	 * Returns the input text exrypted using AES algorithm and the specified key.
-	 * This method requires openssl or mcrypt. Text is padded to 16bytes blocks
+	 * This method requires OpenSSL. Text is padded to 16bytes blocks
 	 * @param $key (string) encryption key
 	 * @param $text (String) input text to be encrypted
 	 * @return String encrypted text
@@ -443,22 +443,19 @@
 	 */
 	public static function _AES($key, $text) {
 		// padding (RFC 2898, PKCS #5: Password-Based Cryptography Specification Version 2.0)
-		$padding = 16 - (strlen($text) % 16);
-		$text .= str_repeat(chr($padding), $padding);
+		$padding = 16 - (strlen(($text ?? '')) % 16);
+		$text .= str_repeat((chr((int) ($padding)) ?? ''), $padding);
 		if (extension_loaded('openssl')) {
 			$iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length('aes-256-cbc'));
 			$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
-			return $iv.substr($text, 0, -16);
-		}
-		$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
-		$text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
-		$text = $iv.$text;
-		return $text;
+			return $iv.substr(($text ?? ''), 0, -16);
+		}
+		throw new \RuntimeException('OpenSSL is required for PDF encryption.');
 	}
 
 	/**
 	 * Returns the input text exrypted using AES algorithm and the specified key.
-	 * This method requires openssl or mcrypt. Text is not padded
+	 * This method requires OpenSSL. Text is not padded
 	 * @param $key (string) encryption key
 	 * @param $text (String) input text to be encrypted
 	 * @return String encrypted text
@@ -470,11 +467,9 @@
 		if (extension_loaded('openssl')) {
 			$iv = str_repeat("\x00", openssl_cipher_iv_length('aes-256-cbc'));
 			$text = openssl_encrypt($text, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
-			return substr($text, 0, -16);
-		}
-		$iv = str_repeat("\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
-		$text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
-		return $text;
+			return substr(($text ?? ''), 0, -16);
+		}
+		throw new \RuntimeException('OpenSSL is required for PDF encryption.');
 	}
 
 	/**
@@ -490,17 +485,13 @@
 	 * @public static
 	 */
 	public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) {
-		if (function_exists('mcrypt_encrypt') AND ($out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM, ''))) {
-			// try to use mcrypt function if exist
-			return $out;
-		}
 		if ($last_enc_key != $key) {
-			$k = str_repeat($key, ((256 / strlen($key)) + 1));
+			$k = str_repeat(($key ?? ''), (int) ((256 / strlen(($key ?? ''))) + 1));
 			$rc4 = range(0, 255);
 			$j = 0;
 			for ($i = 0; $i < 256; ++$i) {
 				$t = $rc4[$i];
-				$j = ($j + $t + ord($k[$i])) % 256;
+				$j = ($j + $t + ord(($k[$i] ?? ''))) % 256;
 				$rc4[$i] = $rc4[$j];
 				$rc4[$j] = $t;
 			}
@@ -509,7 +500,7 @@
 		} else {
 			$rc4 = $last_enc_key_c;
 		}
-		$len = strlen($text);
+		$len = strlen(($text ?? ''));
 		$a = 0;
 		$b = 0;
 		$out = '';
@@ -520,7 +511,7 @@
 			$rc4[$a] = $rc4[$b];
 			$rc4[$b] = $t;
 			$k = $rc4[($rc4[$a] + $rc4[$b]) % 256];
-			$out .= chr(ord($text[$i]) ^ $k);
+			$out .= chr((int) (ord(($text[$i] ?? '')) ^ $k));
 		}
 		return $out;
 	}
@@ -572,14 +563,14 @@
 	 */
 	public static function convertHexStringToString($bs) {
 		$string = ''; // string to be returned
-		$bslength = strlen($bs);
+		$bslength = strlen(($bs ?? ''));
 		if (($bslength % 2) != 0) {
 			// padding
 			$bs .= '0';
 			++$bslength;
 		}
 		for ($i = 0; $i < $bslength; $i += 2) {
-			$string .= chr(hexdec($bs[$i].$bs[($i + 1)]));
+			$string .= chr((int) (hexdec($bs[$i].$bs[($i + 1)])));
 		}
 		return $string;
 	}
@@ -594,9 +585,9 @@
 	 */
 	public static function convertStringToHexString($s) {
 		$bs = '';
-		$chars = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY);
+		$chars = preg_split('//', ($s ?? ''), -1, PREG_SPLIT_NO_EMPTY);
 		foreach ($chars as $c) {
-			$bs .= sprintf('%02s', dechex(ord($c)));
+			$bs .= sprintf('%02s', dechex(ord(($c ?? ''))));
 		}
 		return $bs;
 	}
@@ -611,10 +602,10 @@
 	 */
 	public static function getEncPermissionsString($protection) {
 		$binprot = sprintf('%032b', $protection);
-		$str = chr(bindec(substr($binprot, 24, 8)));
-		$str .= chr(bindec(substr($binprot, 16, 8)));
-		$str .= chr(bindec(substr($binprot, 8, 8)));
-		$str .= chr(bindec(substr($binprot, 0, 8)));
+		$str = chr((int) (bindec(substr(($binprot ?? ''), 24, 8))));
+		$str .= chr((int) (bindec(substr(($binprot ?? ''), 16, 8))));
+		$str .= chr((int) (bindec(substr(($binprot ?? ''), 8, 8))));
+		$str .= chr((int) (bindec(substr(($binprot ?? ''), 0, 8))));
 		return $str;
 	}
 
@@ -628,13 +619,13 @@
 	 */
 	public static function encodeNameObject($name) {
 		$escname = '';
-		$length = strlen($name);
+		$length = strlen(($name ?? ''));
 		for ($i = 0; $i < $length; ++$i) {
 			$chr = $name[$i];
-			if (preg_match('/[0-9a-zA-Z#_=-]/', $chr) == 1) {
+			if (preg_match('/[0-9a-zA-Z#_=-]/', ($chr ?? '')) == 1) {
 				$escname .= $chr;
 			} else {
-				$escname .= sprintf('#%02X', ord($chr));
+				$escname .= sprintf('#%02X', ord(($chr ?? '')));
 			}
 		}
 		return $escname;
@@ -1045,27 +1036,27 @@
 			return array();
 		}
 		// remove comments
-		$cssdata = preg_replace('/\/\*[^\*]*\*\//', '', $cssdata);
+		$cssdata = preg_replace('/\/\*[^\*]*\*\//', '', ($cssdata ?? ''));
 		// remove newlines and multiple spaces
-		$cssdata = preg_replace('/[\s]+/', ' ', $cssdata);
+		$cssdata = preg_replace('/[\s]+/', ' ', ($cssdata ?? ''));
 		// remove some spaces
-		$cssdata = preg_replace('/[\s]*([;:\{\}]{1})[\s]*/', '\\1', $cssdata);
+		$cssdata = preg_replace('/[\s]*([;:\{\}]{1})[\s]*/', '\\1', ($cssdata ?? ''));
 		// remove empty blocks
-		$cssdata = preg_replace('/([^\}\{]+)\{\}/', '', $cssdata);
+		$cssdata = preg_replace('/([^\}\{]+)\{\}/', '', ($cssdata ?? ''));
 		// replace media type parenthesis
-		$cssdata = preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1Â§', $cssdata);
-		$cssdata = preg_replace('/\}\}/si', '}Â§', $cssdata);
+		$cssdata = preg_replace('/@media[\s]+([^\{]*)\{/i', '@media \\1Â§', ($cssdata ?? ''));
+		$cssdata = preg_replace('/\}\}/si', '}Â§', ($cssdata ?? ''));
 		// trim string
-		$cssdata = trim($cssdata);
+		$cssdata = trim(($cssdata ?? ''));
 		// find media blocks (all, braille, embossed, handheld, print, projection, screen, speech, tty, tv)
 		$cssblocks = array();
 		$matches = array();
-		if (preg_match_all('/@media[\s]+([^\Â§]*)Â§([^Â§]*)Â§/i', $cssdata, $matches) > 0) {
+		if (preg_match_all('/@media[\s]+([^\Â§]*)Â§([^Â§]*)Â§/i', ($cssdata ?? ''), $matches) > 0) {
 			foreach ($matches[1] as $key => $type) {
 				$cssblocks[$type] = $matches[2][$key];
 			}
 			// remove media blocks
-			$cssdata = preg_replace('/@media[\s]+([^\Â§]*)Â§([^Â§]*)Â§/i', '', $cssdata);
+			$cssdata = preg_replace('/@media[\s]+([^\Â§]*)Â§([^Â§]*)Â§/i', '', ($cssdata ?? ''));
 		}
 		// keep 'all' and 'print' media, other media types are discarded
 		if (isset($cssblocks['all']) AND !empty($cssblocks['all'])) {
@@ -1078,14 +1069,14 @@
 		$cssblocks = array();
 		$matches = array();
 		// explode css data string into array
-		if (substr($cssdata, -1) == '}') {
+		if (substr(($cssdata ?? ''), -1) == '}') {
 			// remove last parethesis
-			$cssdata = substr($cssdata, 0, -1);
-		}
-		$matches = explode('}', $cssdata);
+			$cssdata = substr(($cssdata ?? ''), 0, -1);
+		}
+		$matches = explode('}', ($cssdata ?? ''));
 		foreach ($matches as $key => $block) {
 			// index 0 contains the CSS selector, index 1 contains CSS properties
-			$cssblocks[$key] = explode('{', $block);
+			$cssblocks[$key] = explode('{', ($block ?? ''));
 			if (!isset($cssblocks[$key][1])) {
 				// remove empty definitions
 				unset($cssblocks[$key]);
@@ -1093,10 +1084,10 @@
 		}
 		// split groups of selectors (comma-separated list of selectors)
 		foreach ($cssblocks as $key => $block) {
-			if (strpos($block[0], ',') > 0) {
-				$selectors = explode(',', $block[0]);
+			if (strpos(($block[0] ?? ''), ',') > 0) {
+				$selectors = explode(',', ($block[0] ?? ''));
 				foreach ($selectors as $sel) {
-					$cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
+					$cssblocks[] = array(0 => trim(($sel ?? '')), 1 => $block[1]);
 				}
 				unset($cssblocks[$key]);
 			}
@@ -1108,11 +1099,11 @@
 			// calculate selector's specificity
 			$matches = array();
 			$a = 0; // the declaration is not from is a 'style' attribute
-			$b = intval(preg_match_all('/[\#]/', $selector, $matches)); // number of ID attributes
-			$c = intval(preg_match_all('/[\[\.]/', $selector, $matches)); // number of other attributes
-			$c += intval(preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches)); // number of pseudo-classes
+			$b = intval(preg_match_all('/[\#]/', ($selector ?? ''), $matches)); // number of ID attributes
+			$c = intval(preg_match_all('/[\[\.]/', ($selector ?? ''), $matches)); // number of other attributes
+			$c += intval(preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', ($selector ?? ''), $matches)); // number of pseudo-classes
 			$d = intval(preg_match_all('/[\>\+\~\s]{1}[a-zA-Z0-9]+/', ' '.$selector, $matches)); // number of element names
-			$d += intval(preg_match_all('/[\:][\:]/', $selector, $matches)); // number of pseudo-elements
+			$d += intval(preg_match_all('/[\:][\:]/', ($selector ?? ''), $matches)); // number of pseudo-elements
 			$specificity = $a.$b.$c.$d;
 			// add specificity to the beginning of the selector
 			$cssdata[$specificity.' '.$selector] = $block[1];
@@ -1136,7 +1127,7 @@
 	 * @see setHtmlVSpace()
 	 * @public static
 	 */
-	public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) {
+	public static function fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces) {
 		// configure parameters for HTML Tidy
 		if ($tidy_options === '') {
 			$tidy_options = array (
@@ -1165,13 +1156,13 @@
 		// get the CSS part
 		$tidy_head = tidy_get_head($tidy);
 		$css = $tidy_head->value;
-		$css = preg_replace('/<style([^>]+)>/ims', '<style>', $css);
-		$css = preg_replace('/<\/style>(.*)<style>/ims', "\n", $css);
-		$css = str_replace('/*<![CDATA[*/', '', $css);
-		$css = str_replace('/*]]>*/', '', $css);
-		preg_match('/<style>(.*)<\/style>/ims', $css, $matches);
+		$css = preg_replace('/<style([^>]+)>/ims', '<style>', ($css ?? ''));
+		$css = preg_replace('/<\/style>(.*)<style>/ims', "\n", ($css ?? ''));
+		$css = str_replace('/*<![CDATA[*/', '', ($css ?? ''));
+		$css = str_replace('/*]]>*/', '', ($css ?? ''));
+		preg_match('/<style>(.*)<\/style>/ims', ($css ?? ''), $matches);
 		if (isset($matches[1])) {
-			$css = strtolower($matches[1]);
+			$css = strtolower(($matches[1] ?? ''));
 		} else {
 			$css = '';
 		}
@@ -1181,10 +1172,10 @@
 		$tidy_body = tidy_get_body($tidy);
 		$html = $tidy_body->value;
 		// fix some self-closing tags
-		$html = str_replace('<br>', '<br />', $html);
+		$html = str_replace('<br>', '<br />', ($html ?? ''));
 		// remove some empty tag blocks
-		$html = preg_replace('/<div([^\>]*)><\/div>/', '', $html);
-		$html = preg_replace('/<p([^\>]*)><\/p>/', '', $html);
+		$html = preg_replace('/<div([^\>]*)><\/div>/', '', ($html ?? ''));
+		$html = preg_replace('/<p([^\>]*)><\/p>/', '', ($html ?? ''));
 		if ($tagvs !== '') {
 			// set vertical space for some XHTML tags
 			$tagvspaces = $tagvs;
@@ -1207,43 +1198,43 @@
 		$tag = $dom[$key]['value'];
 		$class = array();
 		if (isset($dom[$key]['attribute']['class']) AND !empty($dom[$key]['attribute']['class'])) {
-			$class = explode(' ', strtolower($dom[$key]['attribute']['class']));
+			$class = explode(' ', (strtolower(($dom[$key]['attribute']['class'] ?? '')) ?? ''));
 		}
 		$id = '';
 		if (isset($dom[$key]['attribute']['id']) AND !empty($dom[$key]['attribute']['id'])) {
-			$id = strtolower($dom[$key]['attribute']['id']);
-		}
-		$selector = preg_replace('/([\>\+\~\s]{1})([\.]{1})([^\>\+\~\s]*)/si', '\\1*.\\3', $selector);
+			$id = strtolower(($dom[$key]['attribute']['id'] ?? ''));
+		}
+		$selector = preg_replace('/([\>\+\~\s]{1})([\.]{1})([^\>\+\~\s]*)/si', '\\1*.\\3', ($selector ?? ''));
 		$matches = array();
-		if (preg_match_all('/([\>\+\~\s]{1})([a-zA-Z0-9\*]+)([^\>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
+		if (preg_match_all('/([\>\+\~\s]{1})([a-zA-Z0-9\*]+)([^\>\+\~\s]*)/si', ($selector ?? ''), $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
 			$parentop = array_pop($matches[1]);
 			$operator = $parentop[0];
 			$offset = $parentop[1];
 			$lasttag = array_pop($matches[2]);
-			$lasttag = strtolower(trim($lasttag[0]));
+			$lasttag = strtolower((trim(($lasttag[0] ?? '')) ?? ''));
 			if (($lasttag == '*') OR ($lasttag == $tag)) {
 				// the last element on selector is our tag or 'any tag'
 				$attrib = array_pop($matches[3]);
-				$attrib = strtolower(trim($attrib[0]));
+				$attrib = strtolower((trim(($attrib[0] ?? '')) ?? ''));
 				if (!empty($attrib)) {
 					// check if matches class, id, attribute, pseudo-class or pseudo-element
 					switch ($attrib[0]) {
 						case '.': { // class
-							if (in_array(substr($attrib, 1), $class)) {
+							if (in_array(substr(($attrib ?? ''), 1), $class)) {
 								$valid = true;
 							}
 							break;
 						}
 						case '#': { // ID
-							if (substr($attrib, 1) == $id) {
+							if (substr(($attrib ?? ''), 1) == $id) {
 								$valid = true;
 							}
 							break;
 						}
 						case '[': { // attribute
 							$attrmatch = array();
-							if (preg_match('/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i', $attrib, $attrmatch) > 0) {
-								$att = strtolower($attrmatch[1]);
+							if (preg_match('/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i', ($attrib ?? ''), $attrmatch) > 0) {
+								$att = strtolower(($attrmatch[1] ?? ''));
 								$val = $attrmatch[3];
 								if (isset($dom[$key]['attribute'][$att])) {
 									switch ($attrmatch[2]) {
@@ -1254,25 +1245,25 @@
 											break;
 										}
 										case '~=': {
-											if (in_array($val, explode(' ', $dom[$key]['attribute'][$att]))) {
+											if (in_array($val, explode(' ', ($dom[$key]['attribute'][$att] ?? '')))) {
 												$valid = true;
 											}
 											break;
 										}
 										case '^=': {
-											if ($val == substr($dom[$key]['attribute'][$att], 0, strlen($val))) {
+											if ($val == substr(($dom[$key]['attribute'][$att] ?? ''), 0, strlen(($val ?? '')))) {
 												$valid = true;
 											}
 											break;
 										}
 										case '$=': {
-											if ($val == substr($dom[$key]['attribute'][$att], -strlen($val))) {
+											if ($val == substr(($dom[$key]['attribute'][$att] ?? ''), -strlen(($val ?? '')))) {
 												$valid = true;
 											}
 											break;
 										}
 										case '*=': {
-											if (strpos($dom[$key]['attribute'][$att], $val) !== false) {
+											if (strpos(($dom[$key]['attribute'][$att] ?? ''), ($val ?? '')) !== false) {
 												$valid = true;
 											}
 											break;
@@ -1280,7 +1271,7 @@
 										case '|=': {
 											if ($dom[$key]['attribute'][$att] == $val) {
 												$valid = true;
-											} elseif (preg_match('/'.$val.'[\-]{1}/i', $dom[$key]['attribute'][$att]) > 0) {
+											} elseif (preg_match('/'.$val.'[\-]{1}/i', ($dom[$key]['attribute'][$att] ?? '')) > 0) {
 												$valid = true;
 											}
 											break;
@@ -1310,7 +1301,7 @@
 				if ($valid AND ($offset > 0)) {
 					$valid = false;
 					// check remaining selector part
-					$selector = substr($selector, 0, $offset);
+					$selector = substr(($selector ?? ''), 0, $offset);
 					switch ($operator) {
 						case ' ': { // descendant of an element
 							while ($dom[$key]['parent'] > 0) {
@@ -1371,11 +1362,11 @@
 		}
 		// get all styles that apply
 		foreach($css as $selector => $style) {
-			$pos = strpos($selector, ' ');
+			$pos = strpos(($selector ?? ''), ' ');
 			// get specificity
-			$specificity = substr($selector, 0, $pos);
+			$specificity = substr(($selector ?? ''), 0, $pos);
 			// remove specificity
-			$selector = substr($selector, $pos);
+			$selector = substr(($selector ?? ''), $pos);
 			// check if this selector apply to current tag
 			if (self::isValidCSSSelectorForTag($dom, $key, $selector)) {
 				if (!in_array($selector, $selectors)) {
@@ -1411,15 +1402,15 @@
 		$tagstyle = ''; // value to be returned
 		foreach ($css as $style) {
 			// split single css commands
-			$csscmds = explode(';', $style['c']);
+			$csscmds = explode(';', ($style['c'] ?? ''));
 			foreach ($csscmds as $cmd) {
 				if (!empty($cmd)) {
-					$pos = strpos($cmd, ':');
+					$pos = strpos(($cmd ?? ''), ':');
 					if ($pos !== false) {
-						$cmd = substr($cmd, 0, ($pos + 1));
-						if (strpos($tagstyle, $cmd) !== false) {
+						$cmd = substr(($cmd ?? ''), 0, ($pos + 1));
+						if (strpos(($tagstyle ?? ''), ($cmd ?? '')) !== false) {
 							// remove duplicate commands (last commands have high priority)
-							$tagstyle = preg_replace('/'.$cmd.'[^;]+/i', '', $tagstyle);
+							$tagstyle = preg_replace('/'.$cmd.'[^;]+/i', '', ($tagstyle ?? ''));
 						}
 					}
 				}
@@ -1427,7 +1418,7 @@
 			$tagstyle .= ';'.$style['c'];
 		}
 		// remove multiple semicolons
-		$tagstyle = preg_replace('/[;]+/', ';', $tagstyle);
+		$tagstyle = preg_replace('/[;]+/', ';', ($tagstyle ?? ''));
 		return $tagstyle;
 	}
 
@@ -1505,10 +1496,10 @@
 	 * @public static
 	 */
 	public static function revstrpos($haystack, $needle, $offset = 0) {
-		$length = strlen($haystack);
+		$length = strlen(($haystack ?? ''));
 		$offset = ($offset > 0)?($length - $offset):abs($offset);
-		$pos = strpos(strrev($haystack), strrev($needle), $offset);
-		return ($pos === false)?false:($length - $pos - strlen($needle));
+		$pos = strpos((strrev($haystack) ?? ''), (strrev($needle) ?? ''), $offset);
+		return ($pos === false)?false:($length - $pos - strlen(($needle ?? '')));
 	}
 
 	/**
@@ -1522,22 +1513,22 @@
 	public static function getHyphenPatternsFromTEX($file) {
 		// TEX patterns are available at:
 		// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
-		$data = file_get_contents($file);
+		$data = file_get_contents(($file ?? ''));
 		$patterns = array();
 		// remove comments
-		$data = preg_replace('/\%[^\n]*/', '', $data);
+		$data = preg_replace('/\%[^\n]*/', '', ($data ?? ''));
 		// extract the patterns part
-		preg_match('/\\\\patterns\{([^\}]*)\}/i', $data, $matches);
-		$data = trim(substr($matches[0], 10, -1));
+		preg_match('/\\\\patterns\{([^\}]*)\}/i', ($data ?? ''), $matches);
+		$data = trim((substr(($matches[0] ?? ''), 10, -1) ?? ''));
 		// extract each pattern
-		$patterns_array = preg_split('/[\s]+/', $data);
+		$patterns_array = preg_split('/[\s]+/', ($data ?? ''));
 		// create new language array of patterns
 		$patterns = array();
 		foreach($patterns_array as $val) {
 			if (!TCPDF_STATIC::empty_string($val)) {
-				$val = trim($val);
-				$val = str_replace('\'', '\\\'', $val);
-				$key = preg_replace('/[0-9]+/', '', $val);
+				$val = trim(($val ?? ''));
+				$val = str_replace('\'', '\\\'', ($val ?? ''));
+				$key = preg_replace('/[0-9]+/', '', ($val ?? ''));
 				$patterns[$key] = $val;
 			}
 		}
@@ -1667,7 +1658,7 @@
 		// identity matrix
 		$tm = array(1, 0, 0, 1, 0, 0);
 		$transform = array();
-		if (preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
+		if (preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', ($attribute ?? ''), $transform, PREG_SET_ORDER) > 0) {
 			foreach ($transform as $key => $data) {
 				if (!empty($data[2])) {
 					$a = 1;
@@ -1679,7 +1670,7 @@
 					$regs = array();
 					switch ($data[1]) {
 						case 'matrix': {
-							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$a = $regs[1];
 								$b = $regs[2];
 								$c = $regs[3];
@@ -1690,26 +1681,26 @@
 							break;
 						}
 						case 'translate': {
-							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$e = $regs[1];
 								$f = $regs[2];
-							} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							} elseif (preg_match('/([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$e = $regs[1];
 							}
 							break;
 						}
 						case 'scale': {
-							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$a = $regs[1];
 								$d = $regs[2];
-							} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							} elseif (preg_match('/([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$a = $regs[1];
 								$d = $a;
 							}
 							break;
 						}
 						case 'rotate': {
-							if (preg_match('/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$ang = deg2rad($regs[1]);
 								$x = $regs[2];
 								$y = $regs[3];
@@ -1719,7 +1710,7 @@
 								$d = $a;
 								$e = ($x * (1 - $a)) - ($y * $c);
 								$f = ($y * (1 - $d)) - ($x * $b);
-							} elseif (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
+							} elseif (preg_match('/([0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$ang = deg2rad($regs[1]);
 								$a = cos($ang);
 								$b = sin($ang);
@@ -1731,13 +1722,13 @@
 							break;
 						}
 						case 'skewX': {
-							if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$c = tan(deg2rad($regs[1]));
 							}
 							break;
 						}
 						case 'skewY': {
-							if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
+							if (preg_match('/([0-9\-\.]+)/si', ($data[2] ?? ''), $regs)) {
 								$b = tan(deg2rad($regs[1]));
 							}
 							break;
@@ -1789,18 +1780,18 @@
 	 */
 	public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
 		// the bug only happens on PHP 5.2 when using the u modifier
-		if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
-			return preg_split($pattern.$modifiers, $subject, $limit, $flags);
+		if ((strpos(($modifiers ?? ''), 'u') === FALSE) OR (count((preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY) ?? [])) == 2)) {
+			return preg_split($pattern.$modifiers, ($subject ?? ''), $limit, $flags);
 		}
 		// preg_split is bugged - try alternative solution
 		$ret = array();
-		while (($nl = strpos($subject, "\n")) !== FALSE) {
-			$ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
+		while (($nl = strpos(($subject ?? ''), "\n")) !== FALSE) {
+			$ret = array_merge($ret, preg_split($pattern.$modifiers, (substr(($subject ?? ''), 0, $nl) ?? ''), $limit, $flags));
 			$ret[] = "\n";
-			$subject = substr($subject, ($nl + 1));
-		}
-		if (strlen($subject) > 0) {
-			$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
+			$subject = substr(($subject ?? ''), ($nl + 1));
+		}
+		if (strlen(($subject ?? '')) > 0) {
+			$ret = array_merge($ret, preg_split($pattern.$modifiers, ($subject ?? ''), $limit, $flags));
 		}
 		return $ret;
 	}
@@ -1813,7 +1804,7 @@
 	 * @public static
 	 */
 	public static function fopenLocal($filename, $mode) {
-		if (strpos($filename, '://') === false) {
+		if (strpos(($filename ?? ''), '://') === false) {
 			$filename = 'file://'.$filename;
 		} elseif (stream_is_local($filename) !== true) {
 			return false;
@@ -1832,7 +1823,7 @@
 		curl_setopt($crs, CURLOPT_URL, $url);
 		curl_setopt($crs, CURLOPT_NOBODY, true);
 		curl_setopt($crs, CURLOPT_FAILONERROR, true);
-		if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
+		if ((ini_get('open_basedir') == '') && (!'0')) {
 			curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
 		}
 		curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
@@ -1855,10 +1846,10 @@
 	 * @public static
 	 */
 	public static function file_exists($filename) {
-		if (preg_match('|^https?://|', $filename) == 1) {
+		if (preg_match('|^https?://|', ($filename ?? '')) == 1) {
 			return self::url_exists($filename);
 		}
-		if (strpos($filename, '://')) {
+		if (strpos(($filename ?? ''), '://')) {
 			return false; // only support http and https wrappers for security reasons
 		}
 		return @file_exists($filename);
@@ -1876,48 +1867,48 @@
 	public static function fileGetContents($file) {
 		$alt = array($file);
 		//
-		if ((strlen($file) > 1)
+		if ((strlen(($file ?? '')) > 1)
 		    && ($file[0] === '/')
 		    && ($file[1] !== '/')
 		    && !empty($_SERVER['DOCUMENT_ROOT'])
 		    && ($_SERVER['DOCUMENT_ROOT'] !== '/')
 		) {
-		    $findroot = strpos($file, $_SERVER['DOCUMENT_ROOT']);
+		    $findroot = strpos(($file ?? ''), ($_SERVER['DOCUMENT_ROOT'] ?? ''));
 		    if (($findroot === false) || ($findroot > 1)) {
-			$alt[] = htmlspecialchars_decode(urldecode($_SERVER['DOCUMENT_ROOT'].$file));
+			$alt[] = htmlspecialchars_decode((urldecode($_SERVER['DOCUMENT_ROOT'].$file) ?? ''));
 		    }
 		}
 		//
 		$protocol = 'http';
-		if (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
+		if (!empty($_SERVER['HTTPS']) && (strtolower(($_SERVER['HTTPS'] ?? '')) != 'off')) {
 		    $protocol .= 's';
 		}
 		//
 		$url = $file;
-		if (preg_match('%^//%', $url) && !empty($_SERVER['HTTP_HOST'])) {
-			$url = $protocol.':'.str_replace(' ', '%20', $url);
-		}
-		$url = htmlspecialchars_decode($url);
+		if (preg_match('%^//%', ($url ?? '')) && !empty($_SERVER['HTTP_HOST'])) {
+			$url = $protocol.':'.str_replace(' ', '%20', ($url ?? ''));
+		}
+		$url = htmlspecialchars_decode(($url ?? ''));
 		$alt[] = $url;
 		//
-		if (preg_match('%^(https?)://%', $url)
+		if (preg_match('%^(https?)://%', ($url ?? ''))
 		    && empty($_SERVER['HTTP_HOST'])
 		    && empty($_SERVER['DOCUMENT_ROOT'])
 		) {
 			$urldata = parse_url($url);
 			if (empty($urldata['query'])) {
 				$host = $protocol.'://'.$_SERVER['HTTP_HOST'];
-				if (strpos($url, $host) === 0) {
+				if (strpos(($url ?? ''), ($host ?? '')) === 0) {
 				    // convert URL to full server path
-				    $tmp = str_replace($host, $_SERVER['DOCUMENT_ROOT'], $url);
-				    $alt[] = htmlspecialchars_decode(urldecode($tmp));
+				    $tmp = str_replace(($host ?? ''), ($_SERVER['DOCUMENT_ROOT'] ?? ''), ($url ?? ''));
+				    $alt[] = htmlspecialchars_decode((urldecode(($tmp ?? '')) ?? ''));
 				}
 			}
 		}
 		//
 		if (isset($_SERVER['SCRIPT_URI'])
-		    && !preg_match('%^(https?|ftp)://%', $file)
-		    && !preg_match('%^//%', $file)
+		    && !preg_match('%^(https?|ftp)://%', ($file ?? ''))
+		    && !preg_match('%^//%', ($file ?? ''))
 		) {
 		    $urldata = @parse_url($_SERVER['SCRIPT_URI']);
 		    $alt[] = $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
@@ -1928,14 +1919,14 @@
 			if (!self::file_exists($path)) {
 				return false;
 			}
-			$ret = @file_get_contents($path);
+			$ret = @file_get_contents(($path ?? ''));
 			if ($ret !== false) {
 			    return $ret;
 			}
 			// try to use CURL for URLs
 			if (!ini_get('allow_url_fopen')
 				&& function_exists('curl_init')
-				&& preg_match('%^(https?|ftp)://%', $path)
+				&& preg_match('%^(https?|ftp)://%', ($path ?? ''))
 			) {
 				// try to get remote file data using cURL
 				$crs = curl_init();
@@ -1943,7 +1934,7 @@
 				curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
 				curl_setopt($crs, CURLOPT_FAILONERROR, true);
 				curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
-				if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
+				if ((ini_get('open_basedir') == '') && (!'0')) {
 				    curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
 				}
 				curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
@@ -1971,7 +1962,7 @@
 	 * @public static
 	 */
 	public static function _getULONG($str, $offset) {
-		$v = unpack('Ni', substr($str, $offset, 4));
+		$v = unpack('Ni', substr(($str ?? ''), $offset, 4));
 		return $v['i'];
 	}
 
@@ -1985,7 +1976,7 @@
 	 * @public static
 	 */
 	public static function _getUSHORT($str, $offset) {
-		$v = unpack('ni', substr($str, $offset, 2));
+		$v = unpack('ni', substr(($str ?? ''), $offset, 2));
 		return $v['i'];
 	}
 
@@ -1999,7 +1990,7 @@
 	 * @public static
 	 */
 	public static function _getSHORT($str, $offset) {
-		$v = unpack('si', substr($str, $offset, 2));
+		$v = unpack('si', substr(($str ?? ''), $offset, 2));
 		return $v['i'];
 	}
 
@@ -2062,7 +2053,7 @@
 	 * @public static
 	 */
 	public static function _getBYTE($str, $offset) {
-		$v = unpack('Ci', substr($str, $offset, 1));
+		$v = unpack('Ci', substr(($str ?? ''), $offset, 1));
 		return $v['i'];
 	}
 	/**
@@ -2080,7 +2071,7 @@
 		if ($data === false) {
 			return false;
 		}
-		$rest = ($length - strlen($data));
+		$rest = ($length - strlen(($data ?? '')));
 		if (($rest > 0) && !feof($handle)) {
 			$data .= self::rfread($handle, $rest);
 		}
@@ -2485,7 +2476,7 @@
 	 * @since 5.0.010 (2010-05-17)
 	 * @public static
 	 */
-	public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) {
+	public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points, $k, $pagedim=array()) {
 		if (!isset($pagedim[$page])) {
 			// initialize array
 			$pagedim[$page] = array();
--- a/intranet/tcpdf/include/tcpdf_fonts.php
+++ b/intranet/tcpdf/include/tcpdf_fonts.php
@@ -79,13 +79,13 @@
 		// build new font name for TCPDF compatibility
 		$font_path_parts = pathinfo($fontfile);
 		if (!isset($font_path_parts['filename'])) {
-			$font_path_parts['filename'] = substr($font_path_parts['basename'], 0, -(strlen($font_path_parts['extension']) + 1));
-		}
-		$font_name = strtolower($font_path_parts['filename']);
-		$font_name = preg_replace('/[^a-z0-9_]/', '', $font_name);
+			$font_path_parts['filename'] = substr(($font_path_parts['basename'] ?? ''), 0, -(strlen(($font_path_parts['extension'] ?? '')) + 1));
+		}
+		$font_name = strtolower(($font_path_parts['filename'] ?? ''));
+		$font_name = preg_replace('/[^a-z0-9_]/', '', ($font_name ?? ''));
 		$search  = array('bold', 'oblique', 'italic', 'regular');
 		$replace = array('b', 'i', 'i', '');
-		$font_name = str_replace($search, $replace, $font_name);
+		$font_name = str_replace(($search ?? ''), ($replace ?? ''), ($font_name ?? ''));
 		if (empty($font_name)) {
 			// set generic name
 			$font_name = 'tcpdffont';
@@ -102,14 +102,14 @@
 		$fmetric['file'] = $font_name;
 		$fmetric['ctg'] = $font_name.'.ctg.z';
 		// get font data
-		$font = file_get_contents($fontfile);
-		$fmetric['originalsize'] = strlen($font);
+		$font = file_get_contents(($fontfile ?? ''));
+		$fmetric['originalsize'] = strlen(($font ?? ''));
 		// autodetect font type
 		if (empty($fonttype)) {
 			if (TCPDF_STATIC::_getULONG($font, 0) == 0x10000) {
 				// True Type (Unicode or not)
 				$fonttype = 'TrueTypeUnicode';
-			} elseif (substr($font, 0, 4) == 'OTTO') {
+			} elseif (substr(($font ?? ''), 0, 4) == 'OTTO') {
 				// Open Type (Unicode or not)
 				//Unsupported font format: OpenType with CFF data
 				return false;
@@ -145,7 +145,7 @@
 			}
 		}
 		// set encoding maps (if any)
-		$fmetric['enc'] = preg_replace('/[^A-Za-z0-9_\-]/', '', $enc);
+		$fmetric['enc'] = preg_replace('/[^A-Za-z0-9_\-]/', '', ($enc ?? ''));
 		$fmetric['diff'] = '';
 		if (($fmetric['type'] == 'TrueType') OR ($fmetric['type'] == 'Type1')) {
 			if (!empty($enc) AND ($enc != 'cp1252') AND isset(TCPDF_FONT_DATA::$encmap[$enc])) {
@@ -168,21 +168,21 @@
 		if ($fmetric['type'] == 'Type1') {
 			// ---------- TYPE 1 ----------
 			// read first segment
-			$a = unpack('Cmarker/Ctype/Vsize', substr($font, 0, 6));
+			$a = unpack('Cmarker/Ctype/Vsize', substr(($font ?? ''), 0, 6));
 			if ($a['marker'] != 128) {
 				// Font file is not a valid binary Type1
 				return false;
 			}
 			$fmetric['size1'] = $a['size'];
-			$data = substr($font, 6, $fmetric['size1']);
+			$data = substr(($font ?? ''), 6, $fmetric['size1']);
 			// read second segment
-			$a = unpack('Cmarker/Ctype/Vsize', substr($font, (6 + $fmetric['size1']), 6));
+			$a = unpack('Cmarker/Ctype/Vsize', substr(($font ?? ''), (6 + $fmetric['size1']), 6));
 			if ($a['marker'] != 128) {
 				// Font file is not a valid binary Type1
 				return false;
 			}
 			$fmetric['size2'] = $a['size'];
-			$encrypted = substr($font, (12 + $fmetric['size1']), $fmetric['size2']);
+			$encrypted = substr(($font ?? ''), (12 + $fmetric['size1']), $fmetric['size2']);
 			$data .= $encrypted;
 			// store compressed font
 			$fmetric['file'] .= '.z';
@@ -191,29 +191,29 @@
 			fclose($fp);
 			// get font info
 			$fmetric['Flags'] = $flags;
-			preg_match ('#/FullName[\s]*\(([^\)]*)#', $font, $matches);
-			$fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $matches[1]);
-			preg_match('#/FontBBox[\s]*{([^}]*)#', $font, $matches);
-			$fmetric['bbox'] = trim($matches[1]);
-			$bv = explode(' ', $fmetric['bbox']);
+			preg_match ('#/FullName[\s]*\(([^\)]*)#', ($font ?? ''), $matches);
+			$fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', ($matches[1] ?? ''));
+			preg_match('#/FontBBox[\s]*{([^}]*)#', ($font ?? ''), $matches);
+			$fmetric['bbox'] = trim(($matches[1] ?? ''));
+			$bv = explode(' ', ($fmetric['bbox'] ?? ''));
 			$fmetric['Ascent'] = intval($bv[3]);
 			$fmetric['Descent'] = intval($bv[1]);
-			preg_match('#/ItalicAngle[\s]*([0-9\+\-]*)#', $font, $matches);
+			preg_match('#/ItalicAngle[\s]*([0-9\+\-]*)#', ($font ?? ''), $matches);
 			$fmetric['italicAngle'] = intval($matches[1]);
 			if ($fmetric['italicAngle'] != 0) {
 				$fmetric['Flags'] |= 64;
 			}
-			preg_match('#/UnderlinePosition[\s]*([0-9\+\-]*)#', $font, $matches);
+			preg_match('#/UnderlinePosition[\s]*([0-9\+\-]*)#', ($font ?? ''), $matches);
 			$fmetric['underlinePosition'] = intval($matches[1]);
-			preg_match('#/UnderlineThickness[\s]*([0-9\+\-]*)#', $font, $matches);
+			preg_match('#/UnderlineThickness[\s]*([0-9\+\-]*)#', ($font ?? ''), $matches);
 			$fmetric['underlineThickness'] = intval($matches[1]);
-			preg_match('#/isFixedPitch[\s]*([^\s]*)#', $font, $matches);
+			preg_match('#/isFixedPitch[\s]*([^\s]*)#', ($font ?? ''), $matches);
 			if ($matches[1] == 'true') {
 				$fmetric['Flags'] |= 1;
 			}
 			// get internal map
 			$imap = array();
-			if (preg_match_all('#dup[\s]([0-9]+)[\s]*/([^\s]*)[\s]put#sU', $font, $fmap, PREG_SET_ORDER) > 0) {
+			if (preg_match_all('#dup[\s]([0-9]+)[\s]*/([^\s]*)[\s]put#sU', ($font ?? ''), $fmap, PREG_SET_ORDER) > 0) {
 				foreach ($fmap as $v) {
 					$imap[$v[2]] = $v[1];
 				}
@@ -222,31 +222,31 @@
 			$r = 55665; // eexec encryption constant
 			$c1 = 52845;
 			$c2 = 22719;
-			$elen = strlen($encrypted);
+			$elen = strlen(($encrypted ?? ''));
 			$eplain = '';
 			for ($i = 0; $i < $elen; ++$i) {
-				$chr = ord($encrypted[$i]);
-				$eplain .= chr($chr ^ ($r >> 8));
+				$chr = ord(($encrypted[$i] ?? ''));
+				$eplain .= chr((int) ($chr ^ ($r >> 8)));
 				$r = ((($chr + $r) * $c1 + $c2) % 65536);
 			}
-			if (preg_match('#/ForceBold[\s]*([^\s]*)#', $eplain, $matches) > 0) {
+			if (preg_match('#/ForceBold[\s]*([^\s]*)#', ($eplain ?? ''), $matches) > 0) {
 				if ($matches[1] == 'true') {
 					$fmetric['Flags'] |= 0x40000;
 				}
 			}
-			if (preg_match('#/StdVW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) {
+			if (preg_match('#/StdVW[\s]*\[([^\]]*)#', ($eplain ?? ''), $matches) > 0) {
 				$fmetric['StemV'] = intval($matches[1]);
 			} else {
 				$fmetric['StemV'] = 70;
 			}
-			if (preg_match('#/StdHW[\s]*\[([^\]]*)#', $eplain, $matches) > 0) {
+			if (preg_match('#/StdHW[\s]*\[([^\]]*)#', ($eplain ?? ''), $matches) > 0) {
 				$fmetric['StemH'] = intval($matches[1]);
 			} else {
 				$fmetric['StemH'] = 30;
 			}
-			if (preg_match('#/BlueValues[\s]*\[([^\]]*)#', $eplain, $matches) > 0) {
-				$bv = explode(' ', $matches[1]);
-				if (count($bv) >= 6) {
+			if (preg_match('#/BlueValues[\s]*\[([^\]]*)#', ($eplain ?? ''), $matches) > 0) {
+				$bv = explode(' ', ($matches[1] ?? ''));
+				if (count(($bv ?? [])) >= 6) {
 					$v1 = intval($bv[2]);
 					$v2 = intval($bv[4]);
 					if ($v1 <= $v2) {
@@ -265,15 +265,15 @@
 				$fmetric['CapHeight'] = 700;
 			}
 			// get the number of random bytes at the beginning of charstrings
-			if (preg_match('#/lenIV[\s]*([0-9]*)#', $eplain, $matches) > 0) {
+			if (preg_match('#/lenIV[\s]*([0-9]*)#', ($eplain ?? ''), $matches) > 0) {
 				$lenIV = intval($matches[1]);
 			} else {
 				$lenIV = 4;
 			}
 			$fmetric['Leading'] = 0;
 			// get charstring data
-			$eplain = substr($eplain, (strpos($eplain, '/CharStrings') + 1));
-			preg_match_all('#/([A-Za-z0-9\.]*)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', $eplain, $matches, PREG_SET_ORDER);
+			$eplain = substr(($eplain ?? ''), (strpos(($eplain ?? ''), '/CharStrings') + 1));
+			preg_match_all('#/([A-Za-z0-9\.]*)[\s][0-9]+[\s]RD[\s](.*)[\s]ND#sU', ($eplain ?? ''), $matches, PREG_SET_ORDER);
 			if (!empty($enc) AND isset(TCPDF_FONT_DATA::$encmap[$enc])) {
 				$enc_map = TCPDF_FONT_DATA::$encmap[$enc];
 			} else {
@@ -299,10 +299,10 @@
 				$c1 = 52845;
 				$c2 = 22719;
 				$cd = $v[2];
-				$clen = strlen($cd);
+				$clen = strlen(($cd ?? ''));
 				$ccom = array();
 				for ($i = 0; $i < $clen; ++$i) {
-					$chr = ord($cd[$i]);
+					$chr = ord(($cd[$i] ?? ''));
 					$ccom[] = ($chr ^ ($r >> 8));
 					$r = ((($chr + $r) * $c1 + $c2) % 65536);
 				}
@@ -328,7 +328,7 @@
 						$cdec[$ck] = ((-($ccom[$i] - 251) * 256) - $ccom[($i + 1)] - 108);
 						$i += 2;
 					} elseif ($ccom[$i] == 255) {
-						$sval = chr($ccom[($i + 1)]).chr($ccom[($i + 2)]).chr($ccom[($i + 3)]).chr($ccom[($i + 4)]);
+						$sval = chr((int) ($ccom[($i + 1)])).chr((int) ($ccom[($i + 2)])).chr((int) ($ccom[($i + 3)])).chr((int) ($ccom[($i + 4)]));
 						$vsval = unpack('li', $sval);
 						$cdec[$ck] = $vsval['i'];
 						$i += 5;
@@ -351,7 +351,7 @@
 					$fmetric['cw'] .= ','.$cid.'=>'.$fmetric['MissingWidth'];
 				}
 			}
-			$fmetric['AvgWidth'] = round($fmetric['AvgWidth'] / count($cwidths));
+			$fmetric['AvgWidth'] = round($fmetric['AvgWidth'] / count(($cwidths ?? [])));
 		} else {
 			// ---------- TRUE TYPE ----------
 			$offset = 0; // offset position of the font data
@@ -382,7 +382,7 @@
 			// ---------- get tables ----------
 			for ($i = 0; $i < $numTables; ++$i) {
 				// get table info
-				$tag = substr($font, $offset, 4);
+				$tag = substr(($font ?? ''), $offset, 4);
 				$offset += 4;
 				$table[$tag] = array();
 				$table[$tag]['checkSum'] = TCPDF_STATIC::_getULONG($font, $offset);
@@ -508,8 +508,8 @@
 					$stringOffset = TCPDF_STATIC::_getUSHORT($font, $offset);
 					$offset += 2;
 					$offset = ($table['name']['offset'] + $stringStorageOffset + $stringOffset);
-					$fmetric['name'] = substr($font, $offset, $stringLength);
-					$fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $fmetric['name']);
+					$fmetric['name'] = substr(($font ?? ''), $offset, $stringLength);
+					$fmetric['name'] = preg_replace('/[^a-zA-Z0-9_\-]/', '', ($fmetric['name'] ?? ''));
 					break;
 				} else {
 					$offset += 4; // skip String length, String offset
@@ -817,7 +817,7 @@
 				}
 			}
 		} // end of true type
-		if (($fmetric['type'] == 'TrueTypeUnicode') AND (count($ctg) == 256)) {
+		if (($fmetric['type'] == 'TrueTypeUnicode') AND (count(($ctg ?? [])) == 256)) {
 			$fmetric['type'] = 'TrueType';
 		}
 		// ---------- create php font file ----------
@@ -906,9 +906,9 @@
 		$pfile .= '\'MissingWidth\'=>'.$fmetric['MissingWidth'].'';
 		$pfile .= ');'."\n";
 		if (!empty($fmetric['cbbox'])) {
-			$pfile .= '$cbbox=array('.substr($fmetric['cbbox'], 1).');'."\n";
-		}
-		$pfile .= '$cw=array('.substr($fmetric['cw'], 1).');'."\n";
+			$pfile .= '$cbbox=array('.substr(($fmetric['cbbox'] ?? ''), 1).');'."\n";
+		}
+		$pfile .= '$cw=array('.substr(($fmetric['cw'] ?? ''), 1).');'."\n";
 		$pfile .= '// --- EOF ---'."\n";
 		// store file
 		$fp = TCPDF_STATIC::fopenLocal($outpath.$font_name.'.php', 'w');
@@ -932,7 +932,7 @@
 		$tlen = ($length / 4);
 		$offset = 0;
 		for ($i = 0; $i < $tlen; ++$i) {
-			$v = unpack('Ni', substr($table, $offset, 4));
+			$v = unpack('Ni', substr(($table ?? ''), $offset, 4));
 			$sum += $v['i'];
 			$offset += 4;
 		}
@@ -967,7 +967,7 @@
 		// for each table
 		for ($i = 0; $i < $numTables; ++$i) {
 			// get table info
-			$tag = substr($font, $offset, 4);
+			$tag = substr(($font ?? ''), $offset, 4);
 			$offset += 4;
 			$table[$tag] = array();
 			$table[$tag]['checkSum'] = TCPDF_STATIC::_getULONG($font, $offset);
@@ -1298,7 +1298,7 @@
 		for ($i = 0; $i < $tot_num_glyphs; ++$i) {
 			if (isset($subsetglyphs[$i])) {
 				$length = ($indexToLoc[($i + 1)] - $indexToLoc[$i]);
-				$glyf .= substr($font, ($glyf_offset + $indexToLoc[$i]), $length);
+				$glyf .= substr(($font ?? ''), ($glyf_offset + $indexToLoc[$i]), $length);
 			} else {
 				$length = 0;
 			}
@@ -1316,10 +1316,10 @@
 		$offset = 12;
 		foreach ($table as $tag => $val) {
 			if (in_array($tag, $table_names)) {
-				$table[$tag]['data'] = substr($font, $table[$tag]['offset'], $table[$tag]['length']);
+				$table[$tag]['data'] = substr(($font ?? ''), $table[$tag]['offset'], $table[$tag]['length']);
 				if ($tag == 'head') {
 					// set the checkSumAdjustment to 0
-					$table[$tag]['data'] = substr($table[$tag]['data'], 0, 8)."\x0\x0\x0\x0".substr($table[$tag]['data'], 12);
+					$table[$tag]['data'] = substr(($table[$tag]['data'] ?? ''), 0, 8)."\x0\x0\x0\x0".substr(($table[$tag]['data'] ?? ''), 12);
 				}
 				$pad = 4 - ($table[$tag]['length'] % 4);
 				if ($pad != 4) {
@@ -1337,7 +1337,7 @@
 		}
 		// add loca
 		$table['loca']['data'] = $loca;
-		$table['loca']['length'] = strlen($loca);
+		$table['loca']['length'] = strlen(($loca ?? ''));
 		$pad = 4 - ($table['loca']['length'] % 4);
 		if ($pad != 4) {
 			// the length of a table must be a multiple of four bytes
@@ -1349,7 +1349,7 @@
 		$offset += $table['loca']['length'];
 		// add glyf
 		$table['glyf']['data'] = $glyf;
-		$table['glyf']['length'] = strlen($glyf);
+		$table['glyf']['length'] = strlen(($glyf ?? ''));
 		$pad = 4 - ($table['glyf']['length'] % 4);
 		if ($pad != 4) {
 			// the length of a table must be a multiple of four bytes
@@ -1361,7 +1361,7 @@
 		// rebuild font
 		$font = '';
 		$font .= pack('N', 0x10000); // sfnt version
-		$numTables = count($table);
+		$numTables = count(($table ?? []));
 		$font .= pack('n', $numTables); // numTables
 		$entrySelector = floor(log($numTables, 2));
 		$searchRange = pow(2, $entrySelector) * 16;
@@ -1380,8 +1380,8 @@
 			$font .= $data['data'];
 		}
 		// set checkSumAdjustment on head table
-		$checkSumAdjustment = 0xB1B0AFBA - self::_getTTFtableChecksum($font, strlen($font));
-		$font = substr($font, 0, $table['head']['offset'] + 8).pack('N', $checkSumAdjustment).substr($font, $table['head']['offset'] + 12);
+		$checkSumAdjustment = 0xB1B0AFBA - self::_getTTFtableChecksum($font, strlen(($font ?? '')));
+		$font = substr(($font ?? ''), 0, $table['head']['offset'] + 8).pack('N', $checkSumAdjustment).substr(($font ?? ''), $table['head']['offset'] + 12);
 		return $font;
 	}
 
@@ -1451,7 +1451,7 @@
 		$nextk = -1;
 		$prevint = false;
 		foreach ($range as $k => $ws) {
-			$cws = count($ws);
+			$cws = count(($ws ?? []));
 			if (($k == $nextk) AND (!$prevint) AND ((!isset($ws['interval'])) OR ($cws < 4))) {
 				if (isset($range[$k]['interval'])) {
 					unset($range[$k]['interval']);
@@ -1479,9 +1479,9 @@
 		// output data
 		$w = '';
 		foreach ($range as $k => $ws) {
-			if (count(array_count_values($ws)) == 1) {
+			if (count((array_count_values($ws) ?? [])) == 1) {
 				// interval mode is more compact
-				$w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0];
+				$w .= ' '.$k.' '.($k + count(($ws ?? [])) - 1).' '.$ws[0];
 			} else {
 				// range mode
 				$w .= ' '.$k.' [ '.implode(' ', $ws).' ]';
@@ -1508,8 +1508,8 @@
 			if ($gid > 0xFFFF) {
 				$gid -= 0x10000;
 			}
-			$map[($cid * 2)] = chr($gid >> 8);
-			$map[(($cid * 2) + 1)] = chr($gid & 0xFF);
+			$map[($cid * 2)] = chr((int) ($gid >> 8));
+			$map[(($cid * 2) + 1)] = chr((int) ($gid & 0xFF));
 		}
 		return $map;
 	}
@@ -1521,7 +1521,7 @@
 	 */
 	public static function _getfontpath() {
 		if (!defined('K_PATH_FONTS') AND is_dir($fdir = realpath(dirname(__FILE__).'/../fonts'))) {
-			if (substr($fdir, -1) != '/') {
+			if (substr(($fdir ?? ''), -1) != '/') {
 				$fdir .= '/';
 			}
 			define('K_PATH_FONTS', $fdir);
@@ -1664,20 +1664,21 @@
 	 * @public static
 	 */
 	public static function unichr($c, $unicode=true) {
+		$c = (int) $c;
 		if (!$unicode) {
-			return chr($c);
+			return chr((int) ($c));
 		} elseif ($c <= 0x7F) {
 			// one byte
-			return chr($c);
+			return chr((int) ($c));
 		} elseif ($c <= 0x7FF) {
 			// two bytes
-			return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
+			return chr((int) (0xC0 | $c >> 6)).chr((int) (0x80 | $c & 0x3F));
 		} elseif ($c <= 0xFFFF) {
 			// three bytes
-			return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+			return chr((int) (0xE0 | $c >> 12)).chr((int) (0x80 | $c >> 6 & 0x3F)).chr((int) (0x80 | $c & 0x3F));
 		} elseif ($c <= 0x10FFFF) {
 			// four bytes
-			return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+			return chr((int) (0xF0 | $c >> 18)).chr((int) (0x80 | $c >> 12 & 0x3F)).chr((int) (0x80 | $c >> 6 & 0x3F)).chr((int) (0x80 | $c & 0x3F));
 		} else {
 			return '';
 		}
@@ -1752,16 +1753,16 @@
 			} elseif ($char == 0xFFFD) {
 				$outstr .= "\xFF\xFD"; // replacement character
 			} elseif ($char < 0x10000) {
-				$outstr .= chr($char >> 0x08);
-				$outstr .= chr($char & 0xFF);
+				$outstr .= chr((int) ($char >> 0x08));
+				$outstr .= chr((int) ($char & 0xFF));
 			} else {
 				$char -= 0x10000;
 				$w1 = 0xD800 | ($char >> 0x0a);
 				$w2 = 0xDC00 | ($char & 0x3FF);
-				$outstr .= chr($w1 >> 0x08);
-				$outstr .= chr($w1 & 0xFF);
-				$outstr .= chr($w2 >> 0x08);
-				$outstr .= chr($w2 & 0xFF);
+				$outstr .= chr((int) ($w1 >> 0x08));
+				$outstr .= chr((int) ($w1 & 0xFF));
+				$outstr .= chr((int) ($w2 >> 0x08));
+				$outstr .= chr((int) ($w2 & 0xFF));
 			}
 		}
 		return $outstr;
@@ -1792,11 +1793,11 @@
 	 * @public static
 	 */
 	public static function UTF8ArrSubString($strarr, $start='', $end='', $unicode=true) {
-		if (strlen($start) == 0) {
+		if (strlen(($start ?? '')) == 0) {
 			$start = 0;
 		}
-		if (strlen($end) == 0) {
-			$end = count($strarr);
+		if (strlen(($end ?? '')) == 0) {
+			$end = count(($strarr ?? []));
 		}
 		$string = '';
 		for ($i = $start; $i < $end; ++$i) {
@@ -1815,11 +1816,11 @@
 	 * @public static
 	 */
 	public static function UniArrSubString($uniarr, $start='', $end='') {
-		if (strlen($start) == 0) {
+		if (strlen(($start ?? '')) == 0) {
 			$start = 0;
 		}
-		if (strlen($end) == 0) {
-			$end = count($uniarr);
+		if (strlen(($end ?? '')) == 0) {
+			$end = count(($uniarr ?? []));
 		}
 		$string = '';
 		for ($i=$start; $i < $end; ++$i) {
@@ -1865,10 +1866,10 @@
 		$outstr = ''; // string to be returned
 		foreach ($unicode as $char) {
 			if ($char < 256) {
-				$outstr .= chr($char);
+				$outstr .= chr((int) ($char));
 			} elseif (array_key_exists($char, TCPDF_FONT_DATA::$uni_utf8tolatin)) {
 				// map from UTF-8
-				$outstr .= chr(TCPDF_FONT_DATA::$uni_utf8tolatin[$char]);
+				$outstr .= chr((int) (TCPDF_FONT_DATA::$uni_utf8tolatin[$char]));
 			} elseif ($char == 0xFFFD) {
 				// skip
 			} else {
@@ -1927,7 +1928,7 @@
 	 */
 	public static function getUniord($uch) {
 		if (function_exists('mb_convert_encoding')) {
-			list(, $char) = @unpack('N', mb_convert_encoding($uch, 'UCS-4BE', 'UTF-8'));
+			list(, $char) = @unpack('N', mb_convert_encoding(($uch ?? ''), 'UCS-4BE', 'UTF-8'));
 			if ($char >= 0) {
 				return $char;
 			}
@@ -1935,9 +1936,9 @@
 		$bytes = array(); // array containing single character byte sequences
 		$countbytes = 0;
 		$numbytes = 1; // number of octetc needed to represent the UTF-8 character
-		$length = strlen($uch);
+		$length = strlen(($uch ?? ''));
 		for ($i = 0; $i < $length; ++$i) {
-			$char = ord($uch[$i]); // get one string character at time
+			$char = ord(($uch[$i] ?? '')); // get one string character at time
 			if ($countbytes == 0) { // get starting octect
 				if ($char <= 0x7F) {
 					return $char; // use the character "as is" because is ASCII
@@ -1994,13 +1995,13 @@
 	 * @author Nicola Asuni
 	 * @public static
 	 */
-	public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
+	public static function UTF8StringToArray($str, $isunicode, &$currentfont) {
 		if ($isunicode) {
 			// requires PCRE unicode support turned on
 			$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
 			$carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars);
 		} else {
-			$chars = str_split($str);
+			$chars = str_split(($str ?? ''));
 			$carr = array_map('ord', $chars);
 		}
 		if (is_array($currentfont['subsetchars']) && is_array($carr)) {
@@ -2020,7 +2021,7 @@
 	 * @since 3.2.000 (2008-06-23)
 	 * @public static
 	 */
-	public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont) {
+	public static function UTF8ToLatin1($str, $isunicode, &$currentfont) {
 		$unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values
 		return self::UTF8ArrToLatin1($unicode);
 	}
@@ -2036,7 +2037,7 @@
 	 * @since 1.53.0.TC005 (2005-01-05)
 	 * @public static
 	 */
-	public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont) {
+	public static function UTF8ToUTF16BE($str, $setbom, $isunicode, &$currentfont) {
 		if (!$isunicode) {
 			return $str; // string is not in unicode
 		}
@@ -2056,7 +2057,7 @@
 	 * @since 2.1.000 (2008-01-08)
 	 * @public static
 	 */
-	public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) {
+	public static function utf8StrRev($str, $setbom, $forcertl, $isunicode, &$currentfont) {
 		return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont);
 	}
 
@@ -2073,7 +2074,7 @@
 	 * @since 4.9.000 (2010-03-27)
 	 * @public static
 	 */
-	public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) {
+	public static function utf8StrArrRev($arr, $str, $setbom, $forcertl, $isunicode, &$currentfont) {
 		return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom);
 	}
 
@@ -2089,7 +2090,7 @@
 	 * @since 2.4.000 (2008-03-06)
 	 * @public static
 	 */
-	public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont) {
+	public static function utf8Bidi($ta, $str, $forcertl, $isunicode, &$currentfont) {
 		// paragraph embedding level
 		$pel = 0;
 		// max level
@@ -2099,18 +2100,18 @@
 			$str = self::UTF8ArrSubString($ta, '', '', $isunicode);
 		}
 		// check if string contains arabic text
-		if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $str)) {
+		if (preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC ?? ''), ($str ?? ''))) {
 			$arabic = true;
 		} else {
 			$arabic = false;
 		}
 		// check if string contains RTL text
-		if (!($forcertl OR $arabic OR preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $str))) {
+		if (!($forcertl OR $arabic OR preg_match((TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL ?? ''), ($str ?? '')))) {
 			return $ta;
 		}
 
 		// get number of chars
-		$numchars = count($ta);
+		$numchars = count(($ta ?? []));
 
 		if ($forcertl == 'R') {
 			$pel = 1;
@@ -2196,8 +2197,8 @@
 				}
 			} elseif ($ta[$i] == TCPDF_FONT_DATA::$uni_PDF) {
 				// X7. With each PDF, determine the matching embedding or override code. If there was a valid matching code, restore (pop) the last remembered (pushed) embedding level and directional override.
-				if (count($remember)) {
-					$last = count($remember ) - 1;
+				if (count(($remember ?? []))) {
+					$last = count(($remember ?? []) ) - 1;
 					if (($remember[$last]['num'] == TCPDF_FONT_DATA::$uni_RLE) OR
 						($remember[$last]['num'] == TCPDF_FONT_DATA::$uni_LRE) OR
 						($remember[$last]['num'] == TCPDF_FONT_DATA::$uni_RLO) OR
@@ -2238,7 +2239,7 @@
 		// 3.3.3 Resolving Weak Types
 		// Weak types are now resolved one level run at a time. At level run boundaries where the type of the character on the other side of the boundary is required, the type assigned to sor or eor is used.
 		// Nonspacing marks are now resolved based on the previous characters.
-		$numchars = count($chardata);
+		$numchars = count(($chardata ?? []));
 
 		// W1. Examine each nonspacing mark (NSM) in the level run, and change the type of the NSM to the type of the previous character. If the NSM is at the start of the level run, it will get the type of sor.
 		$prevlevel = -1; // track level changes
@@ -2601,7 +2602,7 @@
 				}
 			}
 			$chardata = array_values($chardata2);
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			unset($chardata2);
 			unset($arabicarr);
 			unset($laaletter);
--- a/intranet/tcpdf/include/tcpdf_filters.php
+++ b/intranet/tcpdf/include/tcpdf_filters.php
@@ -151,27 +151,27 @@
 		// initialize string to return
 		$decoded = '';
 		// all white-space characters shall be ignored
-		$data = preg_replace('/[\s]/', '', $data);
+		$data = preg_replace('/[\s]/', '', ($data ?? ''));
 		// check for EOD character: GREATER-THAN SIGN (3Eh)
-		$eod = strpos($data, '>');
+		$eod = strpos(($data ?? ''), '>');
 		if ($eod !== false) {
 			// remove EOD and extra data (if any)
-			$data = substr($data, 0, $eod);
+			$data = substr(($data ?? ''), 0, $eod);
 			$eod = true;
 		}
 		// get data length
-		$data_length = strlen($data);
+		$data_length = strlen(($data ?? ''));
 		if (($data_length % 2) != 0) {
 			// odd number of hexadecimal digits
 			if ($eod) {
 				// EOD shall behave as if a 0 (zero) followed the last digit
-				$data = substr($data, 0, -1).'0'.substr($data, -1);
+				$data = substr(($data ?? ''), 0, -1).'0'.substr(($data ?? ''), -1);
 			} else {
 				self::Error('decodeFilterASCIIHexDecode: invalid code');
 			}
 		}
 		// check for invalid characters
-		if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
+		if (preg_match('/[^a-fA-F\d]/', ($data ?? '')) > 0) {
 			self::Error('decodeFilterASCIIHexDecode: invalid code');
 		}
 		// get one byte of binary data for each pair of ASCII hexadecimal digits
@@ -191,22 +191,22 @@
 		// initialize string to return
 		$decoded = '';
 		// all white-space characters shall be ignored
-		$data = preg_replace('/[\s]/', '', $data);
+		$data = preg_replace('/[\s]/', '', ($data ?? ''));
 		// remove start sequence 2-character sequence <~ (3Ch)(7Eh)
-		if (strpos($data, '<~') !== false) {
+		if (strpos(($data ?? ''), '<~') !== false) {
 			// remove EOD and extra data (if any)
-			$data = substr($data, 2);
+			$data = substr(($data ?? ''), 2);
 		}
 		// check for EOD: 2-character sequence ~> (7Eh)(3Eh)
-		$eod = strpos($data, '~>');
+		$eod = strpos(($data ?? ''), '~>');
 		if ($eod !== false) {
 			// remove EOD and extra data (if any)
-			$data = substr($data, 0, $eod);
+			$data = substr(($data ?? ''), 0, $eod);
 		}
 		// data length
-		$data_length = strlen($data);
+		$data_length = strlen(($data ?? ''));
 		// check for invalid characters
-		if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
+		if (preg_match('/[^\x21-\x75,\x74]/', ($data ?? '')) > 0) {
 			self::Error('decodeFilterASCII85Decode: invalid code');
 		}
 		// z sequence
@@ -219,7 +219,7 @@
 		// for each byte
 		for ($i = 0; $i < $data_length; ++$i) {
 			// get char value
-			$char = ord($data[$i]);
+			$char = ord(($data[$i] ?? ''));
 			if ($char == 122) { // 'z'
 				if ($group_pos == 0) {
 					$decoded .= $zseq;
@@ -230,7 +230,7 @@
 				// the value represented by a group of 5 characters should never be greater than 2^32 - 1
 				$tuple += (($char - 33) * $pow85[$group_pos]);
 				if ($group_pos == 4) {
-					$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
+					$decoded .= chr((int) ($tuple >> 24)).chr((int) ($tuple >> 16)).chr((int) ($tuple >> 8)).chr((int) ($tuple));
 					$tuple = 0;
 					$group_pos = 0;
 				} else {
@@ -244,15 +244,15 @@
 		// last tuple (if any)
 		switch ($group_pos) {
 			case 4: {
-				$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
+				$decoded .= chr((int) ($tuple >> 24)).chr((int) ($tuple >> 16)).chr((int) ($tuple >> 8));
 				break;
 			}
 			case 3: {
-				$decoded .= chr($tuple >> 24).chr($tuple >> 16);
+				$decoded .= chr((int) ($tuple >> 24)).chr((int) ($tuple >> 16));
 				break;
 			}
 			case 2: {
-				$decoded .= chr($tuple >> 24);
+				$decoded .= chr((int) ($tuple >> 24));
 				break;
 			}
 			case 1: {
@@ -275,14 +275,14 @@
 		// initialize string to return
 		$decoded = '';
 		// data length
-		$data_length = strlen($data);
+		$data_length = strlen(($data ?? ''));
 		// convert string to binary string
 		$bitstring = '';
 		for ($i = 0; $i < $data_length; ++$i) {
-			$bitstring .= sprintf('%08b', ord($data{$i}));
+			$bitstring .= sprintf('%08b', ord(($data[$i] ?? '')));
 		}
 		// get the number of bits
-		$data_length = strlen($bitstring);
+		$data_length = strlen(($bitstring ?? ''));
 		// initialize code length in bits
 		$bitlen = 9;
 		// initialize dictionary index
@@ -290,14 +290,14 @@
 		// initialize the dictionary (with the first 256 entries).
 		$dictionary = array();
 		for ($i = 0; $i < 256; ++$i) {
-			$dictionary[$i] = chr($i);
+			$dictionary[$i] = chr((int) ($i));
 		}
 		// previous val
 		$prev_index = 0;
 		// while we encounter EOD marker (257), read code_length bits
-		while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
+		while (($data_length > 0) AND (($index = bindec(substr(($bitstring ?? ''), 0, $bitlen))) != 257)) {
 			// remove read bits from string
-			$bitstring = substr($bitstring, $bitlen);
+			$bitstring = substr(($bitstring ?? ''), $bitlen);
 			// update number of bits
 			$data_length -= $bitlen;
 			if ($index == 256) { // clear-table marker
@@ -309,7 +309,7 @@
 				// reset the dictionary (with the first 256 entries).
 				$dictionary = array();
 				for ($i = 0; $i < 256; ++$i) {
-					$dictionary[$i] = chr($i);
+					$dictionary[$i] = chr((int) ($i));
 				}
 			} elseif ($prev_index == 256) {
 				// first entry
@@ -372,24 +372,24 @@
 		// initialize string to return
 		$decoded = '';
 		// data length
-		$data_length = strlen($data);
+		$data_length = strlen(($data ?? ''));
 		$i = 0;
 		while($i < $data_length) {
 			// get current byte value
-			$byte = ord($data{$i});
+			$byte = ord(($data[$i] ?? ''));
 			if ($byte == 128) {
 				// a length value of 128 denote EOD
 				break;
 			} elseif ($byte < 128) {
 				// if the length byte is in the range 0 to 127
 				// the following length + 1 (1 to 128) bytes shall be copied literally during decompression
-				$decoded .= substr($data, ($i + 1), ($byte + 1));
+				$decoded .= substr(($data ?? ''), ($i + 1), ($byte + 1));
 				// move to next block
 				$i += ($byte + 2);
 			} else {
 				// if length is in the range 129 to 255,
 				// the following single byte shall be copied 257 - length (2 to 128) times during decompression
-				$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
+				$decoded .= str_repeat(($data[($i + 1)] ?? ''), (257 - $byte));
 				// move to next block
 				$i += 2;
 			}
--- a/intranet/tcpdf/include/tcpdf_colors.php
+++ b/intranet/tcpdf/include/tcpdf_colors.php
@@ -250,11 +250,11 @@
 		if (isset($spotc[$name])) {
 			return $spotc[$name];
 		}
-		$color = preg_replace('/[\s]*/', '', $name); // remove extra spaces
-		$color = strtolower($color);
+		$color = preg_replace('/[\s]*/', '', ($name ?? '')); // remove extra spaces
+		$color = strtolower(($color ?? ''));
 		if (isset(self::$spotcolor[$color])) {
 			if (!isset($spotc[$name])) {
-				$i = (1 + count($spotc));
+				$i = (1 + count(($spotc ?? [])));
 				$spotc[$name] = array('C' => self::$spotcolor[$color][0], 'M' => self::$spotcolor[$color][1], 'Y' => self::$spotcolor[$color][2], 'K' => self::$spotcolor[$color][3], 'name' => self::$spotcolor[$color][4], 'i' => $i);
 			}
 			return $spotc[self::$spotcolor[$color][4]];
@@ -271,11 +271,11 @@
 	 * @public static
 	 */
 	public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'=>128,'G'=>128,'B'=>128)) {
-		$color = preg_replace('/[\s]*/', '', $hcolor); // remove extra spaces
-		$color = strtolower($color);
+		$color = preg_replace('/[\s]*/', '', ($hcolor ?? '')); // remove extra spaces
+		$color = strtolower(($color ?? ''));
 		// check for javascript color array syntax
-		if (strpos($color, '[') !== false) {
-			if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\]]/', $color, $m) > 0) {
+		if (strpos(($color ?? ''), '[') !== false) {
+			if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\]]/', ($color ?? ''), $m) > 0) {
 				$returncolor = array();
 				switch ($m[1]) {
 					case 'cmyk': {
@@ -306,24 +306,24 @@
 				}
 				return $returncolor;
 			}
-		} elseif ((substr($color, 0, 4) != 'cmyk') AND (substr($color, 0, 3) != 'rgb') AND (($dotpos = strpos($color, '.')) !== false)) {
+		} elseif ((substr(($color ?? ''), 0, 4) != 'cmyk') AND (substr(($color ?? ''), 0, 3) != 'rgb') AND (($dotpos = strpos(($color ?? ''), '.')) !== false)) {
 			// remove class parent (i.e.: color.red)
-			$color = substr($color, ($dotpos + 1));
+			$color = substr(($color ?? ''), ($dotpos + 1));
 			if ($color == 'transparent') {
 				// transparent (empty array)
 				return array();
 			}
 		}
-		if (strlen($color) == 0) {
+		if (strlen(($color ?? '')) == 0) {
 			return $defcol;
 		}
 		// RGB ARRAY
-		if (substr($color, 0, 3) == 'rgb') {
-			$codes = substr($color, 4);
-			$codes = str_replace(')', '', $codes);
-			$returncolor = explode(',', $codes);
+		if (substr(($color ?? ''), 0, 3) == 'rgb') {
+			$codes = substr(($color ?? ''), 4);
+			$codes = str_replace(')', '', ($codes ?? ''));
+			$returncolor = explode(',', ($codes ?? ''));
 			foreach ($returncolor as $key => $val) {
-				if (strpos($val, '%') > 0) {
+				if (strpos(($val ?? ''), '%') > 0) {
 					// percentage
 					$returncolor[$key] = (255 * intval($val) / 100);
 				} else {
@@ -335,12 +335,12 @@
 			return $returncolor;
 		}
 		// CMYK ARRAY
-		if (substr($color, 0, 4) == 'cmyk') {
-			$codes = substr($color, 5);
-			$codes = str_replace(')', '', $codes);
-			$returncolor = explode(',', $codes);
+		if (substr(($color ?? ''), 0, 4) == 'cmyk') {
+			$codes = substr(($color ?? ''), 5);
+			$codes = str_replace(')', '', ($codes ?? ''));
+			$returncolor = explode(',', ($codes ?? ''));
 			foreach ($returncolor as $key => $val) {
-				if (strpos($val, '%') !== false) {
+				if (strpos(($val ?? ''), '%') !== false) {
 					// percentage
 					$returncolor[$key] = (100 * intval($val) / 100);
 				} else {
@@ -365,15 +365,15 @@
 				return $returncolor;
 			}
 		} else {
-			$color_code = substr($color, 1);
+			$color_code = substr(($color ?? ''), 1);
 		}
 		// HEXADECIMAL REPRESENTATION
-		switch (strlen($color_code)) {
+		switch (strlen(($color_code ?? ''))) {
 			case 3: {
 				// 3-digit RGB hexadecimal representation
-				$r = substr($color_code, 0, 1);
-				$g = substr($color_code, 1, 1);
-				$b = substr($color_code, 2, 1);
+				$r = substr(($color_code ?? ''), 0, 1);
+				$g = substr(($color_code ?? ''), 1, 1);
+				$b = substr(($color_code ?? ''), 2, 1);
 				$returncolor = array();
 				$returncolor['R'] = max(0, min(255, hexdec($r.$r)));
 				$returncolor['G'] = max(0, min(255, hexdec($g.$g)));
@@ -383,18 +383,18 @@
 			case 6: {
 				// 6-digit RGB hexadecimal representation
 				$returncolor = array();
-				$returncolor['R'] = max(0, min(255, hexdec(substr($color_code, 0, 2))));
-				$returncolor['G'] = max(0, min(255, hexdec(substr($color_code, 2, 2))));
-				$returncolor['B'] = max(0, min(255, hexdec(substr($color_code, 4, 2))));
+				$returncolor['R'] = max(0, min(255, hexdec(substr(($color_code ?? ''), 0, 2))));
+				$returncolor['G'] = max(0, min(255, hexdec(substr(($color_code ?? ''), 2, 2))));
+				$returncolor['B'] = max(0, min(255, hexdec(substr(($color_code ?? ''), 4, 2))));
 				break;
 			}
 			case 8: {
 				// 8-digit CMYK hexadecimal representation
 				$returncolor = array();
-				$returncolor['C'] = max(0, min(100, round(hexdec(substr($color_code, 0, 2)) / 2.55)));
-				$returncolor['M'] = max(0, min(100, round(hexdec(substr($color_code, 2, 2)) / 2.55)));
-				$returncolor['Y'] = max(0, min(100, round(hexdec(substr($color_code, 4, 2)) / 2.55)));
-				$returncolor['K'] = max(0, min(100, round(hexdec(substr($color_code, 6, 2)) / 2.55)));
+				$returncolor['C'] = max(0, min(100, round(hexdec(substr(($color_code ?? ''), 0, 2)) / 2.55)));
+				$returncolor['M'] = max(0, min(100, round(hexdec(substr(($color_code ?? ''), 2, 2)) / 2.55)));
+				$returncolor['Y'] = max(0, min(100, round(hexdec(substr(($color_code ?? ''), 4, 2)) / 2.55)));
+				$returncolor['K'] = max(0, min(100, round(hexdec(substr(($color_code ?? ''), 6, 2)) / 2.55)));
 				break;
 			}
 			default: {
@@ -415,7 +415,7 @@
 	public static function getColorStringFromArray($c) {
 		$c = array_values($c);
 		$color = '[';
-		switch (count($c)) {
+		switch (count(($c ?? []))) {
 			case 4: {
 				// CMYK
 				$color .= sprintf('%F %F %F %F', (max(0, min(100, floatval($c[0]))) / 100), (max(0, min(100, floatval($c[1]))) / 100), (max(0, min(100, floatval($c[2]))) / 100), (max(0, min(100, floatval($c[3]))) / 100));
@@ -444,8 +444,8 @@
 	 * @public static
 	 */
 	public static function _JScolor($color) {
-		if (substr($color, 0, 1) == '#') {
-			return sprintf("['RGB',%F,%F,%F]", (hexdec(substr($color, 1, 2)) / 255), (hexdec(substr($color, 3, 2)) / 255), (hexdec(substr($color, 5, 2)) / 255));
+		if (substr(($color ?? ''), 0, 1) == '#') {
+			return sprintf("['RGB',%F,%F,%F]", (hexdec(substr(($color ?? ''), 1, 2)) / 255), (hexdec(substr(($color ?? ''), 3, 2)) / 255), (hexdec(substr(($color ?? ''), 5, 2)) / 255));
 		}
 		if (!in_array($color, self::$jscolor)) {
 			// default transparent color
--- a/intranet/tcpdf/include/tcpdf_images.php
+++ b/intranet/tcpdf/include/tcpdf_images.php
@@ -71,15 +71,15 @@
 	public static function getImageFileType($imgfile, $iminfo=array()) {
 		$type = '';
 		if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
-			$mime = explode('/', $iminfo['mime']);
-			if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
-				$type = strtolower(trim($mime[1]));
+			$mime = explode('/', ($iminfo['mime'] ?? ''));
+			if ((count(($mime ?? [])) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
+				$type = strtolower((trim(($mime[1] ?? '')) ?? ''));
 			}
 		}
 		if (empty($type)) {
 			$fileinfo = pathinfo($imgfile);
 			if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
-				$type = strtolower(trim($fileinfo['extension']));
+				$type = strtolower((trim(($fileinfo['extension'] ?? '')) ?? ''));
 			}
 		}
 		if ($type == 'jpg') {
@@ -104,10 +104,10 @@
 		$palletsize = imagecolorstotal($image);
 		if (($tid >= 0) AND ($tid < $palletsize)) {
 			// get the colors for the transparency index
-			$tcol = imagecolorsforindex($image, $tid);
-		}
-		$tid = imagecolorallocate($new_image, $tcol['red'], $tcol['green'], $tcol['blue']);
-		imagefill($new_image, 0, 0, $tid);
+			$tcol = imagecolorsforindex($image, (int) ($tid));
+		}
+		$tid = imagecolorallocate($new_image, (int) ($tcol['red']), (int) ($tcol['green']), (int) ($tcol['blue']));
+		imagefill($new_image, 0, 0, (int) ($tid));
 		imagecolortransparent($new_image, $tid);
 		return $new_image;
 	}
@@ -145,7 +145,7 @@
 	 * @public static
 	 */
 	public static function _toJPEG($image, $quality, $tempfile) {
-		imagejpeg($image, $tempfile, $quality);
+		imagejpeg($image, $tempfile, (int) ($quality));
 		imagedestroy($image);
 		$retvars = self::_parsejpeg($tempfile);
 		// tidy up by removing temporary image
@@ -202,27 +202,27 @@
 			}
 		}
 		// get file content
-		$data = file_get_contents($file);
+		$data = file_get_contents(($file ?? ''));
 		// check for embedded ICC profile
 		$icc = array();
 		$offset = 0;
-		while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
+		while (($pos = strpos(($data ?? ''), "ICC_PROFILE\0", $offset)) !== false) {
 			// get ICC sequence length
 			$length = (TCPDF_STATIC::_getUSHORT($data, ($pos - 2)) - 16);
 			// marker sequence number
-			$msn = max(1, ord($data[($pos + 12)]));
+			$msn = max(1, ord(($data[($pos + 12)] ?? '')));
 			// number of markers (total of APP2 used)
-			$nom = max(1, ord($data[($pos + 13)]));
+			$nom = max(1, ord(($data[($pos + 13)] ?? '')));
 			// get sequence segment
-			$icc[($msn - 1)] = substr($data, ($pos + 14), $length);
+			$icc[($msn - 1)] = substr(($data ?? ''), ($pos + 14), $length);
 			// move forward to next sequence
 			$offset = ($pos + 14 + $length);
 		}
 		// order and compact ICC segments
-		if (count($icc) > 0) {
+		if (count(($icc ?? [])) > 0) {
 			ksort($icc);
 			$icc = implode('', $icc);
-			if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
+			if ((ord(($icc[36] ?? '')) != 0x61) OR (ord(($icc[37] ?? '')) != 0x63) OR (ord(($icc[38] ?? '')) != 0x73) OR (ord(($icc[39] ?? '')) != 0x70)) {
 				// invalid ICC profile
 				$icc = false;
 			}
@@ -257,8 +257,8 @@
 		}
 		$w = TCPDF_STATIC::_freadint($f);
 		$h = TCPDF_STATIC::_freadint($f);
-		$bpc = ord(fread($f, 1));
-		$ct = ord(fread($f, 1));
+		$bpc = ord((fread($f, 1) ?? ''));
+		$ct = ord((fread($f, 1) ?? ''));
 		if ($ct == 0) {
 			$colspace = 'DeviceGray';
 		} elseif ($ct == 2) {
@@ -270,17 +270,17 @@
 			fclose($f);
 			return 'pngalpha';
 		}
-		if (ord(fread($f, 1)) != 0) {
+		if (ord((fread($f, 1) ?? '')) != 0) {
 			// Unknown compression method
 			fclose($f);
 			return false;
 		}
-		if (ord(fread($f, 1)) != 0) {
+		if (ord((fread($f, 1) ?? '')) != 0) {
 			// Unknown filter method
 			fclose($f);
 			return false;
 		}
-		if (ord(fread($f, 1)) != 0) {
+		if (ord((fread($f, 1) ?? '')) != 0) {
 			// Interlacing not supported
 			fclose($f);
 			return false;
@@ -304,14 +304,14 @@
 				// read transparency info
 				$t = TCPDF_STATIC::rfread($f, $n);
 				if ($ct == 0) { // DeviceGray
-					$trns = array(ord($t[1]));
+					$trns = array(ord(($t[1] ?? '')));
 				} elseif ($ct == 2) { // DeviceRGB
-					$trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
+					$trns = array(ord(($t[1] ?? '')), ord(($t[3] ?? '')), ord(($t[5] ?? '')));
 				} else { // Indexed
 					if ($n > 0) {
 						$trns = array();
 						for ($i = 0; $i < $n; ++ $i) {
-							$trns[] = ord($t{$i});
+							$trns[] = ord(($t[$i] ?? ''));
 						}
 					}
 				}
@@ -323,11 +323,11 @@
 			} elseif ($type == 'iCCP') {
 				// skip profile name
 				$len = 0;
-				while ((ord(fread($f, 1)) != 0) AND ($len < 80)) {
+				while ((ord((fread($f, 1) ?? '')) != 0) AND ($len < 80)) {
 					++$len;
 				}
 				// get compression method
-				if (ord(fread($f, 1)) != 0) {
+				if (ord((fread($f, 1) ?? '')) != 0) {
 					// Unknown filter method
 					fclose($f);
 					return false;
--- a/intranet/tcpdf/include/barcodes/pdf417.php
+++ b/intranet/tcpdf/include/barcodes/pdf417.php
@@ -546,7 +546,7 @@
 			array_shift($codewords);
 		}
 		// count number of codewords
-		$numcw = count($codewords);
+		$numcw = count(($codewords ?? []));
 		if ($numcw > 925) {
 			// reached maximum data codeword capacity
 			return false;
@@ -583,7 +583,7 @@
 				$macrocw[] = 922;
 			}
 			// update total codewords
-			$numcw += count($macrocw);
+			$numcw += count(($macrocw ?? []));
 		}
 		// set error correction level
 		$ecl = $this->getErrorCorrectionLevel($ecl, $numcw);
@@ -704,7 +704,7 @@
 			// row stop code
 			$row .= $pstop;
 			// convert the string to array
-			$arow = preg_split('//', $row, -1, PREG_SPLIT_NO_EMPTY);
+			$arow = preg_split('//', ($row ?? ''), -1, PREG_SPLIT_NO_EMPTY);
 			// duplicate row to get the desired height
 			for ($h = 0; $h < ROWHEIGHT; ++$h) {
 				$barcode_array['bcode'][] = $arow;
@@ -817,29 +817,29 @@
 		$sequence_array = array(); // array to be returned
 		$numseq = array();
 		// get numeric sequences
-		preg_match_all('/([0-9]{13,44})/', $code, $numseq, PREG_OFFSET_CAPTURE);
-		$numseq[1][] = array('', strlen($code));
+		preg_match_all('/([0-9]{13,44})/', ($code ?? ''), $numseq, PREG_OFFSET_CAPTURE);
+		$numseq[1][] = array('', strlen(($code ?? '')));
 		$offset = 0;
 		foreach($numseq[1] as $seq) {
-			$seqlen = strlen($seq[0]);
+			$seqlen = strlen(($seq[0] ?? ''));
 			if ($seq[1] > 0) {
 				// extract text sequence before the number sequence
-				$prevseq = substr($code, $offset, ($seq[1] - $offset));
+				$prevseq = substr(($code ?? ''), $offset, ($seq[1] - $offset));
 				$textseq = array();
 				// get text sequences
-				preg_match_all('/([\x09\x0a\x0d\x20-\x7e]{5,})/', $prevseq, $textseq, PREG_OFFSET_CAPTURE);
-				$textseq[1][] = array('', strlen($prevseq));
+				preg_match_all('/([\x09\x0a\x0d\x20-\x7e]{5,})/', ($prevseq ?? ''), $textseq, PREG_OFFSET_CAPTURE);
+				$textseq[1][] = array('', strlen(($prevseq ?? '')));
 				$txtoffset = 0;
 				foreach($textseq[1] as $txtseq) {
-					$txtseqlen = strlen($txtseq[0]);
+					$txtseqlen = strlen(($txtseq[0] ?? ''));
 					if ($txtseq[1] > 0) {
 						// extract byte sequence before the text sequence
-						$prevtxtseq = substr($prevseq, $txtoffset, ($txtseq[1] - $txtoffset));
-						if (strlen($prevtxtseq) > 0) {
+						$prevtxtseq = substr(($prevseq ?? ''), $txtoffset, ($txtseq[1] - $txtoffset));
+						if (strlen(($prevtxtseq ?? '')) > 0) {
 							// add BYTE sequence
-							if ((strlen($prevtxtseq) == 1) AND ((count($sequence_array) > 0) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) {
+							if ((strlen(($prevtxtseq ?? '')) == 1) AND ((count(($sequence_array ?? [])) > 0) AND ($sequence_array[(count(($sequence_array ?? [])) - 1)][0] == 900))) {
 								$sequence_array[] = array(913, $prevtxtseq);
-							} elseif ((strlen($prevtxtseq) % 6) == 0) {
+							} elseif ((strlen(($prevtxtseq ?? '')) % 6) == 0) {
 								$sequence_array[] = array(924, $prevtxtseq);
 							} else {
 								$sequence_array[] = array(901, $prevtxtseq);
@@ -876,9 +876,9 @@
 			case 900: { // Text Compaction mode latch
 				$submode = 0; // default Alpha sub-mode
 				$txtarr = array(); // array of characters and sub-mode switching characters
-				$codelen = strlen($code);
+				$codelen = strlen(($code ?? ''));
 				for ($i = 0; $i < $codelen; ++$i) {
-					$chval = ord($code{$i});
+					$chval = ord(($code[$i] ?? ''));
 					if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) {
 						// we are on the same sub-mode
 						$txtarr[] = $k;
@@ -888,7 +888,7 @@
 							// search new sub-mode
 							if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) {
 								// $s is the new submode
-								if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code{($i + 1)}), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) {
+								if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord(($code[($i + 1)] ?? '')), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) {
 									// shift (temporary change only for this char)
 									if ($s == 3) {
 										// shift to puntuaction
@@ -910,7 +910,7 @@
 						}
 					}
 				}
-				$txtarrlen = count($txtarr);
+				$txtarrlen = count(($txtarr ?? []));
 				if (($txtarrlen % 2) != 0) {
 					// add padding
 					$txtarr[] = 29;
@@ -924,22 +924,22 @@
 			}
 			case 901:
 			case 924: { // Byte Compaction mode latch
-				while (($codelen = strlen($code)) > 0) {
+				while (($codelen = strlen(($code ?? ''))) > 0) {
 					if ($codelen > 6) {
-						$rest = substr($code, 6);
-						$code = substr($code, 0, 6);
+						$rest = substr(($code ?? ''), 6);
+						$code = substr(($code ?? ''), 0, 6);
 						$sublen = 6;
 					} else {
 						$rest = '';
-						$sublen = strlen($code);
+						$sublen = strlen(($code ?? ''));
 					}
 					if ($sublen == 6) {
-						$t = bcmul(''.ord($code[0]), '1099511627776');
-						$t = bcadd($t, bcmul(''.ord($code[1]), '4294967296'));
-						$t = bcadd($t, bcmul(''.ord($code[2]), '16777216'));
-						$t = bcadd($t, bcmul(''.ord($code[3]), '65536'));
-						$t = bcadd($t, bcmul(''.ord($code[4]), '256'));
-						$t = bcadd($t, ''.ord($code[5]));
+						$t = bcmul(''.ord(($code[0] ?? '')), '1099511627776');
+						$t = bcadd($t, bcmul(''.ord(($code[1] ?? '')), '4294967296'));
+						$t = bcadd($t, bcmul(''.ord(($code[2] ?? '')), '16777216'));
+						$t = bcadd($t, bcmul(''.ord(($code[3] ?? '')), '65536'));
+						$t = bcadd($t, bcmul(''.ord(($code[4] ?? '')), '256'));
+						$t = bcadd($t, ''.ord(($code[5] ?? '')));
 						// tmp array for the 6 bytes block
 						$cw6 = array();
 						do {
@@ -952,7 +952,7 @@
 						$cw = array_merge($cw, $cw6);
 					} else {
 						for ($i = 0; $i < $sublen; ++$i) {
-							$cw[] = ord($code{$i});
+							$cw[] = ord(($code[$i] ?? ''));
 						}
 					}
 					$code = $rest;
@@ -960,10 +960,10 @@
 				break;
 			}
 			case 902: { // Numeric Compaction mode latch
-				while (($codelen = strlen($code)) > 0) {
+				while (($codelen = strlen(($code ?? ''))) > 0) {
 					if ($codelen > 44) {
-						$rest = substr($code, 44);
-						$code = substr($code, 0, 44);
+						$rest = substr(($code ?? ''), 44);
+						$code = substr(($code ?? ''), 0, 44);
 					} else {
 						$rest = '';
 					}
@@ -978,7 +978,7 @@
 				break;
 			}
 			case 913: { // Byte Compaction mode shift
-				$cw[] = ord($code);
+				$cw[] = ord(($code ?? ''));
 				break;
 			}
 		}
--- a/intranet/tcpdf/include/barcodes/datamatrix.php
+++ b/intranet/tcpdf/include/barcodes/datamatrix.php
@@ -240,7 +240,7 @@
 		// get data codewords
 		$cw = $this->getHighLevelEncoding($code);
 		// number of data codewords
-		$nd = count($cw);
+		$nd = count(($cw ?? []));
 		// check size
 		if ($nd > 1558) {
 			return false;
@@ -521,7 +521,7 @@
 	 * @protected
 	 */
 	protected function lookAheadTest($data, $pos, $mode) {
-		$data_length = strlen($data);
+		$data_length = strlen(($data ?? ''));
 		if ($pos >= $data_length) {
 			return $mode;
 		}
@@ -554,7 +554,7 @@
 				return ENC_C40;
 			}
 			// get char
-			$chr = ord($data[$pos + $charscount]);
+			$chr = ord(($data[$pos + $charscount] ?? ''));
 			$charscount++;
 			// STEP L
 			if ($this->isCharMode($chr, ENC_ASCII_NUM)) {
@@ -629,7 +629,7 @@
 					if ($numch[ENC_C40] == $numch[ENC_X12]) {
 						$k = ($pos + $charscount + 1);
 						while ($k < $data_length) {
-							$tmpchr = ord($data{$k});
+							$tmpchr = ord(($data[$k] ?? ''));
 							if ($this->isCharMode($tmpchr, ENC_X12)) {
 								return ENC_X12;
 							} elseif (!($this->isCharMode($tmpchr, ENC_X12) OR $this->isCharMode($tmpchr, ENC_C40))) {
@@ -710,15 +710,15 @@
 		$pos = 0; // current position
 		$cw = array(); // array of codewords to be returned
 		$cw_num = 0; // number of data codewords
-		$data_length = strlen($data); // number of chars
+		$data_length = strlen(($data ?? '')); // number of chars
 		while ($pos < $data_length) {
 			// set last used encoding
 			$this->last_enc = $enc;
 			switch ($enc) {
 				case ENC_ASCII: { // STEP B. While in ASCII encodation
-					if (($data_length > 1) AND ($pos < ($data_length - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) {
+					if (($data_length > 1) AND ($pos < ($data_length - 1)) AND ($this->isCharMode(ord(($data[$pos] ?? '')), ENC_ASCII_NUM) AND $this->isCharMode(ord(($data[$pos + 1] ?? '')), ENC_ASCII_NUM))) {
 						// 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode.
-						$cw[] = (intval(substr($data, $pos, 2)) + 130);
+						$cw[] = (intval(substr(($data ?? ''), $pos, 2)) + 130);
 						++$cw_num;
 						$pos += 2;
 					} else {
@@ -731,7 +731,7 @@
 							++$cw_num;
 						} else {
 							// get new byte
-							$chr = ord($data[$pos]);
+							$chr = ord(($data[$pos] ?? ''));
 							++$pos;
 							if ($this->isCharMode($chr, ENC_ASCII_EXT)) {
 								// 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character.
@@ -759,7 +759,7 @@
 					$charset = $this->chset[$set_id];
 					do {
 						// 2. process the next character in C40 encodation.
-						$chr = ord($data[$epos]);
+						$chr = ord(($data[$epos] ?? ''));
 						++$epos;
 						// check for extended character
 						if ($chr & 0x80) {
@@ -877,7 +877,7 @@
 					$newenc = $enc;
 					do {
 						// 2. process the next character in EDIFACT encodation.
-						$chr = ord($data[$epos]);
+						$chr = ord(($data[$epos] ?? ''));
 						if ($this->isCharMode($chr, ENC_EDF)) {
 							++$epos;
 							$temp_cw[] = $chr;
@@ -939,7 +939,7 @@
 							break; // exit from B256 mode
 						} else {
 							// 2. Otherwise, process the next character in Base 256 encodation.
-							$chr = ord($data[$pos]);
+							$chr = ord(($data[$pos] ?? ''));
 							++$pos;
 							$temp_cw[] = $chr;
 							++$field_length;
--- a/intranet/tcpdf/include/barcodes/qrcode.php
+++ b/intranet/tcpdf/include/barcodes/qrcode.php
@@ -258,11 +258,11 @@
 	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
 	 */
 	function str_split($string, $split_length=1) {
-		if ((strlen($string) > $split_length) OR (!$split_length)) {
+		if ((strlen(($string ?? '')) > $split_length) OR (!$split_length)) {
 			do {
-				$c = strlen($string);
-				$parts[] = substr($string, 0, $split_length);
-				$string = substr($string, $split_length);
+				$c = strlen(($string ?? ''));
+				$parts[] = substr(($string ?? ''), 0, $split_length);
+				$string = substr(($string ?? ''), $split_length);
 			} while ($string !== false);
 		} else {
 			$parts = array($string);
@@ -658,13 +658,13 @@
 			return false;
 		}
 		$qrTab = $this->binarize($this->data);
-		$size = count($qrTab);
+		$size = count(($qrTab ?? []));
 		$barcode_array['num_rows'] = $size;
 		$barcode_array['num_cols'] = $size;
 		$barcode_array['bcode'] = array();
 		foreach ($qrTab as $line) {
 			$arrAdd = array();
-			foreach (str_split($line) as $char) {
+			foreach (str_split(($line ?? '')) as $char) {
 				$arrAdd[] = ($char=='1')?1:0;
 			}
 			$barcode_array['bcode'][] = $arrAdd;
@@ -687,11 +687,11 @@
 	 * @return array frame in binary form
 	 */
 	protected function binarize($frame) {
-		$len = count($frame);
+		$len = count(($frame ?? []));
 		// the frame is square (width = height)
 		foreach ($frame as &$frameLine) {
 			for ($i=0; $i<$len; $i++) {
-				$frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0';
+				$frameLine[$i] = (ord(($frameLine[$i] ?? ''))&1)?'1':'0';
 			}
 		}
 		return $frame;
@@ -784,7 +784,7 @@
 	 * @param $val (int) value of the character to set
 	 */
 	protected function setFrameAt($at, $val) {
-		$this->frame[$at['y']][$at['x']] = chr($val);
+		$this->frame[$at['y']][$at['x']] = chr((int) ($val));
 	}
 
 	/**
@@ -793,7 +793,7 @@
 	 * @return value at specified position
 	 */
 	protected function getFrameAt($at) {
-		return ord($this->frame[$at['y']][$at['x']]);
+		return ord(($this->frame[$at['y']][$at['x']] ?? ''));
 	}
 
 	/**
@@ -843,7 +843,7 @@
 			}
 			$this->x = $x;
 			$this->y = $y;
-		} while(ord($this->frame[$y][$x]) & 0x80);
+		} while(ord(($this->frame[$y][$x] ?? '')) & 0x80);
 		return array('x'=>$x, 'y'=>$y);
 	}
 
@@ -948,11 +948,11 @@
 			} else {
 				$v = 0x84;
 			}
-			$frame[8][$width - 1 - $i] = chr($v);
+			$frame[8][$width - 1 - $i] = chr((int) ($v));
 			if ($i < 6) {
-				$frame[$i][8] = chr($v);
+				$frame[$i][8] = chr((int) ($v));
 			} else {
-				$frame[$i + 1][8] = chr($v);
+				$frame[$i + 1][8] = chr((int) ($v));
 			}
 			$format = $format >> 1;
 		}
@@ -963,11 +963,11 @@
 		} else {
 			$v = 0x84;
 		}
-		$frame[$width - 7 + $i][8] = chr($v);
+		$frame[$width - 7 + $i][8] = chr((int) ($v));
 		if ($i == 0) {
-			$frame[8][7] = chr($v);
+			$frame[8][7] = chr((int) ($v));
 		} else {
-			$frame[8][6 - $i] = chr($v);
+			$frame[8][6 - $i] = chr((int) ($v));
 		}
 		$format = $format >> 1;
 		}
@@ -1065,7 +1065,7 @@
 		$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
 		for ($y=0; $y<$width; ++$y) {
 			for ($x=0; $x<$width; ++$x) {
-				if (ord($frame[$y][$x]) & 0x80) {
+				if (ord(($frame[$y][$x] ?? '')) & 0x80) {
 					$bitMask[$y][$x] = 0;
 				} else {
 					$maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
@@ -1096,9 +1096,9 @@
 		for ($y=0; $y<$width; ++$y) {
 			for ($x=0; $x<$width; ++$x) {
 				if ($bitMask[$y][$x] == 1) {
-					$d[$y][$x] = chr(ord($s[$y][$x]) ^ ((int)($bitMask[$y][$x])));
-				}
-				$b += (int)(ord($d[$y][$x]) & 1);
+					$d[$y][$x] = chr((int) (ord(($s[$y][$x] ?? '')) ^ ((int)($bitMask[$y][$x]))));
+				}
+				$b += (int)(ord(($d[$y][$x] ?? '')) & 1);
 			}
 		}
 		return $b;
@@ -1167,18 +1167,18 @@
 			}
 			for ($x=0; $x<$width; ++$x) {
 				if (($x > 0) AND ($y > 0)) {
-					$b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
-					$w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
+					$b22 = ord(($frameY[$x] ?? '')) & ord(($frameY[$x-1] ?? '')) & ord(($frameYM[$x] ?? '')) & ord(($frameYM[$x-1] ?? ''));
+					$w22 = ord(($frameY[$x] ?? '')) | ord(($frameY[$x-1] ?? '')) | ord(($frameYM[$x] ?? '')) | ord(($frameYM[$x-1] ?? ''));
 					if (($b22 | ($w22 ^ 1)) & 1) {
 						$demerit += N2;
 					}
 				}
-				if (($x == 0) AND (ord($frameY[$x]) & 1)) {
+				if (($x == 0) AND (ord(($frameY[$x] ?? '')) & 1)) {
 					$this->runLength[0] = -1;
 					$head = 1;
 					$this->runLength[$head] = 1;
 				} elseif ($x > 0) {
-					if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
+					if ((ord(($frameY[$x] ?? '')) ^ ord(($frameY[$x-1] ?? ''))) & 1) {
 						$head++;
 						$this->runLength[$head] = 1;
 					} else {
@@ -1192,12 +1192,12 @@
 			$head = 0;
 			$this->runLength[0] = 1;
 			for ($y=0; $y<$width; ++$y) {
-				if (($y == 0) AND (ord($frame[$y][$x]) & 1)) {
+				if (($y == 0) AND (ord(($frame[$y][$x] ?? '')) & 1)) {
 					$this->runLength[0] = -1;
 					$head = 1;
 					$this->runLength[$head] = 1;
 				} elseif ($y > 0) {
-					if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
+					if ((ord(($frame[$y][$x] ?? '')) ^ ord(($frame[$y-1][$x] ?? ''))) & 1) {
 						$head++;
 						$this->runLength[$head] = 1;
 					} else {
@@ -1225,7 +1225,7 @@
 		if (QR_FIND_FROM_RANDOM !== false) {
 			$howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
 			for ($i = 0; $i <  $howManuOut; ++$i) {
-				$remPos = rand (0, count($checked_masks)-1);
+				$remPos = rand (0, count(($checked_masks ?? []))-1);
 				unset($checked_masks[$remPos]);
 				$checked_masks = array_values($checked_masks);
 			}
@@ -1260,10 +1260,10 @@
 	 * @return boolean true of false
 	 */
 	 protected function isdigitat($str, $pos) {
-		if ($pos >= strlen($str)) {
+		if ($pos >= strlen(($str ?? ''))) {
 			return false;
 		}
-		return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
+		return ((ord(($str[$pos] ?? '')) >= ord('0'))&&(ord(($str[$pos] ?? '')) <= ord('9')));
 	}
 
 	/**
@@ -1273,10 +1273,10 @@
 	 * @return boolean true of false
 	 */
 	 protected function isalnumat($str, $pos) {
-		if ($pos >= strlen($str)) {
+		if ($pos >= strlen(($str ?? ''))) {
 			return false;
 		}
-		return ($this->lookAnTable(ord($str[$pos])) >= 0);
+		return ($this->lookAnTable(ord(($str[$pos] ?? ''))) >= 0);
 	}
 
 	/**
@@ -1285,7 +1285,7 @@
 	 * @return int mode
 	 */
 	 protected function identifyMode($pos) {
-		if ($pos >= strlen($this->dataStr)) {
+		if ($pos >= strlen(($this->dataStr ?? ''))) {
 			return QR_MODE_NL;
 		}
 		$c = $this->dataStr[$pos];
@@ -1294,9 +1294,9 @@
 		} elseif ($this->isalnumat($this->dataStr, $pos)) {
 			return QR_MODE_AN;
 		} elseif ($this->hint == QR_MODE_KJ) {
-			if ($pos+1 < strlen($this->dataStr)) {
+			if ($pos+1 < strlen(($this->dataStr ?? ''))) {
 				$d = $this->dataStr[$pos+1];
-				$word = (ord($c) << 8) | ord($d);
+				$word = (ord(($c ?? '')) << 8) | ord(($d ?? ''));
 				if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) {
 					return QR_MODE_KJ;
 				}
@@ -1333,7 +1333,7 @@
 				return $this->eatAn();
 			}
 		}
-		$this->items = $this->appendNewInputItem($this->items, QR_MODE_NM, $run, str_split($this->dataStr));
+		$this->items = $this->appendNewInputItem($this->items, QR_MODE_NM, $run, str_split(($this->dataStr ?? '')));
 		return $run;
 	}
 
@@ -1372,7 +1372,7 @@
 				return $this->eat8();
 			}
 		}
-		$this->items = $this->appendNewInputItem($this->items, QR_MODE_AN, $run, str_split($this->dataStr));
+		$this->items = $this->appendNewInputItem($this->items, QR_MODE_AN, $run, str_split(($this->dataStr ?? '')));
 		return $run;
 	}
 
@@ -1385,7 +1385,7 @@
 		while($this->identifyMode($p) == QR_MODE_KJ) {
 			$p += 2;
 		}
-		$this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr));
+		$this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split(($this->dataStr ?? '')));
 		return $run;
 	}
 
@@ -1397,7 +1397,7 @@
 		$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
 		$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
 		$p = 1;
-		$dataStrLen = strlen($this->dataStr);
+		$dataStrLen = strlen(($this->dataStr ?? ''));
 		while($p < $dataStrLen) {
 			$mode = $this->identifyMode($p);
 			if ($mode == QR_MODE_KJ) {
@@ -1434,7 +1434,7 @@
 			}
 		}
 		$run = $p;
-		$this->items = $this->appendNewInputItem($this->items, QR_MODE_8B, $run, str_split($this->dataStr));
+		$this->items = $this->appendNewInputItem($this->items, QR_MODE_8B, $run, str_split(($this->dataStr ?? '')));
 		return $run;
 	}
 
@@ -1443,7 +1443,7 @@
 	 * @return (int)
 	 */
 	 protected function splitString() {
-		while (strlen($this->dataStr) > 0) {
+		while (strlen(($this->dataStr ?? '')) > 0) {
 			$mode = $this->identifyMode(0);
 			switch ($mode) {
 				case QR_MODE_NM: {
@@ -1473,7 +1473,7 @@
 			if ($length < 0) {
 				return -1;
 			}
-			$this->dataStr = substr($this->dataStr, $length);
+			$this->dataStr = substr(($this->dataStr ?? ''), $length);
 		}
 		return 0;
 	}
@@ -1482,15 +1482,15 @@
 	 * toUpper
 	 */
 	 protected function toUpper() {
-		$stringLen = strlen($this->dataStr);
+		$stringLen = strlen(($this->dataStr ?? ''));
 		$p = 0;
 		while ($p < $stringLen) {
-			$mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint);
+			$mode = $this->identifyMode(substr(($this->dataStr ?? ''), $p), $this->hint);
 			if ($mode == QR_MODE_KJ) {
 				$p += 2;
 			} else {
-				if ((ord($this->dataStr[$p]) >= ord('a')) AND (ord($this->dataStr[$p]) <= ord('z'))) {
-					$this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32);
+				if ((ord(($this->dataStr[$p] ?? '')) >= ord('a')) AND (ord(($this->dataStr[$p] ?? '')) <= ord('z'))) {
+					$this->dataStr[$p] = chr((int) (ord(($this->dataStr[$p] ?? '')) - 32));
 				}
 				$p++;
 			}
@@ -1512,8 +1512,8 @@
 	 */
 	 protected function newInputItem($mode, $size, $data, $bstream=null) {
 		$setData = array_slice($data, 0, $size);
-		if (count($setData) < $size) {
-			$setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0));
+		if (count(($setData ?? [])) < $size) {
+			$setData = array_merge($setData, array_fill(0, ($size - count(($setData ?? []))), 0));
 		}
 		if (!$this->check($mode, $size, $setData)) {
 			return NULL;
@@ -1539,17 +1539,17 @@
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']);
 		for ($i=0; $i < $words; ++$i) {
-			$val  = (ord($inputitem['data'][$i*3  ]) - ord('0')) * 100;
-			$val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10;
-			$val += (ord($inputitem['data'][$i*3+2]) - ord('0'));
+			$val  = (ord(($inputitem['data'][$i*3  ] ?? '')) - ord('0')) * 100;
+			$val += (ord(($inputitem['data'][$i*3+1] ?? '')) - ord('0')) * 10;
+			$val += (ord(($inputitem['data'][$i*3+2] ?? '')) - ord('0'));
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val);
 		}
 		if ($inputitem['size'] - $words * 3 == 1) {
-			$val = ord($inputitem['data'][$words*3]) - ord('0');
+			$val = ord(($inputitem['data'][$words*3] ?? '')) - ord('0');
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
 		} elseif (($inputitem['size'] - ($words * 3)) == 2) {
-			$val  = (ord($inputitem['data'][$words*3  ]) - ord('0')) * 10;
-			$val += (ord($inputitem['data'][$words*3+1]) - ord('0'));
+			$val  = (ord(($inputitem['data'][$words*3  ] ?? '')) - ord('0')) * 10;
+			$val += (ord(($inputitem['data'][$words*3+1] ?? '')) - ord('0'));
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val);
 		}
 		return $inputitem;
@@ -1567,12 +1567,12 @@
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02);
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']);
 		for ($i=0; $i < $words; ++$i) {
-			$val  = (int)($this->lookAnTable(ord($inputitem['data'][$i*2])) * 45);
-			$val += (int)($this->lookAnTable(ord($inputitem['data'][($i*2)+1])));
+			$val  = (int)($this->lookAnTable(ord(($inputitem['data'][$i*2] ?? ''))) * 45);
+			$val += (int)($this->lookAnTable(ord(($inputitem['data'][($i*2)+1] ?? ''))));
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val);
 		}
 		if ($inputitem['size'] & 1) {
-			$val = $this->lookAnTable(ord($inputitem['data'][($words * 2)]));
+			$val = $this->lookAnTable(ord(($inputitem['data'][($words * 2)] ?? '')));
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 6, $val);
 		}
 		return $inputitem;
@@ -1589,7 +1589,7 @@
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4);
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']);
 		for ($i=0; $i < $inputitem['size']; ++$i) {
-			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i]));
+			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord(($inputitem['data'][$i] ?? '')));
 		}
 		return $inputitem;
 	}
@@ -1605,7 +1605,7 @@
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8);
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2));
 		for ($i=0; $i<$inputitem['size']; $i+=2) {
-			$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]);
+			$val = (ord(($inputitem['data'][$i] ?? '')) << 8) | ord(($inputitem['data'][$i+1] ?? ''));
 			if ($val <= 0x9ffc) {
 				$val -= 0x8140;
 			} else {
@@ -1626,9 +1626,9 @@
 	 protected function encodeModeStructure($inputitem) {
 		$inputitem['bstream'] = array();
 		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x03);
-		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][1]) - 1);
-		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][0]) - 1);
-		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][2]));
+		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord(($inputitem['data'][1] ?? '')) - 1);
+		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord(($inputitem['data'][0] ?? '')) - 1);
+		$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord(($inputitem['data'][2] ?? '')));
 		return $inputitem;
 	}
 
@@ -1747,7 +1747,7 @@
 	 */
 	 protected function checkModeNum($size, $data) {
 		for ($i=0; $i<$size; ++$i) {
-			if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){
+			if ((ord(($data[$i] ?? '')) < ord('0')) OR (ord(($data[$i] ?? '')) > ord('9'))){
 				return false;
 			}
 		}
@@ -1771,7 +1771,7 @@
 	 */
 	 protected function checkModeAn($size, $data) {
 		for ($i=0; $i<$size; ++$i) {
-			if ($this->lookAnTable(ord($data[$i])) == -1) {
+			if ($this->lookAnTable(ord(($data[$i] ?? ''))) == -1) {
 				return false;
 			}
 		}
@@ -1841,7 +1841,7 @@
 			return false;
 		}
 		for ($i=0; $i<$size; $i+=2) {
-			$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
+			$val = (ord(($data[$i] ?? '')) << 8) | ord(($data[$i+1] ?? ''));
 			if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) {
 				return false;
 			}
@@ -2012,7 +2012,7 @@
 		$total = 0;
 		foreach ($items as $key => $item) {
 			$items[$key] = $this->encodeBitStream($item, $this->version);
-			$bits = count($items[$key]['bstream']);
+			$bits = count(($items[$key]['bstream'] ?? []));
 			$total += $bits;
 		}
 		return array($items, $total);
@@ -2056,7 +2056,7 @@
 	 	if (is_null($bstream)) {
 	 		return null;
 	 	}
-		$bits = count($bstream);
+		$bits = count(($bstream ?? []));
 		$maxwords = $this->getDataLength($this->version, $this->level);
 		$maxbits = $maxwords * 8;
 		if ($maxbits == $bits) {
@@ -2181,10 +2181,10 @@
 	 * @return array bitstream
 	 */
 	 protected function appendBitstream($bitstream, $append) {
-		if ((!is_array($append)) OR (count($append) == 0)) {
+		if ((!is_array($append)) OR (count(($append ?? [])) == 0)) {
 			return $bitstream;
 		}
-		if (count($bitstream) == 0) {
+		if (count(($bitstream ?? [])) == 0) {
 			return $append;
 		}
 		return array_values(array_merge($bitstream, $append));
@@ -2229,7 +2229,7 @@
 		if (is_null($bstream)) {
 	 		return null;
 	 	}
-		$size = count($bstream);
+		$size = count(($bstream ?? []));
 		if ($size == 0) {
 			return array();
 		}
@@ -2271,7 +2271,7 @@
 	 * @return array srctab
 	 */
 	 protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
-		$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
+		$srctab[$y] = substr_replace(($srctab[$y] ?? ''), ((($replLen !== false)?substr(($repl ?? ''),0,$replLen):$repl ?? '' ?? '')), $x, ($replLen !== false)?$replLen:strlen(($repl ?? '')));
 		return $srctab;
 	}
 
@@ -2383,7 +2383,7 @@
 	 * @return array spec
 	 */
 	protected function getEccSpec($version, $level, $spec) {
-		if (count($spec) < 5) {
+		if (count(($spec ?? [])) < 5) {
 			$spec = array(0, 0, 0, 0, 0);
 		}
 		$b1 = $this->eccTable[$version][$level][0];
@@ -2559,8 +2559,8 @@
 		// Timing pattern
 		$wo = $width - 15;
 		for ($i=1; $i < $wo; ++$i) {
-			$frame[6][7+$i] = chr(0x90 | ($i & 1));
-			$frame[7+$i][6] = chr(0x90 | ($i & 1));
+			$frame[6][7+$i] = chr((int) (0x90 | ($i & 1)));
+			$frame[7+$i][6] = chr((int) (0x90 | ($i & 1)));
 		}
 		// Alignment pattern
 		$frame = $this->putAlignmentPattern($version, $frame, $width);
@@ -2570,14 +2570,14 @@
 			$v = $vinf;
 			for ($x=0; $x<6; ++$x) {
 				for ($y=0; $y<3; ++$y) {
-					$frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
+					$frame[($width - 11)+$y][$x] = chr((int) (0x88 | ($v & 1)));
 					$v = $v >> 1;
 				}
 			}
 			$v = $vinf;
 			for ($y=0; $y<6; ++$y) {
 				for ($x=0; $x<3; ++$x) {
-					$frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
+					$frame[$y][$x+($width - 11)] = chr((int) (0x88 | ($v & 1)));
 					$v = $v >> 1;
 				}
 			}
--- a/intranet/tcpdf/examples/example_008.php
+++ b/intranet/tcpdf/examples/example_008.php
@@ -76,7 +76,7 @@
 $pdf->AddPage();
 
 // get esternal file content
-$utf8text = file_get_contents('data/utf8test.txt', false);
+$utf8text = file_get_contents('data/utf8test.txt', (false ?? false));
 
 // set color for text
 $pdf->SetTextColor(0, 63, 127);
--- a/intranet/tcpdf/examples/example_011.php
+++ b/intranet/tcpdf/examples/example_011.php
@@ -36,7 +36,7 @@
 		$lines = file($file);
 		$data = array();
 		foreach($lines as $line) {
-			$data[] = explode(';', chop($line));
+			$data[] = explode(';', (chop($line) ?? ''));
 		}
 		return $data;
 	}
@@ -51,7 +51,7 @@
 		$this->SetFont('', 'B');
 		// Header
 		$w = array(40, 35, 40, 45);
-		$num_headers = count($header);
+		$num_headers = count(($header ?? []));
 		for($i = 0; $i < $num_headers; ++$i) {
 			$this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
 		}
--- a/intranet/tcpdf/examples/example_010.php
+++ b/intranet/tcpdf/examples/example_010.php
@@ -76,7 +76,7 @@
 	public function ChapterBody($file, $mode=false) {
 		$this->selectColumn();
 		// get esternal file content
-		$content = file_get_contents($file, false);
+		$content = file_get_contents(($file ?? ''), (false ?? false));
 		// set font
 		$this->SetFont('times', '', 9);
 		$this->SetTextColor(50, 50, 50);
--- a/intranet/mpdf60/compress.php
+++ b/intranet/mpdf60/compress.php
@@ -81,7 +81,7 @@
 }
 
 $inc = $_POST['inc'];
-if (is_array($inc) && count($inc)>0 ) { 
+if (is_array($inc) && count(($inc ?? []))>0 ) { 
 	foreach($inc AS $i=>$v) {
 		$key = array_search($i, $excl);
 		unset($excl[$key]);
@@ -89,15 +89,15 @@
 }
 
 if (!defined('PHP_VERSION_ID')) {
-    $version = explode('.', PHP_VERSION);
+    $version = explode('.', (PHP_VERSION ?? ''));
     define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
 }
-if (PHP_VERSION_ID < 50300) { $mqr = @get_magic_quotes_runtime(); }
+if (PHP_VERSION_ID < 50300) { $mqr = @false; }
 	else { $mqr=0; }
-if ($mqr) { set_magic_quotes_runtime(0); }
+if ($mqr) { false; }
 
 $l = file('mpdf_source.php');
-if (!count($l)) { die("ERROR - Could not find mpdf_source.php file in current directory"); }
+if (!count(($l ?? []))) { die("ERROR - Could not find mpdf_source.php file in current directory"); }
 $exclflags = array();
 $x = '';
 
@@ -118,14 +118,14 @@
 foreach($l AS $k=>$ln) {
 	$exclude = false;
 	// *XXXXX*
-	preg_match_all("/\/\/ \*([A-Za-z\-]+)\*/", $ln, $m);
+	preg_match_all("/\/\/ \*([A-Za-z\-]+)\*/", ($ln ?? ''), $m);
 	foreach($m[1] AS $mm) {
 		if (in_array($mm, $excl)) {
 			$exclude = true;
 		}
 	}
 	/*-- XXXXX --*/
-	preg_match_all("/\/\*-- ([A-Za-z\-]+) --\*\//", $ln, $m);
+	preg_match_all("/\/\*-- ([A-Za-z\-]+) --\*\//", ($ln ?? ''), $m);
 	foreach($m[1] AS $mm) {
 		if (in_array($mm, $excl)) {
 			$exclflags[$mm] = true;
@@ -134,14 +134,14 @@
 	}
 	$exclflags = array_unique($exclflags);
 	/*-- END XXXX --*/
-	preg_match_all("/\/\*-- END ([A-Za-z\-]+) --\*\//", $ln, $m);
+	preg_match_all("/\/\*-- END ([A-Za-z\-]+) --\*\//", ($ln ?? ''), $m);
 	foreach($m[1] AS $mm) {
 		if (in_array($mm, $excl)) {
 			unset($exclflags[$mm]);
 		}
 		$exclude = true;
 	}
-	if (count($exclflags)==0 && !$exclude) { 
+	if (count(($exclflags ?? []))==0 && !$exclude) { 
 		$x .= $ln; 
 	}
 }
@@ -156,7 +156,7 @@
 }
 if (!$check) { die("ERROR - Could not write to mpdf.php file. Are permissions correctly set?"); }
 echo '<p><b>mPDF file generated successfully!</b></p>';
-echo '<div>mPDF file size '.number_format((strlen($x)/1024)).' kB</div>';
+echo '<div>mPDF file size '.number_format((strlen(($x ?? ''))/1024)).' kB</div>';
 
 unset($l);
 unset($x);
--- a/intranet/mpdf60/config_lang2fonts.php
+++ b/intranet/mpdf60/config_lang2fonts.php
@@ -16,15 +16,15 @@
 */
 
 function GetLangOpts($llcc, $adobeCJK, &$fontdata) {
-	$tags = preg_split('/-/',$llcc);
-	$lang = strtolower($tags[0]);
+	$tags = preg_split('/-/',($llcc ?? ''));
+	$lang = strtolower(($tags[0] ?? ''));
 	$country = '';
 	$script = '';
 	if (isset($tags[1]) && $tags[1]) { 
-		if (strlen($tags[1]) == 4) { $script = strtolower($tags[1]); }
-		else { $country = strtolower($tags[1]); }
+		if (strlen(($tags[1] ?? '')) == 4) { $script = strtolower(($tags[1] ?? '')); }
+		else { $country = strtolower(($tags[1] ?? '')); }
 	}
-	if (isset($tags[2]) && $tags[2]) { $country = strtolower($tags[2]); }
+	if (isset($tags[2]) && $tags[2]) { $country = strtolower(($tags[2] ?? '')); }
 
 	$unifont = "";
 	$coreSuitable = false;
--- a/intranet/mpdf60/mpdf.php
+++ b/intranet/mpdf60/mpdf.php
@@ -49,7 +49,7 @@
 define('FC_SMALLCAPS',512);
 
 
-if (!defined('_MPDF_PATH')) define('_MPDF_PATH', dirname(preg_replace('/\\\\/','/',__FILE__)) . '/');
+if (!defined('_MPDF_PATH')) define('_MPDF_PATH', dirname(preg_replace('/\\\\/','/',(__FILE__ ?? ''))) . '/');
 if (!defined('_MPDF_URI')) define('_MPDF_URI',_MPDF_PATH);
 
 require_once(_MPDF_PATH.'includes/functions.php');
@@ -82,12 +82,29 @@
 if (!function_exists("mb_strlen")) { die("Error - mPDF requires mb_string functions. Ensure that PHP is compiled with php_mbstring.dll enabled."); }
 
 if (!defined('PHP_VERSION_ID')) {
-    $version = explode('.', PHP_VERSION);
+    $version = explode('.', (PHP_VERSION ?? ''));
     define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
 }
 
+#[\AllowDynamicProperties]
 class mPDF
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $U;
+    public $baselineO;
+    public $tbrotForms;
+    public $res;
+    public $qrcode;
+    public $failedimages;
+    public $_tempimg;
+    public $_tempimglnk;
+    public $meter;
+    public $n_ocg_print;
+    public $n_ocg_view;
+    public $n_ocg_hidden;
+    public $n_js;
+    public $js;
+
 
 ///////////////////////////////
 // EXTERNAL (PUBLIC) VARIABLES
@@ -810,7 +827,7 @@
 // **********************************
 // **********************************
 
-function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
+function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
 
 /*-- BACKGROUNDS --*/
 		if (!class_exists('grad', false)) { include(_MPDF_PATH.'classes/grad.php'); }
@@ -959,7 +976,7 @@
 	$this->baselineS = 0.3;		// Sets default height for <strike> text as factor of fontsize
 	$this->baselineO = 1.1;		// Sets default height for overline text as factor of fontsize
 
-	$this->noImageFile = str_replace("\\","/",dirname(__FILE__)) . '/includes/no_image.jpg';
+	$this->noImageFile = str_replace("\\","/",(dirname(__FILE__) ?? '')) . '/includes/no_image.jpg';
 	$this->subPos = 0;
 	$this->normalLineheight = 1.3;	// This should be overridden in config.php - but it is so important a default value is put here
 	// These are intended as configuration variables, and should be set in config.php - which will override these values; 
@@ -1121,27 +1138,27 @@
 
 	$optcore = false;
 	$onlyCoreFonts = false;
-	if (preg_match('/([\-+])aCJK/i',$mode, $m)) {
-		$mode = preg_replace('/([\-+])aCJK/i','',$mode);	// mPDF 6
+	if (preg_match('/([\-+])aCJK/i',($mode ?? ''), $m)) {
+		$mode = preg_replace('/([\-+])aCJK/i','',($mode ?? ''));	// mPDF 6
 		if ($m[1]=='+') { $this->useAdobeCJK = true; }
 		else { $this->useAdobeCJK = false; }
 	}
 
-	if (strlen($mode)==1) {
+	if (strlen(($mode ?? ''))==1) {
 		if ($mode=='s') { $this->percentSubset = 100; $mode = ''; }
 		else if ($mode=='c') { $onlyCoreFonts = true; $mode = ''; }
 	}
-	else if (substr($mode,-2)=='-s') {
+	else if (substr(($mode ?? ''),-2)=='-s') {
 		$this->percentSubset = 100; 
-		$mode = substr($mode,0,strlen($mode)-2);
-	}
-	else if (substr($mode,-2)=='-c') {
+		$mode = substr(($mode ?? ''),0,strlen(($mode ?? ''))-2);
+	}
+	else if (substr(($mode ?? ''),-2)=='-c') {
 		$onlyCoreFonts = true;
-		$mode = substr($mode,0,strlen($mode)-2);
-	}
-	else if (substr($mode,-2)=='-x') {
+		$mode = substr(($mode ?? ''),0,strlen(($mode ?? ''))-2);
+	}
+	else if (substr(($mode ?? ''),-2)=='-x') {
 		$optcore = true;
-		$mode = substr($mode,0,strlen($mode)-2);
+		$mode = substr(($mode ?? ''),0,strlen(($mode ?? ''))-2);
 	}
 
 	// Autodetect if mode is a language_country string (en-GB or en_GB or en)
@@ -1200,8 +1217,8 @@
 
 	if ($default_font=='') { 
 	  if ($this->onlyCoreFonts) { 
-		if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->mono_fonts)) { $default_font = 'ccourier'; }
-		else if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->sans_fonts)) { $default_font = 'chelvetica'; }
+		if (in_array(strtolower(($this->defaultCSS['BODY']['FONT-FAMILY'] ?? '')),$this->mono_fonts)) { $default_font = 'ccourier'; }
+		else if (in_array(strtolower(($this->defaultCSS['BODY']['FONT-FAMILY'] ?? '')),$this->sans_fonts)) { $default_font = 'chelvetica'; }
 		else { $default_font = 'ctimes'; }
 	  }
 	  else { $default_font = $this->defaultCSS['BODY']['FONT-FAMILY']; }
@@ -1292,7 +1309,7 @@
 	{
 		if ($format=='') { $format = 'A4'; }
 		$pfo = 'P';
-		if(preg_match('/([0-9a-zA-Z]*)-L/i',$format,$m)) {	// e.g. A4-L = A4 landscape
+		if(preg_match('/([0-9a-zA-Z]*)-L/i',($format ?? ''),$m)) {	// e.g. A4-L = A4 landscape
 			$format=$m[1]; 
 			$pfo='L'; 
 		}
@@ -1312,7 +1329,7 @@
 	$this->fw=$this->fwPt/_MPDFK;
 	$this->fh=$this->fhPt/_MPDFK;
 	//Page orientation
-	$orientation=strtolower($orientation);
+	$orientation=strtolower(($orientation ?? ''));
 	if($orientation=='p' or $orientation=='portrait')
 	{
 		$orientation='P';
@@ -1333,7 +1350,7 @@
 }
 
 function _getPageFormat($format) {
-		switch (strtoupper($format)) {
+		switch (strtoupper(($format ?? ''))) {
 			case '4A0': {$format = array(4767.87,6740.79); break;}
 			case '2A0': {$format = array(3370.39,4767.87); break;}
 			case 'A0': {$format = array(2383.94,3370.39); break;}
@@ -1504,11 +1521,11 @@
 
 function RestrictUnicodeFonts($res) {
 	// $res = array of (Unicode) fonts to restrict to: e.g. norasi|norasiB - language specific
-	if (count($res)) {	// Leave full list of available fonts if passed blank array
+	if (count(($res ?? []))) {	// Leave full list of available fonts if passed blank array
 		$this->available_unifonts = $res;
 	}
 	else { $this->available_unifonts = $this->default_available_fonts; }
-	if (count($this->available_unifonts) == 0) { $this->available_unifonts[] = $this->default_available_fonts[0]; }
+	if (count(($this->available_unifonts ?? [])) == 0) { $this->available_unifonts[] = $this->default_available_fonts[0]; }
 	$this->available_unifonts = array_values($this->available_unifonts);
 }
 
@@ -1660,10 +1677,10 @@
 }
 
 function AddExtGState($parms) {
-	$n = count($this->extgstates);
+	$n = count(($this->extgstates ?? []));
 	// check if graphics state already exists
 	for ($i=1; $i<=$n; $i++) {
-	  if (count($this->extgstates[$i]['parms']) == count($parms)) {
+	  if (count(($this->extgstates[$i]['parms'] ?? [])) == count(($parms ?? []))) {
 	    $same = true;
 	    foreach($this->extgstates[$i]['parms'] AS $k=>$v) {
 		if (!isset($parms[$k]) || $parms[$k] != $v) { $same = false; break; }
@@ -1759,14 +1776,14 @@
 	//Terminate document
 	if($this->state==3)	return;
 	if($this->page==0) $this->AddPage($this->CurOrientation);
-	if (count($this->cellBorderBuffer)) { $this->printcellbuffer(); }	// *TABLES*
+	if (count(($this->cellBorderBuffer ?? []))) { $this->printcellbuffer(); }	// *TABLES*
 	if ($this->tablebuffer) { $this->printtablebuffer(); }	// *TABLES*
 /*-- COLUMNS --*/
 
 	if ($this->ColActive) {
 		$this->SetColumns(0);
 		$this->ColActive = 0; 
-		if (count($this->columnbuffer)) { $this->printcolumnbuffer(); }
+		if (count(($this->columnbuffer ?? []))) { $this->printcolumnbuffer(); }
 	}
 /*-- END COLUMNS --*/
 
@@ -1776,7 +1793,7 @@
 	$s .= $this->PrintBodyBackgrounds();
 
 	$s .= $this->PrintPageBackgrounds();
-	$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]);
+	$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', ($this->pages[$this->page] ?? ''));
 	$this->pageBackgrounds = array();
 
 	if($this->visibility!='visible')
@@ -1788,7 +1805,7 @@
 		$this->Footer();
 		$this->InFooter=false;
 	}
-	if ($this->tocontents && ($this->tocontents->TOCmark || count($this->tocontents->m_TOC))) { $this->tocontents->insertTOC(); }	// *TOC*
+	if ($this->tocontents && ($this->tocontents->TOCmark || count(($this->tocontents->m_TOC ?? [])))) { $this->tocontents->insertTOC(); }	// *TOC*
 
 	//Close page
 	$this->_endpage();
@@ -1798,7 +1815,7 @@
 }
 
 /*-- BACKGROUNDS --*/
-function _resizeBackgroundImage($imw, $imh, $cw, $ch, $resize=0, $repx, $repy, $pba=array(), $size=array()) {
+function _resizeBackgroundImage($imw, $imh, $cw, $ch, $resize, $repx, $repy, $pba=array(), $size=array()) {
 	// pba is background positioning area (from CSS background-origin) may not always be set [x,y,w,h]
 	// size is from CSS3 background-size - takes precendence over old resize 
 	//	$w - absolute length or % or auto or cover | contain
@@ -1904,8 +1921,8 @@
 		else if (stristr($properties['BACKGROUND-SIZE'] ,'cover') ) { $bsw = $bsh = 'cover'; }
 		else {
 			$bsw = $bsh = 'auto';
-			$sz = preg_split('/\s+/',trim($properties['BACKGROUND-SIZE']));
-			if (count($sz)==2) { $bsw = $sz[0]; $bsh = $sz[1]; }
+			$sz = preg_split('/\s+/',(trim(($properties['BACKGROUND-SIZE'] ?? '')) ?? ''));
+			if (count(($sz ?? []))==2) { $bsw = $sz[0]; $bsh = $sz[1]; }
 			else { $bsw = $sz[0]; }
 			if (!stristr($bsw ,'%') && !stristr($bsw ,'auto') ) { $bsw = $this->ConvertSize($bsw ,$maxwidth,$this->FontSize); }
 			if (!stristr($bsh ,'%') && !stristr($bsh ,'auto') ) { $bsh = $this->ConvertSize($bsh ,$maxwidth,$this->FontSize); }
@@ -1913,7 +1930,7 @@
 		$size = array('w'=>$bsw, 'h'=>$bsh);
 	}
 	else { $size = false; }	// mPDF 6
-	   if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',$properties['BACKGROUND-IMAGE'])) {
+	   if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',($properties['BACKGROUND-IMAGE'] ?? ''))) {
 		return array('gradient'=>$properties['BACKGROUND-IMAGE'], 'origin'=>$origin, 'size'=>$size );
 	   }
 	   else {
@@ -1924,11 +1941,11 @@
 			$orig_w = $sizesarray['WIDTH']*_MPDFK;		// in user units i.e. mm
  			$orig_h = $sizesarray['HEIGHT']*_MPDFK;		// (using $this->img_dpi)
 			if (isset($properties['BACKGROUND-IMAGE-RESOLUTION'])) { 
-				if (preg_match('/from-image/i', $properties['BACKGROUND-IMAGE-RESOLUTION']) && isset($sizesarray['set-dpi']) && $sizesarray['set-dpi']>0) {
+				if (preg_match('/from-image/i', ($properties['BACKGROUND-IMAGE-RESOLUTION'] ?? '')) && isset($sizesarray['set-dpi']) && $sizesarray['set-dpi']>0) {
 					$orig_w *= $this->img_dpi / $sizesarray['set-dpi'];
 					$orig_h *= $this->img_dpi / $sizesarray['set-dpi'];
 				}
-				else if (preg_match('/(\d+)dpi/i', $properties['BACKGROUND-IMAGE-RESOLUTION'], $m)) {
+				else if (preg_match('/(\d+)dpi/i', ($properties['BACKGROUND-IMAGE-RESOLUTION'] ?? ''), $m)) {
 					$dpi = $m[1]; 
 					if ($dpi > 0) {
 						$orig_w *= $this->img_dpi / $dpi;
@@ -1945,7 +1962,7 @@
 			$x_pos = 0;
 			$y_pos = 0;
 			if (isset($properties['BACKGROUND-POSITION'])) { 
-				$ppos = preg_split('/\s+/',$properties['BACKGROUND-POSITION']);
+				$ppos = preg_split('/\s+/',($properties['BACKGROUND-POSITION'] ?? ''));
 				$x_pos = $ppos[0];
 				$y_pos = $ppos[1];
 				if (!stristr($x_pos ,'%') ) { $x_pos = $this->ConvertSize($x_pos ,$maxwidth,$this->FontSize); }
@@ -1978,11 +1995,11 @@
 
 	if ($this->bodyBackgroundColor) {
 		$s .= 'q ' .$this->SetFColor($this->bodyBackgroundColor, true)."\n";
-		if ($this->bodyBackgroundColor{0}==5) {	// RGBa
-			$s .= $this->SetAlpha(ord($this->bodyBackgroundColor{4})/100, 'Normal', true, 'F')."\n";
-		}
-		else if ($this->bodyBackgroundColor{0}==6) {	// CMYKa
-			$s .= $this->SetAlpha(ord($this->bodyBackgroundColor{5})/100, 'Normal', true, 'F')."\n";
+		if ($this->bodyBackgroundColor[0]==5) {	// RGBa
+			$s .= $this->SetAlpha(ord(($this->bodyBackgroundColor[4] ?? ''))/100, 'Normal', true, 'F')."\n";
+		}
+		else if ($this->bodyBackgroundColor[0]==6) {	// CMYKa
+			$s .= $this->SetAlpha(ord(($this->bodyBackgroundColor[5] ?? ''))/100, 'Normal', true, 'F')."\n";
 		}
 		$s .= sprintf('%.3F %.3F %.3F %.3F re f Q', ($clx*_MPDFK), ($cly*_MPDFK),$clw*_MPDFK,$clh*_MPDFK)."\n";
 	}
@@ -1995,14 +2012,14 @@
 		}
 	}
 	if ($this->bodyBackgroundImage) {
-	   if (isset($this->bodyBackgroundImage['gradient']) && $this->bodyBackgroundImage['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $this->bodyBackgroundImage['gradient'])) {
+	   if (isset($this->bodyBackgroundImage['gradient']) && $this->bodyBackgroundImage['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($this->bodyBackgroundImage['gradient'] ?? ''))) {
 		$g = $this->grad->parseMozGradient( $this->bodyBackgroundImage['gradient']);
 		if ($g) {
 			$s .= $this->grad->Gradient($clx, $cly, $clw, $clh, $g['type'], $g['stops'], $g['colorspace'], $g['coords'], $g['extend'], true);
 		}
 	   }
 	   else if ($this->bodyBackgroundImage['image_id']) {	// Background pattern
-			$n = count($this->patterns)+1;
+			$n = count(($this->patterns ?? []))+1;
 			// If using resize, uses TrimBox (not including the bleed)
 			list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($this->bodyBackgroundImage['orig_w'], $this->bodyBackgroundImage['orig_h'], $clw, $clh, $this->bodyBackgroundImage['resize'], $this->bodyBackgroundImage['x_repeat'], $this->bodyBackgroundImage['y_repeat']);
 
@@ -2052,11 +2069,11 @@
 			if (isset($pb['shadow']) && $pb['shadow']) { $s .= $pb['shadow']."\n"; }
 			if (isset($pb['clippath']) && $pb['clippath']) { $s .= $pb['clippath']."\n"; }
 			$s .= 'q '.$this->SetFColor($pb['col'], true)."\n";
-			if ($pb['col']{0}==5) {	// RGBa
-				$s .= $this->SetAlpha(ord($pb['col']{4})/100, 'Normal', true, 'F')."\n"; 
-			}
-			else if ($pb['col']{0}==6) {	// CMYKa
-				$s .= $this->SetAlpha(ord($pb['col']{5})/100, 'Normal', true, 'F')."\n";
+			if ($pb['col'][0]==5) {	// RGBa
+				$s .= $this->SetAlpha(ord(($pb['col'][4] ?? ''))/100, 'Normal', true, 'F')."\n"; 
+			}
+			else if ($pb['col'][0]==6) {	// CMYKa
+				$s .= $this->SetAlpha(ord(($pb['col'][5] ?? ''))/100, 'Normal', true, 'F')."\n";
 			}
 			$s .= sprintf('%.3F %.3F %.3F %.3F re f Q',$pb['x']*_MPDFK,($this->h-$pb['y'])*_MPDFK,$pb['w']*_MPDFK,-$pb['h']*_MPDFK)."\n";
 			if (isset($pb['clippath']) && $pb['clippath']) { $s .= 'Q'."\n"; }
@@ -2093,7 +2110,7 @@
 		  else if (isset($pb['image_id']) && $pb['image_id']) {	// Background Image
 			$pb['y'] -= $adjustmenty; 
 			$pb['h'] += $adjustmenty; 
-			$n = count($this->patterns)+1;
+			$n = count(($this->patterns ?? []))+1;
 			list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($pb['orig_w'], $pb['orig_h'], $pb['w'], $pb['h'], $pb['resize'], $pb['x_repeat'], $pb['y_repeat'], $pb['bpa'], $pb['size']);
 			$this->patterns[$n] = array('x'=>$pb['x'], 'y'=>$pb['y'], 'w'=>$pb['w'], 'h'=>$pb['h'], 'pgh'=>$this->h, 'image_id'=>$pb['image_id'], 'orig_w'=>$orig_w, 'orig_h'=>$orig_h, 'x_pos'=>$pb['x_pos'], 'y_pos'=>$pb['y_pos'], 'x_repeat'=>$x_repeat, 'y_repeat'=>$y_repeat, 'itype'=>$pb['itype'], 'bpa'=>$pb['bpa']);
 			$x = $pb['x']*_MPDFK;
@@ -2234,11 +2251,11 @@
 		foreach ($pbs AS $pb) {
 	 	 if ((!isset($pb['gradient']) || !$pb['gradient']) && (!isset($pb['image_id']) || !$pb['image_id'])) {
 			$s .= 'q '.$this->SetFColor($pb['col'], true)."\n";
-			if ($pb['col']{0}==5) {	// RGBa
-				$s .= $this->SetAlpha(ord($pb['col']{4})/100, 'Normal', true, 'F')."\n"; 
-			}
-			else if ($pb['col']{0}==6) {	// CMYKa
-				$s .= $this->SetAlpha(ord($pb['col']{5})/100, 'Normal', true, 'F')."\n";
+			if ($pb['col'][0]==5) {	// RGBa
+				$s .= $this->SetAlpha(ord(($pb['col'][4] ?? ''))/100, 'Normal', true, 'F')."\n"; 
+			}
+			else if ($pb['col'][0]==6) {	// CMYKa
+				$s .= $this->SetAlpha(ord(($pb['col'][5] ?? ''))/100, 'Normal', true, 'F')."\n";
 			}
 			$s .= sprintf('%.3F %.3F %.3F %.3F re %s Q',$pb['x']*_MPDFK,($this->h-$pb['y'])*_MPDFK,$pb['w']*_MPDFK,-$pb['h']*_MPDFK,'f')."\n";
 		  }
@@ -2250,7 +2267,7 @@
 		  if (isset($pb['image_id']) && $pb['image_id']) {	// Background pattern
 			$pb['y'] -= $adjustmenty; 
 			$pb['h'] += $adjustmenty; 
-			$n = count($this->patterns)+1;
+			$n = count(($this->patterns ?? []))+1;
 			list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($pb['orig_w'], $pb['orig_h'], $pb['w'], $pb['h'], $pb['resize'], $pb['x_repeat'], $pb['y_repeat']);
 			$this->patterns[$n] = array('x'=>$pb['x'], 'y'=>$pb['y'], 'w'=>$pb['w'], 'h'=>$pb['h'], 'pgh'=>$this->h, 'image_id'=>$pb['image_id'], 'orig_w'=>$orig_w, 'orig_h'=>$orig_h, 'x_pos'=>$pb['x_pos'], 'y_pos'=>$pb['y_pos'], 'x_repeat'=>$x_repeat, 'y_repeat'=>$y_repeat, 'itype'=>$pb['itype']);
 			$x = $pb['x']*_MPDFK;
@@ -2518,7 +2535,7 @@
 	// Float DIV
 	// Cannot do with columns on, or if any change in page orientation/margins etc.
 	// If next page already exists - i.e background /headers and footers already written
-	if ($this->state > 0 && $this->page < count($this->pages)) {
+	if ($this->state > 0 && $this->page < count(($this->pages ?? []))) {
 		$bak_cml = $this->cMarginL;
 		$bak_cmr = $this->cMarginR; 
 		$bak_dw = $this->divwidth;
@@ -2539,7 +2556,7 @@
 		$s = $this->PrintPageBackgrounds();
 
 		// Writes after the marker so not overwritten later by page background etc.
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 		$this->pageBackgrounds = array();
 		$family=$this->FontFamily;
 		$style=$this->FontStyle;
@@ -2592,8 +2609,8 @@
 
 	$bak_lh = $this->lineheight;
 
-	$orientation = substr(strtoupper($orientation),0,1);
-	$condition = strtoupper($condition);
+	$orientation = substr((strtoupper(($orientation ?? '')) ?? ''),0,1);
+	$condition = strtoupper(($condition ?? ''));
 
 
 	if ($condition == 'E') {	// only adds new page if needed to create an Even page
@@ -2677,7 +2694,7 @@
 		$s .= $this->PrintBodyBackgrounds();
 
 		$s .= $this->PrintPageBackgrounds();
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', ($this->pages[$this->page] ?? ''));
 		$this->pageBackgrounds = array();
 	}
 
@@ -2831,7 +2848,7 @@
 function AddSpotColorsFromFile($file) {
 	$colors = @file($file) or die("Cannot load spot colors file - ".$file);
 	foreach($colors AS $sc) {
-		list($name, $c, $m, $y, $k) = preg_split("/\t/",$sc);
+		list($name, $c, $m, $y, $k) = preg_split("/\t/",($sc ?? ''));
 		$c = intval($c);
 		$m = intval($m);
 		$y = intval($y);
@@ -2841,9 +2858,9 @@
 }
 
 function AddSpotColor($name, $c, $m, $y, $k) {
-	$name = strtoupper(trim($name));
+	$name = strtoupper((trim(($name ?? '')) ?? ''));
 	if(!isset($this->spotColors[$name])) {
-		$i=count($this->spotColors)+1;
+		$i=count(($this->spotColors ?? []))+1;
 		$this->spotColors[$name]=array('i'=>$i,'c'=>$c,'m'=>$m,'y'=>$y,'k'=>$k);
 		$this->spotColorIDs[$i]=$name;
 	}
@@ -2852,20 +2869,20 @@
 function SetColor($col, $type='') {
 	$out = '';
 	if (!$col) { return ''; }	// mPDF 6
-	if ($col{0}==3 || $col{0}==5) {	// RGB / RGBa
-		$out = sprintf('%.3F %.3F %.3F rg',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255);
-	}
-	else if ($col{0}==1) {	// GRAYSCALE
-		$out = sprintf('%.3F g',ord($col{1})/255);
-	}
-	else if ($col{0}==2) {	// SPOT COLOR
-		$out = sprintf('/CS%d cs %.3F scn',ord($col{1}),ord($col{2})/100);
-	}
-	else if ($col{0}==4 || $col{0}==6) {	// CMYK / CMYKa
-		$out = sprintf('%.3F %.3F %.3F %.3F k', ord($col{1})/100, ord($col{2})/100, ord($col{3})/100, ord($col{4})/100);
-	}
-	if ($type=='Draw') { $out = strtoupper($out); }	// e.g. rg => RG
-	else if ($type=='CodeOnly') { $out = preg_replace('/\s(rg|g|k)/','',$out); }
+	if ($col[0]==3 || $col[0]==5) {	// RGB / RGBa
+		$out = sprintf('%.3F %.3F %.3F rg',ord(($col[1] ?? ''))/255,ord(($col[2] ?? ''))/255,ord(($col[3] ?? ''))/255);
+	}
+	else if ($col[0]==1) {	// GRAYSCALE
+		$out = sprintf('%.3F g',ord(($col[1] ?? ''))/255);
+	}
+	else if ($col[0]==2) {	// SPOT COLOR
+		$out = sprintf('/CS%d cs %.3F scn',ord(($col[1] ?? '')),ord(($col[2] ?? ''))/100);
+	}
+	else if ($col[0]==4 || $col[0]==6) {	// CMYK / CMYKa
+		$out = sprintf('%.3F %.3F %.3F %.3F k', ord(($col[1] ?? ''))/100, ord(($col[2] ?? ''))/100, ord(($col[3] ?? ''))/100, ord(($col[4] ?? ''))/100);
+	}
+	if ($type=='Draw') { $out = strtoupper(($out ?? '')); }	// e.g. rg => RG
+	else if ($type=='CodeOnly') { $out = preg_replace('/\s(rg|g|k)/','',($out ?? '')); }
 	return $out; 
 }
 
@@ -2932,7 +2949,7 @@
 function _getCharWidth(&$cw, $u, $isdef=true) {
 	$w = 0;
 	if ($u==0) { $w = false; }
-	else if (isset($cw[$u*2+1])) { $w = (ord($cw[$u*2]) << 8) + ord($cw[$u*2+1]); }
+	else if (isset($cw[$u*2+1])) { $w = (ord(($cw[$u*2] ?? '')) << 8) + ord(($cw[$u*2+1] ?? '')); }
 	if ($w == 65535) { return 0; }
 	else if ($w) { return $w; }
 	else if ($isdef) { return false; }
@@ -2942,7 +2959,7 @@
 function _charDefined(&$cw, $u) {
 	$w = 0;
 	if ($u==0) { return false; }
-	if (isset($cw[$u*2+1])) { $w = (ord($cw[$u*2]) << 8) + ord($cw[$u*2+1]); }
+	if (isset($cw[$u*2+1])) { $w = (ord(($cw[$u*2] ?? '')) << 8) + ord(($cw[$u*2+1] ?? '')); }
 	if ($w) { return true; }
 	else { return false; }
 }
@@ -2955,8 +2972,8 @@
 	if ($c == chr(173) && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { 
 		return 0;
 	}
-	else if (($this->textvar & FC_SMALLCAPS) && isset($this->upperCase[ord($c)])) { 	// mPDF 5.7.1
-		$charw = $this->CurrentFont['cw'][chr($this->upperCase[ord($c)])];
+	else if (($this->textvar & FC_SMALLCAPS) && isset($this->upperCase[ord(($c ?? ''))])) { 	// mPDF 5.7.1
+		$charw = $this->CurrentFont['cw'][chr((int) ($this->upperCase[ord(($c ?? ''))]))];
 		if ($charw!==false) { 
 			$charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
 			$w+=$charw; 
@@ -2965,8 +2982,8 @@
 	else if (isset($this->CurrentFont['cw'][$c])) { 
 		$w += $this->CurrentFont['cw'][$c]; 
 	} 
-	else if (isset($this->CurrentFont['cw'][ord($c)])) { 
-		$w += $this->CurrentFont['cw'][ord($c)]; 
+	else if (isset($this->CurrentFont['cw'][ord(($c ?? ''))])) { 
+		$w += $this->CurrentFont['cw'][ord(($c ?? ''))]; 
 	}
 	$w *=  ($this->FontSize/ 1000);
 	if ($this->minwSpacing || $this->fixedlSpacing) {
@@ -3041,13 +3058,13 @@
 			$nb_spaces = 0;
 			$kashida = 0;
 			// mPDF ITERATION
-			if ($this->iterationCounter) $s = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/', '\\1', $s);
+			if ($this->iterationCounter) $s = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/', '\\1', ($s ?? ''));
 			if (!$this->usingCoreFont) {
 				$discards = substr_count($s,"\xc2\xad");	// mPDF 6 soft hyphens [U+00AD]
 				$unicode = $this->UTF8StringToArray($s, $addSubset);
 				if ($this->minwSpacing || $this->fixedlSpacing) {
 					$nb_spaces = mb_substr_count($s,' ', $this->mb_enc);  
-					$nb_carac = count($unicode) - $discards ;	// mPDF 6 
+					$nb_carac = count(($unicode ?? [])) - $discards ;	// mPDF 6 
 					// mPDF 5.7.1
 					// Use GPOS OTL
 					if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
@@ -3118,15 +3135,15 @@
 			} 
 			else {
 				if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { 
-			      	$s = str_replace(chr(173),'',$s ); 
-				}
-				$nb_carac = $l = strlen($s);
+			      	$s = str_replace((chr(173) ?? ''),'',($s ?? '') ); 
+				}
+				$nb_carac = $l = strlen(($s ?? ''));
 				if ($this->minwSpacing || $this->fixedlSpacing) {
 					$nb_spaces = substr_count($s,' ');  
 				}
 				for($i=0; $i<$l; $i++) {
-					if (($textvar & FC_SMALLCAPS) && isset($this->upperCase[ord($s[$i])])) { 	// mPDF 5.7.1
-						$charw = $cw[chr($this->upperCase[ord($s[$i])])];
+					if (($textvar & FC_SMALLCAPS) && isset($this->upperCase[ord(($s[$i] ?? ''))])) { 	// mPDF 5.7.1
+						$charw = $cw[chr((int) ($this->upperCase[ord(($s[$i] ?? ''))]))];
 						if ($charw!==false) { 
 							$charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
 							$w+=$charw; 
@@ -3135,8 +3152,8 @@
 					else if (isset($cw[$s[$i]])) { 
 						$w += $cw[$s[$i]]; 
 					} 
-					else if (isset($cw[ord($s[$i])])) { 
-						$w += $cw[ord($s[$i])]; 
+					else if (isset($cw[ord(($s[$i] ?? ''))])) { 
+						$w += $cw[ord(($s[$i] ?? ''))]; 
 					}
 					if (($textvar & FC_KERNING) && $i>0) {	// mPDF 5.7.1
 						if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$s[$i]])) { 
@@ -3208,9 +3225,9 @@
 
 function AddFont($family,$style='') {
 	if(empty($family)) { return; }
-	$family = strtolower($family);
-	$style=strtoupper($style);
-	$style=str_replace('U','',$style);
+	$family = strtolower(($family ?? ''));
+	$style=strtoupper(($style ?? ''));
+	$style=str_replace('U','',($style ?? ''));
 	if($style=='IB') $style='BI';
 	$fontkey = $family.$style;
 	// check if the font has been already added
@@ -3291,7 +3308,7 @@
 		if ($kerninfo) $haskerninfo = true;
 		$haskernGPOS = $ttf->haskernGPOS;
 		$hassmallcapsGSUB = $ttf->hassmallcapsGSUB;
-		$name = preg_replace('/[ ()]/','',$ttf->fullName);
+		$name = preg_replace('/[ ()]/','',($ttf->fullName ?? ''));
 		$sip = $ttf->sipset;
 		$smp = $ttf->smpset;
 		// mPDF 6
@@ -3320,7 +3337,7 @@
 		'MissingWidth'=>round($ttf->defaultWidth)
 		);
 		$panose = '';
-		if (count($ttf->panose)) {
+		if (count(($ttf->panose ?? []))) {
 			$panoseArray = array_merge(array($ttf->sFamilyClass, $ttf->sFamilySubClass), $ttf->panose);
 			foreach($panoseArray as $value)
 				$panose .= ' '.dechex($value);
@@ -3374,22 +3391,22 @@
 			$s.='$rtlPUAstr=\''.$rtlPUAstr."';\n"; 
 		}
 		else $s.='$rtlPUAstr=\'\';'."\n";
-		if (count($GSUBScriptLang)) {
+		if (count(($GSUBScriptLang ?? []))) {
 			$s.='$GSUBScriptLang='.var_export($GSUBScriptLang,true).";\n"; 
 		}
-		if (count($GSUBFeatures)) {
+		if (count(($GSUBFeatures ?? []))) {
 			$s.='$GSUBFeatures='.var_export($GSUBFeatures,true).";\n"; 
 		}
-		if (count($GSUBLookups)) {
+		if (count(($GSUBLookups ?? []))) {
 			$s.='$GSUBLookups='.var_export($GSUBLookups,true).";\n"; 
 		}
-		if (count($GPOSScriptLang)) {
+		if (count(($GPOSScriptLang ?? []))) {
 			$s.='$GPOSScriptLang='.var_export($GPOSScriptLang,true).";\n"; 
 		}
-		if (count($GPOSFeatures)) {
+		if (count(($GPOSFeatures ?? []))) {
 			$s.='$GPOSFeatures='.var_export($GPOSFeatures,true).";\n"; 
 		}
-		if (count($GPOSLookups)) {
+		if (count(($GPOSLookups ?? []))) {
 			$s.='$GPOSLookups='.var_export($GPOSLookups,true).";\n"; 
 		}
 		if ($kerninfo) { 
@@ -3398,14 +3415,14 @@
 		$s.="?>";
 		if (is_writable(dirname(_MPDF_TTFONTDATAPATH.'x'))) {
 			$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.mtx.php',"w");
-			fwrite($fh,$s,strlen($s));
+			fwrite($fh,$s,strlen(($s ?? '')));
 			fclose($fh);
 			$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.cw.dat',"wb");
-			fwrite($fh,$cw,strlen($cw));
+			fwrite($fh,$cw,strlen(($cw ?? '')));
 			fclose($fh);
 			// mPDF 5.7.1
 			$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.gid.dat',"wb");
-			fwrite($fh,$glyphIDtoUni,strlen($glyphIDtoUni));
+			fwrite($fh,$glyphIDtoUni,strlen(($glyphIDtoUni ?? '')));
 			fclose($fh);
 			if (file_exists(_MPDF_TTFONTDATAPATH.$fontkey.'.cgm')) unlink(_MPDF_TTFONTDATAPATH.$fontkey.'.cgm');
 			if (file_exists(_MPDF_TTFONTDATAPATH.$fontkey.'.z')) unlink(_MPDF_TTFONTDATAPATH.$fontkey.'.z');
@@ -3447,7 +3464,7 @@
 
 
 
-	$i = count($this->fonts)+$this->extraFontSubsets+1;
+	$i = count(($this->fonts ?? []))+$this->extraFontSubsets+1;
 	if ($sip || $smp) {
 		$this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'panose'=>$panose, 'unitsPerEm'=>$unitsPerEm, 'up'=>$up, 'ut'=>$ut, 'strs'=>$strs, 'strp'=>$strp, 'cw'=>$cw, 'ttffile'=>$ttffile, 'fontkey'=>$fontkey, 'subsets'=>array(0=>range(0,127)), 'subsetfontids'=>array($i), 'used'=>false, 'sip'=>$sip, 'sipext'=>$sipext, 'smp'=>$smp, 'TTCfontID' => $TTCfontID, 'useOTL' => (isset($this->fontdata[$family]['useOTL']) ? $this->fontdata[$family]['useOTL'] : false), 'useKashida' => (isset($this->fontdata[$family]['useKashida']) ? $this->fontdata[$family]['useKashida'] : false), 'GSUBScriptLang'=>$GSUBScriptLang, 'GSUBFeatures'=>$GSUBFeatures, 'GSUBLookups'=>$GSUBLookups, 'GPOSScriptLang'=>$GPOSScriptLang, 'GPOSFeatures'=>$GPOSFeatures, 'GPOSLookups'=>$GPOSLookups, 'rtlPUAstr'=>$rtlPUAstr, 'glyphIDtoUni'=>$glyphIDtoUni, 'haskerninfo'=>$haskerninfo, 'haskernGPOS'=>$haskernGPOS, 'hassmallcapsGSUB'=>$hassmallcapsGSUB);	// mPDF 5.7.1	// mPDF 6
 	}
@@ -3464,7 +3481,7 @@
 
 
 function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
-	$family=strtolower($family);
+	$family=strtolower(($family ?? ''));
 	if (!$this->onlyCoreFonts) {
 		if ($family == 'sans' || $family == 'sans-serif') { $family = $this->sans_fonts[0]; }
 		if ($family == 'serif') { $family = $this->serif_fonts[0]; }
@@ -3484,7 +3501,7 @@
 			$this->Error("Symbol and Zapfdingbats cannot be embedded in mPDF (required for PDFA1-b or PDFX/1-a).");
 		   }
 		   if ($family == 'ctimes'  || $family == 'ccourier' || $family == 'chelvetica') { 
-			if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Core Adobe font ".ucfirst($family)." cannot be embedded in mPDF, which is required for PDFA1-b or PDFX/1-a. (Embedded font will be substituted.)"; }
+			if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Core Adobe font ".ucfirst(($family ?? ''))." cannot be embedded in mPDF, which is required for PDFA1-b or PDFX/1-a. (Embedded font will be substituted.)"; }
 			if ($family == 'chelvetica') { $family = 'sans'; }
 			if ($family == 'ctimes') { $family = 'serif'; }
 			if ($family == 'ccourier') { $family = 'mono'; }
@@ -3498,7 +3515,7 @@
 
 	// mPDF 5.7.1
 	if ($style) {
-		$style=strtoupper($style);
+		$style=strtoupper(($style ?? ''));
 		if ($style=='IB') $style='BI';
 	}
 	if ($size==0) $size=$this->FontSizePt;
@@ -3509,7 +3526,7 @@
 	if (!$stylekey) { $stylekey = "R"; }
 
 	if (!$this->onlyCoreFonts && !$this->usingCoreFont) {
-		if(!isset($this->fonts[$fontkey]) || count($this->default_available_fonts) != count($this->available_unifonts) ) { // not already added
+		if(!isset($this->fonts[$fontkey]) || count(($this->default_available_fonts ?? [])) != count(($this->available_unifonts ?? [])) ) { // not already added
 /*-- CJK-FONTS --*/
 		  // CJK fonts
 		  if (in_array($fontkey,$this->available_CJK_fonts)) {
@@ -3528,7 +3545,7 @@
 			}
 
 			// Else if only one font available - set it (assumes if only one font available it will not have a style)
-			else if (count($this->available_unifonts) == 1) {
+			else if (count(($this->available_unifonts ?? [])) == 1) {
 				$family = $this->available_unifonts[0];
 				$style = '';
 			}
@@ -3538,7 +3555,7 @@
 				// else substitute font of similar type
 				if (in_array($family,$this->sans_fonts)) { 
 					$i = array_intersect($this->sans_fonts,$this->available_unifonts);
-					if (count($i)) {
+					if (count(($i ?? []))) {
 						$i = array_values($i);
 						// with requested style if possible
 						if (!in_array(($i[0].$style),$this->available_unifonts)) {
@@ -3550,7 +3567,7 @@
 				}
 				else if (in_array($family,$this->serif_fonts)) { 
 					$i = array_intersect($this->serif_fonts,$this->available_unifonts);
-					if (count($i)) {
+					if (count(($i ?? []))) {
 						$i = array_values($i);
 						// with requested style if possible
 						if (!in_array(($i[0].$style),$this->available_unifonts)) {
@@ -3562,7 +3579,7 @@
 				}
 				else if (in_array($family,$this->mono_fonts)) {
 					$i = array_intersect($this->mono_fonts,$this->available_unifonts);
-					if (count($i)) {
+					if (count(($i ?? []))) {
 						$i = array_values($i);
 						// with requested style if possible
 						if (!in_array(($i[0].$style),$this->available_unifonts)) {
@@ -3576,7 +3593,7 @@
 				if (!$found) {
 					// set first available font
 					$fs = $this->available_unifonts[0];
-					preg_match('/^([a-z_0-9\-]+)([BI]{0,2})$/',$fs,$fas);	// Allow "-"
+					preg_match('/^([a-z_0-9\-]+)([BI]{0,2})$/',($fs ?? ''),$fas);	// Allow "-"
 					// with requested style if possible
 					$ws = $fas[1].$style;
 					if (in_array($ws,$this->available_unifonts)) {
@@ -3654,11 +3671,11 @@
 			if (isset($this->CoreFonts[$fontkey])) {
 				//Load metric file
 				$file=$family;
-				if($family=='ctimes' || $family=='chelvetica' || $family=='ccourier') { $file.=strtolower($style); }
+				if($family=='ctimes' || $family=='chelvetica' || $family=='ccourier') { $file.=strtolower(($style ?? '')); }
 				$file.='.php';
 				include(_MPDF_PATH.'font/'.$file);
 				if(!isset($cw)) { $this->Error('Could not include font metric file'); }
-				$i=count($this->fonts)+$this->extraFontSubsets+1;
+				$i=count(($this->fonts ?? []))+$this->extraFontSubsets+1;
 				$this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw);
 				if ($this->useKerning && isset($kerninfo)) { $this->fonts[$fontkey]['kerninfo'] = $kerninfo; }
 			}
@@ -3707,7 +3724,7 @@
 
 function AddLink() {
 	//Create a new internal link
-	$n=count($this->links)+1;
+	$n=count(($this->links ?? []))+1;
 	$this->links[$n]=array(0,0);
 	return $n;
 }
@@ -3740,7 +3757,7 @@
 	//Put a link on the page
 	$this->PageLinks[$this->page][]= $l;
 	// Save cross-reference to Column buffer
-	$ref = count($this->PageLinks[$this->page])-1;	// *COLUMNS*
+	$ref = count(($this->PageLinks[$this->page] ?? []))-1;	// *COLUMNS*
 	$this->columnLinks[$this->CurrCol][INTVAL($this->x)][INTVAL($this->y)] = $ref;	// *COLUMNS*
 
 }
@@ -3754,13 +3771,13 @@
 
 	// ARTIFICIAL BOLD AND ITALIC
 	$s = 'q ';
-	if ($this->falseBoldWeight && strpos($this->ReqFontStyle,"B") !== false && strpos($this->FontStyle,"B") === false) {
+	if ($this->falseBoldWeight && strpos(($this->ReqFontStyle ?? ''),"B") !== false && strpos(($this->FontStyle ?? ''),"B") === false) {
 		$s  .= '2 Tr 1 J 1 j ';
 		$s .= sprintf('%.3F w ',($this->FontSize/130)*_MPDFK*$this->falseBoldWeight);
-		$tc = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG
+		$tc = strtoupper(($this->TextColor ?? '')); // change 0 0 0 rg to 0 0 0 RG
 		if($this->FillColor!=$tc) { $s .= $tc.' '; }		// stroke (outline) = same colour as text(fill)
 	}
-	if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) {
+	if (strpos(($this->ReqFontStyle ?? ''),"I") !== false && strpos(($this->FontStyle ?? ''),"I") === false) {
 		$aix = '1 0 0.261799 1 %.3F %.3F Tm'; 
 	}
 	else { $aix = '%.3F %.3F Td'; }
@@ -3772,10 +3789,10 @@
 	$this->CurrentFont['used']= true;
 
 	if ($this->usingCoreFont) {
-	      $txt2 = str_replace(chr(160),chr(32),$txt);
+	      $txt2 = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($txt ?? ''));
 	}
 	else {
-	      $txt2 = str_replace(chr(194).chr(160),chr(32),$txt); 
+	      $txt2 = str_replace(chr(194).chr(160),(chr(32) ?? ''),($txt ?? '')); 
 	}
 
 	$px = $x;
@@ -3824,7 +3841,7 @@
 	$s .= ' ';
 
 	if(($textvar & FD_UNDERLINE) && $txt!='') {	// mPDF 5.7.1
-		$c = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG
+		$c = strtoupper(($this->TextColor ?? '')); // change 0 0 0 rg to 0 0 0 RG
 		if($this->FillColor!=$c) { $s.= ' '.$c.' '; }
 		if (isset($this->CurrentFont['up']) && $this->CurrentFont['up']) { $up=$this->CurrentFont['up']; }
 		else { $up = -100; }
@@ -3839,7 +3856,7 @@
 	}
    	// STRIKETHROUGH
 	if(($textvar & FD_LINETHROUGH) && $txt!='') {	// mPDF 5.7.1
-		$c = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG
+		$c = strtoupper(($this->TextColor ?? '')); // change 0 0 0 rg to 0 0 0 RG
 		if($this->FillColor!=$c) { $s.= ' '.$c.' '; }
     		//Superscript and Subscript Y coordinate adjustment (now for striked-through texts)
 		if (isset($this->CurrentFont['desc']['CapHeight']) && $this->CurrentFont['desc']['CapHeight']) { $ch=$this->CurrentFont['desc']['CapHeight']; }
@@ -3866,10 +3883,10 @@
 	if ($this->text_input_as_HTML) {
 		$txt = $this->all_entities_to_utf8($txt);
 	}
-	if ($this->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mb_enc,'UTF-8'); }
+	if ($this->usingCoreFont) { $txt = mb_convert_encoding(($txt ?? ''),($this->mb_enc ?? ''),'UTF-8'); }
 
 	// DIRECTIONALITY
-	if (preg_match("/([".$this->pregRTLchars."])/u", $txt)) { $this->biDirectional = true; }	// *OTL*
+	if (preg_match("/([".$this->pregRTLchars."])/u", ($txt ?? ''))) { $this->biDirectional = true; }	// *OTL*
 
 	$textvar = 0;
 	$save_OTLtags = $this->OTLtags;
@@ -3899,9 +3916,9 @@
 	if ($this->text_input_as_HTML) {
 		$txt = $this->all_entities_to_utf8($txt);
 	}
-	if ($this->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mb_enc,'UTF-8'); }
+	if ($this->usingCoreFont) { $txt = mb_convert_encoding(($txt ?? ''),($this->mb_enc ?? ''),'UTF-8'); }
 	// DIRECTIONALITY
-	if (preg_match("/([".$this->pregRTLchars."])/u", $txt)) { $this->biDirectional = true; }	// *OTL*
+	if (preg_match("/([".$this->pregRTLchars."])/u", ($txt ?? ''))) { $this->biDirectional = true; }	// *OTL*
 
 	$textvar = 0;
 	$save_OTLtags = $this->OTLtags;
@@ -3951,8 +3968,8 @@
 	$kashida_present = false;
 	$kashida_space = 0;
 	if ($w >0 && $inclCursive && isset($this->CurrentFont['useKashida']) && $this->CurrentFont['useKashida'] && !empty($cOTLdata)) {
-		for($c=0;$c<count($cOTLdata);$c++) {
-			for($i=0;$i<strlen($cOTLdata[$c]['group']);$i++) {
+		for($c=0;$c<count(($cOTLdata ?? []));$c++) {
+			for($i=0;$i<strlen(($cOTLdata[$c]['group'] ?? ''));$i++) {
 				if (isset($cOTLdata[$c]['GPOSinfo'][$i]['kashida']) && $cOTLdata[$c]['GPOSinfo'][$i]['kashida']>0) {
 					$kashida_present = true; 
 					break 2;
@@ -3968,10 +3985,10 @@
 		$max_kashida_in_word = 0;
 		$last_kashida_in_word = -1;
 
-		for($c=0;$c<count($cOTLdata);$c++) {
-			for($i=0;$i<strlen($cOTLdata[$c]['group']);$i++) {
-
-				if ($cOTLdata[$c]['group']{$i}=='S') {
+		for($c=0;$c<count(($cOTLdata ?? []));$c++) {
+			for($i=0;$i<strlen(($cOTLdata[$c]['group'] ?? ''));$i++) {
+
+				if ($cOTLdata[$c]['group'][$i]=='S') {
 					// Save from last word
 					if ($max_kashida_in_word) { 
 						$k_ctr++; 
@@ -4019,8 +4036,8 @@
 		// Otherwise fontstretch is too small and errors
 		// If not just leave to adjust word-spacing
 		if ($tatw && (($kashida_space/$k_ctr) / $tatw) > 0.01) {
-			for($c=0;$c<count($cOTLdata);$c++) {
-				for($i=0;$i<strlen($cOTLdata[$c]['group']);$i++) {
+			for($c=0;$c<count(($cOTLdata ?? []));$c++) {
+				for($i=0;$i<strlen(($cOTLdata[$c]['group'] ?? ''));$i++) {
 					if (isset($cOTLdata[$c]['GPOSinfo'][$i]['kashida']) && $cOTLdata[$c]['GPOSinfo'][$i]['kashida']>0) {
 						// At this point kashida is a number representing priority (higher number - higher priority)
 						// We are now going to set it as an actual length
@@ -4081,10 +4098,10 @@
 	// Expects input to be mb_encoded if necessary and RTL reversed
 	// NON_BREAKING SPACE
 	if ($this->usingCoreFont) {
-	      $txt = str_replace(chr(160),chr(32),$txt);
+	      $txt = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($txt ?? ''));
 	}
 	else {
-	      $txt = str_replace(chr(194).chr(160),chr(32),$txt);
+	      $txt = str_replace(chr(194).chr(160),(chr(32) ?? ''),($txt ?? ''));
 	}
 
 	$oldcolumn = $this->CurrCol;
@@ -4392,13 +4409,13 @@
 	if(is_string($border)) {	// If "border", does not come from WriteFlowingBlock or FinishFlowingBlock
 		$x=$this->x;
 		$y=$this->y;
-		if(is_int(strpos($border,'L')))
+		if(is_int(strpos(($border ?? ''),'L')))
 			$s.=sprintf('%.3F %.3F m %.3F %.3F l S ',$x*_MPDFK,($this->h-$bord_boxtop)*_MPDFK,$x*_MPDFK,($this->h-($bord_boxbottom))*_MPDFK);
-		if(is_int(strpos($border,'T')))
+		if(is_int(strpos(($border ?? ''),'T')))
 			$s.=sprintf('%.3F %.3F m %.3F %.3F l S ',$x*_MPDFK,($this->h-$bord_boxtop)*_MPDFK,($x+$w)*_MPDFK,($this->h-$bord_boxtop)*_MPDFK);
-		if(is_int(strpos($border,'R')))
+		if(is_int(strpos(($border ?? ''),'R')))
 			$s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($x+$w)*_MPDFK,($this->h-$bord_boxtop)*_MPDFK,($x+$w)*_MPDFK,($this->h-($bord_boxbottom))*_MPDFK);
-		if(is_int(strpos($border,'B')))
+		if(is_int(strpos(($border ?? ''),'B')))
 			$s.=sprintf('%.3F %.3F m %.3F %.3F l S ',$x*_MPDFK,($this->h-($bord_boxbottom))*_MPDFK,($x+$w)*_MPDFK,($this->h-($bord_boxbottom))*_MPDFK);
 	}
 
@@ -4408,7 +4425,7 @@
 		if ($exactWidth)
 			$stringWidth = $w;  
 		else 
-			$stringWidth = $this->GetStringWidth($txt, true, $OTLdata, $textvar) + ( $this->charspacing * mb_strlen( $txt, $this->mb_enc )/_MPDFK )
+			$stringWidth = $this->GetStringWidth($txt, true, $OTLdata, $textvar) + ( $this->charspacing * mb_strlen( ($txt ?? ''), $this->mb_enc )/_MPDFK )
 				 + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ) / _MPDFK );
 
 		// Set x OFFSET FOR PRINTING
@@ -4429,15 +4446,15 @@
 			$s .=" $this->DrawColor ";
 			$s .=" 2 Tr ";
     		}
-		else if ($this->falseBoldWeight && strpos($this->ReqFontStyle,"B") !== false && strpos($this->FontStyle,"B") === false && !($textvar & FC_SMALLCAPS)) {	// can't use together with OUTLINE or Small Caps	// mPDF 5.7.1	??? why not with SmallCaps ???
+		else if ($this->falseBoldWeight && strpos(($this->ReqFontStyle ?? ''),"B") !== false && strpos(($this->FontStyle ?? ''),"B") === false && !($textvar & FC_SMALLCAPS)) {	// can't use together with OUTLINE or Small Caps	// mPDF 5.7.1	??? why not with SmallCaps ???
 			$s .= ' 2 Tr 1 J 1 j ';
 			$s .= ' '.sprintf('%.3F w',($this->FontSize/130)*_MPDFK*$this->falseBoldWeight).' ';
-			$tc = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG
+			$tc = strtoupper(($this->TextColor ?? '')); // change 0 0 0 rg to 0 0 0 RG
 			if($this->FillColor!=$tc) { $s .= ' '.$tc.' '; }		// stroke (outline) = same colour as text(fill)
 		}
 		else { $s .=" 0 Tr "; }
 
-		if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) {	// Artificial italic
+		if (strpos(($this->ReqFontStyle ?? ''),"I") !== false && strpos(($this->FontStyle ?? ''),"I") === false) {	// Artificial italic
 			$aix = '1 0 0.261799 1 %.3F %.3F Tm '; 
 		}
 		else { $aix = '%.3F %.3F Td '; }
@@ -4480,13 +4497,13 @@
 		// IF NOT corefonts AND IS wordspacing AND NOT SIP AND NOT SmCaps AND NOT Kerning AND NOT OTL
 		// Output text word by word with an adjustment to the intercharacter spacing for SPACEs to form word spacing
 		// IF multibyte - Tw has no effect - need to do word spacing using an adjustment before each space
-		else if (!$this->usingCoreFont && $this->ws && !((isset($this->CurrentFont['sip']) && $this->CurrentFont['sip']) || (isset($this->CurrentFont['smp']) && $this->CurrentFont['smp'])) && !($textvar & FC_SMALLCAPS) && !($textvar & FC_KERNING) && !(isset($this->CurrentFont['useOTL']) && ($this->CurrentFont['useOTL'] & 0xFF) && (!empty($OTLdata['GPOSinfo']) || (strpos($OTLdata['group'],'M')!==false && $this->charspacing)) )) {
+		else if (!$this->usingCoreFont && $this->ws && !((isset($this->CurrentFont['sip']) && $this->CurrentFont['sip']) || (isset($this->CurrentFont['smp']) && $this->CurrentFont['smp'])) && !($textvar & FC_SMALLCAPS) && !($textvar & FC_KERNING) && !(isset($this->CurrentFont['useOTL']) && ($this->CurrentFont['useOTL'] & 0xFF) && (!empty($OTLdata['GPOSinfo']) || (strpos(($OTLdata['group'] ?? ''),'M')!==false && $this->charspacing)) )) {
 			$space = " ";
 			$space= $this->UTF8ToUTF16BE($space, false);
 			$space=$this->_escape($space); 
 			$sub .=sprintf('BT '.$aix.' %.3F Tc [',$px,$py, $this->charspacing);
-			$t = explode(' ',$txt2);
-			$numt = count($t);
+			$t = explode(' ',($txt2 ?? ''));
+			$numt = count(($t ?? []));
 			for($i=0;$i<$numt;$i++) {
 				$tx = $t[$i]; 
 				$tx = $this->UTF8ToUTF16BE($tx , false);
@@ -4592,14 +4609,14 @@
 			foreach($this->textshadow AS $ts) {
 					$s .= ' q ';
 					$s .= $this->SetTColor($ts['col'], true)."\n";
-					if ($ts['col']{0}==5 && ord($ts['col']{4})<100) {	// RGBa
-						$s .= $this->SetAlpha(ord($ts['col']{4})/100, 'Normal', true, 'F')."\n"; 
+					if ($ts['col'][0]==5 && ord(($ts['col'][4] ?? ''))<100) {	// RGBa
+						$s .= $this->SetAlpha(ord(($ts['col'][4] ?? ''))/100, 'Normal', true, 'F')."\n"; 
 					}
-					else if ($ts['col']{0}==6 && ord($ts['col']{5})<100) {	// CMYKa
-						$s .= $this->SetAlpha(ord($ts['col']{5})/100, 'Normal', true, 'F')."\n"; 
+					else if ($ts['col'][0]==6 && ord(($ts['col'][5] ?? ''))<100) {	// CMYKa
+						$s .= $this->SetAlpha(ord(($ts['col'][5] ?? ''))/100, 'Normal', true, 'F')."\n"; 
 					}
-					else if ($ts['col']{0}==1 && $ts['col']{2}==1 && ord($ts['col']{3})<100) {	// Gray
-						$s .= $this->SetAlpha(ord($ts['col']{3})/100, 'Normal', true, 'F')."\n"; 
+					else if ($ts['col'][0]==1 && $ts['col'][2]==1 && ord(($ts['col'][3] ?? ''))<100) {	// Gray
+						$s .= $this->SetAlpha(ord(($ts['col'][3] ?? ''))/100, 'Normal', true, 'F')."\n"; 
 					}
 					$s .= sprintf(' 1 0 0 1 %.4F %.4F cm', $ts['x']*_MPDFK, -$ts['y']*_MPDFK)."\n";
 					$s .= $sub;
@@ -4624,7 +4641,7 @@
 		$this->_out(sprintf('BT %.3F Tc ET',$this->charspacing));	 
 	}
 	$this->lasth=$h;
-	if( strpos($txt,"\n") !== false) $ln=1; // cell recognizes \n from <BR> tag
+	if( strpos(($txt ?? ''),"\n") !== false) $ln=1; // cell recognizes \n from <BR> tag
 	if($ln>0)
 	{
 		//Go to next line
@@ -4682,7 +4699,7 @@
 		$tj = '('; 
 	}
 
-	for($i=0;$i<count($unicode);$i++) {
+	for($i=0;$i<count(($unicode ?? []));$i++) {
 		$c = $unicode[$i];
 		$tx = '';
 		$XshiftBefore = $XshiftAfter;
@@ -4722,7 +4739,7 @@
 				$XshiftAfter += $wordspacing;
 			}
 
-			if (substr($OTLdata['group'],($i+1),1)!='M') {	// Don't add inter-character spacing before Marks
+			if (substr(($OTLdata['group'] ?? ''),($i+1),1)!='M') {	// Don't add inter-character spacing before Marks
 				$XshiftAfter += $charspacing;
 			}
 
@@ -4799,22 +4816,22 @@
 						$groupBreak = true;
 						$fontid = $this->CurrentFont['subsetfontids'][$j];
 					}
-					$tx = sprintf("%02s", strtoupper(dechex($init)));
+					$tx = sprintf("%02s", strtoupper((dechex($init) ?? '')));
 					break;
 				}
-				else if (count($this->CurrentFont['subsets'][$j]) < 255) {
-					$n = count($this->CurrentFont['subsets'][$j]);
+				else if (count(($this->CurrentFont['subsets'][$j] ?? [])) < 255) {
+					$n = count(($this->CurrentFont['subsets'][$j] ?? []));
 					$this->CurrentFont['subsets'][$j][$n] = $c;
 					if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
 						$groupBreak = true;
 						$fontid = $this->CurrentFont['subsetfontids'][$j];
 					}
-					$tx = sprintf("%02s", strtoupper(dechex($n)));
+					$tx = sprintf("%02s", strtoupper((dechex($n) ?? '')));
 					break;
 				}
 				else if (!isset($this->CurrentFont['subsets'][($j+1)])) {
 					$this->CurrentFont['subsets'][($j+1)] = array(0=>0);
-					$this->CurrentFont['subsetfontids'][($j+1)] = count($this->fonts)+$this->extraFontSubsets+1;
+					$this->CurrentFont['subsetfontids'][($j+1)] = count(($this->fonts ?? []))+$this->extraFontSubsets+1;
 					$this->extraFontSubsets++;
 				}
 			}
@@ -4822,7 +4839,7 @@
 		else {
 			$tx = code2utf($c);
 			if ($this->usingCoreFont) { 
-				$tx = utf8_decode($tx);
+				$tx = mb_convert_encoding(($tx ?? ''), 'ISO-8859-1', 'UTF-8');
 			}
 			else {
 				$tx = $this->UTF8ToUTF16BE($tx, false);
@@ -4859,7 +4876,7 @@
 
 			// Get YPlacement from next Base character
 			$nextbase = $i+1;
-			while($OTLdata['group']{$nextbase}!='C') { $nextbase++; }
+			while($OTLdata['group'][$nextbase]!='C') { $nextbase++; }
 			if (isset($GPOSinfo[$nextbase]) && isset($GPOSinfo[$nextbase]['YPlacement']) && $GPOSinfo[$nextbase]['YPlacement']) { 
 				$YPlacement = $GPOSinfo[$nextbase]['YPlacement'] * $this->FontSizePt / $this->CurrentFont['unitsPerEm']; 
 			}
@@ -4872,21 +4889,21 @@
 						if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
 							$fontid = $this->CurrentFont['subsetfontids'][$j];
 						}
-						$tx = sprintf("%02s", strtoupper(dechex($init)));
+						$tx = sprintf("%02s", strtoupper((dechex($init) ?? '')));
 						break;
 					}
-					else if (count($this->CurrentFont['subsets'][$j]) < 255) {
-						$n = count($this->CurrentFont['subsets'][$j]);
+					else if (count(($this->CurrentFont['subsets'][$j] ?? [])) < 255) {
+						$n = count(($this->CurrentFont['subsets'][$j] ?? []));
 						$this->CurrentFont['subsets'][$j][$n] = $c;
 						if ($this->CurrentFont['subsetfontids'][$j] != $last_fontid) {
 							$fontid = $this->CurrentFont['subsetfontids'][$j];
 						}
-						$tx = sprintf("%02s", strtoupper(dechex($n)));
+						$tx = sprintf("%02s", strtoupper((dechex($n) ?? '')));
 						break;
 					}
 					else if (!isset($this->CurrentFont['subsets'][($j+1)])) {
 						$this->CurrentFont['subsets'][($j+1)] = array(0=>0);
-						$this->CurrentFont['subsetfontids'][($j+1)] = count($this->fonts)+$this->extraFontSubsets+1;
+						$this->CurrentFont['subsetfontids'][($j+1)] = count(($this->fonts ?? []))+$this->extraFontSubsets+1;
 						$this->extraFontSubsets++;
 					}
 				}
@@ -4902,7 +4919,7 @@
 				$fontstretch = 100;
 				$nt = intval($kashida / $tatw);
 				$nudgeback = (($nt+1)*$tatw) - $kashida;
-				$optx = str_repeat($tx, $nt);
+				$optx = str_repeat(($tx ?? ''), $nt);
 				if ($sipset) { $optx .= sprintf('>%d<',($nudgeback) ); }
 				else { $optx .= sprintf(')%d(',($nudgeback) ); }
 				$optx .= $tx;	// #last
@@ -4942,7 +4959,7 @@
 			$tj .= sprintf(' /F%d %.3F Tf ', $original_fontid, $fontsize); 
 			$tj .= '[';
 		}
-		$tj = preg_replace('/([^\\\])<>/', '\\1 ', $tj);
+		$tj = preg_replace('/([^\\\])<>/', '\\1 ', ($tj ?? ''));
 	}
 	else {
 		$tj .= ')';
@@ -4952,7 +4969,7 @@
 			$tj .= sprintf(' /F%d %.3F Tf ', $original_fontid, $fontsize); 
 			$tj .= '[';
 		}
-		$tj = preg_replace('/([^\\\])\(\)/', '\\1 ', $tj);
+		$tj = preg_replace('/([^\\\])\(\)/', '\\1 ', ($tj ?? ''));
 	}
 
 
@@ -4970,13 +4987,13 @@
 		  $space= $this->UTF8ToUTF16BE($space , false);
 		  $space=$this->_escape($space ); 
 		  $s = sprintf(' BT '.$aix,$x*_MPDFK,($this->h-$y)*_MPDFK);
-		  $t = explode(' ',$txt);
-		  for($i=0;$i<count($t);$i++) {
+		  $t = explode(' ',($txt ?? ''));
+		  for($i=0;$i<count(($t ?? []));$i++) {
 			$tx = $t[$i]; 
 
 			$tj = '(';
 			$unicode = $this->UTF8StringToArray($tx);
-			for($ti=0;$ti<count($unicode);$ti++) {
+			for($ti=0;$ti<count(($unicode ?? []));$ti++) {
 				if ($ti > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($ti-1)]][$unicode[$ti]]))  {
 							$kern = -$this->CurrentFont['kerninfo'][$unicode[($ti-1)]][$unicode[$ti]];
 							$tj .= sprintf(')%d(',$kern);
@@ -4989,7 +5006,7 @@
 			$s.=sprintf(' %.3F Tc [%s] TJ',$this->charspacing,$tj);
 
 
-			if (($i+1)<count($t)) {
+			if (($i+1)<count(($t ?? []))) {
 				$s.=sprintf(' %.3F Tc (%s) Tj',$this->ws+$this->charspacing,$space);
 			}
 		  }
@@ -4999,7 +5016,7 @@
 	$s = '';
 	$tj = '(';
 	$unicode = $this->UTF8StringToArray($txt);
-	for($i=0;$i<count($unicode);$i++) {
+	for($i=0;$i<count(($unicode ?? []));$i++) {
 		if ($i > 0 && isset($this->CurrentFont['kerninfo'][$unicode[($i-1)]][$unicode[$i]])) {
 					$kern = -$this->CurrentFont['kerninfo'][$unicode[($i-1)]][$unicode[$i]];
 					$tj .= sprintf(')%d(',$kern);
@@ -5014,7 +5031,7 @@
    else {	// CORE Font
 	$s = '';
 	$tj = '(';
-	$l = strlen($txt);
+	$l = strlen(($txt ?? ''));
 	for($i=0;$i<$l;$i++) {
 		if ($i > 0 && isset($this->CurrentFont['kerninfo'][$txt[($i-1)]][$txt[$i]])) {
 			$kern = -$this->CurrentFont['kerninfo'][$txt[($i-1)]][$txt[$i]];
@@ -5041,8 +5058,8 @@
 		if ($this->text_input_as_HTML) {
 			$txt = $this->all_entities_to_utf8($txt);
 		}
-		if ($this->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mb_enc,'UTF-8'); }
-		if (preg_match("/([".$this->pregRTLchars."])/u", $txt)) { $this->biDirectional = true; }	// *OTL*
+		if ($this->usingCoreFont) { $txt = mb_convert_encoding(($txt ?? ''),($this->mb_enc ?? ''),'UTF-8'); }
+		if (preg_match("/([".$this->pregRTLchars."])/u", ($txt ?? ''))) { $this->biDirectional = true; }	// *OTL*
 /*-- OTL --*/
 		$OTLdata = array();
 		// Use OTL OpenType Table Layout - GSUB & GPOS
@@ -5067,14 +5084,14 @@
 
 	$wmax = ($w - ($this->cMarginL+$this->cMarginR));
 	if ($this->usingCoreFont)  {
-		$s=str_replace("\r",'',$txt);
-		$nb=strlen($s);
+		$s=str_replace("\r",'',($txt ?? ''));
+		$nb=strlen(($s ?? ''));
 		while($nb>0 and $s[$nb-1]=="\n")	$nb--;
 	}
 	else {
-		$s=str_replace("\r",'',$txt);
-		$nb=mb_strlen($s, $this->mb_enc );
-		while($nb>0 and mb_substr($s,$nb-1,1,$this->mb_enc )=="\n")	$nb--;
+		$s=str_replace("\r",'',($txt ?? ''));
+		$nb=mb_strlen(($s ?? ''), $this->mb_enc );
+		while($nb>0 and mb_substr(($s ?? ''),$nb-1,1,$this->mb_enc )=="\n")	$nb--;
 	}
 	$b=0;
 	if($border) {
@@ -5085,9 +5102,9 @@
 		}
 		else {
 			$b2='';
-			if(is_int(strpos($border,'L')))	$b2.='L';
-			if(is_int(strpos($border,'R')))	$b2.='R';
-			$b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
+			if(is_int(strpos(($border ?? ''),'L')))	$b2.='L';
+			if(is_int(strpos(($border ?? ''),'R')))	$b2.='R';
+			$b=is_int(strpos(($border ?? ''),'T')) ? $b2.'T' : $b2;
 		}
 	}
 	$sep=-1;
@@ -5102,15 +5119,15 @@
 
    if (!$this->usingCoreFont)  {
 	$inclCursive=false;
-	if (preg_match("/([".$this->pregCURSchars."])/u", $s)) { $inclCursive = true; }
+	if (preg_match("/([".$this->pregCURSchars."])/u", ($s ?? ''))) { $inclCursive = true; }
 	while($i<$nb) {
 		//Get next character
-		$c = mb_substr($s,$i,1,$this->mb_enc );
+		$c = mb_substr(($s ?? ''),$i,1,$this->mb_enc );
 		if($c == "\n") {
 			//Explicit line break
 			// WORD SPACING
 			$this->ResetSpacing();
-			$tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mb_enc));
+			$tmp = rtrim((mb_substr(($s ?? ''),$j,$i-$j,$this->mb_enc) ?? ''));
 			$tmpOTLdata = false;
 /*-- OTL --*/
 			if (isset($OTLdata)) {
@@ -5144,7 +5161,7 @@
 				if($i==$j) $i++;
 				// WORD SPACING
 				$this->ResetSpacing();
-				$tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mb_enc));
+				$tmp = rtrim((mb_substr(($s ?? ''),$j,$i-$j,$this->mb_enc) ?? ''));
 				$tmpOTLdata = false;
 /*-- OTL --*/
 				if (isset($OTLdata)) {
@@ -5156,7 +5173,7 @@
 				$this->Cell($w,$h,$tmp,$b,2,$align,$fill,$link,0,0,0,'M', 0, false, $tmpOTLdata);
 			}
 			else {
-				$tmp = rtrim(mb_substr($s,$j,$sep-$j,$this->mb_enc));
+				$tmp = rtrim((mb_substr(($s ?? ''),$j,$sep-$j,$this->mb_enc) ?? ''));
 				$tmpOTLdata = false;
 /*-- OTL --*/
 				if (isset($OTLdata)) {
@@ -5169,9 +5186,9 @@
 					// JUSTIFY J using Unicode fonts (Word spacing doesn't work)
 					// WORD SPACING UNICODE
 					// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
-					$tmp = str_replace(chr(194).chr(160),chr(32),$tmp ); 
+					$tmp = str_replace(chr(194).chr(160),(chr(32) ?? ''),($tmp ?? '') ); 
 					$len_ligne = $this->GetStringWidth($tmp, false, $tmpOTLdata);
-					$nb_carac = mb_strlen( $tmp , $this->mb_enc ) ;  
+					$nb_carac = mb_strlen( ($tmp ?? '') , $this->mb_enc ) ;  
 					$nb_spaces = mb_substr_count( $tmp ,' ', $this->mb_enc ) ;  
 					// Take off number of Marks
 					// Use GPOS OTL
@@ -5218,7 +5235,7 @@
 			//Explicit line break
 			// WORD SPACING
 			$this->ResetSpacing();
-			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link);
+			$this->Cell($w,$h,substr(($s ?? ''),$j,$i-$j),$b,2,$align,$fill,$link);
 			if ($maxrows!=false && isset($this->mpdfform) && ($this->y - $start_y) / $h > $maxrows) { return false; }
 			$i++;
 			$sep=-1;
@@ -5242,25 +5259,25 @@
 				if($i==$j) $i++;
 				// WORD SPACING
 				$this->ResetSpacing();
-				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link);
+				$this->Cell($w,$h,substr(($s ?? ''),$j,$i-$j),$b,2,$align,$fill,$link);
 			}
 			else {
 				if($align=='J') {
-					$tmp = rtrim(substr($s,$j,$sep-$j));
+					$tmp = rtrim((substr(($s ?? ''),$j,$sep-$j) ?? ''));
 					//////////////////////////////////////////
 					// JUSTIFY J using Unicode fonts (Word spacing doesn't work)
 					// WORD SPACING NON_UNICODE/CJK
 					// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
-					$tmp = str_replace(chr(160),chr(32),$tmp);
+					$tmp = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($tmp ?? ''));
 					$len_ligne = $this->GetStringWidth($tmp );
-					$nb_carac = strlen( $tmp ) ;  
+					$nb_carac = strlen( ($tmp ?? '') ) ;  
 					$nb_spaces = substr_count( $tmp ,' ' ) ;  
 					$tmpOTLdata = array();
 					list($charspacing,$ws,$kashida) = $this->GetJspacing($nb_carac,$nb_spaces,((($wmax) - $len_ligne) * _MPDFK),false, $tmpOTLdata);
 					$this->SetSpacing($charspacing,$ws);
 					//////////////////////////////////////////
 				}
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill,$link);
+				$this->Cell($w,$h,substr(($s ?? ''),$j,$sep-$j),$b,2,$align,$fill,$link);
 				$i=$sep+1;
 			}
 			if ($maxrows!=false && isset($this->mpdfform) && ($this->y - $start_y) / $h > $maxrows) { return false; }
@@ -5280,9 +5297,9 @@
 
    }
 	//Last chunk
-   if($border and is_int(strpos($border,'B')))	$b.='B';
+   if($border and is_int(strpos(($border ?? ''),'B')))	$b.='B';
    if (!$this->usingCoreFont)  {
-		$tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mb_enc));
+		$tmp = rtrim((mb_substr(($s ?? ''),$j,$i-$j,$this->mb_enc) ?? ''));
 		$tmpOTLdata = false;
 /*-- OTL --*/
 		if (isset($OTLdata)) {
@@ -5293,7 +5310,7 @@
 /*-- END OTL --*/
    		$this->Cell($w,$h,$tmp,$b,2,$align,$fill,$link,0,0,0,'M', 0, false, $tmpOTLdata);
    }
-   else { $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill,$link); }
+   else { $this->Cell($w,$h,substr(($s ?? ''),$j,$i-$j),$b,2,$align,$fill,$link); }
    $this->x=$this->lMargin;
 }
 
@@ -5358,12 +5375,12 @@
 	$this->inlineDisplayOff = $saved['display_off'];
 
 	$this->lSpacingCSS = $saved[ 'lSpacingCSS' ];
-	if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
+	if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper(($this->lSpacingCSS ?? '')) != 'NORMAL') {
 		$this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
 	}
 	else { $this->fixedlSpacing = false; }
 	$this->wSpacingCSS = $saved[ 'wSpacingCSS' ];
-	if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { 
+	if ($this->wSpacingCSS && strtoupper(($this->wSpacingCSS ?? '')) != 'NORMAL') { 
 		$this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
 	}
 	else { $this->minwSpacing = 0; }
@@ -5524,12 +5541,12 @@
 	$hanger = '';
 	// Always right trim!
 	// Right trim last content and adjust width if needed to justify (later)
-	if (isset($content[count($content)-1]) && preg_match('/[ ]+$/',$content[count($content)-1], $m)) {
-		$strip = strlen($m[0]);
-		$content[count($content)-1] = substr($content[count($content)-1],0,(strlen($content[count($content)-1])-$strip));
+	if (isset($content[count(($content ?? []))-1]) && preg_match('/[ ]+$/',($content[count(($content ?? []))-1] ?? ''), $m)) {
+		$strip = strlen(($m[0] ?? ''));
+		$content[count(($content ?? []))-1] = substr(($content[count(($content ?? []))-1] ?? ''),0,(strlen(($content[count(($content ?? []))-1] ?? ''))-$strip));
 /*-- OTL --*/
 		if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
-			$this->otl->trimOTLdata($cOTLdata[count($cOTLdata)-1], false, true);
+			$this->otl->trimOTLdata($cOTLdata[count(($cOTLdata ?? []))-1], false, true);
 		}
 /*-- END OTL --*/
 	}
@@ -5564,7 +5581,7 @@
 		$fpaddingR = 0;
 		$fpaddingL = 0;
 /*-- CSS-FLOAT --*/
-		if (count($this->floatDivs)) {
+		if (count(($this->floatDivs ?? []))) {
 			list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
 			if ($r_exists) { $fpaddingR = $r_width; }
 			if ($l_exists) { $fpaddingL = $l_width; }
@@ -5587,7 +5604,7 @@
 
 	$this->_setInlineBlockHeights($lineBox, $stackHeight, $content, $font, $is_table);
 
-	if ($is_table && count($content)==0) { $stackHeight = 0; }
+	if ($is_table && count(($content ?? []))==0) { $stackHeight = 0; }
 
 		if ($table_draft) { 
 			$this->y += $stackHeight;
@@ -5616,13 +5633,13 @@
 				}
 /*-- END OTL --*/
 				else { 	// *OTL*
-					$content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk ); 
-					$content[$k] = $chunk = str_replace(chr(194).chr(160),chr(32),$chunk ); 
+					$content[$k] = $chunk = str_replace("\xc2\xad",'',($chunk ?? '') ); 
+					$content[$k] = $chunk = str_replace(chr(194).chr(160),(chr(32) ?? ''),($chunk ?? '') ); 
 				}	// *OTL*
 			}
 			else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
-			      $content[$k] = $chunk = str_replace(chr(173),'',$chunk );
-				$content[$k] = $chunk = str_replace(chr(160),chr(32),$chunk );
+			      $content[$k] = $chunk = str_replace((chr(173) ?? ''),'',($chunk ?? '') );
+				$content[$k] = $chunk = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($chunk ?? '') );
 			}
 			$contentWidth += $this->GetStringWidth( $chunk, true, (isset($cOTLdata[$k]) ? $cOTLdata[$k] : false), $this->textvar ) * _MPDFK;
 
@@ -5638,15 +5655,15 @@
 		  }
 		}
 
-		if(isset($font[count($font)-1])) {
-			$lastfontreqstyle = (isset($font[count($font)-1]['ReqFontStyle']) ? $font[count($font)-1]['ReqFontStyle'] : '');
-			$lastfontstyle = (isset($font[count($font)-1]['style']) ? $font[count($font)-1]['style'] : '');
+		if(isset($font[count(($font ?? []))-1])) {
+			$lastfontreqstyle = (isset($font[count(($font ?? []))-1]['ReqFontStyle']) ? $font[count(($font ?? []))-1]['ReqFontStyle'] : '');
+			$lastfontstyle = (isset($font[count(($font ?? []))-1]['style']) ? $font[count(($font ?? []))-1]['style'] : '');
 		}
 		else {
 			$lastfontreqstyle=null;
 			$lastfontstyle=null;
 		}
-		if ($blockdir == 'ltr' && strpos($lastfontreqstyle,"I") !== false && strpos($lastfontstyle,"I") === false) {	// Artificial italic
+		if ($blockdir == 'ltr' && strpos(($lastfontreqstyle ?? ''),"I") !== false && strpos(($lastfontstyle ?? ''),"I") === false) {	// Artificial italic
 			$lastitalic = $this->FontSize*0.15*_MPDFK;
 		}
 		else { $lastitalic = 0; }
@@ -5746,7 +5763,7 @@
 	$fpaddingR = 0;
 	$fpaddingL = 0;
 /*-- CSS-FLOAT --*/
-	if (count($this->floatDivs)) {
+	if (count(($this->floatDivs ?? []))) {
 		list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
 		if ($r_exists) { $fpaddingR = $r_width; }
 		if ($l_exists) { $fpaddingL = $l_width; }
@@ -5778,7 +5795,7 @@
 		$dottab = false;
 		foreach ( $content as $k => $chunk ) {
 			if (!isset($this->objectbuffer[$k]) || (isset($this->objectbuffer[$k]) && !$this->objectbuffer[$k])) {
-				$nb_carac += mb_strlen( $chunk, $this->mb_enc );  
+				$nb_carac += mb_strlen( ($chunk ?? ''), $this->mb_enc );  
 				$nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc );  
 				// mPDF 6
 				// Use GPOS OTL
@@ -5788,7 +5805,7 @@
 						$nb_marks = substr_count($cOTLdata[$k]['group'], 'M');
 						$nb_carac -= $nb_marks ;
 					}
-					if (preg_match("/([".$this->pregCURSchars."])/u", $chunk)) { $inclCursive = true; }	
+					if (preg_match("/([".$this->pregCURSchars."])/u", ($chunk ?? ''))) { $inclCursive = true; }	
 				}
 			}
 			else { 
@@ -5798,7 +5815,7 @@
 		}
 
 		// DIRECTIONALITY RTL
-		$chunkorder = range(0, count($content)-1);	// mPDF 6
+		$chunkorder = range(0, count(($content ?? []))-1);	// mPDF 6
 /*-- OTL --*/
 		// mPDF 6
 		if ($blockdir == 'rtl' || $this->biDirectional)  {
@@ -5812,11 +5829,11 @@
 		// And correct for XPlacement on last character
 		// BIDI is applied 
 		foreach($chunkorder AS $aord=>$k) {
-			if (count($cOTLdata)) {
+			if (count(($cOTLdata ?? []))) {
 				$this->restoreFont( $font[ $k ], false);
 				// ...FinishFlowingBlock...
-				if ($aord == count($chunkorder)-1 && isset($cOTLdata[$aord]['group'])) {	// Last chunk on line
-					$nGPOS = strlen($cOTLdata[$aord]['group'])-1;	// Last character
+				if ($aord == count(($chunkorder ?? []))-1 && isset($cOTLdata[$aord]['group'])) {	// Last chunk on line
+					$nGPOS = strlen(($cOTLdata[$aord]['group'] ?? ''))-1;	// Last character
 					if (isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL']) || isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceR'])) {
 						if (isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL'])) {
 							$w = $cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL'] * 1000/$this->CurrentFont['unitsPerEm'];
@@ -5845,10 +5862,10 @@
 
 		// if it's justified, we need to find the char/word spacing (or if orphans have allowed length of line to go over the maxwidth)
 		// If "orphans" in fact is just a final space - ignore this
-		$lastchar = mb_substr($content[(count($chunkorder)-1)],mb_strlen($content[(count($chunkorder)-1)], $this->mb_enc)-1, 1, $this->mb_enc);
-		if (preg_match("/[".$this->CJKoverflow."]/u", $lastchar)) { $CJKoverflow = true; }
+		$lastchar = mb_substr(($content[(count(($chunkorder ?? []))-1)] ?? ''),mb_strlen(($content[(count(($chunkorder ?? []))-1)] ?? ''), $this->mb_enc)-1, 1, $this->mb_enc);
+		if (preg_match("/[".$this->CJKoverflow."]/u", ($lastchar ?? ''))) { $CJKoverflow = true; }
 		else {$CJKoverflow = false; } 
-		if ((((($contentWidth + $lastitalic) > $maxWidth) && ($content[(count($chunkorder)-1)] != ' ') )  ||
+		if ((((($contentWidth + $lastitalic) > $maxWidth) && ($content[(count(($chunkorder ?? []))-1)] != ' ') )  ||
 			(!$endofblock && $align=='J' && ($next=='image' || $next=='select' || $next=='input' || $next=='textarea' || ($next=='br' && $this->justifyB4br))))  && !($CJKoverflow && $this->allowCJKoverflow) ) {
  		  // WORD SPACING
 			list($jcharspacing,$jws,$jkashida) = $this->GetJspacing($nb_carac,$nb_spaces,($maxWidth-$lastitalic-$contentWidth-$WidthCorrection-(($this->cMarginL+$this->cMarginR)*_MPDFK)-($paddingL+$paddingR +(($fpaddingL + $fpaddingR) * _MPDFK) )),$inclCursive, $cOTLdata);
@@ -5856,10 +5873,10 @@
 /*-- CJK-FONTS --*/
 		else if ($this->checkCJK && $align=='J' && $CJKoverflow && $this->allowCJKoverflow && $this->CJKforceend) {
 		// force-end overhang
-			$hanger = mb_substr($content[(count($chunkorder)-1)],mb_strlen($content[(count($chunkorder)-1)],$this->mb_enc)-1,1,$this->mb_enc );
-			if (preg_match("/[".$this->CJKoverflow."]/u", $hanger)) {
-				$content[(count($chunkorder)-1)] = mb_substr($content[(count($chunkorder)-1)],0,mb_strlen($content[(count($chunkorder)-1)],$this->mb_enc)-1,$this->mb_enc );
-				$this->restoreFont( $font[ $chunkorder[count($chunkorder)-1] ],false );
+			$hanger = mb_substr(($content[(count(($chunkorder ?? []))-1)] ?? ''),mb_strlen(($content[(count(($chunkorder ?? []))-1)] ?? ''),$this->mb_enc)-1,1,$this->mb_enc );
+			if (preg_match("/[".$this->CJKoverflow."]/u", ($hanger ?? ''))) {
+				$content[(count(($chunkorder ?? []))-1)] = mb_substr(($content[(count(($chunkorder ?? []))-1)] ?? ''),0,mb_strlen(($content[(count(($chunkorder ?? []))-1)] ?? ''),$this->mb_enc)-1,$this->mb_enc );
+				$this->restoreFont( $font[ $chunkorder[count(($chunkorder ?? []))-1] ],false );
 				$contentWidth -= $this->GetStringWidth($hanger) * _MPDFK;
 				$nb_carac -= 1;
 				list($jcharspacing,$jws,$jkashida) = $this->GetJspacing($nb_carac,$nb_spaces,($maxWidth-$lastitalic-$contentWidth-$WidthCorrection-(($this->cMarginL+$this->cMarginR)*_MPDFK)-($paddingL+$paddingR +(($fpaddingL + $fpaddingR) * _MPDFK) )),$inclCursive, $cOTLdata);
@@ -5897,7 +5914,7 @@
 			$this->maxPosL = min($this->maxPosL , ($this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $empty)); 
 		}
 
-		$arraysize = count($chunkorder);
+		$arraysize = count(($chunkorder ?? []));
 
 		$margins = ($this->cMarginL+$this->cMarginR) + ($ipaddingL+$ipaddingR + $fpaddingR + $fpaddingR );
 
@@ -5943,9 +5960,9 @@
 
 			$this->restoreFont( $font[ $k ] ); 	// mPDF 5.7
 
-			if ($is_table && substr($align,0,1)=='D' && $aord==0 ) {
-				$dp = $this->decimal_align[substr($align,0,2)];
-				$s = preg_split('/'.preg_quote($dp,'/').'/', $content[0], 2); 	// ? needs to be /u if not core
+			if ($is_table && substr(($align ?? ''),0,1)=='D' && $aord==0 ) {
+				$dp = $this->decimal_align[substr(($align ?? ''),0,2)];
+				$s = preg_split('/'.preg_quote(($dp ?? ''),'/').'/', ($content[0] ?? ''), 2); 	// ? needs to be /u if not core
 				$s0 = $this->GetStringWidth($s[0], false);
 				$this->x += ($this->decimal_offset - $s0);
 			}
@@ -5966,14 +5983,14 @@
 				$save_fill = $fill; $spanfill = 1; $fill = 1;
 			}
 			if (!empty($this->spanborddet)) { 
-				if (strpos($contentB[$k],'L')!==false && isset($this->spanborddet['L'])) $this->x += $this->spanborddet['L']['w'];
-				if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0; 
-				if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0; 
+				if (strpos(($contentB[$k] ?? ''),'L')!==false && isset($this->spanborddet['L'])) $this->x += $this->spanborddet['L']['w'];
+				if (strpos(($contentB[$k] ?? ''),'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0; 
+				if (strpos(($contentB[$k] ?? ''),'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0; 
 			}
 			// WORD SPACING
 			// mPDF 5.7.1
 		      $stringWidth = $this->GetStringWidth($chunk, true, (isset($cOTLdata[$aord]) ? $cOTLdata[$aord] : false), $this->textvar );
-			$nch = mb_strlen($chunk,$this->mb_enc );
+			$nch = mb_strlen(($chunk ?? ''),$this->mb_enc );
 			// Use GPOS OTL
 			if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
 				if (isset($cOTLdata[$aord]['group']) && $cOTLdata[$aord]['group']) {
@@ -6014,7 +6031,7 @@
 
 
 			if (!empty($this->spanborddet)) { 
-				if (strpos($contentB[$k],'R')!==false && $aord != $arraysize-1)  $this->x += $this->spanborddet['R']['w'];
+				if (strpos(($contentB[$k] ?? ''),'R')!==false && $aord != $arraysize-1)  $this->x += $this->spanborddet['R']['w'];
 			}
 	 		// *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
 			if (isset($spanfill) && $spanfill) { 
@@ -6211,7 +6228,7 @@
 				$tr .= ' '. $this->transformRotate(180, $objattr['INNER-X'],($objattr['INNER-Y'] +$objattr['INNER-HEIGHT'] ),true) ;
 			}
 			else { $tr = ''; }
-			$tr = trim($tr);
+			$tr = trim(($tr ?? ''));
 			if ($tr) { $tr .= ' '; }
 			$gradmask = '';
 
@@ -6222,55 +6239,55 @@
 				$maxsize_y = $h;
 				$cx = $x + $w/2;
 				$cy = $y + $h/2;
-				preg_match_all('/(translatex|translatey|translate|scalex|scaley|scale|rotate|skewX|skewY|skew)\((.*?)\)/is',$objattr['transform'],$m);
-				if (count($m[0])) {
-					for($i=0; $i<count($m[0]); $i++) {
-						$c = strtolower($m[1][$i]);
-						$v = trim($m[2][$i]);
-						$vv = preg_split('/[ ,]+/',$v);
-						if ($c=='translate' && count($vv)) {
+				preg_match_all('/(translatex|translatey|translate|scalex|scaley|scale|rotate|skewX|skewY|skew)\((.*?)\)/is',($objattr['transform'] ?? ''),$m);
+				if (count(($m[0] ?? []))) {
+					for($i=0; $i<count(($m[0] ?? [])); $i++) {
+						$c = strtolower(($m[1][$i] ?? ''));
+						$v = trim(($m[2][$i] ?? ''));
+						$vv = preg_split('/[ ,]+/',($v ?? ''));
+						if ($c=='translate' && count(($vv ?? []))) {
 							$translate_x = $this->ConvertSize($vv[0],$maxsize_x,false,false);
-							if (count($vv)==2) { $translate_y = $this->ConvertSize($vv[1],$maxsize_y,false,false); }
+							if (count(($vv ?? []))==2) { $translate_y = $this->ConvertSize($vv[1],$maxsize_y,false,false); }
 							else { $translate_y = 0; }
 							$tr2 .= $this->transformTranslate($translate_x, $translate_y, true).' ';
 						}
-						else if ($c=='translatex' && count($vv)) {
+						else if ($c=='translatex' && count(($vv ?? []))) {
 							$translate_x = $this->ConvertSize($vv[0],$maxsize_x,false,false);
 							$tr2 .= $this->transformTranslate($translate_x, 0, true).' ';
 						}
-						else if ($c=='translatey' && count($vv)) {
+						else if ($c=='translatey' && count(($vv ?? []))) {
 							$translate_y = $this->ConvertSize($vv[1],$maxsize_y,false,false);
 							$tr2 .= $this->transformTranslate(0, $translate_y, true).' ';
 						}
-						else if ($c=='scale' && count($vv)) {
+						else if ($c=='scale' && count(($vv ?? []))) {
 							$scale_x = $vv[0] * 100;
-							if (count($vv)==2) { $scale_y = $vv[1] * 100; }
+							if (count(($vv ?? []))==2) { $scale_y = $vv[1] * 100; }
 							else { $scale_y = $scale_x; }
 							$tr2 .= $this->transformScale($scale_x, $scale_y, $cx, $cy, true).' ';
 						}
-						else if ($c=='scalex' && count($vv)) {
+						else if ($c=='scalex' && count(($vv ?? []))) {
 							$scale_x = $vv[0] * 100;
 							$tr2 .= $this->transformScale($scale_x, 0, $cx, $cy, true).' ';
 						}
-						else if ($c=='scaley' && count($vv)) {
+						else if ($c=='scaley' && count(($vv ?? []))) {
 							$scale_y = $vv[1] * 100;
 							$tr2 .= $this->transformScale(0, $scale_y, $cx, $cy, true).' ';
 						}
-						else if ($c=='skew' && count($vv)) {
+						else if ($c=='skew' && count(($vv ?? []))) {
 							$angle_x = $this->ConvertAngle($vv[0], false);
-							if (count($vv)==2) { $angle_y = $this->ConvertAngle($vv[1], false); }
+							if (count(($vv ?? []))==2) { $angle_y = $this->ConvertAngle($vv[1], false); }
 							else { $angle_y = 0; }
 							$tr2 .= $this->transformSkew($angle_x, $angle_y, $cx, $cy, true).' ';
 						}
-						else if ($c=='skewx' && count($vv)) {
+						else if ($c=='skewx' && count(($vv ?? []))) {
 							$angle = $this->ConvertAngle($vv[0], false);
 							$tr2 .= $this->transformSkew($angle, 0, $cx, $cy, true).' ';
 						}
-						else if ($c=='skewy' && count($vv)) {
+						else if ($c=='skewy' && count(($vv ?? []))) {
 							$angle = $this->ConvertAngle($vv[0], false);
 							$tr2 .= $this->transformSkew(0, $angle, $cx, $cy, true).' ';
 						}
-						else if ($c=='rotate' && count($vv)) {
+						else if ($c=='rotate' && count(($vv ?? []))) {
 							$angle = $this->ConvertAngle($vv[0]);
 							$tr2 .= $this->transformRotate($angle, $cx, $cy, true).' ';
 						}
@@ -6307,7 +6324,7 @@
 				$g = $this->grad->parseMozGradient( $objattr['GRADIENT-MASK'] );
 				if ($g) {
 					$dummy = $this->grad->Gradient($objattr['INNER-X'], $objattr['INNER-Y'], $obiw, $obih, $g['type'], $g['stops'], $g['colorspace'], $g['coords'], $g['extend'], true, true);
-					$gradmask = '/TGS'.count($this->gradients).' gs ';
+					$gradmask = '/TGS'.count(($this->gradients ?? [])).' gs ';
 				}
 			}
 /*-- END BACKGROUNDS --*/
@@ -6535,7 +6552,7 @@
 function _printListBullet($x, $y, $size, $type, $color) {
 	// x and y are the centre of the bullet; size is the width and/or height in mm
 	$fcol = $this->SetTColor($color,true);
-	$lcol = strtoupper($fcol); // change 0 0 0 rg to 0 0 0 RG
+	$lcol = strtoupper(($fcol ?? '')); // change 0 0 0 rg to 0 0 0 RG
 	$this->_out( sprintf('q %s %s',$lcol, $fcol) );
 	$this->_out( '0 j 0 J [] 0 d' );
 	if ($type=='square') {
@@ -6561,11 +6578,11 @@
 	while ($charctr<0) {	// go back to previous $content[]
 		$contentctr--;
 		if ($contentctr<0) { return false; }
-   		if ($this->usingCoreFont) { $charctr = strlen( $content[$contentctr] )-1; }
-   		else { $charctr = mb_strlen( $content[$contentctr], $this->mb_enc )-1; }
+   		if ($this->usingCoreFont) { $charctr = strlen( ($content[$contentctr] ?? '') )-1; }
+   		else { $charctr = mb_strlen( ($content[$contentctr] ?? ''), $this->mb_enc )-1; }
 	}
 	if ($this->usingCoreFont) { $lastchar = $content[$contentctr][$charctr]; }
-	else { $lastchar = mb_substr($content[$contentctr],$charctr,1,$this->mb_enc ); }
+	else { $lastchar = mb_substr(($content[$contentctr] ?? ''),$charctr,1,$this->mb_enc ); }
 	return $lastchar;
 }
 // Get previous character
@@ -6575,11 +6592,11 @@
 	while ($charctr<0) {	// go back to previous $content[]
 		$contentctr--;
 		if ($contentctr<0) { return false; }
-   		if ($this->usingCoreFont) { $charctr = strlen( $content[$contentctr] )-1; }
-   		else { $charctr = mb_strlen( $content[$contentctr], $this->mb_enc )-1; }
+   		if ($this->usingCoreFont) { $charctr = strlen( ($content[$contentctr] ?? '') )-1; }
+   		else { $charctr = mb_strlen( ($content[$contentctr] ?? ''), $this->mb_enc )-1; }
 	}
 	if ($this->usingCoreFont) {$lastchar = $content[$contentctr][$charctr]; }
-	else { $lastchar = mb_substr($content[$contentctr],$charctr,1,$this->mb_enc ); }
+	else { $lastchar = mb_substr(($content[$contentctr] ?? ''),$charctr,1,$this->mb_enc ); }
 	return $lastchar;
 }
 
@@ -6619,7 +6636,7 @@
 	$content[] = '';
 	$contentB[] = '';
 	$cOTLdata[] = $sOTLdata;	// mPDF 5.7.1
-	$currContent =& $content[ count( $content ) - 1 ];
+	$currContent =& $content[ count( ($content ?? []) ) - 1 ];
 
 	$CJKoverflow = false;
 	$Oikomi = false;	// mPDF 6
@@ -6655,7 +6672,7 @@
 		$fpaddingR = 0;
 		$fpaddingL = 0;
 /*-- CSS-FLOAT --*/
-		if (count($this->floatDivs)) {
+		if (count(($this->floatDivs ?? []))) {
 			list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
 			if ($r_exists) { $fpaddingR = $r_width; }
 			if ($l_exists) { $fpaddingL = $l_width; }
@@ -6674,7 +6691,7 @@
    }	// *TABLES*
 
      //OBJECTS - IMAGES & FORM Elements (NB has already skipped line/page if required - in printbuffer)
-      if (substr($s,0,3) == "\xbb\xa4\xac") { //identifier has been identified!
+      if (substr(($s ?? ''),0,3) == "\xbb\xa4\xac") { //identifier has been identified!
 		$objattr = $this->_getObjAttr($s);
 		$h_corr = 0; 
 		if ($is_table) {	// *TABLES*
@@ -6688,7 +6705,7 @@
 
 		// SET LINEHEIGHT for this line ================ RESET AT END
 		$stackHeight = MAX($stackHeight,$objattr['OUTER-HEIGHT']);
-		$this->objectbuffer[count($content)-1] = $objattr;
+		$this->objectbuffer[count(($content ?? []))-1] = $objattr;
 		// if (isset($objattr['vertical-align'])) { $valign = $objattr['vertical-align']; }
 		// else { $valign = ''; }
 		// LIST MARKERS	// mPDF 6  Lists
@@ -6708,10 +6725,10 @@
 	}
 
    if ($this->usingCoreFont) {
-	$clen = strlen( $s );
+	$clen = strlen( ($s ?? '') );
    }
    else {
-	$clen = mb_strlen( $s, $this->mb_enc );
+	$clen = mb_strlen( ($s ?? ''), $this->mb_enc );
    }
 
    // for every character in the string
@@ -6730,7 +6747,7 @@
 		}
 	}
 	else {
-		$c = mb_substr($s,$i,1,$this->mb_enc );
+		$c = mb_substr(($s ?? ''),$i,1,$this->mb_enc );
 		$cw = ($this->GetCharWidthNonCore($c, false) * _MPDFK);
 		// mPDF 5.7.1
 		// Use OTL GPOS 
@@ -6743,7 +6760,7 @@
 			}
 		}
 		if (($this->textvar & FC_KERNING) && $i > 0) {	// mPDF 5.7.1
-	     		$lastc = mb_substr($s,($i-1),1,$this->mb_enc );
+	     		$lastc = mb_substr(($s ?? ''),($i-1),1,$this->mb_enc );
 			$ulastc = $this->UTF8StringToArray($lastc, false);
 			$uc = $this->UTF8StringToArray($c, false);
 			if (isset($this->CurrentFont['kerninfo'][$ulastc[0]][$uc[0]])) { 
@@ -6754,11 +6771,11 @@
 
 	if ($i==0) {
 		$cw += $lbw*_MPDFK;
-		$contentB[(count($contentB)-1)] .= 'L';
+		$contentB[(count(($contentB ?? []))-1)] .= 'L';
 	}
 	if ($i==($clen-1)) {
 		$cw += $rbw*_MPDFK;
-		$contentB[(count($contentB)-1)] .= 'R';
+		$contentB[(count(($contentB ?? []))-1)] .= 'R';
 	}
 	if ($c==' ') {
 		$currContent .= $c;
@@ -6785,7 +6802,7 @@
 	$fpaddingR = 0;
 	$fpaddingL = 0;
 /*-- CSS-FLOAT --*/
-	if (count($this->floatDivs)) {
+	if (count(($this->floatDivs ?? []))) {
 		list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
 		if ($r_exists) { $fpaddingR = $r_width; }
 		if ($l_exists) { $fpaddingL = $l_width; }
@@ -6826,9 +6843,9 @@
 		// LINE BREAKING
 		/////////////////////
 		$breakfound = false;
-		$contentctr = count($content)-1;
-		if ($this->usingCoreFont) { $charctr = strlen($currContent); }
-		else { $charctr = mb_strlen($currContent,$this->mb_enc ); }
+		$contentctr = count(($content ?? []))-1;
+		if ($this->usingCoreFont) { $charctr = strlen(($currContent ?? '')); }
+		else { $charctr = mb_strlen(($currContent ?? ''),$this->mb_enc ); }
 		$checkchar = $c;
 		$prevchar = $this->_getPrevChar($contentctr, $charctr, $content);
 
@@ -6847,12 +6864,12 @@
 			$followingchar = '';
 			if ($i<($clen-1)) {
 				if ($this->usingCoreFont) { $followingchar = $s[$i+1]; }
-				else { $followingchar = mb_substr($s,$i+1,1,$this->mb_enc ); }
+				else { $followingchar = mb_substr(($s ?? ''),$i+1,1,$this->mb_enc ); }
 			}
 			/////////////////////
 			// 1a) Overflow punctuation
 			/////////////////////
-			if (preg_match("/[".$this->pregCJKchars."]/u",$prevchar) && preg_match("/[".$this->CJKoverflow."]/u", $checkchar) && $this->allowCJKorphans) {
+			if (preg_match("/[".$this->pregCJKchars."]/u",($prevchar ?? '')) && preg_match("/[".$this->CJKoverflow."]/u", ($checkchar ?? '')) && $this->allowCJKorphans) {
 				// add character onto this line
 				$currContent .= $c;
 				$contentWidth += $cw;
@@ -6864,10 +6881,10 @@
 			//  or next character cannot start line (and not splitting CJK numerals)
 			/////////////////////
 			// NB otherwise it move lastchar(s) to next line to keep $c company = Oidashi, which is done below in standard way
-			else if (preg_match("/[".$this->pregCJKchars."]/u",$checkchar) && $this->allowCJKorphans && 
-				(preg_match("/[".$this->CJKleading."]/u", $followingchar) || preg_match("/[".$this->CJKfollowing."]/u", $checkchar)) && 
-				!preg_match("/[".$this->CJKleading."]/u", $checkchar) && !preg_match("/[".$this->CJKfollowing."]/u", $followingchar) && 
-				!(preg_match("/[0-9\x{ff10}-\x{ff19}]/u", $followingchar) && preg_match("/[0-9\x{ff10}-\x{ff19}]/u", $checkchar))) {
+			else if (preg_match("/[".$this->pregCJKchars."]/u",($checkchar ?? '')) && $this->allowCJKorphans && 
+				(preg_match("/[".$this->CJKleading."]/u", ($followingchar ?? '')) || preg_match("/[".$this->CJKfollowing."]/u", ($checkchar ?? ''))) && 
+				!preg_match("/[".$this->CJKleading."]/u", ($checkchar ?? '')) && !preg_match("/[".$this->CJKfollowing."]/u", ($followingchar ?? '')) && 
+				!(preg_match("/[0-9\x{ff10}-\x{ff19}]/u", ($followingchar ?? '')) && preg_match("/[0-9\x{ff10}-\x{ff19}]/u", ($checkchar ?? '')))) {
 				// add character onto this line
 				$currContent .= $c;
 				$contentWidth += $cw;
@@ -6885,15 +6902,15 @@
 			$currWord = '';
 			// Look back and ahead to get current word
 			for($ac = $charctr-1; $ac>=0; $ac--) {
-				if ($this->usingCoreFont) { $addc = substr($currContent,$ac,1); }
-				else { $addc = mb_substr($currContent,$ac,1,$this->mb_enc ); }
+				if ($this->usingCoreFont) { $addc = substr(($currContent ?? ''),$ac,1); }
+				else { $addc = mb_substr(($currContent ?? ''),$ac,1,$this->mb_enc ); }
 				if ($addc == ' ') { break; }
 				$currWord = $addc.$currWord;
 			}
 			$start = $ac+1; 
 			for($ac = $i; $ac<($clen-1); $ac++) {
-				if ($this->usingCoreFont) { $addc = substr($s,$ac,1); }
-				else { $addc = mb_substr($s,$ac,1,$this->mb_enc ); }
+				if ($this->usingCoreFont) { $addc = substr(($s ?? ''),$ac,1); }
+				else { $addc = mb_substr(($s ?? ''),$ac,1,$this->mb_enc ); }
 				if ($addc == ' ') { break; }
 				$currWord .= $addc;
 			}
@@ -6929,13 +6946,13 @@
 				// Look back to get first part of current word
 				$checkw = '';
 				for($ac = $charctr-1; $ac>=0; $ac--) {
-					if ($this->usingCoreFont) { $addc = substr($currContent,$ac,1); }
-					else { $addc = mb_substr($currContent,$ac,1,$this->mb_enc ); }
+					if ($this->usingCoreFont) { $addc = substr(($currContent ?? ''),$ac,1); }
+					else { $addc = mb_substr(($currContent ?? ''),$ac,1,$this->mb_enc ); }
 					if ($addc == ' ') { break; }
 					$checkw = $addc.$checkw;
 				}
 				// Don't break if HyphenMinus AND (a URL or before a numeral or before a >)
-				if ((!preg_match('/(http:|ftp:|https:|www\.)/',$checkw) && $checkchar!='>' && !preg_match('/[0-9]/',$checkchar)) || $prevchar == "\xe2\x80\x90") {
+				if ((!preg_match('/(http:|ftp:|https:|www\.)/',($checkw ?? '')) && $checkchar!='>' && !preg_match('/[0-9]/',($checkchar ?? ''))) || $prevchar == "\xe2\x80\x90") {
 					$breakfound = array($cutcontentctr, $cutcharctr, $cutcontentctr, $cutcharctr, 'cut');
 				}
 			}
@@ -6944,7 +6961,7 @@
 			/////////////////////
 			else if (isset($this->textparam['hyphens']) && $this->textparam['hyphens'] != 2 && !$this->usingCoreFont && $prevchar == "\xc2\xad") { 
 				$breakfound = array($cutcontentctr, $cutcharctr, $cutcontentctr, $cutcharctr, 'cut');
-				$content[$contentctr] = mb_substr($content[$contentctr],0,$charctr,$this->mb_enc) . '-' . mb_substr($content[$contentctr],$charctr+1,mb_strlen($content[$contentctr]),$this->mb_enc);
+				$content[$contentctr] = mb_substr(($content[$contentctr] ?? ''),0,$charctr,$this->mb_enc) . '-' . mb_substr(($content[$contentctr] ?? ''),$charctr+1,mb_strlen(($content[$contentctr] ?? '')),$this->mb_enc);
 				if (!empty($cOTLdata[$contentctr])) {
 					$cOTLdata[$contentctr]['char_data'][$charctr] = array('bidi_class'=>9, 'uni'=>45);
 					$cOTLdata[$contentctr]['group'][$charctr] = 'C';
@@ -6952,16 +6969,16 @@
 			}
 			else if (isset($this->textparam['hyphens']) && $this->textparam['hyphens'] != 2 && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats' && $prevchar == chr(173)) { 
 				$breakfound = array($cutcontentctr, $cutcharctr, $cutcontentctr, $cutcharctr, 'cut');
-				$content[$contentctr] = substr($content[$contentctr],0,$charctr) . '-' . substr($content[$contentctr],$charctr+1);
+				$content[$contentctr] = substr(($content[$contentctr] ?? ''),0,$charctr) . '-' . substr(($content[$contentctr] ?? ''),$charctr+1);
 			}
 /*-- CJK-FONTS --*/
 			/////////////////////
 			// 7) Break at CJK characters (unless forbidden characters to end or start line)
 			// CJK Avoiding line break in the middle of numerals
 			/////////////////////
-			else if (!$this->usingCoreFont && $this->checkCJK && preg_match("/[".$this->pregCJKchars."]/u",$checkchar) && 
-				!preg_match("/[".$this->CJKfollowing."]/u", $checkchar) && !preg_match("/[".$this->CJKleading."]/u", $prevchar) && 
-				!(preg_match("/[0-9\x{ff10}-\x{ff19}]/u", $prevchar) && preg_match("/[0-9\x{ff10}-\x{ff19}]/u", $checkchar))) {
+			else if (!$this->usingCoreFont && $this->checkCJK && preg_match("/[".$this->pregCJKchars."]/u",($checkchar ?? '')) && 
+				!preg_match("/[".$this->CJKfollowing."]/u", ($checkchar ?? '')) && !preg_match("/[".$this->CJKleading."]/u", ($prevchar ?? '')) && 
+				!(preg_match("/[0-9\x{ff10}-\x{ff19}]/u", ($prevchar ?? '')) && preg_match("/[0-9\x{ff10}-\x{ff19}]/u", ($checkchar ?? '')))) {
 					$breakfound = array($cutcontentctr, $cutcharctr, $cutcontentctr, $cutcharctr, 'cut');
 			}
 /*-- END CJK-FONTS --*/
@@ -6984,7 +7001,7 @@
 			$cutcharctr = $breakfound[3];
 			$type = $breakfound[4];
 			// Cache chunks which are already processed, but now need to be passed on to the new line
-			for ($ix=count($content)-1;$ix>$cutcontentctr;$ix--) {
+			for ($ix=count(($content ?? []))-1;$ix>$cutcontentctr;$ix--) {
 				// save and crop off any subsequent chunks
 /*-- OTL --*/
 				if (!empty($sOTLdata)) {
@@ -6999,12 +7016,12 @@
 
 			// Next cache the part which will start the next line
 			if ($this->usingCoreFont) {
-				$savedPreContent[] = substr($content[$cutcontentctr],$cutcharctr);
+				$savedPreContent[] = substr(($content[$cutcontentctr] ?? ''),$cutcharctr);
 			}
 			else {
-				$savedPreContent[] = mb_substr($content[$cutcontentctr],$cutcharctr,mb_strlen($content[$cutcontentctr]),$this->mb_enc);
-			}
-			$savedPreContentB[] = preg_replace('/L/','',$contentB[$cutcontentctr]);
+				$savedPreContent[] = mb_substr(($content[$cutcontentctr] ?? ''),$cutcharctr,mb_strlen(($content[$cutcontentctr] ?? '')),$this->mb_enc);
+			}
+			$savedPreContentB[] = preg_replace('/L/','',($contentB[$cutcontentctr] ?? ''));
 			$savedPreFont[] = $font[$cutcontentctr];
 /*-- OTL --*/
 			if (!empty($sOTLdata)) {
@@ -7021,27 +7038,27 @@
 				array_pop($cOTLdata);
 			}
 
-			$currContent =& $content[ count( $content ) - 1 ];
+			$currContent =& $content[ count( ($content ?? []) ) - 1 ];
 			if ($this->usingCoreFont) {
-				$currContent = substr($currContent,0,$charctr);
+				$currContent = substr(($currContent ?? ''),0,$charctr);
 			}
 			else {
-				$currContent = mb_substr($currContent,0,$charctr,$this->mb_enc);
+				$currContent = mb_substr(($currContent ?? ''),0,$charctr,$this->mb_enc);
 			}
 
 			if (!empty($sOTLdata)) {
-				$savedPreOTLdata[] = $this->otl->splitOTLdata($cOTLdata[(count($cOTLdata)-1)], mb_strlen($currContent,$this->mb_enc));
-			}
-
-			if (strpos($contentB[(count($contentB)-1)],'R')!==false) {			// ???
-				$contentB[count($content)-1] = preg_replace('/R/','',$contentB[count($content)-1]);	// ???
+				$savedPreOTLdata[] = $this->otl->splitOTLdata($cOTLdata[(count(($cOTLdata ?? []))-1)], mb_strlen(($currContent ?? ''),$this->mb_enc));
+			}
+
+			if (strpos(($contentB[(count(($contentB ?? []))-1)] ?? ''),'R')!==false) {			// ???
+				$contentB[count(($content ?? []))-1] = preg_replace('/R/','',($contentB[count(($content ?? []))-1] ?? ''));	// ???
 			}
 
 			if ($type=='hyphen') {
 				$currContent .= '-';
-				if (!empty($cOTLdata[(count($cOTLdata)-1)])) {
-					$cOTLdata[(count($cOTLdata)-1)]['char_data'][] = array('bidi_class'=>9, 'uni'=>45);
-					$cOTLdata[(count($cOTLdata)-1)]['group'] .= 'C';
+				if (!empty($cOTLdata[(count(($cOTLdata ?? []))-1)])) {
+					$cOTLdata[(count(($cOTLdata ?? []))-1)]['char_data'][] = array('bidi_class'=>9, 'uni'=>45);
+					$cOTLdata[(count(($cOTLdata ?? []))-1)]['group'] .= 'C';
 				}
 			}
 
@@ -7060,32 +7077,32 @@
 		if (!is_array($breakfound)) {
 			$savedFont = $this->saveFont();
 			if (!empty($sOTLdata)) {
-				$savedOTLdata = $this->otl->splitOTLdata($cOTLdata[(count($cOTLdata)-1)], mb_strlen($currContent,$this->mb_enc));
-			}
-		}
-
-		if ($content[ count($content)-1 ] == '' && !isset($this->objectbuffer[ count($content)-1 ])) {
+				$savedOTLdata = $this->otl->splitOTLdata($cOTLdata[(count(($cOTLdata ?? []))-1)], mb_strlen(($currContent ?? ''),$this->mb_enc));
+			}
+		}
+
+		if ($content[ count(($content ?? []))-1 ] == '' && !isset($this->objectbuffer[ count(($content ?? []))-1 ])) {
 			array_pop($content);
 			array_pop($contentB);
 			array_pop($font);
 			array_pop($cOTLdata);
-			$currContent =& $content[ count($content)-1 ];
+			$currContent =& $content[ count(($content ?? []))-1 ];
 		}
 
 		// Right Trim current content - including CJK space, and for OTLdata
 		// incl. CJK - strip CJK space at end of line &#x3000; = \xe3\x80\x80 = CJK space
-		$currContent = rtrim( $currContent );
-		if ($this->checkCJK) { $currContent = preg_replace("/\xe3\x80\x80$/",'',$currContent) ; }	// *CJK-FONTS*
+		$currContent = rtrim( ($currContent ?? '') );
+		if ($this->checkCJK) { $currContent = preg_replace("/\xe3\x80\x80$/",'',($currContent ?? '')) ; }	// *CJK-FONTS*
 /*-- OTL --*/
 		if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
-			$this->otl->trimOTLdata($cOTLdata[count($cOTLdata)-1], false, true);	// NB also does U+3000
+			$this->otl->trimOTLdata($cOTLdata[count(($cOTLdata ?? []))-1], false, true);	// NB also does U+3000
 		}
 /*-- END OTL --*/
 
 
 		// Selected OBJECTS are moved forward to next line, unless they come before a space or U+200B (type='discard')
-		if (isset($this->objectbuffer[(count($content)-1)]) && (!isset($type) || $type != 'discard')) {
-			$objtype = $this->objectbuffer[(count($content)-1)]['type'];
+		if (isset($this->objectbuffer[(count(($content ?? []))-1)]) && (!isset($type) || $type != 'discard')) {
+			$objtype = $this->objectbuffer[(count(($content ?? []))-1)]['type'];
 			if ($objtype=='dottab' || $objtype=='bookmark' || $objtype=='indexentry' || $objtype=='toc' || $objtype=='annot') {
 				$savedObj = array_pop( $this->objectbuffer );
 			}
@@ -7093,7 +7110,7 @@
 
 
 		// Decimal alignment (cancel if wraps to > 1 line)
-		if ($is_table && substr($align,0,1)=='D' ) { $align=substr($align,2,1); }
+		if ($is_table && substr(($align ?? ''),0,1)=='D' ) { $align=substr(($align ?? ''),2,1); }
 
 		$lineBox = array();
 
@@ -7117,11 +7134,11 @@
 		  }
 		  else if (!isset($this->objectbuffer[$k]) || (isset($this->objectbuffer[$k]) && !$this->objectbuffer[$k])) { 
 			$this->restoreFont( $font[ $k ], false);
-			if ($this->checkCJK && $k == count($content)-1 && $CJKoverflow && $align=='J' && $this->allowCJKoverflow && $this->CJKforceend) {
+			if ($this->checkCJK && $k == count(($content ?? []))-1 && $CJKoverflow && $align=='J' && $this->allowCJKoverflow && $this->CJKforceend) {
 			  // force-end overhang
-				$hanger = mb_substr($chunk,mb_strlen($chunk,$this->mb_enc)-1,1,$this->mb_enc );
+				$hanger = mb_substr(($chunk ?? ''),mb_strlen(($chunk ?? ''),$this->mb_enc)-1,1,$this->mb_enc );
 				// Probably ought to do something with char_data and GPOS in cOTLdata...
-				$content[$k] = $chunk = mb_substr($chunk,0,mb_strlen($chunk,$this->mb_enc)-1,$this->mb_enc );
+				$content[$k] = $chunk = mb_substr(($chunk ?? ''),0,mb_strlen(($chunk ?? ''),$this->mb_enc)-1,$this->mb_enc );
 			}
 
 			// Soft Hyphens chr(173) + Replace NBSP with SPACE + Set inclcursive if includes CURSIVE TEXT
@@ -7130,32 +7147,32 @@
 				if ((isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) || !empty($sOTLdata)) {
 					$this->otl->removeChar($chunk, $cOTLdata[$k], "\xc2\xad");
 					$this->otl->replaceSpace($chunk, $cOTLdata[$k]);	// NBSP -> space
-					if (preg_match("/([".$this->pregCURSchars."])/u", $chunk)) { $inclCursive = true; }	
+					if (preg_match("/([".$this->pregCURSchars."])/u", ($chunk ?? ''))) { $inclCursive = true; }	
 					$content[$k] = $chunk; 
 				}
 /*-- END OTL --*/
 				else { 	// *OTL*
-					$content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk ); 
-					$content[$k] = $chunk = str_replace(chr(194).chr(160),chr(32),$chunk ); 
+					$content[$k] = $chunk = str_replace("\xc2\xad",'',($chunk ?? '') ); 
+					$content[$k] = $chunk = str_replace(chr(194).chr(160),(chr(32) ?? ''),($chunk ?? '') ); 
 				}	// *OTL*
 			}
 			else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
-				$content[$k] = $chunk = str_replace(chr(173),'',$chunk );
-				$content[$k] = $chunk = str_replace(chr(160),chr(32),$chunk );
+				$content[$k] = $chunk = str_replace((chr(173) ?? ''),'',($chunk ?? '') );
+				$content[$k] = $chunk = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($chunk ?? '') );
 			}
 
 			$contentWidth += $this->GetStringWidth( $chunk, true, (isset($cOTLdata[$k]) ? $cOTLdata[$k] : false), $this->textvar ) * _MPDFK; 	// mPDF 5.7.1
 			if (!empty($this->spanborddet)) { 
-				if (isset($this->spanborddet['L']['w']) && strpos($contentB[$k],'L')!==false) $contentWidth += $this->spanborddet['L']['w'] * _MPDFK; 
-				if (isset($this->spanborddet['R']['w']) && strpos($contentB[$k],'R')!==false) $contentWidth += $this->spanborddet['R']['w'] * _MPDFK; 
+				if (isset($this->spanborddet['L']['w']) && strpos(($contentB[$k] ?? ''),'L')!==false) $contentWidth += $this->spanborddet['L']['w'] * _MPDFK; 
+				if (isset($this->spanborddet['R']['w']) && strpos(($contentB[$k] ?? ''),'R')!==false) $contentWidth += $this->spanborddet['R']['w'] * _MPDFK; 
 			}
 		  }
 
 		}
 
-		$lastfontreqstyle = (isset($font[count($font)-1]['ReqFontStyle']) ? $font[count($font)-1]['ReqFontStyle'] : '');
-		$lastfontstyle = (isset($font[count($font)-1]['style']) ? $font[count($font)-1]['style'] : '');
-		if ($blockdir == 'ltr' && strpos($lastfontreqstyle,"I") !== false && strpos($lastfontstyle,"I") === false) {	// Artificial italic
+		$lastfontreqstyle = (isset($font[count(($font ?? []))-1]['ReqFontStyle']) ? $font[count(($font ?? []))-1]['ReqFontStyle'] : '');
+		$lastfontstyle = (isset($font[count(($font ?? []))-1]['style']) ? $font[count(($font ?? []))-1]['style'] : '');
+		if ($blockdir == 'ltr' && strpos(($lastfontreqstyle ?? ''),"I") !== false && strpos(($lastfontstyle ?? ''),"I") === false) {	// Artificial italic
 			$lastitalic = $this->FontSize*0.15*_MPDFK;
 		}
 		else { $lastitalic = 0; }
@@ -7166,7 +7183,7 @@
 		// NOW FORMAT THE LINE TO OUTPUT
 if (!$table_draft) {
 		// DIRECTIONALITY RTL
-		$chunkorder = range(0, count($content)-1);	// mPDF 5.7
+		$chunkorder = range(0, count(($content ?? []))-1);	// mPDF 5.7
 /*-- OTL --*/
 		// mPDF 6
 		if ($blockdir == 'rtl' || $this->biDirectional)  {
@@ -7178,11 +7195,11 @@
 /*-- END OTL --*/
 		// Remove any XAdvance from OTL data at end of line
 		foreach($chunkorder AS $aord=>$k) {
-			if (count($cOTLdata)) {
+			if (count(($cOTLdata ?? []))) {
 				$this->restoreFont( $font[ $k ], false);
 				// ...WriteFlowingBlock...
-				if ($aord == count($chunkorder)-1 && isset($cOTLdata[$aord]['group'])) {	// Last chunk on line
-					$nGPOS = strlen($cOTLdata[$aord]['group'])-1;	// Last character
+				if ($aord == count(($chunkorder ?? []))-1 && isset($cOTLdata[$aord]['group'])) {	// Last chunk on line
+					$nGPOS = strlen(($cOTLdata[$aord]['group'] ?? ''))-1;	// Last character
 					if (isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL']) || isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceR'])) {
 						if (isset($cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL'])) {
 							$w = $cOTLdata[$aord]['GPOSinfo'][$nGPOS]['XAdvanceL'] * 1000/$this->CurrentFont['unitsPerEm'];
@@ -7223,7 +7240,7 @@
 	    		foreach($chunkorder AS $aord=>$k) {	// mPDF 5.7
 				$chunk = $content[$aord];
 				if (!isset($this->objectbuffer[$k]) || (isset($this->objectbuffer[$k]) && !$this->objectbuffer[$k])) {
-					$nb_carac += mb_strlen( $chunk, $this->mb_enc ) ;  
+					$nb_carac += mb_strlen( ($chunk ?? ''), $this->mb_enc ) ;  
 					$nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc ) ;  
 					// Use GPOS OTL
 					if (isset($this->CurrentFont['useOTL']) && ($this->CurrentFont['useOTL'] & 0xFF)) {
@@ -7317,7 +7334,7 @@
 			if ($this->ColActive) { $this->breakpoints[$this->CurrCol][] = $this->y; }	// *COLUMNS*
 		}
 
-		$arraysize = count($chunkorder);
+		$arraysize = count(($chunkorder ?? []));
 
 		$margins = ($this->cMarginL+$this->cMarginR) + ($ipaddingL+$ipaddingR + $fpaddingR + $fpaddingR );
  
@@ -7378,16 +7395,16 @@
 				$save_fill = $fill; $spanfill = 1; $fill = 1;
 			}
 			if (!empty($this->spanborddet)) { 
-				if (strpos($contentB[$k],'L')!==false) $this->x += (isset($this->spanborddet['L']['w']) ? $this->spanborddet['L']['w'] : 0);
-				if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0; 
-				if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0; 
+				if (strpos(($contentB[$k] ?? ''),'L')!==false) $this->x += (isset($this->spanborddet['L']['w']) ? $this->spanborddet['L']['w'] : 0);
+				if (strpos(($contentB[$k] ?? ''),'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0; 
+				if (strpos(($contentB[$k] ?? ''),'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0; 
 			}
 
 			// WORD SPACING
 			// StringWidth this time includes any kashida spacing
 			$stringWidth = $this->GetStringWidth($chunk, true, (isset($cOTLdata[$aord]) ? $cOTLdata[$aord] : false), $this->textvar, true);
 
-			$nch = mb_strlen($chunk,$this->mb_enc );
+			$nch = mb_strlen(($chunk ?? ''),$this->mb_enc );
 			// Use GPOS OTL
 			if (isset($this->CurrentFont['useOTL']) && ($this->CurrentFont['useOTL'] & 0xFF)) {
 				if (isset($cOTLdata[$aord]['group']) && $cOTLdata[$aord]['group']) {
@@ -7425,7 +7442,7 @@
 			else $this->Cell( $stringWidth, $stackHeight, $chunk, '', 0, '', $fill, $this->HREF, 0, 0,0,'M', $fill, true, (isset($cOTLdata[$aord]) ? $cOTLdata[$aord] : false), $this->textvar, (isset($lineBox[$k]) ? $lineBox[$k] : false));//first or middle part	
 
 			if (!empty($this->spanborddet)) { 
-				if (strpos($contentB[$k],'R')!==false && $aord != $arraysize-1)  $this->x += $this->spanborddet['R']['w'];
+				if (strpos(($contentB[$k] ?? ''),'R')!==false && $aord != $arraysize-1)  $this->x += $this->spanborddet['R']['w'];
 			}
 	 		// *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
 			if (isset($spanfill) && $spanfill) { 
@@ -7473,8 +7490,8 @@
 			$cOTLdata[] = array();	// mPDF 5.7.1
 			$contentWidth += $savedObj['OUTER-WIDTH'] * _MPDFK;
 		}
-		if (count($savedPreContent) > 0) {
-			for($ix=count($savedPreContent)-1;$ix>=0;$ix--) {
+		if (count(($savedPreContent ?? [])) > 0) {
+			for($ix=count(($savedPreContent ?? []))-1;$ix>=0;$ix--) {
 				$font[] = $savedPreFont[$ix];
 				$content[] = $savedPreContent[$ix];
 				$contentB[] = $savedPreContentB[$ix];
@@ -7489,15 +7506,15 @@
 				}
 				if ($ix>0) {
 					$contentWidth += $this->GetStringWidth( $savedPreContent[$ix], true, (isset($savedPreOTLdata[$ix]) ? $savedPreOTLdata[$ix] : false), $this->textvar  ) * _MPDFK;	// mPDF 5.7.1
-					if (strpos($savedPreContentB[$ix],'L')!==false) $contentWidth += $lbw;
-					if (strpos($savedPreContentB[$ix],'R')!==false) $contentWidth += $rbw;
+					if (strpos(($savedPreContentB[$ix] ?? ''),'L')!==false) $contentWidth += $lbw;
+					if (strpos(($savedPreContentB[$ix] ?? ''),'R')!==false) $contentWidth += $rbw;
 				}
 			}
 			$savedPreContent = array();
 			$savedPreContentB = array();
 			$savedPreOTLdata = array();	// mPDF 5.7.1
 			$savedPreFont = array();
-			$content[ (count($content)-1) ] .= $c;
+			$content[ (count(($content ?? []))-1) ] .= $c;
 		}
 		else {
 			$font[] = $savedFont;
@@ -7506,8 +7523,8 @@
 			$cOTLdata[] = $savedOTLdata;	// mPDF 5.7.1
 		}
 
-		$currContent =& $content[ (count($content)-1) ];
-		$this->restoreFont( $font[ (count($font)-1) ]);	// mPDF 6.0
+		$currContent =& $content[ (count(($content ?? []))-1) ];
+		$this->restoreFont( $font[ (count(($font ?? []))-1) ]);	// mPDF 6.0
 
 /*-- CJK-FONTS --*/
 		// CJK - strip CJK space at start of line
@@ -7515,7 +7532,7 @@
 		if ($this->checkCJK && $currContent == "\xe3\x80\x80") { 
 			$currContent = ''; 
 			if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
-				$this->otl->trimOTLdata($cOTLdata[count($cOTLdata)-1], true, false);	// left trim U+3000
+				$this->otl->trimOTLdata($cOTLdata[count(($cOTLdata ?? []))-1], true, false);	// left trim U+3000
 			}
 		}
 /*-- END CJK-FONTS --*/
@@ -7526,8 +7543,8 @@
 			$rbw = (isset($this->spanborddet['R']['w']) ? $this->spanborddet['R']['w'] : 0);
 		}
 
-		$contentWidth += $this->GetStringWidth( $currContent, false, (isset($cOTLdata[(count($cOTLdata)-1)]) ? $cOTLdata[(count($cOTLdata)-1)] : false), $this->textvar ) * _MPDFK;	// mPDF 5.7.1
-		if (strpos($savedContentB,'L')!==false) $contentWidth += $lbw;
+		$contentWidth += $this->GetStringWidth( $currContent, false, (isset($cOTLdata[(count(($cOTLdata ?? []))-1)]) ? $cOTLdata[(count(($cOTLdata ?? []))-1)] : false), $this->textvar ) * _MPDFK;	// mPDF 5.7.1
+		if (strpos(($savedContentB ?? ''),'L')!==false) $contentWidth += $lbw;
 		$CJKoverflow = false;
 		$hanger = '';
       }
@@ -7743,7 +7760,7 @@
 
 	  if ($this->watermarkImgBehind) { 
 		$outstring = $this->watermarkImgAlpha . "\n" . $outstring . "\n" . $this->SetAlpha(1, 'Normal', true) . "\n";
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$outstring."\n".'\\1', $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$outstring."\n".'\\1', ($this->pages[$this->page] ?? ''));
 	  }
 	  else { $this->_out($outstring); }
 
@@ -7842,10 +7859,10 @@
 /*-- HTML-CSS --*/
 
 function _getObjAttr($t) {
-	$c = explode("\xbb\xa4\xac",$t,2);
-	$c = explode(",",$c[1],2);
+	$c = explode("\xbb\xa4\xac",($t ?? ''),2);
+	$c = explode(",",($c[1] ?? ''),2);
 	foreach($c as $v) {
-		$v = explode("=",$v,2);
+		$v = explode("=",($v ?? ''),2);
 		$sp[$v[0]] = $v[1];
 	}
 	return (unserialize($sp['objattr']));
@@ -8195,7 +8212,7 @@
 
 
 	if (($this->PDFA || $this->PDFX) && $this->encrypted) { $this->Error("PDFA1-b or PDFX/1-a does not permit encryption of documents."); }
-	if (count($this->PDFAXwarnings) && (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto))) {
+	if (count(($this->PDFAXwarnings ?? [])) && (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto))) {
 		if ($this->PDFA) {
 			echo '<div>WARNING - This file could not be generated as it stands as a PDFA1-b compliant file.</div>';
 			echo '<div>These issues can be automatically fixed by mPDF using <i>$mpdf-&gt;PDFAauto=true;</i></div>';
@@ -8218,14 +8235,14 @@
 	if ($this->showStats) {
 		echo '<div>Compiled in '.sprintf('%.2F',(microtime(true) - $this->time0)).' seconds (total)</div>';
 		echo '<div>Peak Memory usage '.number_format((memory_get_peak_usage(true)/(1024*1024)),2).' MB</div>';
-		echo '<div>PDF file size '.number_format((strlen($this->buffer)/1024)).' kB</div>';
-		echo '<div>Number of fonts '.count($this->fonts).'</div>';
+		echo '<div>PDF file size '.number_format((strlen(($this->buffer ?? ''))/1024)).' kB</div>';
+		echo '<div>Number of fonts '.count(($this->fonts ?? [])).'</div>';
 		exit;
 	}
 
 
 	if(is_bool($dest)) $dest=$dest ? 'D' : 'F';
-	$dest=strtoupper($dest);
+	$dest=strtoupper(($dest ?? ''));
 	if($dest=='') {
 		if($name=='') {
 			$name='mpdf.pdf';
@@ -8241,7 +8258,7 @@
 		//Save to local file
 		$f=fopen(_MPDF_TEMP_PATH.$tempfile.'.pdf','wb');
 		if(!$f) $this->Error('Unable to create temporary output file: '.$tempfile.'.pdf');
-		fwrite($f,$this->buffer,strlen($this->buffer));
+		fwrite($f,$this->buffer,strlen(($this->buffer ?? '')));
 		fclose($f);
 		$this->UpdateProgressBar(3,'','Finished');
 
@@ -8272,7 +8289,7 @@
 		var hiddenField = document.createElement("input");
 		hiddenField.setAttribute("type", "hidden");
 		hiddenField.setAttribute("name", "path");
-		hiddenField.setAttribute("value", "'.urlencode(_MPDF_TEMP_PATH).'");
+		hiddenField.setAttribute("value", "'.urlencode((_MPDF_TEMP_PATH ?? '')).'");
 		form.appendChild(hiddenField);
 
 		document.body.appendChild(form); 
@@ -8299,7 +8316,7 @@
 					$this->Error('Some data has already been output to browser, can\'t send PDF file');
 				if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
 					// don't use length if server using compression
-					header('Content-Length: '.strlen($this->buffer));
+					header('Content-Length: '.strlen(($this->buffer ?? '')));
 				}
 				header('Content-disposition: inline; filename="'.$name.'"');
 				header('Cache-Control: public, must-revalidate, max-age=0'); 
@@ -8325,7 +8342,7 @@
 			header('Content-Type: application/pdf', false);
 			if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) OR empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
 				// don't use length if server using compression
-				header('Content-Length: '.strlen($this->buffer));
+				header('Content-Length: '.strlen(($this->buffer ?? '')));
 			}
 			header('Content-disposition: attachment; filename="'.$name.'"');
  			echo $this->buffer;
@@ -8334,7 +8351,7 @@
 			//Save to local file
 			$f=fopen($name,'wb');
 			if(!$f) $this->Error('Unable to create output file: '.$name);
-			fwrite($f,$this->buffer,strlen($this->buffer));
+			fwrite($f,$this->buffer,strlen(($this->buffer ?? '')));
 			fclose($f);
 			break;
 		   case 'S':
@@ -8349,9 +8366,9 @@
 	// DELETE OLD TMP FILES - Housekeeping
 	// Delete any files in tmp/ directory that are >1 hrs old
 		$interval = 3600;
-		if ($handle = @opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) {	// mPDF 5.7.3
+		if ($handle = @opendir(preg_replace('/\/$/','',(_MPDF_TEMP_PATH ?? '')))) {	// mPDF 5.7.3
 		   while (false !== ($file = readdir($handle))) { 
-			if (($file != "..") && ($file != ".") && !is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && (substr($file, 0, 1) !== '.') && ($file !='dummy.txt')) { // mPDF 5.7.3
+			if (($file != "..") && ($file != ".") && !is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && (substr(($file ?? ''), 0, 1) !== '.') && ($file !='dummy.txt')) { // mPDF 5.7.3
 				unlink(_MPDF_TEMP_PATH.$file); 
 			}
 		   }
@@ -8376,7 +8393,7 @@
 	//Check for decimal separator
 	if(sprintf('%.1f',1.0)!='1.0')
 		setlocale(LC_NUMERIC,'C');
-	$mqr=ini_get("magic_quotes_runtime");
+	$mqr='0';
 	if ($mqr) { $this->Error('mPDF requires magic_quotes_runtime to be turned off e.g. by using ini_set("magic_quotes_runtime", 0);'); }
 }
 
@@ -8413,10 +8430,10 @@
 		$this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
 		$this->x = $this->lMargin;
 		$this->y = $this->margin_header;
-		$html = str_replace('{PAGENO}',$pnstr,$html);
-		$html = str_replace($this->aliasNbPgGp,$pntstr,$html );	// {nbpg}
-		$html = str_replace($this->aliasNbPg,$nb,$html );	// {nb}
-		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),$html );	// mPDF 5.7
+		$html = str_replace('{PAGENO}',($pnstr ?? ''),($html ?? ''));
+		$html = str_replace(($this->aliasNbPgGp ?? ''),($pntstr ?? ''),($html ?? '') );	// {nbpg}
+		$html = str_replace(($this->aliasNbPg ?? ''),($nb ?? ''),($html ?? '') );	// {nb}
+		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),($html ?? '') );	// mPDF 5.7
 
 		$this->HTMLheaderPageLinks = array();
 		$this->HTMLheaderPageAnnots = array();
@@ -8443,8 +8460,8 @@
 		}
 
 		// Writes over the page background but behind any other output on page
-		$os = preg_replace('/\\\\/','\\\\\\\\',$os);
-		$this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]);
+		$os = preg_replace('/\\\\/','\\\\\\\\',($os ?? ''));
+		$this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', ($this->pages[$n] ?? ''));
 
 		$lks = $this->HTMLheaderPageLinks; 
 		foreach($lks AS $lk) {
@@ -8489,10 +8506,10 @@
 
 		// if bottom-margin==0, corrects to avoid division by zero
 		if ($this->y == $this->h) { $top_y = $this->y = ($this->h - 0.1); }
-		$html = str_replace('{PAGENO}',$pnstr,$html);
-		$html = str_replace($this->aliasNbPgGp,$pntstr,$html );	// {nbpg}
-		$html = str_replace($this->aliasNbPg,$nb,$html );	// {nb}
-		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),$html );	// mPDF 5.7
+		$html = str_replace('{PAGENO}',($pnstr ?? ''),($html ?? ''));
+		$html = str_replace(($this->aliasNbPgGp ?? ''),($pntstr ?? ''),($html ?? '') );	// {nbpg}
+		$html = str_replace(($this->aliasNbPg ?? ''),($nb ?? ''),($html ?? '') );	// {nb}
+		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),($html ?? '') );	// mPDF 5.7
 
 
 		$this->HTMLheaderPageLinks = array();
@@ -8528,8 +8545,8 @@
 		}
 		$os .= $this->StopTransform(true)."\n";
 		// Writes over the page background but behind any other output on page
-		$os = preg_replace('/\\\\/','\\\\\\\\',$os);
-		$this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]);
+		$os = preg_replace('/\\\\/','\\\\\\\\',($os ?? ''));
+		$this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', ($this->pages[$n] ?? ''));
 
 		$lks = $this->HTMLheaderPageLinks; 
 		foreach($lks AS $lk) {
@@ -8581,7 +8598,7 @@
 	// Active Forms
 	$totaladdnum = 0;
 	for($n=1;$n<=$nb;$n++) {
-		if (isset($this->PageLinks[$n])) { $totaladdnum += count($this->PageLinks[$n]); }
+		if (isset($this->PageLinks[$n])) { $totaladdnum += count(($this->PageLinks[$n] ?? [])); }
 /*-- ANNOTATIONS --*/
 		if (isset($this->PageAnnots[$n])) { 
 			foreach ($this->PageAnnots[$n] as $k => $pl) {
@@ -8592,7 +8609,7 @@
 /*-- END ANNOTATIONS --*/
 
 /*-- FORMS --*/
-		if ( count($this->mpdfform->forms) > 0 ) {
+		if ( count(($this->mpdfform->forms ?? [])) > 0 ) {
 			$this->mpdfform->countPageForms($n, $totaladdnum);
 		}
 /*-- END FORMS --*/
@@ -8600,7 +8617,7 @@
 /*-- FORMS --*/
 	// Make a note in the radio button group of the obj_id it will have
 	$ctr = 0;
-	if (count($this->mpdfform->form_radio_groups)) {
+	if (count(($this->mpdfform->form_radio_groups ?? []))) {
 		foreach($this->mpdfform->form_radio_groups AS $name=>$frg) {
 			$this->mpdfform->form_radio_groups[$name]['obj_id'] = $annotid + $totaladdnum + $ctr;
 			$ctr++;
@@ -8636,24 +8653,24 @@
 		foreach($unused as $fk) {
 			if ($this->fonts[$fk]['sip'] || $this->fonts[$fk]['smp']) {
 				foreach($this->fonts[$fk]['subsetfontids'] AS $k => $fid) {
-						$thispage = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$thispage); 
+						$thispage = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',($thispage ?? '')); 
 				}
 			}
 			else { 
-				$thispage = preg_replace('/\s\/F'.$this->fonts[$fk]['i'].' \d[\d.]* Tf\s/is',' ',$thispage); 
+				$thispage = preg_replace('/\s\/F'.$this->fonts[$fk]['i'].' \d[\d.]* Tf\s/is',' ',($thispage ?? '')); 
 			}
 		}
 		// Clean up repeated /GS1 gs statements
 		// For some reason using + for repetition instead of {2,20} crashes PHP Script Interpreter ???
-		$thispage = preg_replace('/(\/GS1 gs\n){2,20}/', "/GS1 gs\n", $thispage);
-
-		$thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.$this->uniqstr.'\s*)/', " ", $thispage);
-		$thispage = preg_replace('/(\s*___HEADER___MARKER'.$this->uniqstr.'\s*)/', " ", $thispage);
-		$thispage = preg_replace('/(\s*___PAGE___START'.$this->uniqstr.'\s*)/', " ", $thispage);
-		$thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.$this->uniqstr.'\s*)/', " ", $thispage);
+		$thispage = preg_replace('/(\/GS1 gs\n){2,20}/', "/GS1 gs\n", ($thispage ?? ''));
+
+		$thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.$this->uniqstr.'\s*)/', " ", ($thispage ?? ''));
+		$thispage = preg_replace('/(\s*___HEADER___MARKER'.$this->uniqstr.'\s*)/', " ", ($thispage ?? ''));
+		$thispage = preg_replace('/(\s*___PAGE___START'.$this->uniqstr.'\s*)/', " ", ($thispage ?? ''));
+		$thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.$this->uniqstr.'\s*)/', " ", ($thispage ?? ''));
 		// mPDF 5.7.3 TRANSFORMS
-		while (preg_match('/(\% BTR(.*?)\% ETR)/is', $thispage, $m)) {
-			$thispage = preg_replace('/(\% BTR.*?\% ETR)/is', '', $thispage, 1)."\n".$m[2];
+		while (preg_match('/(\% BTR(.*?)\% ETR)/is', ($thispage ?? ''), $m)) {
+			$thispage = preg_replace('/(\% BTR.*?\% ETR)/is', '', ($thispage ?? ''), 1)."\n".$m[2];
 		}
 
 		//Page
@@ -8705,7 +8722,7 @@
 		$annotsnum = 0;
 		$embeddedfiles = array();	// mPDF 5.7.2 /EmbeddedFiles
 
-		if (isset($this->PageLinks[$n])) { $annotsnum += count($this->PageLinks[$n]); }
+		if (isset($this->PageLinks[$n])) { $annotsnum += count(($this->PageLinks[$n] ?? [])); }
 /*-- ANNOTATIONS --*/
 		if (isset($this->PageAnnots[$n])) { 
 			foreach ($this->PageAnnots[$n] as $k => $pl) {
@@ -8720,7 +8737,7 @@
 /*-- FORMS --*/
 		// Active Forms
 		$formsnum = 0;
-		if ( count($this->mpdfform->forms) > 0 ) {
+		if ( count(($this->mpdfform->forms ?? [])) > 0 ) {
 			foreach( $this->mpdfform->forms as $val ) {
 				if ( $val['page'] == $n )
 					$formsnum++;
@@ -8734,7 +8751,7 @@
 			} 
 			$annotid += $annotsnum;
 /*-- FORMS --*/
-			if ( count($this->mpdfform->forms) > 0 ) {
+			if ( count(($this->mpdfform->forms ?? [])) > 0 ) {
 				$this->mpdfform->addFormIds($n, $s, $annotid);
 			}
 /*-- END FORMS --*/
@@ -8748,14 +8765,14 @@
 		//Page content
 		$this->_newobj();
 		$p=($this->compress) ? gzcompress($thispage) : $thispage;
-		$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
+		$this->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).'>>');
 		$this->_putstream($p);
 		$this->_out('endobj');
 	}
 	$this->_putannots();	// mPDF 5.7.2
 
 	//Pages root
-	$this->offsets[1]=strlen($this->buffer);
+	$this->offsets[1]=strlen(($this->buffer ?? ''));
 	$this->_out('1 0 obj');
 	$this->_out('<</Type /Pages');
 	$kids='/Kids [';
@@ -8775,7 +8792,7 @@
 	for($n=1;$n<=$nb;$n++)
 	{
 		$annotobjs = array();
-		if(isset($this->PageLinks[$n]) || isset($this->PageAnnots[$n]) || count($this->mpdfform->forms) > 0 ) {
+		if(isset($this->PageLinks[$n]) || isset($this->PageAnnots[$n]) || count(($this->mpdfform->forms ?? [])) > 0 ) {
 			$wPt=$this->pageDim[$n]['w']*_MPDFK;
 			$hPt=$this->pageDim[$n]['h']*_MPDFK;
 
@@ -8798,8 +8815,8 @@
 		//		$annot .= ' /C [1 0 0]';	// Color RGB
 
 				if ($this->PDFA || $this->PDFX) { $annot .= ' /F 28'; }
-				if (strpos($pl[4],'@')===0) {
-					$p=substr($pl[4],1);
+				if (strpos(($pl[4] ?? ''),'@')===0) {
+					$p=substr(($pl[4] ?? ''),1);
 					//	$h=isset($this->OrientationChanges[$p]) ? $wPt : $hPt;
 					$htarg=$this->pageDim[$p]['h']*_MPDFK;
 					$annot.=sprintf(' /Dest [%d 0 R /XYZ 0 %.3F null]>>',1+2*$p,$htarg);
@@ -8844,8 +8861,8 @@
 					else if ($pl['opt']['icon']=='Graph') { $w=20; $h=20; }
 					else { $w=14; $h=20; } 	// PushPin 
 					$f = $pl['opt']['file'];
-					$f = preg_replace('/^.*\//', '', $f);
-					$f = preg_replace('/[^a-zA-Z0-9._]/', '', $f);
+					$f = preg_replace('/^.*\//', '', ($f ?? ''));
+					$f = preg_replace('/[^a-zA-Z0-9._]/', '', ($f ?? ''));
 					$annot .= '/FS <</Type /Filespec /F ('.$f.')';
 					$annot .= '/EF <</F '.($this->n+1).' 0 R>>';
 					$annot .= '>>';
@@ -8873,9 +8890,9 @@
 				$annotcolor = ' /C [';
 				if (isset($pl['opt']['c']) AND $pl['opt']['c']) {
 					$col = $pl['opt']['c'];
-					if ($col{0}==3 || $col{0}==5) { $annotcolor .= sprintf("%.3F %.3F %.3F", ord($col{1})/255,ord($col{2})/255,ord($col{3})/255); }
-					else if ($col{0}==1) { $annotcolor .= sprintf("%.3F", ord($col{1})/255); }
-					else if ($col{0}==4 || $col{0}==6) { $annotcolor .= sprintf("%.3F %.3F %.3F %.3F", ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100); }
+					if ($col[0]==3 || $col[0]==5) { $annotcolor .= sprintf("%.3F %.3F %.3F", ord(($col[1] ?? ''))/255,ord(($col[2] ?? ''))/255,ord(($col[3] ?? ''))/255); }
+					else if ($col[0]==1) { $annotcolor .= sprintf("%.3F", ord(($col[1] ?? ''))/255); }
+					else if ($col[0]==4 || $col[0]==6) { $annotcolor .= sprintf("%.3F %.3F %.3F %.3F", ord(($col[1] ?? ''))/100,ord(($col[2] ?? ''))/100,ord(($col[3] ?? ''))/100,ord(($col[4] ?? ''))/100); }
 					else { $annotcolor .= '1 1 0'; }
 				}
 				else { $annotcolor .= '1 1 0'; }
@@ -8912,11 +8929,11 @@
 				$this->_out('endobj');
 
 				if ($FileAttachment) {
-					$file = @file_get_contents($pl['opt']['file']) or die('mPDF Error: Cannot access file attachment - '.$pl['opt']['file']);
+					$file = @file_get_contents(($pl['opt']['file'] ?? '')) or die('mPDF Error: Cannot access file attachment - '.$pl['opt']['file']);
 					$filestream = gzcompress($file);
 					$this->_newobj();
 					$this->_out('<</Type /EmbeddedFile');
-					$this->_out('/Length '.strlen($filestream));
+					$this->_out('/Length '.strlen(($filestream ?? '')));
 					$this->_out('/Filter /FlateDecode');
 					$this->_out('>>');
 					$this->_putstream($filestream);
@@ -8949,7 +8966,7 @@
 
 /*-- FORMS --*/
 			// Active Forms
-			if ( count($this->mpdfform->forms) > 0 ) {
+			if ( count(($this->mpdfform->forms ?? [])) > 0 ) {
 				$this->mpdfform->_putFormItems($n, $hPt);
 			}
 /*-- END FORMS --*/
@@ -8958,7 +8975,7 @@
 /*-- FORMS --*/
 	// Active Forms - Radio Button Group entries
 	// Output Radio Button Group form entries (radio_on_obj_id already determined)
-	if (count($this->mpdfform->form_radio_groups)) {
+	if (count(($this->mpdfform->form_radio_groups ?? []))) {
 		$this->mpdfform->_putRadioItems($n);
 	}
 /*-- END FORMS --*/
@@ -8967,7 +8984,7 @@
 
 /*-- ANNOTATIONS --*/
 function Annotation($text, $x=0, $y=0, $icon='Note', $author='', $subject='', $opacity=0, $colarray=false, $popup='', $file='') {
-	if (is_array($colarray) && count($colarray)==3) { $colarray = $this->ConvertColor('rgb('.$colarray[0].','.$colarray[1].','.$colarray[2].')'); }
+	if (is_array($colarray) && count(($colarray ?? []))==3) { $colarray = $this->ConvertColor('rgb('.$colarray[0].','.$colarray[1].','.$colarray[2].')'); }
 	if ($colarray === false) { $colarray = $this->ConvertColor('yellow'); }
 	if ($x==0) { $x = $this->x; }
 	if ($y==0) { $y = $this->y; }
@@ -9008,7 +9025,7 @@
 	$this->PageAnnots[$page][] = $an;
 /*-- COLUMNS --*/
 	// Save cross-reference to Column buffer
-	$ref = count($this->PageAnnots[$this->page])-1;
+	$ref = count(($this->PageAnnots[$this->page] ?? []))-1;
 	$this->columnAnnots[$this->CurrCol][INTVAL($this->x)][INTVAL($this->y)] = $ref;
 /*-- END COLUMNS --*/
 }
@@ -9026,8 +9043,8 @@
 			if (isset($f['fontkey']) && $f['fontkey'] == $fontkey && $f['type']=='TTF') { 
 				$used = $f['used']; 
 				if ($used) {
-					$nChars = (ord($f['cw'][0]) << 8) + ord($f['cw'][1]);
-					$usage = intval(count($f['subset'])*100 / $nChars);
+					$nChars = (ord(($f['cw'][0] ?? '')) << 8) + ord(($f['cw'][1] ?? ''));
+					$usage = intval(count(($f['subset'] ?? []))*100 / $nChars);
 					$fsize = $info['length1'];
 					// Always subset the very large TTF files
 					if ($fsize > ($this->maxTTFFilesize *1024)) { $asSubset = true; }
@@ -9058,18 +9075,18 @@
 					$ttf = new TTFontFile();
 					$font = $ttf->repackageTTF($this->FontFiles[$fontkey]['ttffile'], $this->fonts[$fontkey]['TTCfontID'], $this->debugfonts, $this->fonts[$fontkey]['useOTL']);	// mPDF 5.7.1
 
-					$originalsize = strlen($font);
+					$originalsize = strlen(($font ?? ''));
 					$font = gzcompress($font);
 					unset($ttf);
 					if (is_writable(dirname(_MPDF_TTFONTDATAPATH.'x'))) {
 						$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.ps.z',"wb");
-						fwrite($fh,$font,strlen($font));
+						fwrite($fh,$font,strlen(($font ?? '')));
 						fclose($fh);
 						$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.ps.php',"wb");
 						$len = "<?php \n";
 						$len.='$originalsize='.$originalsize.";\n";
 						$len.="?>";
-						fwrite($fh,$len,strlen($len));
+						fwrite($fh,$len,strlen(($len ?? '')));
 						fclose($fh);
 					}
 				}
@@ -9090,13 +9107,13 @@
 					$font = gzcompress($font);
 					if (is_writable(dirname(_MPDF_TTFONTDATAPATH.'x'))) {
 						$fh = fopen(_MPDF_TTFONTDATAPATH.$fontkey.'.z',"wb");
-						fwrite($fh,$font,strlen($font));
+						fwrite($fh,$font,strlen(($font ?? '')));
 						fclose($fh);
 					}
 				}
 			}
 
-			$this->_out('<</Length '.strlen($font));
+			$this->_out('<</Length '.strlen(($font ?? '')));
 			$this->_out('/Filter /FlateDecode');
 			$this->_out('/Length1 '.$originalsize);
 			$this->_out('>>');
@@ -9106,7 +9123,7 @@
 	   }
 	}
 
-	$nfonts = count($this->fonts);
+	$nfonts = count(($this->fonts ?? []));
 	$fctr = 1;
 	foreach($this->fonts as $k=>$font) {
 		//Font objects
@@ -9146,21 +9163,21 @@
 		   $ssfaid="AA";
 		   if (!class_exists('TTFontFile', false)) { include(_MPDF_PATH .'classes/ttfontsuni.php'); }
 		   $ttf = new TTFontFile();
-		   for($sfid=0;$sfid<count($font['subsetfontids']);$sfid++) {
+		   for($sfid=0;$sfid<count(($font['subsetfontids'] ?? []));$sfid++) {
 			$this->fonts[$k]['n'][$sfid]=$this->n+1;		// NB an array for subset
 			$subsetname = 'MPDF'.$ssfaid.'+'.$font['name'];
 			$ssfaid++;
 
 			/* For some strange reason a subset ($sfid > 0) containing less than 97 characters causes an error
 			   so fill up the array */
-			for($j=count($font['subsets'][$sfid]);$j<98;$j++) {
+			for($j=count(($font['subsets'][$sfid] ?? []));$j<98;$j++) {
 				$font['subsets'][$sfid][$j]=0;
 			}
 
 			$subset = $font['subsets'][$sfid];
 			unset($subset[0]);
 			$ttfontstream = $ttf->makeSubsetSIP($font['ttffile'], $subset, $font['TTCfontID'], $this->debugfonts, $font['useOTL']);	// mPDF 5.7.1
-			$ttfontsize = strlen($ttfontstream);
+			$ttfontsize = strlen(($ttfontstream ?? ''));
 			$fontstream = gzcompress($ttfontstream);
 			$widthstring = '';
 			$toUnistring = '';
@@ -9175,16 +9192,16 @@
 					$widthstring .= round($ttf->defaultWidth).' ';
 				}
 				if ($u > 65535) {
-					$utf8 = chr(($u>>18)+240).chr((($u>>12)&63)+128).chr((($u>>6)&63)+128) .chr(($u&63)+128);
-					$utf16 = mb_convert_encoding($utf8, 'UTF-16BE', 'UTF-8');
-					$l1 = ord($utf16[0]);
-					$h1 = ord($utf16[1]);
-					$l2 = ord($utf16[2]);
-					$h2 = ord($utf16[3]);
-					$toUnistring .= sprintf("<%02s> <%02s%02s%02s%02s>\n", strtoupper(dechex($cp)), strtoupper(dechex($l1)), strtoupper(dechex($h1)), strtoupper(dechex($l2)), strtoupper(dechex($h2)));
+					$utf8 = chr((int) (($u>>18)+240)).chr((int) ((($u>>12)&63)+128)).chr((int) ((($u>>6)&63)+128)) .chr((int) (($u&63)+128));
+					$utf16 = mb_convert_encoding(($utf8 ?? ''), 'UTF-16BE', 'UTF-8');
+					$l1 = ord(($utf16[0] ?? ''));
+					$h1 = ord(($utf16[1] ?? ''));
+					$l2 = ord(($utf16[2] ?? ''));
+					$h2 = ord(($utf16[3] ?? ''));
+					$toUnistring .= sprintf("<%02s> <%02s%02s%02s%02s>\n", strtoupper((dechex($cp) ?? '')), strtoupper((dechex($l1) ?? '')), strtoupper((dechex($h1) ?? '')), strtoupper((dechex($l2) ?? '')), strtoupper((dechex($h2) ?? '')));
 				}
 				else {
-					$toUnistring .= sprintf("<%02s> <%04s>\n", strtoupper(dechex($cp)), strtoupper(dechex($u)));
+					$toUnistring .= sprintf("<%02s> <%04s>\n", strtoupper((dechex($cp) ?? '')), strtoupper((dechex($u) ?? '')));
 				}
 			}
 
@@ -9193,7 +9210,7 @@
 			$this->_out('<</Type /Font');
 			$this->_out('/BaseFont /'.$subsetname);
 			$this->_out('/Subtype /TrueType');
-			$this->_out('/FirstChar 0 /LastChar '.(count($font['subsets'][$sfid])-1));
+			$this->_out('/FirstChar 0 /LastChar '.(count(($font['subsets'][$sfid] ?? []))-1));
 			$this->_out('/Widths '.($this->n+1).' 0 R');
 			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
 			$this->_out('/ToUnicode '.($this->n + 3).' 0 R');
@@ -9232,20 +9249,20 @@
 			$toUni .= "<00> <FF>\n";
 			//$toUni .= sprintf("<00> <%02s>\n", strtoupper(dechex(count($font['subsets'][$sfid])-1)));
 			$toUni .= "endcodespacerange\n";
-			$toUni .= count($font['subsets'][$sfid])." beginbfchar\n";
+			$toUni .= count(($font['subsets'][$sfid] ?? []))." beginbfchar\n";
 			$toUni .= $toUnistring;
 			$toUni .= "endbfchar\n";
 			$toUni .= "endcmap\n";
 			$toUni .= "CMapName currentdict /CMap defineresource pop\n";
 			$toUni .= "end\n";
 			$toUni .= "end\n";
-			$this->_out('<</Length '.(strlen($toUni)).'>>');
+			$this->_out('<</Length '.(strlen(($toUni ?? ''))).'>>');
 			$this->_putstream($toUni);
 			$this->_out('endobj');
 
 			//Font file 
 			$this->_newobj();
-			$this->_out('<</Length '.strlen($fontstream));
+			$this->_out('<</Length '.strlen(($fontstream ?? '')));
 			$this->_out('/Filter /FlateDecode');
 			$this->_out('/Length1 '.$ttfontsize);
 			$this->_out('>>');
@@ -9265,7 +9282,7 @@
 				$subset = $font['subset'];
 				unset($subset[0]);
 				$ttfontstream = $ttf->makeSubset($font['ttffile'], $subset, $font['TTCfontID'], $this->debugfonts, $font['useOTL']);
-				$ttfontsize = strlen($ttfontstream);
+				$ttfontsize = strlen(($ttfontstream ?? ''));
 				$fontstream = gzcompress($ttfontstream);
 				$codeToGlyph = $ttf->codeToGlyph;
 				unset($codeToGlyph[0]);
@@ -9330,7 +9347,7 @@
 			$toUni .= "CMapName currentdict /CMap defineresource pop\n";
 			$toUni .= "end\n";
 			$toUni .= "end\n";
-			$this->_out('<</Length '.(strlen($toUni)).'>>');
+			$this->_out('<</Length '.(strlen(($toUni ?? ''))).'>>');
 			$this->_putstream($toUni);
 			$this->_out('endobj');
 
@@ -9370,8 +9387,8 @@
 				$cidtogidmap = '';
 				$cidtogidmap = str_pad('', 256*256*2, "\x00");
 				foreach($codeToGlyph as $cc=>$glyph) {
-					$cidtogidmap[$cc*2] = chr($glyph >> 8);
-					$cidtogidmap[$cc*2 + 1] = chr($glyph & 0xFF);
+					$cidtogidmap[$cc*2] = chr((int) ($glyph >> 8));
+					$cidtogidmap[$cc*2 + 1] = chr((int) ($glyph & 0xFF));
 				}
 				$cidtogidmap = gzcompress($cidtogidmap);
 			}
@@ -9389,20 +9406,20 @@
 					$charToGlyph = $ttf->getCTG($font['ttffile'], $font['TTCfontID'], $this->debugfonts, $font['useOTL']);
 					$cidtogidmap = str_pad('', 256*256*2, "\x00");
 					foreach($charToGlyph as $cc=>$glyph) {
-						$cidtogidmap[$cc*2] = chr($glyph >> 8);
-						$cidtogidmap[$cc*2 + 1] = chr($glyph & 0xFF);
+						$cidtogidmap[$cc*2] = chr((int) ($glyph >> 8));
+						$cidtogidmap[$cc*2 + 1] = chr((int) ($glyph & 0xFF));
 					}
 					unset($ttf);
 					$cidtogidmap = gzcompress($cidtogidmap);
 					if (is_writable(dirname(_MPDF_TTFONTDATAPATH.'x'))) {
 						$fh = fopen(_MPDF_TTFONTDATAPATH.$font['fontkey'].'.cgm',"wb");
-						fwrite($fh,$cidtogidmap,strlen($cidtogidmap));
+						fwrite($fh,$cidtogidmap,strlen(($cidtogidmap ?? '')));
 						fclose($fh);
 					}
 				}
 			}
 			$this->_newobj();
-			$this->_out('<</Length '.strlen($cidtogidmap).'');
+			$this->_out('<</Length '.strlen(($cidtogidmap ?? '')).'');
 			$this->_out('/Filter /FlateDecode');
 			$this->_out('>>');
 			$this->_putstream($cidtogidmap);
@@ -9411,7 +9428,7 @@
 			//Font file 
 			if ($asSubset ) {
 				$this->_newobj();
-				$this->_out('<</Length '.strlen($fontstream));
+				$this->_out('<</Length '.strlen(($fontstream ?? '')));
 				$this->_out('/Filter /FlateDecode');
 				$this->_out('/Length1 '.$ttfontsize);
 				$this->_out('>>');
@@ -9440,7 +9457,7 @@
 		$startcid = 1;
 	}
 	if ($asSubset) { $cwlen = $maxUni + 1; }
-	else { $cwlen = (strlen($font['cw'])/2); }
+	else { $cwlen = (strlen(($font['cw'] ?? ''))/2); }
 
 	// for each character
 	for ($cid=$startcid; $cid<$cwlen; $cid++) {
@@ -9455,12 +9472,12 @@
 				else { $cw127.='$interval=false'.";\n"; }
 				$cw127.='$range='.var_export($range,true).";\n";
 				$cw127.="?>";
-				fwrite($fh,$cw127,strlen($cw127));
+				fwrite($fh,$cw127,strlen(($cw127 ?? '')));
 				fclose($fh);
 			}
 		}
 		if ($font['cw'][$cid*2] == "\00" && $font['cw'][$cid*2+1] == "\00") { continue; }
-		$width = (ord($font['cw'][$cid*2]) << 8) + ord($font['cw'][$cid*2+1]);
+		$width = (ord(($font['cw'][$cid*2] ?? '')) << 8) + ord(($font['cw'][$cid*2+1] ?? ''));
 		if ($width == 65535) { $width = 0; }
 		if ($asSubset && $cid > 255 && (!isset($font['subset'][$cid]) || !$font['subset'][$cid])) {
 			continue;
@@ -9509,7 +9526,7 @@
 	if (!$asSubset) {
 		if (is_writable(dirname(_MPDF_TTFONTDATAPATH.'x'))) {
 			$fh = fopen(_MPDF_TTFONTDATAPATH.$font['fontkey'].'.cw',"wb");
-			fwrite($fh,$w,strlen($w));
+			fwrite($fh,$w,strlen(($w ?? '')));
 			fclose($fh);
 		}
 	}
@@ -9521,7 +9538,7 @@
 	$nextk = -1;
 	$prevint = false;
 	foreach ($range as $k => $ws) {
-		$cws = count($ws);
+		$cws = count(($ws ?? []));
 		if (($k == $nextk) AND (!$prevint) AND ((!isset($ws['interval'])) OR ($cws < 4))) {
 			if (isset($range[$k]['interval'])) {
 				unset($range[$k]['interval']);
@@ -9547,9 +9564,9 @@
 	// output data
 	$w = '';
 	foreach ($range as $k => $ws) {
-		if (count(array_count_values($ws)) == 1) {
+		if (count((array_count_values($ws) ?? [])) == 1) {
 			// interval mode is more compact
-			$w .= ' '.$k.' '.($k + count($ws) - 1).' '.$ws[0];
+			$w .= ' '.$k.' '.($k + count(($ws ?? [])) - 1).' '.$ws[0];
 		} else {
 			// range mode
 			$w .= ' '.$k.' [ '.implode(' ', $ws).' ]' . "\n";
@@ -9662,7 +9679,7 @@
 {
 	$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
 	reset($this->images);
-	while(list($file,$info)=each($this->images)) {
+	foreach ($this->images as $file => $info) {
 		$this->_newobj();
 		$this->images[$file]['n']=$this->n;
 		$this->_out('<</Type /XObject');
@@ -9684,7 +9701,7 @@
 		}
 		else if($info['cs']=='Indexed') {
 			if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) { $this->Error("PDFA1-b and PDFX/1-a files do not permit using mixed colour space (".$file.")."); }
-			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
+			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen(($info['pal'] ?? ''))/3-1).' '.($this->n+1).' 0 R]');
 		}
 		else {
 			$this->_out('/ColorSpace /'.$info['cs']);
@@ -9699,11 +9716,11 @@
 		if(isset($info['parms'])) { $this->_out($info['parms']); }
 		if(isset($info['trns']) and is_array($info['trns'])) {
 			$trns='';
-			for($i=0;$i<count($info['trns']);$i++)
+			for($i=0;$i<count(($info['trns'] ?? []));$i++)
 				$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
 			$this->_out('/Mask ['.$trns.']');
 		}
-		$this->_out('/Length '.strlen($info['data']).'>>');
+		$this->_out('/Length '.strlen(($info['data'] ?? '')).'>>');
 		$this->_putstream($info['data']);
 		unset($this->images[$file]['data']);
 		$this->_out('endobj');
@@ -9712,7 +9729,7 @@
 		if ($icc) {
 			$this->_newobj();
 			$icc = ($this->compress) ? gzcompress($info['icc']) : $info['icc'];
-			$this->_out('<</N '.$info['ch'].' '.$filter.'/Length '.strlen($icc).'>>');
+			$this->_out('<</N '.$info['ch'].' '.$filter.'/Length '.strlen(($icc ?? '')).'>>');
 			$this->_putstream($icc);
 			$this->_out('endobj');
 		}
@@ -9720,7 +9737,7 @@
 		 else if($info['cs']=='Indexed') {
 			$this->_newobj();
 			$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
-			$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
+			$this->_out('<<'.$filter.'/Length '.strlen(($pal ?? '')).'>>');
 			$this->_putstream($pal);
 			$this->_out('endobj');
 		}
@@ -9742,7 +9759,7 @@
 		$this->_out('/Creator '.$this->_UTF16BEtextstring($this->creator));
 
 	$z = date('O'); // +0200
-	$offset = substr($z,0,3)."'".substr($z,3,2)."'";
+	$offset = substr(($z ?? ''),0,3)."'".substr(($z ?? ''),3,2)."'";
 	$this->_out('/CreationDate '.$this->_textstring(date('YmdHis').$offset));
 	$this->_out('/ModDate '.$this->_textstring(date('YmdHis').$offset));
 	if ($this->PDFX) {
@@ -9756,7 +9773,7 @@
 	$this->MetadataRoot = $this->n;
 	$Producer = 'mPDF '.mPDF_VERSION;
 	$z = date('O'); // +0200
-	$offset = substr($z,0,3).':'.substr($z,3,2);
+	$offset = substr(($z ?? ''),0,3).':'.substr(($z ?? ''),3,2);
 	$CreationDate = date('Y-m-d\TH:i:s').$offset;	// 2006-03-10T10:47:26-05:00 2006-06-19T09:05:17Z
 	$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff),
 			mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
@@ -9833,7 +9850,7 @@
 	$m .= ' </x:xmpmeta>'."\n";
 	$m .= str_repeat(str_repeat(' ',100)."\n",20);	// 2-4kB whitespace padding required
 	$m .= '<?xpacket end="w"?>';	// "r" read only
-	$this->_out('<</Type/Metadata/Subtype/XML/Length '.strlen($m).'>>');
+	$this->_out('<</Type/Metadata/Subtype/XML/Length '.strlen(($m ?? '')).'>>');
 	$this->_putstream($m);
 	$this->_out('endobj');
 }
@@ -9846,7 +9863,7 @@
 	if ($this->PDFA) {
 		$this->_out('/S /GTS_PDFA1');
 		if ($this->ICCProfile) {
-			$this->_out('/Info ('.preg_replace('/_/',' ',$this->ICCProfile).')');
+			$this->_out('/Info ('.preg_replace('/_/',' ',($this->ICCProfile ?? '')).')');
 			$this->_out('/OutputConditionIdentifier (Custom)');
 			$this->_out('/OutputCondition ()');
 		}
@@ -9860,7 +9877,7 @@
 	else if ($this->PDFX) {	// always a CMYK profile
 		$this->_out('/S /GTS_PDFX');
 		if ($this->ICCProfile) {
-			$this->_out('/Info ('.preg_replace('/_/',' ',$this->ICCProfile).')');
+			$this->_out('/Info ('.preg_replace('/_/',' ',($this->ICCProfile ?? '')).')');
 			$this->_out('/OutputConditionIdentifier (Custom)');
 			$this->_out('/OutputCondition ()');
 			$this->_out('/DestOutputProfile '.($this->n+1).' 0 R');
@@ -9888,7 +9905,7 @@
 	else { $this->_out('/N 3'); }
 	if ($this->compress)
 		$this->_out('/Filter /FlateDecode ');
-	$this->_out('/Length '.strlen($s).'>>');
+	$this->_out('/Length '.strlen(($s ?? '')).'>>');
 	$this->_putstream($s);
 	$this->_out('endobj');
 }
@@ -9912,12 +9929,12 @@
 	}
 
 /*-- BOOKMARKS --*/
-	if(count($this->BMoutlines)>0) {
+	if(count(($this->BMoutlines ?? []))>0) {
 	      $this->_out('/Outlines '.$this->OutlineRoot.' 0 R');
 	      $this->_out('/PageMode /UseOutlines');
 	}
 /*-- END BOOKMARKS --*/
-	if(is_int(strpos($this->DisplayPreferences,'FullScreen'))) $this->_out('/PageMode /FullScreen');
+	if(is_int(strpos(($this->DisplayPreferences ?? ''),'FullScreen'))) $this->_out('/PageMode /FullScreen');
 
 	// Metadata
 	if ($this->PDFA || $this->PDFX) { 
@@ -9929,7 +9946,7 @@
 	}
 
 /*-- FORMS --*/
-	if (count($this->mpdfform->forms)>0) {
+	if (count(($this->mpdfform->forms ?? []))>0) {
 		$this->mpdfform->_putFormsCatalog();
 	}
 /*-- END FORMS --*/
@@ -9939,14 +9956,14 @@
 
 	if($this->DisplayPreferences || $this->directionality == 'rtl' || $this->mirrorMargins) {
 		$this->_out('/ViewerPreferences<<');
-		if(is_int(strpos($this->DisplayPreferences,'HideMenubar'))) $this->_out('/HideMenubar true');
-		if(is_int(strpos($this->DisplayPreferences,'HideToolbar'))) $this->_out('/HideToolbar true');
-		if(is_int(strpos($this->DisplayPreferences,'HideWindowUI'))) $this->_out('/HideWindowUI true');
-		if(is_int(strpos($this->DisplayPreferences,'DisplayDocTitle'))) $this->_out('/DisplayDocTitle true');
-		if(is_int(strpos($this->DisplayPreferences,'CenterWindow'))) $this->_out('/CenterWindow true');
-		if(is_int(strpos($this->DisplayPreferences,'FitWindow'))) $this->_out('/FitWindow true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'HideMenubar'))) $this->_out('/HideMenubar true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'HideToolbar'))) $this->_out('/HideToolbar true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'HideWindowUI'))) $this->_out('/HideWindowUI true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'DisplayDocTitle'))) $this->_out('/DisplayDocTitle true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'CenterWindow'))) $this->_out('/CenterWindow true');
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'FitWindow'))) $this->_out('/FitWindow true');
 		// /PrintScaling is PDF 1.6 spec.
-		if(is_int(strpos($this->DisplayPreferences,'NoPrintScaling')) && !$this->PDFA && !$this->PDFX) 
+		if(is_int(strpos(($this->DisplayPreferences ?? ''),'NoPrintScaling')) && !$this->PDFA && !$this->PDFX) 
 			$this->_out('/PrintScaling /None');
 		if($this->directionality == 'rtl') $this->_out('/Direction /R2L');
 		// /Duplex is PDF 1.7 spec.
@@ -9956,10 +9973,10 @@
 		}
 		$this->_out('>>');
 	}
-	if($this->open_layer_pane && ($this->hasOC || count($this->layers)))
+	if($this->open_layer_pane && ($this->hasOC || count(($this->layers ?? []))))
 		$this->_out('/PageMode /UseOC');
 
-	if ($this->hasOC || count($this->layers)) {
+	if ($this->hasOC || count(($this->layers ?? []))) {
 		$p = $v = $h = $l = $loff = $lall = $as = '';
 		if ($this->hasOC) {
 			if (($this->hasOC & 1) == 1) $p=$this->n_ocg_print.' 0 R';
@@ -9968,9 +9985,9 @@
 			$as="<</Event /Print /OCGs [$p $v $h] /Category [/Print]>> <</Event /View /OCGs [$p $v $h] /Category [/View]>>";
 		}
 
-		if(count($this->layers)) {
+		if(count(($this->layers ?? []))) {
 			foreach($this->layers as $k=>$layer) {
-				if (strtolower($this->layerDetails[$k]['state'])=='hidden') { $loff .= $layer['n'].' 0 R '; }
+				if (strtolower(($this->layerDetails[$k]['state'] ?? ''))=='hidden') { $loff .= $layer['n'].' 0 R '; }
 				else { $l .= $layer['n'].' 0 R '; }
 				$lall .= $layer['n'].' 0 R ';
 			}
@@ -10000,30 +10017,30 @@
 		if ($font['sip'] || $font['smp']) {
 			foreach($font['subsetfontids'] AS $k => $fid) {
 				foreach($this->pages AS $pn=>$page) { 
-					$this->pages[$pn] = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]); 
+					$this->pages[$pn] = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',($this->pages[$pn] ?? '')); 
 				}
 			}
 		}
 		else { 
 				foreach($this->pages AS $pn=>$page) { 
-					$this->pages[$pn] = preg_replace('/\s\/F'.$font['i'].' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]); 
+					$this->pages[$pn] = preg_replace('/\s\/F'.$font['i'].' \d[\d.]* Tf\s/is',' ',($this->pages[$pn] ?? '')); 
 				}
 		}
 	   }
 	}
 
-	if (count($this->layers)) {
+	if (count(($this->layers ?? []))) {
 	  foreach($this->pages AS $pn=>$page) { 
-		preg_match_all('/\/OCZ-index \/ZI(\d+) BDC(.*?)(EMCZ)-index/is',$this->pages[$pn],$m1);
-		preg_match_all('/\/OCBZ-index \/ZI(\d+) BDC(.*?)(EMCBZ)-index/is',$this->pages[$pn],$m2);
-		preg_match_all('/\/OCGZ-index \/ZI(\d+) BDC(.*?)(EMCGZ)-index/is',$this->pages[$pn],$m3);
+		preg_match_all('/\/OCZ-index \/ZI(\d+) BDC(.*?)(EMCZ)-index/is',($this->pages[$pn] ?? ''),$m1);
+		preg_match_all('/\/OCBZ-index \/ZI(\d+) BDC(.*?)(EMCBZ)-index/is',($this->pages[$pn] ?? ''),$m2);
+		preg_match_all('/\/OCGZ-index \/ZI(\d+) BDC(.*?)(EMCGZ)-index/is',($this->pages[$pn] ?? ''),$m3);
 		$m = array();
 		for ($i=0;$i<4;$i++) {
 			$m[$i] = array_merge($m1[$i],$m2[$i],$m3[$i]);
 		}
-		if (count($m[0])) {
+		if (count(($m[0] ?? []))) {
 			$sortarr = array();
-			for($i=0;$i<count($m[0]);$i++) {
+			for($i=0;$i<count(($m[0] ?? []));$i++) {
 				$key = $m[1][$i]*2;
 				if ($m[3][$i]=='EMCZ') $key +=2;	// background first then gradient then normal
 				else if ($m[3][$i]=='EMCGZ') $key +=1;
@@ -10031,11 +10048,11 @@
 			} 
 			asort($sortarr);
 			foreach($sortarr AS $i=>$k) {
-				$this->pages[$pn] = str_replace($m[0][$i],'',$this->pages[$pn] );
+				$this->pages[$pn] = str_replace(($m[0][$i] ?? ''),'',($this->pages[$pn] ?? '') );
 				$this->pages[$pn] .= "\n".$m[0][$i]."\n";
 			} 
-			$this->pages[$pn] = preg_replace('/\/OC[BG]{0,1}Z-index \/ZI(\d+) BDC/is','/OC /ZI\\1 BDC ',$this->pages[$pn]); 
-			$this->pages[$pn] = preg_replace('/EMC[BG]{0,1}Z-index/is','EMC',$this->pages[$pn]); 
+			$this->pages[$pn] = preg_replace('/\/OC[BG]{0,1}Z-index \/ZI(\d+) BDC/is','/OC /ZI\\1 BDC ',($this->pages[$pn] ?? '')); 
+			$this->pages[$pn] = preg_replace('/EMC[BG]{0,1}Z-index/is','EMC',($this->pages[$pn] ?? '')); 
 		}
 	  }
 	}
@@ -10066,7 +10083,7 @@
 	$this->_out('>>');
 	$this->_out('endobj');
 	//Cross-ref
-	$o=strlen($this->buffer);
+	$o=strlen(($this->buffer ?? ''));
 	$this->_out('xref');
 	$this->_out('0 '.($this->n+1));
 	$this->_out('0000000000 65535 f ');
@@ -10084,7 +10101,7 @@
 	$this->state=3;
 /*-- IMPORTS --*/
 
-	if ($this->enableImports && count($this->parsers) > 0) {
+	if ($this->enableImports && count(($this->parsers ?? [])) > 0) {
 	  	foreach ($this->parsers as $k => $_){
 			$this->parsers[$k]->closeFile();
 			$this->parsers[$k] = null;
@@ -10160,7 +10177,7 @@
 	if(!$orientation)
 		$orientation=$this->DefOrientation;
 	else {
-		$orientation=strtoupper(substr($orientation,0,1));
+		$orientation=strtoupper((substr(($orientation ?? ''),0,1) ?? ''));
 		if($orientation!=$this->DefOrientation)
 			$this->OrientationChanges[$this->page]=true;
 	}
@@ -10221,13 +10238,13 @@
 
 	// If Page Margins are re-defined
 	// strlen()>0 is used to pick up (integer) 0, (string) '0', or set value
-	if ((strlen($mgl)>0 && $this->DeflMargin != $mgl) || (strlen($mgr)>0 && $this->DefrMargin != $mgr) || (strlen($mgt)>0 && $this->tMargin != $mgt) || (strlen($mgb)>0 && $this->bMargin != $mgb) || (strlen($mgh)>0 && $this->margin_header!=$mgh) || (strlen($mgf)>0 && $this->margin_footer!=$mgf)) {
-		if (strlen($mgl)>0)  $this->DeflMargin = $mgl;
-		if (strlen($mgr)>0)  $this->DefrMargin = $mgr;
-		if (strlen($mgt)>0)  $this->tMargin = $mgt;
-		if (strlen($mgb)>0)  $this->bMargin = $mgb;
-		if (strlen($mgh)>0)  $this->margin_header=$mgh;
-		if (strlen($mgf)>0)  $this->margin_footer=$mgf;
+	if ((strlen(($mgl ?? ''))>0 && $this->DeflMargin != $mgl) || (strlen(($mgr ?? ''))>0 && $this->DefrMargin != $mgr) || (strlen(($mgt ?? ''))>0 && $this->tMargin != $mgt) || (strlen(($mgb ?? ''))>0 && $this->bMargin != $mgb) || (strlen(($mgh ?? ''))>0 && $this->margin_header!=$mgh) || (strlen(($mgf ?? ''))>0 && $this->margin_footer!=$mgf)) {
+		if (strlen(($mgl ?? ''))>0)  $this->DeflMargin = $mgl;
+		if (strlen(($mgr ?? ''))>0)  $this->DefrMargin = $mgr;
+		if (strlen(($mgt ?? ''))>0)  $this->tMargin = $mgt;
+		if (strlen(($mgb ?? ''))>0)  $this->bMargin = $mgb;
+		if (strlen(($mgh ?? ''))>0)  $this->margin_header=$mgh;
+		if (strlen(($mgf ?? ''))>0)  $this->margin_footer=$mgf;
 		$this->ResetMargins();
 		$this->SetAutoPageBreak($this->autoPageBreak,$this->bMargin);
 		$this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
@@ -10246,48 +10263,48 @@
 	$this->FontFamily='';
 
 	// HEADERS AND FOOTERS	// mPDF 6
-	if ($ohvalue<0 || strtoupper($ohvalue)=='OFF') { 
+	if ($ohvalue<0 || strtoupper(($ohvalue ?? ''))=='OFF') { 
 		$this->HTMLHeader = ''; 
 		$resetHTMLHeadersrequired = true;
 	}
 	else if ($ohname && $ohvalue>0) {
-		if (preg_match('/^html_(.*)$/i',$ohname,$n)) { $name = $n[1]; }
+		if (preg_match('/^html_(.*)$/i',($ohname ?? ''),$n)) { $name = $n[1]; }
 		else { $name = $ohname; }
 		if (isset($this->pageHTMLheaders[$name])) { $this->HTMLHeader = $this->pageHTMLheaders[$name]; }
 		else { $this->HTMLHeader = ''; }
 		$resetHTMLHeadersrequired = true;
 	}
 
-	if ($ehvalue<0 || strtoupper($ehvalue)=='OFF') { 
+	if ($ehvalue<0 || strtoupper(($ehvalue ?? ''))=='OFF') { 
 		$this->HTMLHeaderE = ''; 
 		$resetHTMLHeadersrequired = true;
 	}
 	else if ($ehname && $ehvalue>0) {
-		if (preg_match('/^html_(.*)$/i',$ehname,$n)) { $name = $n[1]; }
+		if (preg_match('/^html_(.*)$/i',($ehname ?? ''),$n)) { $name = $n[1]; }
 		else { $name = $ehname; }
 		if (isset($this->pageHTMLheaders[$name])) { $this->HTMLHeaderE = $this->pageHTMLheaders[$name]; } 
 		else { $this->HTMLHeaderE = ''; }
 		$resetHTMLHeadersrequired = true;
 	}
 
-	if ($ofvalue<0 || strtoupper($ofvalue)=='OFF') { 
+	if ($ofvalue<0 || strtoupper(($ofvalue ?? ''))=='OFF') { 
 		$this->HTMLFooter = ''; 
 		$resetHTMLHeadersrequired = true;
 	}
 	else if ($ofname && $ofvalue>0) {
-		if (preg_match('/^html_(.*)$/i',$ofname,$n)) { $name = $n[1]; }
+		if (preg_match('/^html_(.*)$/i',($ofname ?? ''),$n)) { $name = $n[1]; }
 		else { $name = $ofname; }
 		if (isset($this->pageHTMLfooters[$name])) { $this->HTMLFooter = $this->pageHTMLfooters[$name]; }
 		else { $this->HTMLFooter = ''; }
 		$resetHTMLHeadersrequired = true;
 	}
 
-	if ($efvalue<0 || strtoupper($efvalue)=='OFF') { 
+	if ($efvalue<0 || strtoupper(($efvalue ?? ''))=='OFF') { 
 		$this->HTMLFooterE = ''; 
 		$resetHTMLHeadersrequired = true;
 	}
 	else if ($efname && $efvalue>0) {
-		if (preg_match('/^html_(.*)$/i',$efname,$n)) { $name = $n[1]; }
+		if (preg_match('/^html_(.*)$/i',($efname ?? ''),$n)) { $name = $n[1]; }
 		else { $name = $efname; }
 		if (isset($this->pageHTMLfooters[$name])) { $this->HTMLFooterE = $this->pageHTMLfooters[$name]; } 
 		else { $this->HTMLFooterE = ''; }
@@ -10367,7 +10384,7 @@
 		}
 		//Begin a new object
 		if (!$onlynewobj) {
-			$this->offsets[$obj_id] = strlen($this->buffer);
+			$this->offsets[$obj_id] = strlen(($this->buffer ?? ''));
 			$this->_out($obj_id.' 0 obj');
 			$this->_current_obj_id = $obj_id; // for later use with encryption
 		}
@@ -10376,7 +10393,7 @@
 function _dounderline($x,$y,$txt,$OTLdata=false,$textvar=0) {
 	// Now print line exactly where $y secifies - called from Text() and Cell() - adjust  position there
 	// WORD SPACING
-      $w =($this->GetStringWidth($txt,false,$OTLdata,$textvar)*_MPDFK) + ($this->charspacing * mb_strlen( $txt, $this->mb_enc )) 
+      $w =($this->GetStringWidth($txt,false,$OTLdata,$textvar)*_MPDFK) + ($this->charspacing * mb_strlen( ($txt ?? ''), $this->mb_enc )) 
 		 + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ));
 	//Draw a line
 	return sprintf('%.3F %.3F m %.3F %.3F l S',$x*_MPDFK,($this->h-$y)*_MPDFK,($x*_MPDFK)+$w,($this->h-$y)*_MPDFK);
@@ -10396,22 +10413,22 @@
 function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=false, $interpolation=false) { 	// mPDF 6
 	// firsttime i.e. whether to add to this->images - use false when calling iteratively
 	// Image Data passed directly as var:varname
-	if (preg_match('/var:\s*(.*)/',$file, $v)) { 
-		$data = $this->$v[1];
-		$file = md5($data);
-	}
-	if (preg_match('/data:image\/(gif|jpeg|png);base64,(.*)/',$file, $v)) { 
+	if (preg_match('/var:\s*(.*)/',($file ?? ''), $v)) { 
+		$data = $this->{$v[1]};
+		$file = md5(($data ?? ''));
+	}
+	if (preg_match('/data:image\/(gif|jpeg|png);base64,(.*)/',($file ?? ''), $v)) { 
 		$type = $v[1];
-		$data = base64_decode($v[2]);
-		$file = md5($data);
+		$data = base64_decode(($v[2] ?? ''));
+		$file = md5(($data ?? ''));
 	}
 
 	// mPDF 5.7.4 URLs
-	if ($firsttime && $file && substr($file,0,5)!='data:') { $file = str_replace(" ","%20",$file ); }
+	if ($firsttime && $file && substr(($file ?? ''),0,5)!='data:') { $file = str_replace(" ","%20",($file ?? '') ); }
 	if ($firsttime && $orig_srcpath) {
 		// If orig_srcpath is a relative file path (and not a URL), then it needs to be URL decoded
-		if (substr($orig_srcpath,0,5)!='data:') { $orig_srcpath = str_replace(" ","%20",$orig_srcpath); }
-		if (!preg_match('/^(http|ftp)/',$orig_srcpath)) { $orig_srcpath = urldecode_parts($orig_srcpath ); }
+		if (substr(($orig_srcpath ?? ''),0,5)!='data:') { $orig_srcpath = str_replace(" ","%20",($orig_srcpath ?? '')); }
+		if (!preg_match('/^(http|ftp)/',($orig_srcpath ?? ''))) { $orig_srcpath = urldecode_parts($orig_srcpath ); }
 	}
 
 	$ppUx = 0;
@@ -10428,12 +10445,12 @@
  		if ($orig_srcpath && $this->basepathIsLocal && $check = @fopen($orig_srcpath,"rb")) {
 			fclose($check); 
 			$file=$orig_srcpath;
-			$data = file_get_contents($file);
+			$data = file_get_contents(($file ?? ''));
 			$type = $this->_imageTypeFromString($data);
 		}
 		if (!$data && $check = @fopen($file,"rb")) {
 			fclose($check); 
-			$data = file_get_contents($file);
+			$data = file_get_contents(($file ?? ''));
 			$type = $this->_imageTypeFromString($data);
 		}
 		if ((!$data || !$type) && !ini_get('allow_url_fopen') ) {	// only worth trying if remote file and !ini_get('allow_url_fopen')
@@ -10462,7 +10479,7 @@
 		if($family) $this->SetFont($family,$style,$size,false);
 		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing SVG file'); }
 		$info['type']='svg';
-		$info['i']=count($this->formobjects)+1;
+		$info['i']=count(($this->formobjects ?? []))+1;
 		$this->formobjects[$file]=$info;
 		return $info;
 	}
@@ -10473,12 +10490,12 @@
 		if (!$hdr) { return $this->_imageError($file, $firsttime, 'Error parsing JPG header'); }
 		$a = $this->_jpgDataFromHeader($hdr);
 		$channels = intval($a[4]);
-		$j = strpos($data,'JFIF');
+		$j = strpos(($data ?? ''),'JFIF');
 		if ($j) { 
 			//Read resolution
-			$unitSp=ord(substr($data,($j+7),1));
+			$unitSp=ord((substr(($data ?? ''),($j+7),1) ?? ''));
 			if ($unitSp > 0) {
-				$ppUx=$this->_twobytes2int(substr($data,($j+8),2));	// horizontal pixels per meter, usually set to zero
+				$ppUx=$this->_twobytes2int(substr(($data ?? ''),($j+8),2));	// horizontal pixels per meter, usually set to zero
 				if ($unitSp == 2) {	// = dots per cm (if == 1 set as dpi)
 					$ppUx=round($ppUx/10 *25.4);
 				}
@@ -10490,7 +10507,7 @@
 			if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "JPG image may not use CMYK color space - ".$file." - (Image converted to RGB. NB This will alter the colour profile of the image.)"; }
 			$im = @imagecreatefromstring($data);
 			if ($im) {
-				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
+				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5(($file ?? '')).RAND(1,10000).'.png';
 				imageinterlace($im, false);
 				$check = @imagepng($im, $tempfile);
 				if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse JPG(CMYK) image'); }
@@ -10500,7 +10517,7 @@
 				unlink($tempfile);
 				$info['type']='jpg';
 				if ($firsttime) {
-					$info['i']=count($this->images)+1;
+					$info['i']=count(($this->images ?? []))+1;
 					$info['interpolation']=$interpolation;	// mPDF 6
 					$this->images[$file]=$info;
 				}
@@ -10527,24 +10544,24 @@
 			// mPDF 6 ICC profile
 			$offset = 0;
 			$icc = array();
-			while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
+			while (($pos = strpos(($data ?? ''), "ICC_PROFILE\0", $offset)) !== false) {
 				// get ICC sequence length
-				$length = $this->_twobytes2int(substr($data, ($pos - 2),2)) - 16;
-				$sn = max(1, ord($data[($pos + 12)]));
-				$nom = max(1, ord($data[($pos + 13)]));
-				$icc[($sn - 1)] = substr($data, ($pos + 14), $length);
+				$length = $this->_twobytes2int(substr(($data ?? ''), ($pos - 2),2)) - 16;
+				$sn = max(1, ord(($data[($pos + 12)] ?? '')));
+				$nom = max(1, ord(($data[($pos + 13)] ?? '')));
+				$icc[($sn - 1)] = substr(($data ?? ''), ($pos + 14), $length);
 				$offset = ($pos + 14 + $length);
 			}
 			// order and compact ICC segments
-			if (count($icc) > 0) {
+			if (count(($icc ?? [])) > 0) {
 				ksort($icc);
 				$icc = implode('', $icc);
-				if (substr($icc, 36, 4) != 'acsp') {
+				if (substr(($icc ?? ''), 36, 4) != 'acsp') {
 					// invalid ICC profile
 					$icc = false;
 				}
-				$input = substr($icc, 16, 4); 
-				$output = substr($icc, 20, 4);
+				$input = substr(($icc ?? ''), 16, 4); 
+				$output = substr(($icc ?? ''), 20, 4);
 				// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
 				if ($input != 'RGB ' || $output != 'XYZ ') { $icc = false; }
 			} 
@@ -10555,7 +10572,7 @@
 		}
 		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing or converting JPG image'); }
 		if ($firsttime) {
-			$info['i']=count($this->images)+1;
+			$info['i']=count(($this->images ?? []))+1;
 			$info['interpolation']=$interpolation;	// mPDF 6
 			$this->images[$file]=$info;
 		}
@@ -10565,47 +10582,47 @@
 	// PNG
 	else if ($type == 'png') {
 		//Check signature
-		if(substr($data,0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
+		if(substr(($data ?? ''),0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
 			return $this->_imageError($file, $firsttime, 'Error parsing PNG identifier'); 
 		}
 		//Read header chunk
-		if(substr($data,12,4)!='IHDR') { 
+		if(substr(($data ?? ''),12,4)!='IHDR') { 
 			return $this->_imageError($file, $firsttime, 'Incorrect PNG file (no IHDR block found)'); 
 		}
 
-		$w=$this->_fourbytes2int(substr($data,16,4));
-		$h=$this->_fourbytes2int(substr($data,20,4));
-		$bpc=ord(substr($data,24,1));
+		$w=$this->_fourbytes2int(substr(($data ?? ''),16,4));
+		$h=$this->_fourbytes2int(substr(($data ?? ''),20,4));
+		$bpc=ord((substr(($data ?? ''),24,1) ?? ''));
 		$errpng = false;
 		$pngalpha = false;
 		$channels = 0;
 
 	//	if($bpc>8) { $errpng = 'not 8-bit depth'; }	// mPDF 6 Allow through to be handled as native PNG
 
-		$ct=ord(substr($data,25,1));
+		$ct=ord((substr(($data ?? ''),25,1) ?? ''));
 		if($ct==0) { $colspace='DeviceGray'; $channels = 1; }
 		elseif($ct==2) { $colspace='DeviceRGB'; $channels = 3; }
 		elseif($ct==3) { $colspace='Indexed'; $channels = 1; }
 		elseif($ct==4) { $colspace='DeviceGray';  $channels = 1; $errpng = 'alpha channel'; $pngalpha = true; }
 		else { $colspace='DeviceRGB'; $channels = 3; $errpng = 'alpha channel'; $pngalpha = true; } 
 
-		if ($ct < 4 && strpos($data,'tRNS')!==false) {	$errpng = 'transparency'; $pngalpha = true; }	// mPDF 6
-
-		if ($ct == 3 && strpos($data,'iCCP')!==false) {	$errpng = 'indexed plus ICC'; }	// mPDF 6
+		if ($ct < 4 && strpos(($data ?? ''),'tRNS')!==false) {	$errpng = 'transparency'; $pngalpha = true; }	// mPDF 6
+
+		if ($ct == 3 && strpos(($data ?? ''),'iCCP')!==false) {	$errpng = 'indexed plus ICC'; }	// mPDF 6
 
 		// $pngalpha is used as a FLAG of any kind of transparency which COULD be tranferred to an alpha channel 
 		// incl. single-color tarnsparency, depending which type of handling occurs later
 
-		if(ord(substr($data,26,1))!=0) { $errpng = 'compression method'; }	// only 0 should be specified
-		if(ord(substr($data,27,1))!=0) { $errpng = 'filter method'; }		// only 0 should be specified
-		if(ord(substr($data,28,1))!=0) { $errpng = 'interlaced file'; }
-
-		$j = strpos($data,'pHYs');
+		if(ord((substr(($data ?? ''),26,1) ?? ''))!=0) { $errpng = 'compression method'; }	// only 0 should be specified
+		if(ord((substr(($data ?? ''),27,1) ?? ''))!=0) { $errpng = 'filter method'; }		// only 0 should be specified
+		if(ord((substr(($data ?? ''),28,1) ?? ''))!=0) { $errpng = 'interlaced file'; }
+
+		$j = strpos(($data ?? ''),'pHYs');
 		if ($j) { 
 			//Read resolution
-			$unitSp=ord(substr($data,($j+12),1));
+			$unitSp=ord((substr(($data ?? ''),($j+12),1) ?? ''));
 			if ($unitSp == 1) {
-				$ppUx=$this->_fourbytes2int(substr($data,($j+4),4));	// horizontal pixels per meter, usually set to zero
+				$ppUx=$this->_fourbytes2int(substr(($data ?? ''),($j+4),4));	// horizontal pixels per meter, usually set to zero
 				$ppUx=round($ppUx/1000 *25.4);
 			}
 		}
@@ -10613,9 +10630,9 @@
 		// mPDF 6 Gamma correction
 		$gamma_correction = 0; 
 		$gAMA = 0;
-		$j = strpos($data,'gAMA');
-		if ($j && strpos($data,'sRGB')===false) {	// sRGB colorspace - overrides gAMA
-			$gAMA=$this->_fourbytes2int(substr($data,($j+4),4));	// Gamma value times 100000
+		$j = strpos(($data ?? ''),'gAMA');
+		if ($j && strpos(($data ?? ''),'sRGB')===false) {	// sRGB colorspace - overrides gAMA
+			$gAMA=$this->_fourbytes2int(substr(($data ?? ''),($j+4),4));	// Gamma value times 100000
 			$gAMA /= 100000;
 
 			// http://www.libpng.org/pub/png/spec/1.2/PNG-Encoders.html
@@ -10677,33 +10694,33 @@
 			$w = imagesx($im);
 			$h = imagesy($im);
 			if ($im) {
-			   $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
+			   $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5(($file ?? '')).RAND(1,10000).'.png';
 
 			   // Alpha channel set (including using tRNS for Paletted images)
 			   if ($pngalpha) {
 				if ($this->PDFA) { $this->Error("PDFA1-b does not permit images with alpha channel transparency (".$file.")."); }
 
-				$imgalpha = imagecreate($w, $h);
+				$imgalpha = imagecreate((int) ($w), (int) ($h));
 				// generate gray scale pallete
-				for ($c = 0; $c < 256; ++$c) { imagecolorallocate($imgalpha, $c, $c, $c); }
+				for ($c = 0; $c < 256; ++$c) { imagecolorallocate($imgalpha, (int) ($c), (int) ($c), (int) ($c)); }
 
 				// mPDF 6
 				if ($colspace=='Indexed') {	// generate Alpha channel values from tRNS
 					//Read transparency info
 					$transparency = '';
-					$p = strpos($data,'tRNS');
+					$p = strpos(($data ?? ''),'tRNS');
 					if ($p) { 
-						$n=$this->_fourbytes2int(substr($data,($p-4),4));
-						$transparency = substr($data,($p+4),$n);
+						$n=$this->_fourbytes2int(substr(($data ?? ''),($p-4),4));
+						$transparency = substr(($data ?? ''),($p+4),$n);
 						// ord($transparency{$index}) = the alpha value for that index
 						// generate alpha channel
 						for ($ypx = 0; $ypx < $h; ++$ypx) {
 							for ($xpx = 0; $xpx < $w; ++$xpx) {
-								$colorindex = imagecolorat($im, $xpx, $ypx);
+								$colorindex = imagecolorat($im, (int) ($xpx), (int) ($ypx));
 								if ($colorindex >= $n) { $alpha = 255; }
-								else { $alpha = ord($transparency{$colorindex}); }	// 0-255
+								else { $alpha = ord(($transparency[$colorindex] ?? '')); }	// 0-255
 								if ($alpha > 0) {
-									imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
+									imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), (int) ($alpha));
 								}
 							}
 						}
@@ -10711,25 +10728,25 @@
 				}
 				else if ($ct===0 || $ct==2) {	// generate Alpha channel values from tRNS
 					// Get transparency as array of RGB
-					$p = strpos($data,'tRNS');
+					$p = strpos(($data ?? ''),'tRNS');
 					if ($p) { 
 						$trns = '';
-						$n=$this->_fourbytes2int(substr($data,($p-4),4));
-						$t = substr($data,($p+4),$n);	
+						$n=$this->_fourbytes2int(substr(($data ?? ''),($p-4),4));
+						$t = substr(($data ?? ''),($p+4),$n);	
 						if ($colspace=='DeviceGray') { 	// ct===0
-							$trns=array($this->_trnsvalue(substr($t,0,2), $bpc));
+							$trns=array($this->_trnsvalue(substr(($t ?? ''),0,2), $bpc));
 						}
 						else /* $colspace=='DeviceRGB' */ { 	// ct==2
 							$trns=array();
-							$trns[0]=$this->_trnsvalue(substr($t,0,2), $bpc);
-							$trns[1]=$this->_trnsvalue(substr($t,2,2), $bpc);
-							$trns[2]=$this->_trnsvalue(substr($t,4,2), $bpc);
+							$trns[0]=$this->_trnsvalue(substr(($t ?? ''),0,2), $bpc);
+							$trns[1]=$this->_trnsvalue(substr(($t ?? ''),2,2), $bpc);
+							$trns[2]=$this->_trnsvalue(substr(($t ?? ''),4,2), $bpc);
 						}
 
 						// generate alpha channel
 						for ($ypx = 0; $ypx < $h; ++$ypx) {
 							for ($xpx = 0; $xpx < $w; ++$xpx) {
-								$rgb = imagecolorat($im, $xpx, $ypx);
+								$rgb = imagecolorat($im, (int) ($xpx), (int) ($ypx));
 								$r = ($rgb >> 16) & 0xFF;
 								$g = ($rgb >> 8) & 0xFF;
 								$b = $rgb & 0xFF;
@@ -10737,7 +10754,7 @@
 								else if ($r==$trns[0] && $g==$trns[1] && $b==$trns[2]) { $alpha = 0; } 	// ct==2
 								else { $alpha = 255; }
 								if ($alpha > 0) {
-									imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
+									imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), (int) ($alpha));
 								}
 							}
 						}
@@ -10747,9 +10764,9 @@
 					// extract alpha channel
 					for ($ypx = 0; $ypx < $h; ++$ypx) {
 						for ($xpx = 0; $xpx < $w; ++$xpx) {
-							$alpha = (imagecolorat($im, $xpx, $ypx) & 0x7F000000) >> 24;
+							$alpha = (imagecolorat($im, (int) ($xpx), (int) ($ypx)) & 0x7F000000) >> 24;
 							if ($alpha < 127) {
-								imagesetpixel($imgalpha, $xpx, $ypx, (255-($alpha * 2)));
+								imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), ((int) (255-($alpha * 2))));
 							}
 						}
 					}
@@ -10761,7 +10778,7 @@
 				if ($gamma_correction) { imagegammacorrect($im, $gamma_correction, 2.2); }	// mPDF 6 Gamma correction
 
 				// create temp alpha file
-	 		 	$tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.md5($file).RAND(1,10000).'.png';
+	 		 	$tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.md5(($file ?? '')).RAND(1,10000).'.png';
 				if (!is_writable(_MPDF_TEMP_PATH)) { 	// mPDF 5.7.2
 					ob_start(); 
 					$check = @imagepng($imgalpha);
@@ -10771,9 +10788,9 @@
 					$this->_tempimglnk = 'var:_tempimg';
 					ob_end_clean();
 					// extract image without alpha channel
-					$imgplain = imagecreatetruecolor($w, $h);
+					$imgplain = imagecreatetruecolor((int) ($w), (int) ($h));
 					imagealphablending( $imgplain, false );	// mPDF 5.7.2
-					imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
+					imagecopy($imgplain, $im, 0, 0, 0, 0, (int) ($w), (int) ($h));
 					// create temp image file
 					$minfo = $this->_getImage($this->_tempimglnk, false);
 					if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
@@ -10786,7 +10803,7 @@
 					$info = $this->_getImage($this->_tempimglnk, false);
 					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
 					imagedestroy($imgplain);
-					$imgmask = count($this->images)+1;
+					$imgmask = count(($this->images ?? []))+1;
 					$minfo['cs'] = 'DeviceGray';
 					$minfo['i']=$imgmask ;
 					$this->images[$tempfile_alpha] = $minfo;
@@ -10796,9 +10813,9 @@
 					if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile_alpha.') parsing PNG image with alpha channel ('.$errpng.')'); }
 					imagedestroy($imgalpha);
 					// extract image without alpha channel
-					$imgplain = imagecreatetruecolor($w, $h);
+					$imgplain = imagecreatetruecolor((int) ($w), (int) ($h));
 					imagealphablending( $imgplain, false );	// mPDF 5.7.2
-					imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
+					imagecopy($imgplain, $im, 0, 0, 0, 0, (int) ($w), (int) ($h));
 
 					// create temp image file
 					$check = @imagepng($imgplain, $tempfile);
@@ -10808,7 +10825,7 @@
 					$minfo = $this->_getImage($tempfile_alpha, false);
 					unlink($tempfile_alpha);
 					if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile_alpha.') created with GD library to parse PNG image'); }
-					$imgmask = count($this->images)+1;
+					$imgmask = count(($this->images ?? []))+1;
 					$minfo['cs'] = 'DeviceGray';
 					$minfo['i']=$imgmask ;
 					$this->images[$tempfile_alpha] = $minfo;
@@ -10822,7 +10839,7 @@
 				if ($ppUx) { $info['set-dpi'] = $ppUx; }
 				$info['type']='png';
 				if ($firsttime) {
-					$info['i']=count($this->images)+1;
+					$info['i']=count(($this->images ?? []))+1;
 					$info['interpolation']=$interpolation;	// mPDF 6
 					$this->images[$file]=$info;
 				}
@@ -10833,18 +10850,18 @@
 
 				// ICC profile
 				$icc = false;
-				$p = strpos($data,'iCCP');
+				$p = strpos(($data ?? ''),'iCCP');
 				if ($p && $colspace=="Indexed") {	// Cannot have ICC profile and Indexed together
 					$p += 4;
-					$n=$this->_fourbytes2int(substr($data,($p-8),4));
-					$nullsep = strpos(substr($data,$p,80), chr(0));
-					$icc = substr($data, ($p+$nullsep+2), ($n-($nullsep+2)) );
+					$n=$this->_fourbytes2int(substr(($data ?? ''),($p-8),4));
+					$nullsep = strpos((substr(($data ?? ''),$p,80) ?? ''), (chr(0) ?? ''));
+					$icc = substr(($data ?? ''), ($p+$nullsep+2), ($n-($nullsep+2)) );
 					$icc = @gzuncompress($icc);	// Ignored if fails
 					if ($icc) { 
-						if (substr($icc, 36, 4) != 'acsp') { $icc = false; }	// invalid ICC profile
+						if (substr(($icc ?? ''), 36, 4) != 'acsp') { $icc = false; }	// invalid ICC profile
 						else {
-							$input = substr($icc, 16, 4); 
-							$output = substr($icc, 20, 4);
+							$input = substr(($icc ?? ''), 16, 4); 
+							$output = substr(($icc ?? ''), 20, 4);
 							// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
 							if ($input != 'RGB ' || $output != 'XYZ ') { $icc = false; }
 						}
@@ -10879,7 +10896,7 @@
 				if ($ppUx) { $info['set-dpi'] = $ppUx; }
 				$info['type']='png';
 				if ($firsttime) {
-					$info['i']=count($this->images)+1;
+					$info['i']=count(($this->images ?? []))+1;
 					$info['interpolation']=$interpolation;	// mPDF 6
 					if ($icc) { $info['ch'] = $channels; $info['icc'] = $icc; }
 					$this->images[$file]=$info;
@@ -10898,37 +10915,37 @@
 			$icc = false;
 			$p = 33;
 			do {
-				$n=$this->_fourbytes2int(substr($data,$p,4));	$p += 4;
-				$type=substr($data,$p,4);	$p += 4;
+				$n=$this->_fourbytes2int(substr(($data ?? ''),$p,4));	$p += 4;
+				$type=substr(($data ?? ''),$p,4);	$p += 4;
 				if ($type=='PLTE') {
 					//Read palette
-					$pal=substr($data,$p,$n);	$p += $n;
+					$pal=substr(($data ?? ''),$p,$n);	$p += $n;
 					$p += 4;
 				}
 				else if($type=='tRNS') {
 					//Read transparency info
-					$t=substr($data,$p,$n);	$p += $n;
-					if ($ct==0) $trns=array(ord(substr($t,1,1)));
-					else if ($ct==2) $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
+					$t=substr(($data ?? ''),$p,$n);	$p += $n;
+					if ($ct==0) $trns=array(ord((substr(($t ?? ''),1,1) ?? '')));
+					else if ($ct==2) $trns=array(ord((substr(($t ?? ''),1,1) ?? '')),ord((substr(($t ?? ''),3,1) ?? '')),ord((substr(($t ?? ''),5,1) ?? '')));
 					else {
-						$pos=strpos($t,chr(0));
+						$pos=strpos(($t ?? ''),(chr(0) ?? ''));
 						if(is_int($pos)) $trns=array($pos);
 					}
 					$p += 4;
 				}
 				else if ($type=='IDAT') {
-					$pngdata.=substr($data,$p,$n);	$p += $n;
+					$pngdata.=substr(($data ?? ''),$p,$n);	$p += $n;
 					$p += 4;
 				}
 				else if ($type=='iCCP') {
-					$nullsep = strpos(substr($data,$p,80), chr(0));
-					$icc = substr($data, ($p+$nullsep+2), ($n-($nullsep+2)) );
+					$nullsep = strpos((substr(($data ?? ''),$p,80) ?? ''), (chr(0) ?? ''));
+					$icc = substr(($data ?? ''), ($p+$nullsep+2), ($n-($nullsep+2)) );
 					$icc = @gzuncompress($icc);	// Ignored if fails
 					if ($icc) {
-						if (substr($icc, 36, 4) != 'acsp') { $icc = false; }	// invalid ICC profile
+						if (substr(($icc ?? ''), 36, 4) != 'acsp') { $icc = false; }	// invalid ICC profile
 						else {
-							$input = substr($icc, 16, 4); 
-							$output = substr($icc, 20, 4);
+							$input = substr(($icc ?? ''), 16, 4); 
+							$output = substr(($icc ?? ''), 20, 4);
 							// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
 							if ($input != 'RGB ' || $output != 'XYZ ') { $icc = false; }
 						}
@@ -10937,7 +10954,7 @@
 					$p += 4;
 				}
 				else if($type=='IEND') { break; }
-				else if (preg_match('/[a-zA-Z]{4}/',$type)) { $p += $n+4; }
+				else if (preg_match('/[a-zA-Z]{4}/',($type ?? ''))) { $p += $n+4; }
 				else { return $this->_imageError($file, $firsttime, 'Error parsing PNG image data'); }
 			}
 			while($n);
@@ -10954,7 +10971,7 @@
 		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing or converting PNG image'); }
 
 		if ($firsttime) {
-			$info['i']=count($this->images)+1;
+			$info['i']=count(($this->images ?? []))+1;
 			$info['interpolation']=$interpolation;	// mPDF 6
 			$this->images[$file]=$info;
 		}
@@ -10968,7 +10985,7 @@
 		if (isset($gd['GIF Read Support']) && $gd['GIF Read Support']) {
 			$im = @imagecreatefromstring($data);
 			if ($im) {
-				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
+				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5(($file ?? '')).RAND(1,10000).'.png';
 				imagealphablending($im, false);
 				imagesavealpha($im, false); 
 				imageinterlace($im, false);
@@ -10993,7 +11010,7 @@
 				}
 				$info['type']='gif';
 				if ($firsttime) {
-					$info['i']=count($this->images)+1;
+					$info['i']=count(($this->images ?? []))+1;
 					$info['interpolation']=$interpolation;	// mPDF 6
 					$this->images[$file]=$info;
 				}
@@ -11053,7 +11070,7 @@
 		} 
 		$info['type']='gif';
 		if ($firsttime) {
-			$info['i']=count($this->images)+1;
+			$info['i']=count(($this->images ?? []))+1;
 			$info['interpolation']=$interpolation;	// mPDF 6
 			$this->images[$file]=$info;
 		}
@@ -11070,7 +11087,7 @@
 			return $this->_imageError($file, $firsttime, $info['error']); 
 		}
 		if ($firsttime) {
-			$info['i']=count($this->images)+1;
+			$info['i']=count(($this->images ?? []))+1;
 			$info['interpolation']=$interpolation;	// mPDF 6
 			$this->images[$file]=$info;
 		}
@@ -11088,7 +11105,7 @@
 		return $this->_imageError($file, $firsttime, 'Error parsing WMF image'); 
 	  }
 	  $info = array('x'=>$wmfres[2][0],'y'=>$wmfres[2][1],'w'=>$wmfres[3][0],'h'=>$wmfres[3][1],'data'=>$wmfres[1]);
-	  $info['i']=count($this->formobjects)+1;
+	  $info['i']=count(($this->formobjects ?? []))+1;
 	  $info['type']='wmf';
 	  $this->formobjects[$file]=$info;
 	  return $info;
@@ -11102,7 +11119,7 @@
 		if (isset($gd['PNG Support']) && $gd['PNG Support']) {
 			$im = @imagecreatefromstring($data);
 			if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); }
-			$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
+			$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5(($file ?? '')).RAND(1,10000).'.png';
 			imagealphablending($im, false);
 			imagesavealpha($im, false); 
 			imageinterlace($im, false);
@@ -11114,7 +11131,7 @@
 			if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse unknown image type'); }
 			$info['type']='png';
 			if ($firsttime) {
-				$info['i']=count($this->images)+1;
+				$info['i']=count(($this->images ?? []))+1;
 				$info['interpolation']=$interpolation;	// mPDF 6
 				$this->images[$file]=$info;
 			}
@@ -11129,7 +11146,7 @@
 	if ($this->PDFA || $this->PDFX) { $mask=false; }
 	$im = @imagecreatefromstring($data);
 	$info = array();
-	$bpc=ord(substr($data,24,1));
+	$bpc=ord((substr(($data ?? ''),24,1) ?? ''));
 	if ($im) {
 
 		$imgdata = '';
@@ -11143,50 +11160,50 @@
 			if ($colspace=='Indexed') {	// generate Alpha channel values from tRNS - only from PNG
 				//Read transparency info
 				$transparency = '';
-				$p = strpos($data,'tRNS');
+				$p = strpos(($data ?? ''),'tRNS');
 				if ($p) { 
-					$n=$this->_fourbytes2int(substr($data,($p-4),4));
-					$transparency = substr($data,($p+4),$n);	
+					$n=$this->_fourbytes2int(substr(($data ?? ''),($p-4),4));
+					$transparency = substr(($data ?? ''),($p+4),$n);	
 					// ord($transparency{$index}) = the alpha value for that index
 					// generate alpha channel
 					for ($ypx = 0; $ypx < $h; ++$ypx) {
 						for ($xpx = 0; $xpx < $w; ++$xpx) {
-							$colorindex = imagecolorat($im, $xpx, $ypx);
+							$colorindex = imagecolorat($im, (int) ($xpx), (int) ($ypx));
 							if ($colorindex >= $n) { $alpha = 255; }
-							else { $alpha = ord($transparency{$colorindex}); }	// 0-255
-							$mimgdata .= chr($alpha);
+							else { $alpha = ord(($transparency[$colorindex] ?? '')); }	// 0-255
+							$mimgdata .= chr((int) ($alpha));
 						}
 					}
 				}
 			}
 			else if ($pngcolortype===0 || $pngcolortype==2) {	// generate Alpha channel values from tRNS
 				// Get transparency as array of RGB
-				$p = strpos($data,'tRNS');
+				$p = strpos(($data ?? ''),'tRNS');
 				if ($p) { 
 					$trns = '';
-					$n=$this->_fourbytes2int(substr($data,($p-4),4));
-					$t = substr($data,($p+4),$n);	
+					$n=$this->_fourbytes2int(substr(($data ?? ''),($p-4),4));
+					$t = substr(($data ?? ''),($p+4),$n);	
 					if ($colspace=='DeviceGray') { 	// ct===0
-						$trns=array($this->_trnsvalue(substr($t,0,2), $bpc));
+						$trns=array($this->_trnsvalue(substr(($t ?? ''),0,2), $bpc));
 					}
 					else /* $colspace=='DeviceRGB' */ { 	// ct==2
 						$trns=array();
-						$trns[0]=$this->_trnsvalue(substr($t,0,2), $bpc);
-						$trns[1]=$this->_trnsvalue(substr($t,2,2), $bpc);
-						$trns[2]=$this->_trnsvalue(substr($t,4,2), $bpc);
+						$trns[0]=$this->_trnsvalue(substr(($t ?? ''),0,2), $bpc);
+						$trns[1]=$this->_trnsvalue(substr(($t ?? ''),2,2), $bpc);
+						$trns[2]=$this->_trnsvalue(substr(($t ?? ''),4,2), $bpc);
 					}
 
 					// generate alpha channel
 					for ($ypx = 0; $ypx < $h; ++$ypx) {
 						for ($xpx = 0; $xpx < $w; ++$xpx) {
-							$rgb = imagecolorat($im, $xpx, $ypx);
+							$rgb = imagecolorat($im, (int) ($xpx), (int) ($ypx));
 							$r = ($rgb >> 16) & 0xFF;
 							$g = ($rgb >> 8) & 0xFF;
 							$b = $rgb & 0xFF;
 							if ($colspace=='DeviceGray' && $b==$trns[0]) { $alpha = 0; } 
 							else if ($r==$trns[0] && $g==$trns[1] && $b==$trns[2]) { $alpha = 0; } 	// ct==2
 							else { $alpha = 255; }
-							$mimgdata .= chr($alpha);
+							$mimgdata .= chr((int) ($alpha));
 						}
 					}
 				}
@@ -11194,9 +11211,9 @@
 			else {
 				for ($i = 0; $i < $h; $i++) {
 					for ($j = 0; $j < $w; $j++) {
-						$rgb = imagecolorat($im, $j, $i);
+						$rgb = imagecolorat($im, (int) ($j), (int) ($i));
 						$alpha = ($rgb & 0x7F000000) >> 24;
-						if ($alpha < 127) { $mimgdata .= chr(255-($alpha * 2)); }
+						if ($alpha < 127) { $mimgdata .= chr((int) (255-($alpha * 2))); }
 						else { $mimgdata .= chr(0); }
 					}
 				}
@@ -11209,17 +11226,17 @@
 		$trns=array();
 		$trnsrgb = false;
 		if (!$this->PDFA && !$this->PDFX && !$mask) { 	// mPDF 6 added NOT mask
-		   $p = strpos($data,'tRNS');
+		   $p = strpos(($data ?? ''),'tRNS');
 		   if ($p) { 
-			$n=$this->_fourbytes2int(substr($data,($p-4),4));
-			$t = substr($data,($p+4),$n);	
+			$n=$this->_fourbytes2int(substr(($data ?? ''),($p-4),4));
+			$t = substr(($data ?? ''),($p+4),$n);	
 			if ($colspace=='DeviceGray') { 	// ct===0
-				$trns=array($this->_trnsvalue(substr($t,0,2), $bpc));
+				$trns=array($this->_trnsvalue(substr(($t ?? ''),0,2), $bpc));
 			}
 			else if ($colspace=='DeviceRGB') { 	// ct==2
-				$trns[0]=$this->_trnsvalue(substr($t,0,2), $bpc);
-				$trns[1]=$this->_trnsvalue(substr($t,2,2), $bpc);
-				$trns[2]=$this->_trnsvalue(substr($t,4,2), $bpc);
+				$trns[0]=$this->_trnsvalue(substr(($t ?? ''),0,2), $bpc);
+				$trns[1]=$this->_trnsvalue(substr(($t ?? ''),2,2), $bpc);
+				$trns[2]=$this->_trnsvalue(substr(($t ?? ''),4,2), $bpc);
 				$trnsrgb = $trns;
 				if ($targetcs=='DeviceCMYK') {
 					$col = $this->rgb2cmyk(array(3,$trns[0],$trns[1],$trns[2]));
@@ -11235,9 +11252,9 @@
 				}
 			}
 			else {	// Indexed
-				$pos = strpos($t,chr(0));
+				$pos = strpos(($t ?? ''),(chr(0) ?? ''));
 				if (is_int($pos)) {
-					$pal = imagecolorsforindex($im, $pos);
+					$pal = imagecolorsforindex($im, (int) ($pos));
 					$r = $pal['red'];
 					$g = $pal['green'];
 					$b = $pal['blue'];
@@ -11261,12 +11278,12 @@
 		}
 		for ($i = 0; $i < $h; $i++) {
 			for ($j = 0; $j < $w; $j++) {
-				$rgb = imagecolorat($im, $j, $i);
+				$rgb = imagecolorat($im, (int) ($j), (int) ($i));
 				$r = ($rgb >> 16) & 0xFF;
 				$g = ($rgb >> 8) & 0xFF;
 				$b = $rgb & 0xFF;
 				if ($colspace=='Indexed') {
-					$pal = imagecolorsforindex($im, $rgb);
+					$pal = imagecolorsforindex($im, (int) ($rgb));
 					$r = $pal['red'];
 					$g = $pal['green'];
 					$b = $pal['blue'];
@@ -11284,7 +11301,7 @@
 							if ($c4==0) { $c4=1; } else { $c4--; }
 						}
 					}
-					$imgdata .= chr($c1).chr($c2).chr($c3).chr($c4);
+					$imgdata .= chr((int) ($c1)).chr((int) ($c2)).chr((int) ($c3)).chr((int) ($c4));
 				}
 				else if ($targetcs=='DeviceGray') {
 					$c = intval(($r * .21) + ($g * .71) + ($b * .07));
@@ -11294,10 +11311,10 @@
 							if ($c==0) { $c=1; } else { $c--; }
 						}
 					}
-					$imgdata .= chr($c);
+					$imgdata .= chr((int) ($c));
 				}
 				else if ($targetcs=='DeviceRGB') {
-					$imgdata .= chr($r).chr($g).chr($b);
+					$imgdata .= chr((int) ($r)).chr((int) ($g)).chr((int) ($b));
 				}
 			}
 		}
@@ -11315,8 +11332,8 @@
 			$minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png',
 			'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
 			if ($dpi) { $minfo['set-dpi'] = $dpi; }
-			$tempfile = '_tempImgPNG'.md5($data).RAND(1,10000).'.png';
-			$imgmask = count($this->images)+1;
+			$tempfile = '_tempImgPNG'.md5(($data ?? '')).RAND(1,10000).'.png';
+			$imgmask = count(($this->images ?? []))+1;
 			$minfo['i']=$imgmask ;
 			$this->images[$tempfile] = $minfo;
 			$info['masked'] = $imgmask;
@@ -11343,33 +11360,33 @@
 
 function _fourbytes2int($s) {
 	//Read a 4-byte integer from string
-	return (ord($s[0])<<24) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]);
+	return (ord(($s[0] ?? ''))<<24) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? ''));
 }
 
 function _twobytes2int($s) {	// equivalent to _get_ushort
 	//Read a 2-byte integer from string
-	return (ord(substr($s, 0, 1))<<8) + ord(substr($s, 1, 1));
+	return (ord((substr(($s ?? ''), 0, 1) ?? ''))<<8) + ord((substr(($s ?? ''), 1, 1) ?? ''));
 }
 
 function _jpgHeaderFromString(&$data) {
 	$p = 4;
-	$p += $this->_twobytes2int(substr($data, $p, 2));	// Length of initial marker block
-	$marker = substr($data, $p, 2);
-	while($marker != chr(255).chr(192) && $marker != chr(255).chr(194) && $p<strlen($data)) {
+	$p += $this->_twobytes2int(substr(($data ?? ''), $p, 2));	// Length of initial marker block
+	$marker = substr(($data ?? ''), $p, 2);
+	while($marker != chr(255).chr(192) && $marker != chr(255).chr(194) && $p<strlen(($data ?? ''))) {
 		// Start of frame marker (FFC0) or (FFC2) mPDF 4.4.004
-		$p += ($this->_twobytes2int(substr($data, $p+2, 2))) + 2;	// Length of marker block
-		$marker = substr($data, $p, 2);
+		$p += ($this->_twobytes2int(substr(($data ?? ''), $p+2, 2))) + 2;	// Length of marker block
+		$marker = substr(($data ?? ''), $p, 2);
 	}
 	if ($marker != chr(255).chr(192) && $marker != chr(255).chr(194)) { return false; }
-	return substr($data, $p+2, 10);
+	return substr(($data ?? ''), $p+2, 10);
 }
 
 function _jpgDataFromHeader($hdr) {
-	$bpc = ord(substr($hdr, 2, 1));
+	$bpc = ord((substr(($hdr ?? ''), 2, 1) ?? ''));
 	if (!$bpc) { $bpc = 8; }
-	$h = $this->_twobytes2int(substr($hdr, 3, 2));
-	$w = $this->_twobytes2int(substr($hdr, 5, 2));
-	$channels = ord(substr($hdr, 7, 1));
+	$h = $this->_twobytes2int(substr(($hdr ?? ''), 3, 2));
+	$w = $this->_twobytes2int(substr(($hdr ?? ''), 5, 2));
+	$channels = ord((substr(($hdr ?? ''), 7, 1) ?? ''));
 	if ($channels==3) { $colspace='DeviceRGB'; }
 	elseif($channels==4) { $colspace='DeviceCMYK'; }
 	else { $colspace='DeviceGray'; }
@@ -11429,25 +11446,25 @@
 
 function _imageTypeFromString(&$data) {
 	$type = '';
-	if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif' || substr($data, 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8	// mpDF 5.7.2
+	if (substr(($data ?? ''), 6, 4)== 'JFIF' || substr(($data ?? ''), 6, 4)== 'Exif' || substr(($data ?? ''), 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8	// mpDF 5.7.2
 		$type = 'jpeg'; 
 	}
-	else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") { 
+	else if (substr(($data ?? ''), 0, 6)== "GIF87a" || substr(($data ?? ''), 0, 6)== "GIF89a") { 
 		$type = 'gif';
 	}
-	else if (substr($data, 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
+	else if (substr(($data ?? ''), 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
 		$type = 'png';
 	}
 /*-- IMAGES-WMF --*/
-	else if (substr($data, 0, 4)== chr(215).chr(205).chr(198).chr(154)) { 
+	else if (substr(($data ?? ''), 0, 4)== chr(215).chr(205).chr(198).chr(154)) { 
 		$type = 'wmf';
 	}
 /*-- END IMAGES-WMF --*/
-	else if (preg_match('/<svg.*<\/svg>/is',$data)) { 
+	else if (preg_match('/<svg.*<\/svg>/is',($data ?? ''))) { 
 		$type = 'svg';
 	}
 	// BMP images
-	else if (substr($data, 0, 2)== "BM") { 
+	else if (substr(($data ?? ''), 0, 2)== "BM") { 
 		$type = 'bmp';
 	}
 	return $type;
@@ -11457,7 +11474,7 @@
 // Moved outside WMF as also needed for SVG
 function _putformobjects() {
 	reset($this->formobjects);
-	while(list($file,$info)=each($this->formobjects)) {
+	foreach ($this->formobjects as $file => $info) {
 		$this->_newobj();
 		$this->formobjects[$file]['n']=$this->n;
 		$this->_out('<</Type /XObject');
@@ -11467,7 +11484,7 @@
 		if ($this->compress)
 			$this->_out('/Filter /FlateDecode');
 		$data=($this->compress) ? gzcompress($info['data']) : $info['data'];
-		$this->_out('/Length '.strlen($data).'>>');
+		$this->_out('/Length '.strlen(($data ?? '')).'>>');
 		$this->_putstream($data);
 		unset($this->formobjects[$file]['data']);
 		$this->_out('endobj');
@@ -11483,10 +11500,10 @@
 function _freadint($f)
 {
 	//Read a 4-byte integer from file
-	$i=ord(fread($f,1))<<24;
-	$i+=ord(fread($f,1))<<16;
-	$i+=ord(fread($f,1))<<8;
-	$i+=ord(fread($f,1));
+	$i=ord((fread($f,1) ?? ''))<<24;
+	$i+=ord((fread($f,1) ?? ''))<<16;
+	$i+=ord((fread($f,1) ?? ''))<<8;
+	$i+=ord((fread($f,1) ?? ''));
 	return $i;
 }
 
@@ -11513,7 +11530,7 @@
 function _escape($s)
 {
 	// the chr(13) substitution fixes the Bugs item #1421290.
-	return strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
+	return strtr(($s ?? ''), array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
 }
 
 function _putstream($s) {
@@ -11539,13 +11556,13 @@
 		// Images sent from Image() or
 		// later sent as _out($textto) in printbuffer
 		// Line()
-		if (preg_match('/q \d+\.\d\d+ 0 0 (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ cm \/(I|FO)\d+ Do Q/',$s,$m)) {	// Image data 
+		if (preg_match('/q \d+\.\d\d+ 0 0 (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ cm \/(I|FO)\d+ Do Q/',($s ?? ''),$m)) {	// Image data 
 			$h = ($m[1]/_MPDFK);
 			// Update/overwrite the lowest bottom of printing y value for a column
 			$this->ColDetails[$this->CurrCol]['bottom_margin'] = $this->y+$h;
 		}
 /*-- TABLES --*/
-		else if (preg_match('/\d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ ([\-]{0,1}\d+\.\d\d+) re/',$s,$m) && $this->tableLevel>0) { // Rect in table
+		else if (preg_match('/\d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ ([\-]{0,1}\d+\.\d\d+) re/',($s ?? ''),$m) && $this->tableLevel>0) { // Rect in table
 			$h = ($m[1]/_MPDFK);
 			// Update/overwrite the lowest bottom of printing y value for a column
 			$this->ColDetails[$this->CurrCol]['bottom_margin'] = max($this->ColDetails[$this->CurrCol]['bottom_margin'],($this->y+$h));
@@ -11602,10 +11619,10 @@
 	if ($this->text_input_as_HTML) {
 		$texte= $this->all_entities_to_utf8($texte);
 	}
-	if ($this->usingCoreFont) { $texte = mb_convert_encoding($texte,$this->mb_enc,'UTF-8'); }
+	if ($this->usingCoreFont) { $texte = mb_convert_encoding(($texte ?? ''),($this->mb_enc ?? ''),'UTF-8'); }
 
 	// DIRECTIONALITY
-	if (preg_match("/([".$this->pregRTLchars."])/u", $texte)) { $this->biDirectional = true; }	// *OTL*
+	if (preg_match("/([".$this->pregRTLchars."])/u", ($texte ?? ''))) { $this->biDirectional = true; }	// *OTL*
 
 	$textvar = 0;
 	$save_OTLtags = $this->OTLtags;
@@ -11691,7 +11708,7 @@
 
 
 
-function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsize=0, $fontstyle='', $kerning=120, $fontwidth=100, $divider) {
+function CircularText($x, $y, $r, $text, $align, $fontfamily, $fontsize, $fontstyle, $kerning, $fontwidth, $divider) {
 	if (!class_exists('directw', false)) { include(_MPDF_PATH.'classes/directw.php'); }
 	if (empty($this->directw)) { $this->directw = new directw($this); }
 	$this->directw->CircularText($x, $y, $r, $text, $align, $fontfamily, $fontsize, $fontstyle, $kerning, $fontwidth, $divider);
@@ -11756,19 +11773,19 @@
 
 function UTF8StringToArray($str, $addSubset=true) {
    $out = array();
-   $len = strlen($str);
+   $len = strlen(($str ?? ''));
    for ($i = 0; $i < $len; $i++) {
 	$uni = -1;
-      $h = ord($str[$i]);
+      $h = ord(($str[$i] ?? ''));
       if ( $h <= 0x7F )
          $uni = $h;
       elseif ( $h >= 0xC2 ) {
          if ( ($h <= 0xDF) && ($i < $len -1) )
-            $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F);
+            $uni = ($h & 0x1F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
          elseif ( ($h <= 0xEF) && ($i < $len -2) )
-            $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | (ord($str[++$i]) & 0x3F);
+            $uni = ($h & 0x0F) << 12 | (ord(($str[++$i] ?? '')) & 0x3F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
          elseif ( ($h <= 0xF4) && ($i < $len -3) )
-            $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | (ord($str[++$i]) & 0x3F);
+            $uni = ($h & 0x0F) << 18 | (ord(($str[++$i] ?? '')) & 0x3F) << 12 | (ord(($str[++$i] ?? '')) & 0x3F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
       }
 	if ($uni >= 0) {
 		$out[] = $uni;
@@ -11810,24 +11827,24 @@
 				$ret .= '> Tj /F'.$this->CurrentFont['subsetfontids'][$i].' '.$this->FontSizePt.' Tf <';
 				$last_fid = $this->CurrentFont['subsetfontids'][$i];
 			}
-			$ret .= sprintf("%02s", strtoupper(dechex($init)));
+			$ret .= sprintf("%02s", strtoupper((dechex($init) ?? '')));
 			break;
 		}
 		// TrueType embedded SUBSETS
-		else if (count($this->CurrentFont['subsets'][$i]) < 255) {
-			$n = count($this->CurrentFont['subsets'][$i]);
+		else if (count(($this->CurrentFont['subsets'][$i] ?? [])) < 255) {
+			$n = count(($this->CurrentFont['subsets'][$i] ?? []));
 			$this->CurrentFont['subsets'][$i][$n] = $c;
 			if ($this->CurrentFont['subsetfontids'][$i] != $last_fid) {
 				$ret .= '> Tj /F'.$this->CurrentFont['subsetfontids'][$i].' '.$this->FontSizePt.' Tf <';
 				$last_fid = $this->CurrentFont['subsetfontids'][$i];
 			}
-			$ret .= sprintf("%02s", strtoupper(dechex($n)));
+			$ret .= sprintf("%02s", strtoupper((dechex($n) ?? '')));
 			break;
 		}
 		else if (!isset($this->CurrentFont['subsets'][($i+1)])) {
 			// TrueType embedded SUBSETS
 			$this->CurrentFont['subsets'][($i+1)] = array(0=>0);
-			$new_fid = count($this->fonts)+$this->extraFontSubsets+1;
+			$new_fid = count(($this->fonts ?? []))+$this->extraFontSubsets+1;
 			$this->CurrentFont['subsetfontids'][($i+1)] = $new_fid;
 			$this->extraFontSubsets++;
 		}
@@ -11843,20 +11860,20 @@
 
 // Converts UTF-8 strings to UTF16-BE.
 function UTF8ToUTF16BE($str, $setbom=true) {
-	if ($this->checkSIP && preg_match("/([\x{20000}-\x{2FFFF}])/u", $str)) { 
+	if ($this->checkSIP && preg_match("/([\x{20000}-\x{2FFFF}])/u", ($str ?? ''))) { 
 	   if (!in_array($this->currentfontfamily, array('gb','big5','sjis','uhc','gbB','big5B','sjisB','uhcB','gbI','big5I','sjisI','uhcI',
 		'gbBI','big5BI','sjisBI','uhcBI'))) {
-		$str = preg_replace("/[\x{20000}-\x{2FFFF}]/u", chr(0), $str);
+		$str = preg_replace("/[\x{20000}-\x{2FFFF}]/u", (chr(0) ?? ''), ($str ?? ''));
 	   }
 	}
-	if ($this->checkSMP && preg_match("/([\x{10000}-\x{1FFFF}])/u", $str )) { 
-		$str = preg_replace("/[\x{10000}-\x{1FFFF}]/u", chr(0), $str );
+	if ($this->checkSMP && preg_match("/([\x{10000}-\x{1FFFF}])/u", ($str ?? '') )) { 
+		$str = preg_replace("/[\x{10000}-\x{1FFFF}]/u", (chr(0) ?? ''), ($str ?? '') );
 	}
 	$outstr = ""; // string to be returned
 	if ($setbom) {
 		$outstr .= "\xFE\xFF"; // Byte Order Mark (BOM)
 	}
-	$outstr .= mb_convert_encoding($str, 'UTF-16BE', 'UTF-8');
+	$outstr .= mb_convert_encoding(($str ?? ''), 'UTF-16BE', 'UTF-8');
 	return $outstr;
 }
 
@@ -11871,11 +11888,11 @@
 // from class PDF_Chinese CJK EXTENSIONS
 function AddCIDFont($family,$style,$name,&$cw,$CMap,$registry,$desc)
 {
-	$fontkey=strtolower($family).strtoupper($style);
+	$fontkey=strtolower(($family ?? '')).strtoupper(($style ?? ''));
 	if(isset($this->fonts[$fontkey]))
 		$this->Error("Font already added: $family $style");
-	$i=count($this->fonts)+$this->extraFontSubsets+1;
-	$name=str_replace(' ','',$name);
+	$i=count(($this->fonts ?? []))+$this->extraFontSubsets+1;
+	$name=str_replace(' ','',($name ?? ''));
 	if ($family == 'sjis') { $up = -120; } else { $up = -130; }
 	// ? 'up' and 'ut' do not seem to be referenced anywhere
 	$this->fonts[$fontkey]=array('i'=>$i,'type'=>'Type0','name'=>$name,'up'=>$up,'ut'=>40,'cw'=>$cw,'CMap'=>$CMap,'registry'=>$registry,'MissingWidth'=>1000,'desc'=>$desc);
@@ -12002,9 +12019,9 @@
 function SetDefaultFont($font) {
 	// Disallow embedded fonts to be used as defaults in PDFA
 	if ($this->PDFA || $this->PDFX) {
-		if (strtolower($font) == 'ctimes') { $font = 'serif'; }
-		if (strtolower($font) == 'ccourier') { $font = 'monospace'; }
-		if (strtolower($font) == 'chelvetica') { $font = 'sans-serif'; }
+		if (strtolower(($font ?? '')) == 'ctimes') { $font = 'serif'; }
+		if (strtolower(($font ?? '')) == 'ccourier') { $font = 'monospace'; }
+		if (strtolower(($font ?? '')) == 'chelvetica') { $font = 'sans-serif'; }
 	}
   	$font = $this->SetFont($font);	// returns substituted font if necessary
 	$this->default_font = $font;
@@ -12024,15 +12041,15 @@
 
 function SetDefaultBodyCSS($prop, $val) {
    if ($prop) {
-	$this->defaultCSS['BODY'][strtoupper($prop)] = $val;
-	$this->cssmgr->CSS['BODY'][strtoupper($prop)] = $val;
+	$this->defaultCSS['BODY'][strtoupper(($prop ?? ''))] = $val;
+	$this->cssmgr->CSS['BODY'][strtoupper(($prop ?? ''))] = $val;
   }
 }
 
 
 function SetDirectionality($dir='ltr') {
 /*-- OTL --*/
-	if (strtolower($dir) == 'rtl') { 
+	if (strtolower(($dir ?? '')) == 'rtl') { 
 	  if ($this->directionality != 'rtl') {
 		// Swop L/R Margins so page 1 RTL is an 'even' page
 		$tmp = $this->DeflMargin;
@@ -12060,8 +12077,8 @@
 // Return either a number (factor) - based on current set fontsize (if % or em) - or exact lineheight (with 'mm' after it)
 function fixLineheight($v) {
 	$lh = false;
-	if (preg_match('/^[0-9\.,]*$/',$v) && $v >= 0) { return ($v + 0); }
-	else if (strtoupper($v) == 'NORMAL' || $v == 'N') { 
+	if (preg_match('/^[0-9\.,]*$/',($v ?? '')) && $v >= 0) { return ($v + 0); }
+	else if (strtoupper(($v ?? '')) == 'NORMAL' || $v == 'N') { 
 		return 'N'; 	// mPDF 6
 	}
 	else { 
@@ -12100,7 +12117,7 @@
 	if ($lh == 'N') { 
 		$lh = $this->_getNormalLineheight();
 	}
-	if (preg_match('/mm/',$lh)) { 
+	if (preg_match('/mm/',($lh ?? ''))) { 
 		return (($lh + 0.0) / $k); // convert to number
 	}
 	else if ($lh > 0) { 
@@ -12137,7 +12154,7 @@
 		$lineheight = ($fontsize * $lh); 
 		$leading += $linegap;	// specified in hhea or sTypo in OpenType tables	****************************************
 	}
-	else if (preg_match('/mm/',$CSSlineheight)) { $lineheight = (($CSSlineheight + 0.0) / $shrin_k); }	// convert to number
+	else if (preg_match('/mm/',($CSSlineheight ?? ''))) { $lineheight = (($CSSlineheight + 0.0) / $shrin_k); }	// convert to number
 	// ??? If lineheight is a factor e.g. 1.3  ?? use factor x 1em or ? use 'normal' lineheight * factor ******************************
 	// Could depend on value for $text_height - a draft CSS value as set above for now
 	else if ($CSSlineheight > 0) { $lineheight = ($fontsize * $CSSlineheight); }	
@@ -12147,7 +12164,7 @@
 	// and add half to the top and half to the bottom. BUT
 	// If an inline element has a font-size less than the block element, and the line-height is set as an em or % value
 	// it will add too much leading below the font and expand the height of the line - so just use the block element exttop/extbottom:
-	if (preg_match('/mm/',$CSSlineheight) && $ypos['boxtop'] < $blockYpos['boxtop'] && $ypos['boxbottom'] > $blockYpos['boxbottom']) { 
+	if (preg_match('/mm/',($CSSlineheight ?? '')) && $ypos['boxtop'] < $blockYpos['boxtop'] && $ypos['boxbottom'] > $blockYpos['boxbottom']) { 
 		$ypos['exttop'] = $blockYpos['exttop'];
 		$ypos['extbottom'] = $blockYpos['extbottom'];
 	}
@@ -12452,7 +12469,7 @@
   if (!$str) { 
 	if ($_SERVER['SCRIPT_NAME']) { $currentPath = dirname($_SERVER['SCRIPT_NAME']); }
 	else { $currentPath = dirname($_SERVER['PHP_SELF']); }
-	$currentPath = str_replace("\\","/",$currentPath);
+	$currentPath = str_replace("\\","/",($currentPath ?? ''));
 	if ($currentPath == '/') { $currentPath = ''; }
 	if ($host) { 	// mPDF 6
 		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { $currpath = 'https://' . $host . $currentPath .'/'; } 
@@ -12463,11 +12480,11 @@
 	$this->basepathIsLocal = true; 
 	return; 
   }
-  $str = preg_replace('/\?.*/','',$str);
-  if (!preg_match('/(http|https|ftp):\/\/.*\//i',$str)) { $str .= '/'; } 
+  $str = preg_replace('/\?.*/','',($str ?? ''));
+  if (!preg_match('/(http|https|ftp):\/\/.*\//i',($str ?? ''))) { $str .= '/'; } 
   $str .= 'xxx';	// in case $str ends in / e.g. http://www.bbc.co.uk/
   $this->basepath = dirname($str) . "/";	// returns e.g. e.g. http://www.google.com/dir1/dir2/dir3/
-  $this->basepath = str_replace("\\","/",$this->basepath); //If on Windows
+  $this->basepath = str_replace("\\","/",($this->basepath ?? '')); //If on Windows
   $tr = parse_url($this->basepath);
   if (isset($tr['host']) && ($tr['host'] == $host)) { $this->basepathIsLocal = true; }
   else { $this->basepathIsLocal = false; }
@@ -12478,33 +12495,33 @@
 	// When parsing CSS need to pass temporary basepath - so links are relative to current stylesheet
 	if (!$basepath) { $basepath = $this->basepath; }
 	//Fix path value
-	$path = str_replace("\\","/",$path); //If on Windows
+	$path = str_replace("\\","/",($path ?? '')); //If on Windows
 
 	// mPDF 5.7.2
-	if (substr($path,0,2) == "//") { 
+	if (substr(($path ?? ''),0,2) == "//") { 
 		$tr = parse_url($basepath);
 		$path = $tr['scheme'].':'.$path;	// mPDF 6
 	}
 
 	$regexp = '|^./|';	// Inadvertently corrects "./path/etc" and "//www.domain.com/etc"
-	$path = preg_replace($regexp,'',$path);
-
-	if(substr($path,0,1) == '#') { return; }
+	$path = preg_replace(($regexp ?? ''),'',($path ?? ''));
+
+	if(substr(($path ?? ''),0,1) == '#') { return; }
 	// mPDF 5.7.4
-	if (substr($path,0,7) == "mailto:") { return; }
-	if (substr($path,0,3) == "../") { //It is a Relative Link
+	if (substr(($path ?? ''),0,7) == "mailto:") { return; }
+	if (substr(($path ?? ''),0,3) == "../") { //It is a Relative Link
 		$backtrackamount = substr_count($path,"../");
 		$maxbacktrack = substr_count($basepath,"/") - 3;
-		$filepath = str_replace("../",'',$path);
+		$filepath = str_replace("../",'',($path ?? ''));
 		$path = $basepath;
 		//If it is an invalid relative link, then make it go to directory root
 		if ($backtrackamount > $maxbacktrack) $backtrackamount = $maxbacktrack;
 		//Backtrack some directories
-		for( $i = 0 ; $i < $backtrackamount + 1 ; $i++ ) $path = substr( $path, 0 , strrpos($path,"/") );
+		for( $i = 0 ; $i < $backtrackamount + 1 ; $i++ ) $path = substr( ($path ?? ''), 0 , strrpos(($path ?? ''),"/") );
 		$path = $path . "/" . $filepath; //Make it an absolute path
 	}
-	else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link
-		if (substr($path,0,1) == "/") { 
+	else if( strpos(($path ?? ''),":/") === false || strpos(($path ?? ''),":/") > 10) { //It is a Local Link
+		if (substr(($path ?? ''),0,1) == "/") { 
 			$tr = parse_url($basepath);
 			// mPDF 5.7.2
 			$root = '';
@@ -12524,15 +12541,15 @@
 	// If local file try using local path (? quicker, but also allowed even if allow_url_fopen false)
 	$contents = '';
 	// mPDF 5.7.3
-	if (strpos($path,"//") === false ) { $path = preg_replace('/\.css\?.*$/', '.css', $path); }
-	$contents = @file_get_contents($path);
+	if (strpos(($path ?? ''),"//") === false ) { $path = preg_replace('/\.css\?.*$/', '.css', ($path ?? '')); }
+	$contents = @file_get_contents(($path ?? ''));
 	if ($contents) { return $contents; }
 	if ($this->basepathIsLocal) {
 		$tr = parse_url($path);
 		$lp=getenv("SCRIPT_NAME");
 		$ap=realpath($lp);
-		$ap=str_replace("\\","/",$ap);
-		$docroot=substr($ap,0,strpos($ap,$lp));
+		$ap=str_replace("\\","/",($ap ?? ''));
+		$docroot=substr(($ap ?? ''),0,strpos(($ap ?? ''),($lp ?? '')));
 		// WriteHTML parses all paths to full URLs; may be local file name 
 		if ($tr['scheme'] && $tr['host'] && $_SERVER["DOCUMENT_ROOT"] ) { 
 			$localpath = $_SERVER["DOCUMENT_ROOT"] . $tr['path']; 
@@ -12542,7 +12559,7 @@
 			$localpath = $docroot . $tr['path'];
 		}
 		else { $localpath = $path; }
-		$contents = @file_get_contents($localpath);
+		$contents = @file_get_contents(($localpath ?? ''));
 	}
 	// if not use full URL
 	else if (!$contents && !ini_get('allow_url_fopen') && function_exists("curl_init"))  {
@@ -12571,8 +12588,8 @@
 				$lastreset = $psarr['from'];
 			}
 			if ($psarr['type']) { $type = $psarr['type']; }
-			if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
-			else if (strtoupper($psarr['suppress'])=='OFF') { $suppress = 0; }
+			if (strtoupper(($psarr['suppress'] ?? ''))=='ON' || $psarr['suppress']==1) { $suppress = 1; }
+			else if (strtoupper(($psarr['suppress'] ?? ''))=='OFF') { $suppress = 0; }
 		}
 	}
 	if ($suppress) { return ''; }
@@ -12586,7 +12603,7 @@
 	if ($num < 1) { $num = $this->page; }
 	$type = $this->defaultPageNumStyle;	// set default Page Number Style
 	$ppgstart = 1;
-	$ppgend = count($this->pages)+1; 
+	$ppgend = count(($this->pages ?? []))+1; 
 	$suppress = 0;
 	$offset = 0;
 	foreach($this->PageNumSubstitutions AS $psarr) {
@@ -12594,11 +12611,11 @@
 			if ($psarr['reset']) { 
 				if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
 				$ppgstart = $psarr['from'] + $offset; 
-				$ppgend = count($this->pages)+1 + $offset; 
+				$ppgend = count(($this->pages ?? []))+1 + $offset; 
 			}
 			if ($psarr['type']) { $type = $psarr['type']; }
-			if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
-			else if (strtoupper($psarr['suppress'])=='OFF') { $suppress = 0; }
+			if (strtoupper(($psarr['suppress'] ?? ''))=='ON' || $psarr['suppress']==1) { $suppress = 1; }
+			else if (strtoupper(($psarr['suppress'] ?? ''))=='OFF') { $suppress = 0; }
 		}
 		if ($num < $psarr['from']) {
 			if ($psarr['reset']) { 
@@ -12625,13 +12642,13 @@
 		$reverse = false; 	// For pagenumbers, RTL numerals (Hebrew) will get reversed later by bidi
 		$checkfont = false;	// For pagenumbers - font is not set, so no check
 	}
-	$lowertype = strtolower($type);
+	$lowertype = strtolower(($type ?? ''));
 	if ($lowertype == 'upper-latin' || $lowertype == 'upper-alpha' || $type=='A') { $ppgno = $this->dec2alpha($ppgno,true); }
 	else if ($lowertype == 'lower-latin' || $lowertype == 'lower-alpha' || $type=='a') { $ppgno = $this->dec2alpha($ppgno,false);}
 	else if ($lowertype == 'upper-roman' || $type=='I') { $ppgno = $this->dec2roman($ppgno,true); }
 	else if ($lowertype == 'lower-roman' || $type=='i') { $ppgno = $this->dec2roman($ppgno,false); }
 	else if ($lowertype=='hebrew') { $ppgno = $this->dec2hebrew($ppgno, $reverse); }
-	else if (preg_match('/(arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$lowertype,$m)) { 
+	else if (preg_match('/(arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',($lowertype ?? ''),$m)) { 
 	  switch($m[1]) { //Format type
           case 'arabic-indic': $cp = 0x0660; break;
           case 'persian':	
@@ -12672,8 +12689,8 @@
 				$ppgno = $num - $psarr['from'] + 1 + $offset; 
 			}
 			if ($psarr['type']) { $type = $psarr['type']; }
-			if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
-			else if (strtoupper($psarr['suppress'])=='OFF') { $suppress = 0; }
+			if (strtoupper(($psarr['suppress'] ?? ''))=='ON' || $psarr['suppress']==1) { $suppress = 1; }
+			else if (strtoupper(($psarr['suppress'] ?? ''))=='OFF') { $suppress = 0; }
 		}
 		if ($num == $psarr['from']) { $reset = $psarr['reset']; }
 	}
@@ -12704,14 +12721,14 @@
 
 
 /*-- TABLES --*/
-function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',$horf = 'H',$level, $firstSpread=true, $finalSpread=true) {
+function TableHeaderFooter($content,$tablestartpage,$tablestartcolumn,$horf,$level, $firstSpread=true, $finalSpread=true) {
   if(($horf=='H' || $horf=='F') && !empty($content)) {	// mPDF 5.7.2
 	$table = &$this->table[1][1];
 
 	// mPDF 5.7.2
 	if ($horf=='F') { // Table Footer
-		$firstrow = count($table['cells']) - $table['footernrows'];
-		$lastrow = count($table['cells']) - 1;
+		$firstrow = count(($table['cells'] ?? [])) - $table['footernrows'];
+		$lastrow = count(($table['cells'] ?? [])) - 1;
 	}
    	else { 	// Table Header
 		$firstrow = 0;
@@ -12792,11 +12809,11 @@
 	// mPDF ITERATION
 	if ($this->iterationCounter) {
 	   foreach($tablehf['textbuffer'] AS $k=>$t) {
-		if (!is_array($t[0]) && preg_match('/{iteration ([a-zA-Z0-9_]+)}/',$t[0], $m)) {
+		if (!is_array($t[0]) && preg_match('/{iteration ([a-zA-Z0-9_]+)}/',($t[0] ?? ''), $m)) {
 			$vname = '__'.$m[1].'_';
 			if (!isset($this->$vname)) { $this->$vname = 1; }
 			else { $this->$vname++; }
-			$tablehf['textbuffer'][$k][0] = preg_replace('/{iteration '.$m[1].'}/', $this->$vname, $tablehf['textbuffer'][$k][0]);
+			$tablehf['textbuffer'][$k][0] = preg_replace('/{iteration '.$m[1].'}/', ($this->$vname ?? ''), ($tablehf['textbuffer'][$k][0] ?? ''));
 		}
 	   }
 	}
@@ -12845,7 +12862,7 @@
 						$xadj += $table['padding']['L'] + $table['border_details']['L']['w'] ;
 						$wadj += $table['padding']['L'] + $table['border_details']['L']['w'] ;
 			   		}
-			   		if ($colctr == count($content[$i]) ) {	// Right
+			   		if ($colctr == count(($content[$i] ?? [])) ) {	// Right
 						$wadj += $table['padding']['R'] + $table['border_details']['R']['w'] ;
 			   		}
 					$this->SetFColor($color);
@@ -12926,7 +12943,7 @@
 	}
 
 	if (isset($tablehf['background-image']) && $paintcell){
-	  if ($tablehf['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $tablehf['background-image']['gradient'] )) {
+	  if ($tablehf['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($tablehf['background-image']['gradient'] ?? '') )) {
 		$g = $this->grad->parseMozGradient( $tablehf['background-image']['gradient'] );
 		if ($g) {
  		  if ($table['borders_separate']) { 
@@ -12950,7 +12967,7 @@
 		}
 	  }
 	  else if ($tablehf['background-image']['image_id']) {	// Background pattern
-		$n = count($this->patterns)+1;
+		$n = count(($this->patterns ?? []))+1;
  		if ($table['borders_separate']) { 
  			$px = $x+ ($table['border_spacing_H']/2);
 			$py = $y+ ($table['border_spacing_V']/2);
@@ -12987,9 +13004,9 @@
 
  	//Print cell content
       if (!empty($textbuffer)) {
-		if ($horf=='F' && preg_match('/{colsum([0-9]*)[_]*}/', $textbuffer[0][0], $m)) {
+		if ($horf=='F' && preg_match('/{colsum([0-9]*)[_]*}/', ($textbuffer[0][0] ?? ''), $m)) {
 			$rep = sprintf("%01.".intval($m[1])."f", $this->colsums[$colctr-1]);
-			$textbuffer[0][0] = preg_replace('/{colsum[0-9_]*}/', $rep ,$textbuffer[0][0]);
+			$textbuffer[0][0] = preg_replace('/{colsum[0-9_]*}/', ($rep ?? '') ,($textbuffer[0][0] ?? ''));
 		}
 
 		if ($R) {
@@ -13016,7 +13033,7 @@
 					}
 					$str = '';
 					foreach($tablehf['textbuffer'] AS $t) { $str .= $t[0].' '; }
-					$str = rtrim($str);
+					$str = rtrim(($str ?? ''));
 
 					if (!isset($va) || $va=='M') { 
 						$this->y -= ($h-$mih)/2; //Undo what was added earlier VERTICAL ALIGN
@@ -13098,7 +13115,7 @@
 			    }
 
 			   if (isset($content[$i][0]['trbackground-images']) && ($colctr==1 || $table['borders_separate'])) { 
-			    if ($content[$i][0]['trbackground-images']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $content[$i][0]['trbackground-images']['gradient'] )) {
+			    if ($content[$i][0]['trbackground-images']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($content[$i][0]['trbackground-images']['gradient'] ?? '') )) {
 				$g = $this->grad->parseMozGradient( $content[$i][0]['trbackground-images']['gradient'] );
 				if ($g) {
 					$gx = $x0;
@@ -13184,7 +13201,7 @@
 				$this->setBorder($tab_bord , _BORDER_LEFT); 
 				$corner .= 'L';
 			}
-			if ($colctr == count($content[$i]) && $finalSpread) {	// Right
+			if ($colctr == count(($content[$i] ?? [])) && $finalSpread) {	// Right
 				$tbw += $halfspaceR + ($table['border_details']['R']['w']/2);
 				$this->setBorder($tab_bord , _BORDER_RIGHT); 
 				$corner .= 'R';
@@ -13310,10 +13327,10 @@
 		$save_y = $this->y;
 		$this->x = $this->lMargin;
 		$this->y = $this->margin_header;
-		$html = str_replace('{PAGENO}',$this->pagenumPrefix.$this->docPageNum($this->page).$this->pagenumSuffix,$html);
-		$html = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->docPageNumTotal($this->page).$this->nbpgSuffix,$html );
-		$html = str_replace($this->aliasNbPg,$this->page,$html );
-		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),$html ); // mPDF 5.7
+		$html = str_replace('{PAGENO}',$this->pagenumPrefix.$this->docPageNum($this->page).$this->pagenumSuffix,($html ?? ''));
+		$html = str_replace(($this->aliasNbPgGp ?? ''),$this->nbpgPrefix.$this->docPageNumTotal($this->page).$this->nbpgSuffix,($html ?? '') );
+		$html = str_replace(($this->aliasNbPg ?? ''),($this->page ?? ''),($html ?? '') );
+		$html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback'),($html ?? '') ); // mPDF 5.7
 		$this->HTMLheaderPageLinks = array();
 		$this->HTMLheaderPageAnnots = array();
 		$this->HTMLheaderPageForms = array();
@@ -13406,9 +13423,9 @@
 
 // mPDF 6
 function _shareHeaderFooterWidth($cl,$cc,$cr) {	// mPDF 6
-	$l = mb_strlen($cl, 'UTF-8');
-	$c = mb_strlen($cc, 'UTF-8');
-	$r = mb_strlen($cr, 'UTF-8');	
+	$l = mb_strlen(($cl ?? ''), 'UTF-8');
+	$c = mb_strlen(($cc ?? ''), 'UTF-8');
+	$r = mb_strlen(($cr ?? ''), 'UTF-8');	
 	$s = max($l,$r);
 	$tw = $c + 2*$s;
 	if ($tw > 0) { return array(intval($s*100/$tw), intval($c*100/$tw), intval($s*100/$tw)); }
@@ -13524,12 +13541,12 @@
   $oddhtml = '';
   $evenhtml = '';
   if (is_string($Harray)) {
-    if (strlen($Harray)==0) {
+    if (strlen(($Harray ?? ''))==0) {
 	$oddhtml = '';
 	$evenhtml = '';
    }
-   else if (strpos($Harray,'|') !== false) {
-	$hdet = explode('|',$Harray);
+   else if (strpos(($Harray ?? ''),'|') !== false) {
+	$hdet = explode('|',($Harray ?? ''));
 	list($lw, $cw, $rw) = $this->_shareHeaderFooterWidth($hdet[0], $hdet[1], $hdet[2]);
 	$oddhtml = '<table width="100%" style="border-collapse: collapse; margin: 0; vertical-align: bottom; color: #000000; ';
 	if ($this->defaultheaderfontsize) { $oddhtml .= ' font-size: '.$this->defaultheaderfontsize.'pt;'; }
@@ -13608,12 +13625,12 @@
   $oddhtml = '';
   $evenhtml = '';
   if (is_string($Farray)) {
-    if (strlen($Farray)==0) {
+    if (strlen(($Farray ?? ''))==0) {
 	$oddhtml = '';
 	$evenhtml = '';
    }
-   else if (strpos($Farray,'|') !== false) {
-	$hdet = explode('|',$Farray);
+   else if (strpos(($Farray ?? ''),'|') !== false) {
+	$hdet = explode('|',($Farray ?? ''));
 	$oddhtml = '<table width="100%" style="border-collapse: collapse; margin: 0; vertical-align: top; color: #000000; ';
 	if ($this->defaultfooterfontsize) { $oddhtml .= ' font-size: '.$this->defaultfooterfontsize.'pt;'; }
 	if ($this->defaultfooterfontstyle) {
@@ -13819,7 +13836,7 @@
 function hyphenateWord($word, $currptr) {
 	// Do everything inside this function in utf-8
 	// Don't hyphenate web addresses
-	if (preg_match('/^(http:|www\.)/',$word)) { return -1; }
+	if (preg_match('/^(http:|www\.)/',($word ?? ''))) { return -1; }
 
 	$ptr = -1;
 
@@ -13828,18 +13845,18 @@
 		if (file_exists(_MPDF_PATH.'patterns/dictionary.txt')) {
 			$this->SHYdictionary = file(_MPDF_PATH.'patterns/dictionary.txt',FILE_SKIP_EMPTY_LINES);
 			foreach($this->SHYdictionary as $entry) {
-				$entry = trim($entry);
+				$entry = trim(($entry ?? ''));
 				$poss = array();
 				$offset = 0;
 				$p = true;
-				$wl = mb_strlen($entry ,'UTF-8');
+				$wl = mb_strlen(($entry ?? '') ,'UTF-8');
 				while($offset < $wl) {
-					$p = mb_strpos($entry, '/', $offset, 'UTF-8');
-					if ($p !== false) { $poss[] = $p - count($poss); }
+					$p = mb_strpos(($entry ?? ''), '/', $offset, 'UTF-8');
+					if ($p !== false) { $poss[] = $p - count(($poss ?? [])); }
 					else { break; }
 					$offset = $p+1;
 				}
-				if (count($poss)) { $this->SHYdictionaryWords[str_replace('/', '', mb_strtolower($entry))] = $poss; }
+				if (count(($poss ?? []))) { $this->SHYdictionaryWords[str_replace('/', '', (mb_strtolower($entry) ?? ''))] = $poss; }
 			}
 		}
 		$this->loadedSHYdictionary = true;
@@ -13847,19 +13864,19 @@
 
 	if (!in_array($this->SHYlang,$this->SHYlanguages)) { return -1; }
 	// If no pattern loaded or not the best one
-	if (count($this->SHYpatterns) < 1  || ($this->loadedSHYpatterns && $this->loadedSHYpatterns != $this->SHYlang)) {
+	if (count(($this->SHYpatterns ?? [])) < 1  || ($this->loadedSHYpatterns && $this->loadedSHYpatterns != $this->SHYlang)) {
 		include(_MPDF_PATH."patterns/" . $this->SHYlang . ".php"); 
-		$patterns = explode(' ', $patterns);
+		$patterns = explode(' ', ($patterns ?? ''));
 		$new_patterns = array();
-		for($i = 0; $i < count($patterns); $i++) {
+		for($i = 0; $i < count(($patterns ?? [])); $i++) {
 			$value = $patterns[$i];
-			$new_patterns[preg_replace('/[0-9]/', '', $value)] = $value;
+			$new_patterns[preg_replace('/[0-9]/', '', ($value ?? ''))] = $value;
 		}
 		$this->SHYpatterns = $new_patterns;
 		$this->loadedSHYpatterns = $this->SHYlang;
 	}
 
-	if ($this->usingCoreFont) { $word = mb_convert_encoding($word,'UTF-8',$this->mb_enc); }
+	if ($this->usingCoreFont) { $word = mb_convert_encoding(($word ?? ''),'UTF-8',$this->mb_enc); }
 
 	$prepre = '';
 	$postpost = '';
@@ -13867,20 +13884,20 @@
 	$endpunctuation = "\xe2\x80\x9e\xe2\x80\x9d\xe2\x80\x9a\xe2\x80\x99\xc2\xbb";
 
 
-	if (preg_match('/^(["\''.$startpunctuation .'])+(.{'.$this->SHYcharmin.',})$/u',$word,$m)) {
+	if (preg_match('/^(["\''.$startpunctuation .'])+(.{'.$this->SHYcharmin.',})$/u',($word ?? ''),$m)) {
 		$prepre = $m[1];
 		$word = $m[2];
 	}
-	if (preg_match('/^(.{'.$this->SHYcharmin.',})([\'\.,;:!?"'.$endpunctuation .']+)$/u',$word,$m)) {
+	if (preg_match('/^(.{'.$this->SHYcharmin.',})([\'\.,;:!?"'.$endpunctuation .']+)$/u',($word ?? ''),$m)) {
 		$word = $m[1];
 		$postpost = $m[2];
 	}
-	if(mb_strlen($word,'UTF-8') < $this->SHYcharmin) {
+	if(mb_strlen(($word ?? ''),'UTF-8') < $this->SHYcharmin) {
 			return -1;
 	}
 	$success = false;
 
-	$preprelen = mb_strlen($prepre);
+	$preprelen = mb_strlen(($prepre ?? ''));
 
 	if(isset($this->SHYdictionaryWords[mb_strtolower($word)])) {
 	   foreach($this->SHYdictionaryWords[mb_strtolower($word)] AS $i) {
@@ -13892,17 +13909,17 @@
 
 	if (!$success) {
 	   $text_word = '_' . $word . '_';
-	   $word_length = mb_strlen($text_word,'UTF-8');
+	   $word_length = mb_strlen(($text_word ?? ''),'UTF-8');
 	   $text_word = mb_strtolower($text_word,'UTF-8');
 	   $hyphenated_word = array();
 	   $numb3rs = array('0' => true, '1' => true, '2' => true, '3' => true, '4' => true, '5' => true, '6' => true, '7' => true, '8' => true, '9' => true);
 	   for($position = 0; $position <= ($word_length - $this->SHYcharmin); $position++) {
 		$maxwins = min(($word_length - $position), $this->SHYcharmax);
 		for($win = $this->SHYcharmin; $win <= $maxwins; $win++) {
-			if(isset($this->SHYpatterns[mb_substr($text_word, $position, $win,'UTF-8')])) {
-				$pattern = $this->SHYpatterns[mb_substr($text_word, $position, $win,'UTF-8')];
+			if(isset($this->SHYpatterns[mb_substr(($text_word ?? ''), $position, $win,'UTF-8')])) {
+				$pattern = $this->SHYpatterns[mb_substr(($text_word ?? ''), $position, $win,'UTF-8')];
 				$digits = 1;
-				$pattern_length = mb_strlen($pattern,'UTF-8');
+				$pattern_length = mb_strlen(($pattern ?? ''),'UTF-8');
 				for($i = 0; $i < $pattern_length; $i++) {
 					$char = $pattern[$i];
 					if(isset($numb3rs[$char])) {
@@ -13914,7 +13931,7 @@
 			}
 		}
 	   }
-	   for($i = $this->SHYleftmin; $i <= (mb_strlen($word,'UTF-8') - $this->SHYrightmin); $i++) {
+	   for($i = $this->SHYleftmin; $i <= (mb_strlen(($word ?? ''),'UTF-8') - $this->SHYrightmin); $i++) {
 		if(isset($hyphenated_word[$i]) && $hyphenated_word[$i] % 2 != 0) {
 			if (($i+$preprelen) > $currptr) { break ; }
 			$ptr = $i+$preprelen;
@@ -13952,7 +13969,7 @@
 			$this->ReadCharset($html); 
 		}
 		if ($this->charset_in && $sub!=4) {
-			$success = iconv($this->charset_in,'UTF-8//TRANSLIT',$html); 
+			$success = iconv(($this->charset_in ?? ''),'UTF-8//TRANSLIT',($html ?? '')); 
 			if ($success) { $html = $success; }
 		}
 	}
@@ -13971,31 +13988,31 @@
 	if ($sub < 2) { 
 		$this->ReadMetaTags($html); 
 
-		if (preg_match('/<base[^>]*href=["\']([^"\'>]*)["\']/i', $html, $m)) {
+		if (preg_match('/<base[^>]*href=["\']([^"\'>]*)["\']/i', ($html ?? ''), $m)) {
 			$this->SetBasePath($m[1]);
 		}
 		$html = $this->cssmgr->ReadCSS($html);
 
-		if ($this->autoLangToFont && !$this->usingCoreFont && preg_match('/<html [^>]*lang=[\'\"](.*?)[\'\"]/ism',$html,$m)) { 
+		if ($this->autoLangToFont && !$this->usingCoreFont && preg_match('/<html [^>]*lang=[\'\"](.*?)[\'\"]/ism',($html ?? ''),$m)) { 
 			$html_lang = $m[1]; 
 		}
 
-		if (preg_match('/<html [^>]*dir=[\'\"]\s*rtl\s*[\'\"]/ism',$html)) { 
+		if (preg_match('/<html [^>]*dir=[\'\"]\s*rtl\s*[\'\"]/ism',($html ?? ''))) { 
 			$zproperties['DIRECTION'] = 'rtl'; 
 		}
 
 		// allow in-line CSS for body tag to be parsed // Get <body> tag inline CSS
-		if (preg_match('/<body([^>]*)>(.*?)<\/body>/ism',$html,$m) || preg_match('/<body([^>]*)>(.*)$/ism',$html,$m)) { 
+		if (preg_match('/<body([^>]*)>(.*?)<\/body>/ism',($html ?? ''),$m) || preg_match('/<body([^>]*)>(.*)$/ism',($html ?? ''),$m)) { 
 			$html = $m[2]; 
 			// Changed to allow style="background: url('bg.jpg')"
-			if (preg_match('/style=[\"](.*?)[\"]/ism',$m[1],$mm) || preg_match('/style=[\'](.*?)[\']/ism',$m[1],$mm)) { 
+			if (preg_match('/style=[\"](.*?)[\"]/ism',($m[1] ?? ''),$mm) || preg_match('/style=[\'](.*?)[\']/ism',($m[1] ?? ''),$mm)) { 
 				$zproperties = $this->cssmgr->readInlineCSS($mm[1]); 
 			}
-			if (preg_match('/dir=[\'\"]\s*rtl\s*[\'\"]/ism',$m[1])) { 
+			if (preg_match('/dir=[\'\"]\s*rtl\s*[\'\"]/ism',($m[1] ?? ''))) { 
 				$zproperties['DIRECTION'] = 'rtl'; 
 			}
 			if (isset($html_lang) && $html_lang) { $zproperties['LANG'] = $html_lang; }
-			if ($this->autoLangToFont && !$this->onlyCoreFonts && preg_match('/lang=[\'\"](.*?)[\'\"]/ism',$m[1],$mm)) {
+			if ($this->autoLangToFont && !$this->onlyCoreFonts && preg_match('/lang=[\'\"](.*?)[\'\"]/ism',($m[1] ?? ''),$mm)) {
 				$zproperties['LANG'] = $mm[1]; 
 			}
 
@@ -14059,7 +14076,7 @@
 		$ai=0;
 		for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag'],$arr,$ai); }
 		// Output any text left in buffer
-		if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
+		if (count(($this->textbuffer ?? []))) { $this->printbuffer($this->textbuffer); }
 		$this->textbuffer=array();
 	} 
 	else if ($sub == 4) { 
@@ -14068,7 +14085,7 @@
 		$ai=0;
 		for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag'],$arr,$ai); }
 		// Output any text left in buffer
-		if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
+		if (count(($this->textbuffer ?? []))) { $this->printbuffer($this->textbuffer); }
 		$this->bufferoutput = true; 
 		$this->textbuffer=array();
 		$this->headerbuffer='';
@@ -14082,60 +14099,60 @@
 
 	if ($this->autoScriptToLang) { $html = $this->markScriptToLang($html); }
 
-	preg_match_all('/<htmlpageheader([^>]*)>(.*?)<\/htmlpageheader>/si',$html,$h);
-	for($i=0;$i<count($h[1]);$i++) {
-		if (preg_match('/name=[\'|\"](.*?)[\'|\"]/',$h[1][$i],$n)) {
+	preg_match_all('/<htmlpageheader([^>]*)>(.*?)<\/htmlpageheader>/si',($html ?? ''),$h);
+	for($i=0;$i<count(($h[1] ?? []));$i++) {
+		if (preg_match('/name=[\'|\"](.*?)[\'|\"]/',($h[1][$i] ?? ''),$n)) {
 			$this->pageHTMLheaders[$n[1]]['html'] = $h[2][$i]; 
 			$this->pageHTMLheaders[$n[1]]['h'] = $this->_gethtmlheight($h[2][$i]); 
 		}
 	}
-	preg_match_all('/<htmlpagefooter([^>]*)>(.*?)<\/htmlpagefooter>/si',$html,$f);
-	for($i=0;$i<count($f[1]);$i++) {
-		if (preg_match('/name=[\'|\"](.*?)[\'|\"]/',$f[1][$i],$n)) {
+	preg_match_all('/<htmlpagefooter([^>]*)>(.*?)<\/htmlpagefooter>/si',($html ?? ''),$f);
+	for($i=0;$i<count(($f[1] ?? []));$i++) {
+		if (preg_match('/name=[\'|\"](.*?)[\'|\"]/',($f[1][$i] ?? ''),$n)) {
 			$this->pageHTMLfooters[$n[1]]['html'] = $f[2][$i]; 
 			$this->pageHTMLfooters[$n[1]]['h'] = $this->_gethtmlheight($f[2][$i]); 
 		}
 	}
 
-	$html = preg_replace('/<htmlpageheader.*?<\/htmlpageheader>/si','',$html);
-	$html = preg_replace('/<htmlpagefooter.*?<\/htmlpagefooter>/si','',$html);
+	$html = preg_replace('/<htmlpageheader.*?<\/htmlpageheader>/si','',($html ?? ''));
+	$html = preg_replace('/<htmlpagefooter.*?<\/htmlpagefooter>/si','',($html ?? ''));
 
 	if($this->state==0 && $sub!=1 && $sub!=3 && $sub!=4) {
 		$this->AddPage($this->CurOrientation);
 	}
 
 
-	if (isset($hname) && preg_match('/^html_(.*)$/i',$hname,$n)) $this->SetHTMLHeader($this->pageHTMLheaders[$n[1]],'O',true);
-	if (isset($fname) && preg_match('/^html_(.*)$/i',$fname,$n)) $this->SetHTMLFooter($this->pageHTMLfooters[$n[1]],'O');
-
-
-
-	$html=str_replace('<?','< ',$html); //Fix '<?XML' bug from HTML code generated by MS Word
+	if (isset($hname) && preg_match('/^html_(.*)$/i',($hname ?? ''),$n)) $this->SetHTMLHeader($this->pageHTMLheaders[$n[1]],'O',true);
+	if (isset($fname) && preg_match('/^html_(.*)$/i',($fname ?? ''),$n)) $this->SetHTMLFooter($this->pageHTMLfooters[$n[1]],'O');
+
+
+
+	$html=str_replace('<?','< ',($html ?? '')); //Fix '<?XML' bug from HTML code generated by MS Word
 
 	$this->checkSIP = false;
 	$this->checkSMP = false; 
 	$this->checkCJK = false; 
 	if ($this->onlyCoreFonts) { $html = $this->SubstituteChars($html); }
 	else {
-		if (preg_match("/([".$this->pregRTLchars."])/u", $html)) { $this->biDirectional = true; }	// *OTL*
-		if (preg_match("/([\x{20000}-\x{2FFFF}])/u", $html)) { $this->checkSIP = true; }
-		if (preg_match("/([\x{10000}-\x{1FFFF}])/u", $html)) { $this->checkSMP = true; }
+		if (preg_match("/([".$this->pregRTLchars."])/u", ($html ?? ''))) { $this->biDirectional = true; }	// *OTL*
+		if (preg_match("/([\x{20000}-\x{2FFFF}])/u", ($html ?? ''))) { $this->checkSIP = true; }
+		if (preg_match("/([\x{10000}-\x{1FFFF}])/u", ($html ?? ''))) { $this->checkSMP = true; }
 /*-- CJK-FONTS --*/
-		if (preg_match("/([".$this->pregCJKchars."])/u", $html)) { $this->checkCJK = true; }
+		if (preg_match("/([".$this->pregCJKchars."])/u", ($html ?? ''))) { $this->checkCJK = true; }
 /*-- END CJK-FONTS --*/
 	}
 
 	// Don't allow non-breaking spaces that are converted to substituted chars or will break anyway and mess up table width calc.
-	$html = str_replace('<tta>160</tta>',chr(32),$html); 
-	$html = str_replace('</tta><tta>','|',$html); 
-	$html = str_replace('</tts><tts>','|',$html); 
-	$html = str_replace('</ttz><ttz>','|',$html); 
+	$html = str_replace('<tta>160</tta>',(chr(32) ?? ''),($html ?? '')); 
+	$html = str_replace('</tta><tta>','|',($html ?? '')); 
+	$html = str_replace('</tts><tts>','|',($html ?? '')); 
+	$html = str_replace('</ttz><ttz>','|',($html ?? '')); 
 
 	//Add new supported tags in the DisableTags function
 	$html=strip_tags($html,$this->enabledtags); //remove all unsupported tags, but the ones inside the 'enabledtags' string
 
 	//Explode the string in order to parse the HTML code
-	$a=preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+	$a=preg_split('/<(.*?)>/ms',($html ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 	// ? more accurate regexp that allows e.g. <a name="Silly <name>">
 	// if changing - also change in fn.SubstituteChars()
 	// $a = preg_split ('/<((?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -14146,7 +14163,7 @@
 	$pbc = 0;
 	if ($this->progressBar) { $this->UpdateProgressBar(1,0); }	// *PROGRESS-BAR*
 	$this->subPos = -1;
-	$cnt = count($a);
+	$cnt = count(($a ?? []));
 	for($i=0;$i<$cnt; $i++) {
 		$e = $a[$i];
 		if($i%2==0) {
@@ -14156,13 +14173,13 @@
 			if ($this->inMeter) { continue; }
 
 			if ($this->inFixedPosBlock) { $this->fixedPosBlock .= $e; continue; }	// *CSS-POSITION*
-			if (strlen($e) == 0) { continue; }
+			if (strlen(($e ?? '')) == 0) { continue; }
 
 			if ($this->ignorefollowingspaces && !$this->ispre) {
-				if (strlen(ltrim($e)) == 0) { continue; }
-				if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats' && substr($e,0,1) == ' ') {
+				if (strlen((ltrim(($e ?? '')) ?? '')) == 0) { continue; }
+				if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats' && substr(($e ?? ''),0,1) == ' ') {
 					$this->ignorefollowingspaces = false;
-					$e = ltrim($e); 
+					$e = ltrim(($e ?? '')); 
 				}
 			}
 
@@ -14177,7 +14194,7 @@
 					$cnt += $this->SubstituteCharsNonCore($a, $i, $e); 
 				}
 				// CONVERT ENCODING
-				$e = mb_convert_encoding($e,$this->mb_enc,'UTF-8'); 
+				$e = mb_convert_encoding(($e ?? ''),($this->mb_enc ?? ''),'UTF-8'); 
 				if ($this->textvar & FT_UPPERCASE) { $e = mb_strtoupper($e,$this->mb_enc); }	// mPDF 5.7.1
 				else if ($this->textvar & FT_LOWERCASE) { $e = mb_strtolower($e,$this->mb_enc); }	// mPDF 5.7.1
 				else if ($this->textvar & FT_CAPITALIZE) { $e = mb_convert_case($e, MB_CASE_TITLE, "UTF-8"); }	// mPDF 5.7.1
@@ -14205,15 +14222,15 @@
 /*-- END OTL --*/
 				else {	// *OTL*
 					// removes U+200E/U+200F LTR and RTL mark and U+200C/U+200D Zero-width Joiner and Non-joiner
-					$e = preg_replace("/[\xe2\x80\x8c\xe2\x80\x8d\xe2\x80\x8e\xe2\x80\x8f]/u",'',$e);
-					$e = preg_replace("/[\xef\xbb\xbf]/u",'',$e);	// Remove ZWNBSP (also Byte order mark FEFF)
+					$e = preg_replace("/[\xe2\x80\x8c\xe2\x80\x8d\xe2\x80\x8e\xe2\x80\x8f]/u",'',($e ?? ''));
+					$e = preg_replace("/[\xef\xbb\xbf]/u",'',($e ?? ''));	// Remove ZWNBSP (also Byte order mark FEFF)
 				}	// *OTL*
 			}
 			if (($this->tts) || ($this->ttz) || ($this->tta)) {
-				$es = explode('|',$e);
+				$es = explode('|',($e ?? ''));
 				$e = '';
 				foreach($es AS $val) {
-					$e .= chr($val);
+					$e .= chr((int) ($val));
 				}
 			}
 
@@ -14222,7 +14239,7 @@
 /*-- FORMS --*/
 			   //SELECT tag (form element)
 			   if ($this->specialcontent == "type=select") { 
-				$e = ltrim($e); 
+				$e = ltrim(($e ?? '')); 
 				if (!empty($this->OTLdata)) { $this->otl->trimOTLdata($this->OTLdata, true, false); }	// *OTL*
 				$stringwidth = $this->GetStringWidth($e);
 				if (!isset($this->selectoption['MAXWIDTH']) || $stringwidth > $this->selectoption['MAXWIDTH']) { $this->selectoption['MAXWIDTH'] = $stringwidth; }
@@ -14258,7 +14275,7 @@
 /*-- TABLES --*/
 				if ($this->tdbegin) {
      				   if (($this->ignorefollowingspaces) && !$this->ispre) { 
-					$e = ltrim($e); 
+					$e = ltrim(($e ?? '')); 
 					if (!empty($this->OTLdata)) { $this->otl->trimOTLdata($this->OTLdata, true, false); }	// *OTL*
 				   }
 				   if ($e || $e==='0') {
@@ -14284,9 +14301,9 @@
 						}
 					}
 					$this->_saveCellTextBuffer($e, $this->HREF);
-					if (substr($this->cell[$this->row][$this->col]['a'],0,1) == 'D') {
-						$dp = $this->decimal_align[substr($this->cell[$this->row][$this->col]['a'],0,2)];
-						$s = preg_split('/'.preg_quote($dp,'/').'/', $e, 2); 	// ? needs to be /u if not core
+					if (substr(($this->cell[$this->row][$this->col]['a'] ?? ''),0,1) == 'D') {
+						$dp = $this->decimal_align[substr(($this->cell[$this->row][$this->col]['a'] ?? ''),0,2)];
+						$s = preg_split('/'.preg_quote(($dp ?? ''),'/').'/', ($e ?? ''), 2); 	// ? needs to be /u if not core
 						$s0 = $this->GetStringWidth($s[0], false);
 						if (isset($s[1]) && $s[1]) { $s1 = $this->GetStringWidth(($s[1].$dp), false); }
 						else $s1 = 0;
@@ -14316,13 +14333,13 @@
 			// ALL ELSE
 			else {
     				if ($this->ignorefollowingspaces && !$this->ispre) { 
-					$e = ltrim($e); 
+					$e = ltrim(($e ?? '')); 
 					if (!empty($this->OTLdata)) { $this->otl->trimOTLdata($this->OTLdata, true, false); }	// *OTL*
 				}
 				if ($e || $e==='0') $this->_saveTextBuffer($e, $this->HREF);
 			}
   			if ($e || $e==='0') $this->ignorefollowingspaces=false;	// mPDF 6
-			if (substr($e,-1,1) == ' ' && !$this->ispre && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
+			if (substr(($e ?? ''),-1,1) == ' ' && !$this->ispre && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
 				$this->ignorefollowingspaces = true;
 			}
 		}
@@ -14336,7 +14353,7 @@
 			}
 /*-- END PROGRESS-BAR --*/
 
-		    $endtag = trim(strtoupper(substr($e,1)));
+		    $endtag = trim((strtoupper((substr(($e ?? ''),1) ?? '')) ?? ''));
 
 
 /*-- CSS-POSITION --*/
@@ -14403,8 +14420,8 @@
 
 		   else {	// OPENING TAG
 			if($this->blk[$this->blklvl]['hide']) { 
-				if (strpos($e,' ')) { $te = strtoupper(substr($e,0,strpos($e,' '))); }
-				else { $te = strtoupper($e); } 
+				if (strpos(($e ?? ''),' ')) { $te = strtoupper((substr(($e ?? ''),0,strpos(($e ?? ''),' ')) ?? '')); }
+				else { $te = strtoupper(($e ?? '')); } 
 				// mPDF 6
 				if ($te == 'THEAD' || $te == 'TBODY' || $te == 'TFOOT' || $te == 'TR' || $te == 'TD' || $te == 'TH') {
 					$this->lastoptionaltag = $te; 
@@ -14419,36 +14436,36 @@
 
 /*-- CSS-POSITION --*/
 			if ($this->inFixedPosBlock) { 
-				if (strpos($e,' ')) { $te = strtoupper(substr($e,0,strpos($e,' '))); }
-				else { $te = strtoupper($e); } 
+				if (strpos(($e ?? ''),' ')) { $te = strtoupper((substr(($e ?? ''),0,strpos(($e ?? ''),' ')) ?? '')); }
+				else { $te = strtoupper(($e ?? '')); } 
 				$this->fixedPosBlock .= '<'.$e.'>'; 
 				if (in_array($te, $this->outerblocktags) || in_array($te, $this->innerblocktags)) { $this->fixedPosBlockDepth++; }
 				continue; 
 			}
 /*-- END CSS-POSITION --*/
 			$regexp = '|=\'(.*?)\'|s'; // eliminate single quotes, if any
-      		$e = preg_replace($regexp,"=\"\$1\"",$e);
+      		$e = preg_replace(($regexp ?? ''),"=\"\$1\"",($e ?? ''));
 			// changes anykey=anyvalue to anykey="anyvalue" (only do this inside [some] tags)
-			if (substr($e,0,10)!='pageheader' && substr($e,0,10)!='pagefooter' && substr($e,0,12)!='tocpagebreak' && substr($e,0,10)!='indexentry' && substr($e,0,8)!='tocentry') {	// mPDF 6  (ZZZ99H)
+			if (substr(($e ?? ''),0,10)!='pageheader' && substr(($e ?? ''),0,10)!='pagefooter' && substr(($e ?? ''),0,12)!='tocpagebreak' && substr(($e ?? ''),0,10)!='indexentry' && substr(($e ?? ''),0,8)!='tocentry') {	// mPDF 6  (ZZZ99H)
 				$regexp = '| (\\w+?)=([^\\s>"]+)|si'; 
-	      		$e = preg_replace($regexp," \$1=\"\$2\"",$e);
-			}
-
-      		$e = preg_replace('/ (\\S+?)\s*=\s*"/i', " \\1=\"", $e);
+	      		$e = preg_replace(($regexp ?? '')," \$1=\"\$2\"",($e ?? ''));
+			}
+
+      		$e = preg_replace('/ (\\S+?)\s*=\s*"/i', " \\1=\"", ($e ?? ''));
 
       		//Fix path values, if needed
 			$orig_srcpath = '';
 			if ((stristr($e,"href=") !== false) or (stristr($e,"src=") !== false) ) {
 				$regexp = '/ (href|src)\s*=\s*"(.*?)"/i';
-				preg_match($regexp,$e,$auxiliararray);
+				preg_match(($regexp ?? ''),($e ?? ''),$auxiliararray);
 				if (isset($auxiliararray[2])) { $path = $auxiliararray[2]; }
 				else { $path = ''; }
-				if (trim($path) != '' && !(stristr($e,"src=") !== false && substr($path,0,4)=='var:') && substr($path,0,1)!='@') { 
-					$path=htmlspecialchars_decode($path);	// mPDF 5.7.4 URLs
+				if (trim(($path ?? '')) != '' && !(stristr($e,"src=") !== false && substr(($path ?? ''),0,4)=='var:') && substr(($path ?? ''),0,1)!='@') { 
+					$path=htmlspecialchars_decode(($path ?? ''));	// mPDF 5.7.4 URLs
 					$orig_srcpath = $path;
 					$this->GetFullPath($path); 
 					$regexp = '/ (href|src)="(.*?)"/i';
-					$e = preg_replace($regexp,' \\1="'.$path.'"',$e);
+					$e = preg_replace(($regexp ?? ''),' \\1="'.$path.'"',($e ?? ''));
 				}
 			}//END of Fix path values
 
@@ -14459,27 +14476,27 @@
 			// Changed to allow style="background: url('bg.jpg')"
 			// Changed to improve performance; maximum length of \S (attribute) = 16
 			// Increase allowed attribute name to 32 - cutting off "toc-even-header-name" etc.
-			preg_match_all('/\\S{1,32}=["][^"]*["]/',$e,$contents1);
-			preg_match_all('/\\S{1,32}=[\'][^\']*[\']/i',$e,$contents2);
+			preg_match_all('/\\S{1,32}=["][^"]*["]/',($e ?? ''),$contents1);
+			preg_match_all('/\\S{1,32}=[\'][^\']*[\']/i',($e ?? ''),$contents2);
 
 			$contents = array_merge($contents1, $contents2);
-			preg_match('/\\S+/',$e,$a2);
-			$tag=(isset($a2[0]) ? strtoupper($a2[0]) : '');
+			preg_match('/\\S+/',($e ?? ''),$a2);
+			$tag=(isset($a2[0]) ? strtoupper(($a2[0] ?? '')) : '');
 			$attr=array();
 			if ($orig_srcpath) { $attr['ORIG_SRC'] = $orig_srcpath; }
 			if (!empty($contents)) {
 				foreach($contents[0] as $v) {
 					// Changed to allow style="background: url('bg.jpg')"
- 					if(preg_match('/^([^=]*)=["]?([^"]*)["]?$/',$v,$a3) || preg_match('/^([^=]*)=[\']?([^\']*)[\']?$/',$v,$a3)) {
- 						if (strtoupper($a3[1])=='ID' || strtoupper($a3[1])=='CLASS') {	// 4.2.013 Omits STYLE
-   							$attr[strtoupper($a3[1])]=trim(strtoupper($a3[2]));
+ 					if(preg_match('/^([^=]*)=["]?([^"]*)["]?$/',($v ?? ''),$a3) || preg_match('/^([^=]*)=[\']?([^\']*)[\']?$/',($v ?? ''),$a3)) {
+ 						if (strtoupper(($a3[1] ?? ''))=='ID' || strtoupper(($a3[1] ?? ''))=='CLASS') {	// 4.2.013 Omits STYLE
+   							$attr[strtoupper(($a3[1] ?? ''))]=trim((strtoupper(($a3[2] ?? '')) ?? ''));
 						}
 						// includes header-style-right etc. used for <pageheader>
- 						else if (preg_match('/^(HEADER|FOOTER)-STYLE/i',$a3[1])) {
-   							$attr[strtoupper($a3[1])]=trim(strtoupper($a3[2]));
+ 						else if (preg_match('/^(HEADER|FOOTER)-STYLE/i',($a3[1] ?? ''))) {
+   							$attr[strtoupper(($a3[1] ?? ''))]=trim((strtoupper(($a3[2] ?? '')) ?? ''));
 						}
 						else {
-    							$attr[strtoupper($a3[1])]=trim($a3[2]);
+    							$attr[strtoupper(($a3[1] ?? ''))]=trim(($a3[2] ?? ''));
 						}
      					}
   				}
@@ -14492,7 +14509,7 @@
 				$this->fixedPosBlockDepth = 1; 
 			}
 /*-- END CSS-POSITION --*/
-		      if (preg_match('/\/$/',$e)) { $this->closeTag($tag,$a,$i); }
+		      if (preg_match('/\/$/',($e ?? ''))) { $this->closeTag($tag,$a,$i); }
 		   }
 
 		} // end TAG
@@ -14504,7 +14521,7 @@
 		for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag'],$a,$i); }
 
 		// Output any text left in buffer
-		if (count($this->textbuffer) && !$parseonly) { $this->printbuffer($this->textbuffer); }
+		if (count(($this->textbuffer ?? [])) && !$parseonly) { $this->printbuffer($this->textbuffer); }
 		if (!$parseonly) $this->textbuffer=array();
 
 /*-- CSS-FLOAT --*/
@@ -14516,7 +14533,7 @@
 			if ($old_page != $new_page) {
 				$s = $this->PrintPageBackgrounds();
 				// Writes after the marker so not overwritten later by page background etc.
-				$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+				$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 				$this->pageBackgrounds = array();
 				$this->page = $new_page;
 				$this->ResetMargins();
@@ -14534,7 +14551,7 @@
 		//Create Internal Links, if needed
 		if (!empty($this->internallink) ) {
 			foreach($this->internallink as $k=>$v) {
-				if (strpos($k,"#") !== false ) { continue; } //ignore
+				if (strpos(($k ?? ''),"#") !== false ) { continue; } //ignore
 				$ypos = $v['Y'];
 				$pagenum = $v['PAGE'];
 				$sharp = "#";
@@ -14549,7 +14566,7 @@
 		$this->bufferoutput = false; 
 
 /*-- CSS-POSITION --*/
-		if (count($this->fixedPosBlockSave) && $sub != 4) {
+		if (count(($this->fixedPosBlockSave ?? [])) && $sub != 4) {
 		  foreach($this->fixedPosBlockSave AS $fpbs) {
 			$old_page = $this->page;
 			$this->page = $fpbs[2];
@@ -14565,7 +14582,7 @@
 
 /*-- CSS-POSITION --*/
 
-function WriteFixedPosHTML($html='',$x, $y, $w, $h, $overflow='visible', $bounding=array()) {
+function WriteFixedPosHTML($html,$x, $y, $w, $h, $overflow='visible', $bounding=array()) {
 	// $overflow can be 'hidden', 'visible' or 'auto' - 'auto' causes autofit to size
 	// Annotations disabled - enabled in mPDF 5.0
 	// Links do work
@@ -14574,7 +14591,7 @@
 	// Called externally or interally via <div style="position: [fixed|absolute]">
 	// When used internally, $x $y $w $h and $overflow are all overridden by $bounding
 
-	$overflow = strtolower($overflow);
+	$overflow = strtolower(($overflow ?? ''));
 	if($this->state==0) { 
 		$this->AddPage($this->CurOrientation);
 	}
@@ -14594,7 +14611,7 @@
 	$this->writingHTMLfooter = true;
 	$this->InFooter = true;	// suppresses autopagebreaks
 	$save_bgs = $this->pageBackgrounds;
-	$checkinnerhtml = preg_replace('/\s/','',$html);
+	$checkinnerhtml = preg_replace('/\s/','',($html ?? ''));
 
 	if ($w > $this->w) { $x = 0; $w = $this->w; }
 	if ($h > $this->h) { $y = 0; $h = $this->h; }
@@ -14635,8 +14652,8 @@
 		$p = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);
 		if (isset($p['ROTATE']) && ($p['ROTATE']==90 || $p['ROTATE']==-90 || $p['ROTATE']==180)) { $rotate = $p['ROTATE']; }	// mPDF 6
 		else { $rotate = 0; }
-		if (isset($p['OVERFLOW'])) { $overflow = strtolower($p['OVERFLOW']); }
-		if (strtolower($p['POSITION']) == 'fixed') {
+		if (isset($p['OVERFLOW'])) { $overflow = strtolower(($p['OVERFLOW'] ?? '')); }
+		if (strtolower(($p['POSITION'] ?? '')) == 'fixed') {
 			$cont_w = $this->pgwidth;	// $this->blk[0]['inner_width'];
 			$cont_h = $this->h - $this->tMargin - $this->bMargin;
 			$cont_x = $this->lMargin;
@@ -14651,28 +14668,28 @@
 
 		// Pass on in-line properties to the innerhtml
 		$css = '';
-		if (isset($p['TEXT-ALIGN'])) { $css .= 'text-align: '.strtolower($p['TEXT-ALIGN']).'; '; }
-		if (isset($p['TEXT-TRANSFORM'])) { $css .= 'text-transform: '.strtolower($p['TEXT-TRANSFORM']).'; '; }
-		if (isset($p['TEXT-INDENT'])) { $css .= 'text-indent: '.strtolower($p['TEXT-INDENT']).'; '; }
-		if (isset($p['TEXT-DECORATION'])) { $css .= 'text-decoration: '.strtolower($p['TEXT-DECORATION']).'; '; }
-		if (isset($p['FONT-FAMILY'])) { $css .= 'font-family: '.strtolower($p['FONT-FAMILY']).'; '; }
-		if (isset($p['FONT-STYLE'])) { $css .= 'font-style: '.strtolower($p['FONT-STYLE']).'; '; }
-		if (isset($p['FONT-WEIGHT'])) { $css .= 'font-weight: '.strtolower($p['FONT-WEIGHT']).'; '; }
-		if (isset($p['FONT-SIZE'])) { $css .= 'font-size: '.strtolower($p['FONT-SIZE']).'; '; }
-		if (isset($p['LINE-HEIGHT'])) { $css .= 'line-height: '.strtolower($p['LINE-HEIGHT']).'; '; }
-		if (isset($p['TEXT-SHADOW'])) { $css .= 'text-shadow: '.strtolower($p['TEXT-SHADOW']).'; '; }
-		if (isset($p['LETTER-SPACING'])) { $css .= 'letter-spacing: '.strtolower($p['LETTER-SPACING']).'; '; }
+		if (isset($p['TEXT-ALIGN'])) { $css .= 'text-align: '.strtolower(($p['TEXT-ALIGN'] ?? '')).'; '; }
+		if (isset($p['TEXT-TRANSFORM'])) { $css .= 'text-transform: '.strtolower(($p['TEXT-TRANSFORM'] ?? '')).'; '; }
+		if (isset($p['TEXT-INDENT'])) { $css .= 'text-indent: '.strtolower(($p['TEXT-INDENT'] ?? '')).'; '; }
+		if (isset($p['TEXT-DECORATION'])) { $css .= 'text-decoration: '.strtolower(($p['TEXT-DECORATION'] ?? '')).'; '; }
+		if (isset($p['FONT-FAMILY'])) { $css .= 'font-family: '.strtolower(($p['FONT-FAMILY'] ?? '')).'; '; }
+		if (isset($p['FONT-STYLE'])) { $css .= 'font-style: '.strtolower(($p['FONT-STYLE'] ?? '')).'; '; }
+		if (isset($p['FONT-WEIGHT'])) { $css .= 'font-weight: '.strtolower(($p['FONT-WEIGHT'] ?? '')).'; '; }
+		if (isset($p['FONT-SIZE'])) { $css .= 'font-size: '.strtolower(($p['FONT-SIZE'] ?? '')).'; '; }
+		if (isset($p['LINE-HEIGHT'])) { $css .= 'line-height: '.strtolower(($p['LINE-HEIGHT'] ?? '')).'; '; }
+		if (isset($p['TEXT-SHADOW'])) { $css .= 'text-shadow: '.strtolower(($p['TEXT-SHADOW'] ?? '')).'; '; }
+		if (isset($p['LETTER-SPACING'])) { $css .= 'letter-spacing: '.strtolower(($p['LETTER-SPACING'] ?? '')).'; '; }
 		// mPDF 6
-		if (isset($p['FONT-VARIANT-POSITION'])) { $css .= 'font-variant-position: '.strtolower($p['FONT-VARIANT-POSITION']).'; '; }
-		if (isset($p['FONT-VARIANT-CAPS'])) { $css .= 'font-variant-caps: '.strtolower($p['FONT-VARIANT-CAPS']).'; '; }
-		if (isset($p['FONT-VARIANT-LIGATURES'])) { $css .= 'font-variant-ligatures: '.strtolower($p['FONT-VARIANT-LIGATURES']).'; '; }
-		if (isset($p['FONT-VARIANT-NUMERIC'])) { $css .= 'font-variant-numeric: '.strtolower($p['FONT-VARIANT-NUMERIC']).'; '; }
-		if (isset($p['FONT-VARIANT-ALTERNATES'])) { $css .= 'font-variant-alternates: '.strtolower($p['FONT-VARIANT-ALTERNATES']).'; '; }
-		if (isset($p['FONT-FEATURE-SETTINGS'])) { $css .= 'font-feature-settings: '.strtolower($p['FONT-FEATURE-SETTINGS']).'; '; }
-		if (isset($p['FONT-LANGUAGE-OVERRIDE'])) { $css .= 'font-language-override: '.strtolower($p['FONT-LANGUAGE-OVERRIDE']).'; '; }
-		if (isset($p['FONT-KERNING'])) { $css .= 'font-kerning: '.strtolower($p['FONT-KERNING']).'; '; }
-
-		if (isset($p['COLOR'])) { $css .= 'color: '.strtolower($p['COLOR']).'; '; }
+		if (isset($p['FONT-VARIANT-POSITION'])) { $css .= 'font-variant-position: '.strtolower(($p['FONT-VARIANT-POSITION'] ?? '')).'; '; }
+		if (isset($p['FONT-VARIANT-CAPS'])) { $css .= 'font-variant-caps: '.strtolower(($p['FONT-VARIANT-CAPS'] ?? '')).'; '; }
+		if (isset($p['FONT-VARIANT-LIGATURES'])) { $css .= 'font-variant-ligatures: '.strtolower(($p['FONT-VARIANT-LIGATURES'] ?? '')).'; '; }
+		if (isset($p['FONT-VARIANT-NUMERIC'])) { $css .= 'font-variant-numeric: '.strtolower(($p['FONT-VARIANT-NUMERIC'] ?? '')).'; '; }
+		if (isset($p['FONT-VARIANT-ALTERNATES'])) { $css .= 'font-variant-alternates: '.strtolower(($p['FONT-VARIANT-ALTERNATES'] ?? '')).'; '; }
+		if (isset($p['FONT-FEATURE-SETTINGS'])) { $css .= 'font-feature-settings: '.strtolower(($p['FONT-FEATURE-SETTINGS'] ?? '')).'; '; }
+		if (isset($p['FONT-LANGUAGE-OVERRIDE'])) { $css .= 'font-language-override: '.strtolower(($p['FONT-LANGUAGE-OVERRIDE'] ?? '')).'; '; }
+		if (isset($p['FONT-KERNING'])) { $css .= 'font-kerning: '.strtolower(($p['FONT-KERNING'] ?? '')).'; '; }
+
+		if (isset($p['COLOR'])) { $css .= 'color: '.strtolower(($p['COLOR'] ?? '')).'; '; }
 		if (isset($p['Z-INDEX'])) { $css .= 'z-index: '.$p['Z-INDEX'].'; '; }
 		if ($css) {
 			$html = '<div style="'.$css.'">'.$html.'</div>';
@@ -14726,24 +14743,24 @@
 		$bbox_pt = $this->blk[1]['padding_top'];
 		$bbox_pb = $this->blk[1]['padding_bottom'];
 		$bbox_mr = $this->blk[1]['margin_right'];
-		if (isset($p['MARGIN-RIGHT']) && strtolower($p['MARGIN-RIGHT'])=='auto') { $bbox_mr = 'auto'; }
+		if (isset($p['MARGIN-RIGHT']) && strtolower(($p['MARGIN-RIGHT'] ?? ''))=='auto') { $bbox_mr = 'auto'; }
 		$bbox_ml = $this->blk[1]['margin_left'];
-		if (isset($p['MARGIN-LEFT']) && strtolower($p['MARGIN-LEFT'])=='auto') { $bbox_ml = 'auto'; }
+		if (isset($p['MARGIN-LEFT']) && strtolower(($p['MARGIN-LEFT'] ?? ''))=='auto') { $bbox_ml = 'auto'; }
 		$bbox_mt = $this->blk[1]['margin_top'];
-		if (isset($p['MARGIN-TOP']) && strtolower($p['MARGIN-TOP'])=='auto') { $bbox_mt = 'auto'; }
+		if (isset($p['MARGIN-TOP']) && strtolower(($p['MARGIN-TOP'] ?? ''))=='auto') { $bbox_mt = 'auto'; }
 		$bbox_mb = $this->blk[1]['margin_bottom'];
- 		if (isset($p['MARGIN-BOTTOM']) && strtolower($p['MARGIN-BOTTOM'])=='auto') { $bbox_mb = 'auto'; }
-		if (isset($p['LEFT']) && strtolower($p['LEFT'])!='auto') { $bbox_left = $this->ConvertSize($p['LEFT'], $cont_w, $this->FontSize,false); }
+ 		if (isset($p['MARGIN-BOTTOM']) && strtolower(($p['MARGIN-BOTTOM'] ?? ''))=='auto') { $bbox_mb = 'auto'; }
+		if (isset($p['LEFT']) && strtolower(($p['LEFT'] ?? ''))!='auto') { $bbox_left = $this->ConvertSize($p['LEFT'], $cont_w, $this->FontSize,false); }
 		else { $bbox_left = 'auto'; }
- 		if (isset($p['TOP']) && strtolower($p['TOP'])!='auto') { $bbox_top = $this->ConvertSize($p['TOP'], $cont_h, $this->FontSize,false); }
+ 		if (isset($p['TOP']) && strtolower(($p['TOP'] ?? ''))!='auto') { $bbox_top = $this->ConvertSize($p['TOP'], $cont_h, $this->FontSize,false); }
 		else { $bbox_top = 'auto'; }
- 		if (isset($p['RIGHT']) && strtolower($p['RIGHT'])!='auto') { $bbox_right = $this->ConvertSize($p['RIGHT'], $cont_w, $this->FontSize,false); }
+ 		if (isset($p['RIGHT']) && strtolower(($p['RIGHT'] ?? ''))!='auto') { $bbox_right = $this->ConvertSize($p['RIGHT'], $cont_w, $this->FontSize,false); }
 		else { $bbox_right = 'auto'; }
- 		if (isset($p['BOTTOM']) && strtolower($p['BOTTOM'])!='auto') { $bbox_bottom = $this->ConvertSize($p['BOTTOM'], $cont_h, $this->FontSize,false); }
+ 		if (isset($p['BOTTOM']) && strtolower(($p['BOTTOM'] ?? ''))!='auto') { $bbox_bottom = $this->ConvertSize($p['BOTTOM'], $cont_h, $this->FontSize,false); }
 		else { $bbox_bottom = 'auto'; }
- 		if (isset($p['WIDTH']) && strtolower($p['WIDTH'])!='auto') { $inner_w = $this->ConvertSize($p['WIDTH'], $cont_w, $this->FontSize,false); }
+ 		if (isset($p['WIDTH']) && strtolower(($p['WIDTH'] ?? ''))!='auto') { $inner_w = $this->ConvertSize($p['WIDTH'], $cont_w, $this->FontSize,false); }
 		else { $inner_w = 'auto'; }
- 		if (isset($p['HEIGHT']) && strtolower($p['HEIGHT'])!='auto') { $inner_h = $this->ConvertSize($p['HEIGHT'], $cont_h, $this->FontSize,false); }
+ 		if (isset($p['HEIGHT']) && strtolower(($p['HEIGHT'] ?? ''))!='auto') { $inner_h = $this->ConvertSize($p['HEIGHT'], $cont_h, $this->FontSize,false); }
 		else { $inner_h = 'auto'; }
 
 		// If bottom or right pos are set and not left / top - save this to adjust rotated block later
@@ -15107,7 +15124,7 @@
 
 	$s = $this->PrintPageBackgrounds();
 	$s = $rot_start.$s.$rot_end;
-	$this->pages[$this->page] = preg_replace('/___BEFORE_BORDERS___/', "\n".$s."\n", $this->pages[$this->page]);
+	$this->pages[$this->page] = preg_replace('/___BEFORE_BORDERS___/', "\n".$s."\n", ($this->pages[$this->page] ?? ''));
 	$this->pageBackgrounds = array();
 
 	$this->_out($rot_start);
@@ -15291,12 +15308,12 @@
 
 
 function border_details($bd) {
-	$prop = preg_split('/\s+/',trim($bd));
+	$prop = preg_split('/\s+/',(trim(($bd ?? '')) ?? ''));
 
 	if (isset($this->blk[$this->blklvl]['inner_width'])) { $refw = $this->blk[$this->blklvl]['inner_width']; }
 	else if (isset($this->blk[$this->blklvl-1]['inner_width'])) { $refw = $this->blk[$this->blklvl-1]['inner_width']; }
 	else { $refw = $this->w; }
-	if ( count($prop) == 1 ) { 
+	if ( count(($prop ?? [])) == 1 ) { 
 		$bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
 		if ($bsize > 0) {
 			return array('s' => 1, 'w' => $bsize, 'c' => $this->ConvertColor(0), 'style'=>'solid');
@@ -15304,7 +15321,7 @@
 		else { return array('w' => 0, 's' => 0); }
 	}
 
-	else if (count($prop) == 2 ) { 
+	else if (count(($prop ?? [])) == 2 ) { 
 		// 1px solid 
 		if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $prop[2] = ''; }
 		// solid #000000 
@@ -15312,11 +15329,11 @@
 		// 1px #000000 
 		else { $prop[1] = ''; $prop[2] = $prop[1]; }
 	}
-	else if ( count($prop) == 3 ) {
+	else if ( count(($prop ?? [])) == 3 ) {
 		// Change #000000 1px solid to 1px solid #000000 (proper)
-		if (substr($prop[0],0,1) == '#') { $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $prop[2]; $prop[2] = $tmp; }
+		if (substr(($prop[0] ?? ''),0,1) == '#') { $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $prop[2]; $prop[2] = $tmp; }
 		// Change solid #000000 1px to 1px solid #000000 (proper)
-		else if (substr($prop[0],1,1) == '#') { $tmp = $prop[1]; $prop[0] = $prop[2]; $prop[1] = $prop[0]; $prop[2] = $tmp; }
+		else if (substr(($prop[0] ?? ''),1,1) == '#') { $tmp = $prop[1]; $prop[0] = $prop[2]; $prop[1] = $prop[0]; $prop[2] = $tmp; }
 		// Change solid 1px #000000 to 1px solid #000000 (proper)
 		else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { 
 			$tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $tmp; 
@@ -15328,7 +15345,7 @@
 	//color
 	$coul = $this->ConvertColor($prop[2]);	// returns array
 	// Style
-	$prop[1] = strtolower($prop[1]);
+	$prop[1] = strtolower(($prop[1] ?? ''));
 	if (in_array($prop[1],$this->borderstyles) && $bsize > 0) { $on = 1; } 
 	else if ($prop[1] == 'hidden') { $on = 1; $bsize = 0; $coul = ''; } 
 	else if ($prop[1] == 'none') { $on = 0; $bsize = 0; $coul = ''; } 
@@ -15366,7 +15383,7 @@
 
 
 /*-- CSS-PAGE --*/
-function SetPagedMediaCSS($name='', $first, $oddEven) {
+function SetPagedMediaCSS($name, $first, $oddEven) {
 	if ($oddEven == 'E') { 
 		if ($this->directionality=='rtl') { $side = 'R'; }
 		else { $side = 'L'; }
@@ -15375,7 +15392,7 @@
 		if ($this->directionality=='rtl') { $side = 'L'; }
 		else { $side = 'R'; }
 	}
-	$name = strtoupper($name);
+	$name = strtoupper(($name ?? ''));
 	$p = array();
 	$p['SIZE'] = 'AUTO';
 
@@ -15530,8 +15547,8 @@
 		$outer_width_LR = 0;
 		$outer_width_TB = 0;
 		if (!$newformat) {
-			if (strtoupper($p['SIZE']) == 'AUTO') { $p['ORIENTATION']=$this->DefOrientation; }
-			else if (strtoupper($p['SIZE']) == 'LANDSCAPE') { $p['ORIENTATION']='L'; }
+			if (strtoupper(($p['SIZE'] ?? '')) == 'AUTO') { $p['ORIENTATION']=$this->DefOrientation; }
+			else if (strtoupper(($p['SIZE'] ?? '')) == 'LANDSCAPE') { $p['ORIENTATION']='L'; }
 			else { $p['ORIENTATION']='P'; }
 		}
 		if (($p['ORIENTATION']==$this->DefOrientation && !$newformat) || ($newformat && $p['ORIENTATION']=='P')) { 
@@ -15551,9 +15568,9 @@
 	if (isset($p['SUPPRESS']) && $p['SUPPRESS']) { $suppress = $p['SUPPRESS']; }
 
 	if (isset($p['MARKS'])) {
-		if (preg_match('/cross/i', $p['MARKS']) && preg_match('/crop/i', $p['MARKS'])) { $marks = 'CROPCROSS'; }
-	  	else if (strtoupper($p['MARKS']) == 'CROP') { $marks = 'CROP'; }
-	  	else if (strtoupper($p['MARKS']) == 'CROSS') { $marks = 'CROSS'; }
+		if (preg_match('/cross/i', ($p['MARKS'] ?? '')) && preg_match('/crop/i', ($p['MARKS'] ?? ''))) { $marks = 'CROPCROSS'; }
+	  	else if (strtoupper(($p['MARKS'] ?? '')) == 'CROP') { $marks = 'CROP'; }
+	  	else if (strtoupper(($p['MARKS'] ?? '')) == 'CROSS') { $marks = 'CROSS'; }
 	}
 
 	if (isset($p['BACKGROUND-COLOR']) && $p['BACKGROUND-COLOR']) { $bg['BACKGROUND-COLOR'] = $p['BACKGROUND-COLOR']; }
@@ -15606,7 +15623,7 @@
 	if ($old_page != $new_page) {
 		$s = $this->PrintPageBackgrounds();
 		// Writes after the marker so not overwritten later by page background etc.
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 		$this->pageBackgrounds = array();
 		$this->page = $new_page;
 	}
@@ -15625,7 +15642,7 @@
 	$r_max = 0;
 	$l_width = 0;
 	$r_width = 0;
-	if (count($this->floatDivs)) {
+	if (count(($this->floatDivs ?? []))) {
 	  $currpos = ($this->page*1000 + $this->y);
 	  foreach($this->floatDivs AS $f) {
 	    if (($clear && $f['blockContext'] == $this->blk[$blklvl]['blockContext']) || (!$clear && $currpos >= $f['startpos'] && $currpos < ($f['endpos']-0.001) && $f['blklvl'] > $blklvl && $f['blockContext'] == $this->blk[$blklvl]['blockContext'])) {
@@ -15812,7 +15829,7 @@
 			if (isset($properties['COLOR'])) { $p['R']['color'] = $properties['COLOR']; }
 		}
 		if (isset($attr['LINE']) && $attr['LINE']) {	// 0|1|on|off
-			if ($attr['LINE']=='1' || strtoupper($attr['LINE'])=='ON') { $lineset=1; }
+			if ($attr['LINE']=='1' || strtoupper(($attr['LINE'] ?? ''))=='ON') { $lineset=1; }
 			else { $lineset=0; }
 			$p['line'] = $lineset;
 		}
@@ -15831,15 +15848,15 @@
 	else if ($tag=='SETPAGEHEADER' || $tag=='SETPAGEFOOTER') { $pname = '_nonhtmldefault'; }	// mPDF 6
 	else { $pname = '_default'; }
 	if (isset($attr['PAGE']) && $attr['PAGE']) { 	// O|odd|even|E|ALL|[blank]
-		if (strtoupper($attr['PAGE'])=='O' || strtoupper($attr['PAGE'])=='ODD') { $side='odd'; }
-		else if (strtoupper($attr['PAGE'])=='E' || strtoupper($attr['PAGE'])=='EVEN') { $side='even'; }
-		else if (strtoupper($attr['PAGE'])=='ALL') { $side='both'; }
+		if (strtoupper(($attr['PAGE'] ?? ''))=='O' || strtoupper(($attr['PAGE'] ?? ''))=='ODD') { $side='odd'; }
+		else if (strtoupper(($attr['PAGE'] ?? ''))=='E' || strtoupper(($attr['PAGE'] ?? ''))=='EVEN') { $side='even'; }
+		else if (strtoupper(($attr['PAGE'] ?? ''))=='ALL') { $side='both'; }
 		else { $side='odd'; }
 	}
 	else { $side='odd'; }
 	if (isset($attr['VALUE']) && $attr['VALUE']) { 	// -1|1|on|off
-		if ($attr['VALUE']=='1' || strtoupper($attr['VALUE'])=='ON') { $set=1; }
-		else if ($attr['VALUE']=='-1' || strtoupper($attr['VALUE'])=='OFF') { $set=0; }
+		if ($attr['VALUE']=='1' || strtoupper(($attr['VALUE'] ?? ''))=='ON') { $set=1; }
+		else if ($attr['VALUE']=='-1' || strtoupper(($attr['VALUE'] ?? ''))=='OFF') { $set=0; }
 		else { $set=1; }
 	}
 	else { $set=1; }
@@ -15887,8 +15904,8 @@
 
 	if (isset($attr['SHEET-SIZE'])) { 
 		// Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
-		$prop = preg_split('/\s+/',trim($attr['SHEET-SIZE']));
-		if (count($prop) == 2 ) {
+		$prop = preg_split('/\s+/',(trim(($attr['SHEET-SIZE'] ?? '')) ?? ''));
+		if (count(($prop ?? [])) == 2 ) {
 			$newformat = array($this->ConvertSize($prop[0]), $this->ConvertSize($prop[1]));
 		}
 		else { $newformat = $attr['SHEET-SIZE']; }
@@ -15915,17 +15932,17 @@
 	if (isset($attr['ODD-FOOTER-NAME'])) { $ofname = $attr['ODD-FOOTER-NAME']; }
 	if (isset($attr['EVEN-FOOTER-NAME'])) { $efname = $attr['EVEN-FOOTER-NAME']; }
 	$ohvalue = $ehvalue = $ofvalue = $efvalue = 0;
-	if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE']=='1' || strtoupper($attr['ODD-HEADER-VALUE'])=='ON')) { $ohvalue = 1; }
-	else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE']=='-1' || strtoupper($attr['ODD-HEADER-VALUE'])=='OFF')) { $ohvalue = -1; }
-	if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE']=='1' || strtoupper($attr['EVEN-HEADER-VALUE'])=='ON')) { $ehvalue = 1; }
-	else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE']=='-1' || strtoupper($attr['EVEN-HEADER-VALUE'])=='OFF')) { $ehvalue = -1; }
-	if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE']=='1' || strtoupper($attr['ODD-FOOTER-VALUE'])=='ON')) { $ofvalue = 1; }
-	else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE']=='-1' || strtoupper($attr['ODD-FOOTER-VALUE'])=='OFF')) { $ofvalue = -1; }
-	if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE']=='1' || strtoupper($attr['EVEN-FOOTER-VALUE'])=='ON')) { $efvalue = 1; }
-	else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE']=='-1' || strtoupper($attr['EVEN-FOOTER-VALUE'])=='OFF')) { $efvalue = -1; }
-
-	if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION'])=='L' || strtoupper($attr['ORIENTATION'])=='LANDSCAPE')) { $orient = 'L'; }
-	else if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION'])=='P' || strtoupper($attr['ORIENTATION'])=='PORTRAIT')) { $orient = 'P'; }
+	if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE']=='1' || strtoupper(($attr['ODD-HEADER-VALUE'] ?? ''))=='ON')) { $ohvalue = 1; }
+	else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE']=='-1' || strtoupper(($attr['ODD-HEADER-VALUE'] ?? ''))=='OFF')) { $ohvalue = -1; }
+	if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE']=='1' || strtoupper(($attr['EVEN-HEADER-VALUE'] ?? ''))=='ON')) { $ehvalue = 1; }
+	else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE']=='-1' || strtoupper(($attr['EVEN-HEADER-VALUE'] ?? ''))=='OFF')) { $ehvalue = -1; }
+	if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE']=='1' || strtoupper(($attr['ODD-FOOTER-VALUE'] ?? ''))=='ON')) { $ofvalue = 1; }
+	else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE']=='-1' || strtoupper(($attr['ODD-FOOTER-VALUE'] ?? ''))=='OFF')) { $ofvalue = -1; }
+	if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE']=='1' || strtoupper(($attr['EVEN-FOOTER-VALUE'] ?? ''))=='ON')) { $efvalue = 1; }
+	else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE']=='-1' || strtoupper(($attr['EVEN-FOOTER-VALUE'] ?? ''))=='OFF')) { $efvalue = -1; }
+
+	if (isset($attr['ORIENTATION']) && (strtoupper(($attr['ORIENTATION'] ?? ''))=='L' || strtoupper(($attr['ORIENTATION'] ?? ''))=='LANDSCAPE')) { $orient = 'L'; }
+	else if (isset($attr['ORIENTATION']) && (strtoupper(($attr['ORIENTATION'] ?? ''))=='P' || strtoupper(($attr['ORIENTATION'] ?? ''))=='PORTRAIT')) { $orient = 'P'; }
 	else { $orient = $this->CurOrientation; }
 
 	if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) { $pagesel = $attr['PAGE-SELECTOR']; }
@@ -15936,8 +15953,8 @@
 	if ($tag == 'FORMFEED') { $pagebreaktype = 'slice'; }	// can be overridden by PAGE-BREAK-TYPE
 	$startpage = $this->page;
 	if (isset($attr['PAGE-BREAK-TYPE'])) {
-		if (strtolower($attr['PAGE-BREAK-TYPE'])=='cloneall' || strtolower($attr['PAGE-BREAK-TYPE'])=='clonebycss' || strtolower($attr['PAGE-BREAK-TYPE'])=='slice') { 
-			$pagebreaktype = strtolower($attr['PAGE-BREAK-TYPE']); 
+		if (strtolower(($attr['PAGE-BREAK-TYPE'] ?? ''))=='cloneall' || strtolower(($attr['PAGE-BREAK-TYPE'] ?? ''))=='clonebycss' || strtolower(($attr['PAGE-BREAK-TYPE'] ?? ''))=='slice') { 
+			$pagebreaktype = strtolower(($attr['PAGE-BREAK-TYPE'] ?? '')); 
 		}
 	}
 	if ($tag == 'TOCPAGEBREAK') { $pagebreaktype = 'cloneall'; }
@@ -15964,7 +15981,7 @@
 	if (isset($attr['SUPPRESS'])) { $suppress = $attr['SUPPRESS']; }
 
 	if ($tag == 'TOCPAGEBREAK') { $type = 'NEXT-ODD'; }
-	else if(isset($attr['TYPE'])) { $type = strtoupper($attr['TYPE']); }
+	else if(isset($attr['TYPE'])) { $type = strtoupper(($attr['TYPE'] ?? '')); }
 	else { $type = ''; }
 
 	if ($type == 'E' || $type == 'EVEN') { $this->AddPage($orient,'E', $resetpagenum, $pagenumstyle, $suppress,$mgl,$mgr,$mgt,$mgb,$mgh,$mgf,$ohname,$ehname,$ofname,$efname,$ohvalue,$ehvalue,$ofvalue,$efvalue,$pagesel,$newformat); }
@@ -15995,7 +16012,7 @@
      case 'TOCENTRY':
 	if (isset($attr['CONTENT']) && $attr['CONTENT']) {
 		$objattr = array();
-		$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES);
+		$objattr['CONTENT'] = htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES);
 		$objattr['type'] = 'toc';
 		$objattr['vertical-align'] = 'T';
 		if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['toclevel'] = $attr['LEVEL']; } else { $objattr['toclevel'] = 0; }
@@ -16013,11 +16030,11 @@
      case 'INDEXENTRY':
 	if (isset($attr['CONTENT']) && $attr['CONTENT']) {
 		if (isset($attr['XREF']) && $attr['XREF']) {
-			$this->IndexEntry(htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES),$attr['XREF']);
+			$this->IndexEntry(htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES),$attr['XREF']);
 			break;
 		}
 		$objattr = array();
-		$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES);
+		$objattr['CONTENT'] = htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES);
 		$objattr['type'] = 'indexentry';
 		$objattr['vertical-align'] = 'T';
 		$e = "\xbb\xa4\xactype=indexentry,objattr=".serialize($objattr)."\xbb\xa4\xac";
@@ -16032,9 +16049,9 @@
      case 'INDEXINSERT':
 	if (isset($attr['COLLATION'])) { $indexCollationLocale = $attr['COLLATION']; } else { $indexCollationLocale = ''; }
 	if (isset($attr['COLLATION-GROUP'])) { $indexCollationGroup = $attr['COLLATION-GROUP']; } else { $indexCollationGroup = ''; }
-	if (isset($attr['USEDIVLETTERS']) && (strtoupper($attr['USEDIVLETTERS'])=='OFF' || $attr['USEDIVLETTERS']==-1 || $attr['USEDIVLETTERS']==='0')) { $usedivletters = 0; }
+	if (isset($attr['USEDIVLETTERS']) && (strtoupper(($attr['USEDIVLETTERS'] ?? ''))=='OFF' || $attr['USEDIVLETTERS']==-1 || $attr['USEDIVLETTERS']==='0')) { $usedivletters = 0; }
 	else { $usedivletters = 1; }
-	if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $links = true; }
+	if (isset($attr['LINKS']) && (strtoupper(($attr['LINKS'] ?? ''))=='ON' || $attr['LINKS']==1)) { $links = true; }
 	else { $links = false; }
 	$this->InsertIndex($usedivletters, $links, $indexCollationLocale, $indexCollationGroup);
 
@@ -16044,7 +16061,7 @@
 /*-- WATERMARK --*/
      
      case 'WATERMARKTEXT':
-	if (isset($attr['CONTENT']) && $attr['CONTENT']) { $txt = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES); } else { $txt = ''; }
+	if (isset($attr['CONTENT']) && $attr['CONTENT']) { $txt = htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES); } else { $txt = ''; }
 	if (isset($attr['ALPHA']) && $attr['ALPHA']>0) { $alpha = $attr['ALPHA']; } else { $alpha = -1; }
 	$this->SetWatermarkText($txt, $alpha);
 	break;
@@ -16055,12 +16072,12 @@
 	if (isset($attr['ALPHA']) && $attr['ALPHA']>0) { $alpha = $attr['ALPHA']; } else { $alpha = -1; }
 	if (isset($attr['SIZE']) && $attr['SIZE']) { 
 		$size = $attr['SIZE']; 
-		if (strpos($size,',')) { $size = explode(',',$size); }
+		if (strpos(($size ?? ''),',')) { $size = explode(',',($size ?? '')); }
 	} 
 	else { $size = 'D'; }
 	if (isset($attr['POSITION']) && $attr['POSITION']) { 	// mPDF 5.7.2
 		$pos = $attr['POSITION']; 
-		if (strpos($pos,',')) { $pos = explode(',',$pos); }
+		if (strpos(($pos ?? ''),',')) { $pos = explode(',',($pos ?? '')); }
 	} 
 	else { $pos = 'P'; }
 	$this->SetWatermarkImage($src, $alpha, $size, $pos);
@@ -16071,7 +16088,7 @@
      case 'BOOKMARK':
 	if (isset($attr['CONTENT'])) {
 		$objattr = array();
-		$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES);
+		$objattr['CONTENT'] = htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES);
 		$objattr['type'] = 'bookmark';
 		if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['bklevel'] = $attr['LEVEL']; } else { $objattr['bklevel'] = 0; }
 		$e = "\xbb\xa4\xactype=bookmark,objattr=".serialize($objattr)."\xbb\xa4\xac";
@@ -16099,7 +16116,7 @@
 		$objattr['border_bottom']['w'] = 0;
 		$objattr['border_left']['w'] = 0;
 		$objattr['border_right']['w'] = 0;
-		$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES);
+		$objattr['CONTENT'] = htmlspecialchars_decode(($attr['CONTENT'] ?? ''),ENT_QUOTES);
 		$objattr['type'] = 'annot';
 		$objattr['POPUP'] = ''; 
 	}
@@ -16122,8 +16139,8 @@
 	else  { $objattr['COLOR'] = $this->ConvertColor('yellow'); }
 
 	if (isset($attr['POPUP']) && !empty($attr['POPUP'])) { 
-		$pop = preg_split('/\s+/',trim($attr['POPUP']));
-		if (count($pop)>1) { $objattr['POPUP'] = $pop; }
+		$pop = preg_split('/\s+/',(trim(($attr['POPUP'] ?? '')) ?? ''));
+		if (count(($pop ?? []))>1) { $objattr['POPUP'] = $pop; }
 		else { $objattr['POPUP'] = true; }
 	} 
 	$e = "\xbb\xa4\xactype=annot,objattr=".serialize($objattr)."\xbb\xa4\xac";
@@ -16274,42 +16291,42 @@
 	if($this->tableLevel && isset($this->cell[$this->row][$this->col]['direction']) && $this->cell[$this->row][$this->col]['direction'] == 'rtl') { 
 		$currdir = 'rtl'; 
 	}
-	if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower($attr['DIR']); }
-	if(isset($properties['DIRECTION'])) { $currdir = strtolower($properties['DIRECTION']); }
+	if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower(($attr['DIR'] ?? '')); }
+	if(isset($properties['DIRECTION'])) { $currdir = strtolower(($properties['DIRECTION'] ?? '')); }
 
 	// mPDF 6 bidi
 	// cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
 	if ($tag == 'BDO') { 
-		if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x202E; $popd = 'RLOPDF'; }	// U+202E RLO
-		else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x202D; $popd = 'LROPDF'; }	// U+202D LRO
+		if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'rtl') { $bdf = 0x202E; $popd = 'RLOPDF'; }	// U+202E RLO
+		else if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'ltr') { $bdf = 0x202D; $popd = 'LROPDF'; }	// U+202D LRO
 	}
 	else if ($tag == 'BDI') { 
-		if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x2067; $popd = 'RLIPDI'; }	// U+2067 RLI
-		else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x2066; $popd = 'LRIPDI'; }	// U+2066 LRI
+		if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'rtl') { $bdf = 0x2067; $popd = 'RLIPDI'; }	// U+2067 RLI
+		else if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'ltr') { $bdf = 0x2066; $popd = 'LRIPDI'; }	// U+2066 LRI
 		else { $bdf = 0x2068; $popd = 'FSIPDI'; }	// U+2068 FSI
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='bidi-override') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='bidi-override') { 
 		if ($currdir == 'rtl') { $bdf = 0x202E;  $popd = 'RLOPDF';}	// U+202E RLO
 		else { $bdf = 0x202D; $popd = 'LROPDF'; }	// U+202D LRO
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='embed') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='embed') { 
 		if ($currdir == 'rtl') { $bdf = 0x202B;  $popd = 'RLEPDF';}	// U+202B RLE
 		else { $bdf = 0x202A; $popd = 'LREPDF'; }	// U+202A LRE
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='isolate') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='isolate') { 
 		if ($currdir == 'rtl') { $bdf = 0x2067; $popd = 'RLIPDI'; }	// U+2067 RLI
 		else { $bdf = 0x2066; $popd = 'LRIPDI'; }	// U+2066 LRI
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='isolate-override') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='isolate-override') { 
 		if ($currdir == 'rtl') { $bdf = 0x2067; $bdf2 = 0x202E; $popd = 'RLIRLOPDFPDI'; }	// U+2067 RLI // U+202E RLO
 		else { $bdf = 0x2066; $bdf2 = 0x202D; $popd = 'LRILROPDFPDI'; }	// U+2066 LRI  // U+202D LRO
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='plaintext') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='plaintext') { 
 		$bdf = 0x2068; $popd = 'FSIPDI';	// U+2068 FSI
 	}
 	else {
-		if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x202B;  $popd = 'RLEPDF'; }	// U+202B RLE
-		else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x202A;  $popd = 'LREPDF'; }	// U+202A LRE
+		if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'rtl') { $bdf = 0x202B;  $popd = 'RLEPDF'; }	// U+202B RLE
+		else if (isset($attr['DIR']) and strtolower(($attr['DIR'] ?? '')) == 'ltr') { $bdf = 0x202A;  $popd = 'LREPDF'; }	// U+202A LRE
 	}
 
 	if ($bdf) {
@@ -16333,7 +16350,7 @@
 /*-- BOOKMARKS --*/
 		if ($this->anchor2Bookmark) { 
 			$objattr = array();
-			$objattr['CONTENT'] = htmlspecialchars_decode($attr['NAME'],ENT_QUOTES);
+			$objattr['CONTENT'] = htmlspecialchars_decode(($attr['NAME'] ?? ''),ENT_QUOTES);
 			$objattr['type'] = 'bookmark';
 			if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['bklevel'] = $attr['LEVEL']; } else { $objattr['bklevel'] = 0; }
 			$e = "\xbb\xa4\xactype=bookmark,objattr=".serialize($objattr)."\xbb\xa4\xac";
@@ -16410,12 +16427,12 @@
 		$objattr['border_right']['w'] = 0;
 
 		$properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr);
-		if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') { 
+		if(isset($properties ['DISPLAY']) && strtolower(($properties ['DISPLAY'] ?? ''))=='none') { 
 			return; 
 		}
 		$objattr['visibility'] = 'visible'; 
 		if (isset($properties['VISIBILITY'])) {
-			$v = strtolower($properties['VISIBILITY']);
+			$v = strtolower(($properties['VISIBILITY'] ?? ''));
 			if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') { 
 				$objattr['visibility'] = $v; 
 			}
@@ -16436,7 +16453,7 @@
 		if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
 		if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->border_details($properties['BORDER-RIGHT']); }
 
-		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
 		$w = 0;
 		$h = 0;
 		if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
@@ -16447,7 +16464,7 @@
 
 		if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; }
 		if ($this->HREF) {
-			if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+			if (strpos(($this->HREF ?? ''),".") === false && strpos(($this->HREF ?? ''),"@") !== 0) {
 				$href = $this->HREF;
 				while(array_key_exists($href,$this->internallink)) $href="#".$href;
 	    			$this->internallink[$href] = $this->AddLink();
@@ -16463,9 +16480,9 @@
 			include(_MPDF_PATH.'classes/meter.php'); 
 		}
 		$this->meter = new meter();
-		$svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
+		$svg = $this->meter->makeSVG(strtolower(($tag ?? '')), $type, $value, $max, $min, $optimum, $low, $high);
 		//Save to local file
-		$srcpath= _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.strtolower($tag).'.svg';
+		$srcpath= _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.strtolower(($tag ?? '')).'.svg';
 		file_put_contents($srcpath, $svg);
 		$orig_srcpath = $srcpath;
 		$this->GetFullPath($srcpath); 
@@ -16533,7 +16550,7 @@
 	// Added mPDF 3.0 Float DIV - CLEAR
 	if (isset($attr['STYLE'])) {
 		$properties = $this->cssmgr->readInlineCSS($attr['STYLE']);
-		if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper($properties['CLEAR']),$this->blklvl); }	// *CSS-FLOAT*
+		if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper(($properties['CLEAR'] ?? '')),$this->blklvl); }	// *CSS-FLOAT*
 	}
 
 	// mPDF 6 bidi
@@ -16551,16 +16568,16 @@
 	$inlinepre = '';
 	$inlinepost = '';
 	$iBDF = array();
-	if (count($this->InlineBDF)) {
+	if (count(($this->InlineBDF ?? []))) {
 		foreach($this->InlineBDF AS $k => $ib) {
 			foreach($ib AS $ib2) { $iBDF[$ib2[1]] = $ib2[0]; }
 		}
-		if (count($iBDF)) {
+		if (count(($iBDF ?? []))) {
 			ksort($iBDF);
-			for($i=count($iBDF)-1;$i>=0;$i--) {
+			for($i=count(($iBDF ?? []))-1;$i>=0;$i--) {
 				$inlinepre .= $this->_setBidiCodes('end', $iBDF[$i]);
 			}
-			for($i=0;$i<count($iBDF);$i++) {
+			for($i=0;$i<count(($iBDF ?? []));$i++) {
 				$inlinepost .= $this->_setBidiCodes('start', $iBDF[$i]);
 			}
 		}
@@ -16584,9 +16601,9 @@
 	}
 	else  {
 /*-- END TABLES --*/
-		if (count($this->textbuffer)) {
-			$this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/ $/','',$this->textbuffer[count($this->textbuffer)-1][0]);
-			if (!empty($this->textbuffer[count($this->textbuffer)-1][18])) { $this->otl->trimOTLdata($this->textbuffer[count($this->textbuffer)-1][18], false, true); }	// *OTL*
+		if (count(($this->textbuffer ?? []))) {
+			$this->textbuffer[count(($this->textbuffer ?? []))-1][0] = preg_replace('/ $/','',($this->textbuffer[count(($this->textbuffer ?? []))-1][0] ?? ''));
+			if (!empty($this->textbuffer[count(($this->textbuffer ?? []))-1][18])) { $this->otl->trimOTLdata($this->textbuffer[count(($this->textbuffer ?? []))-1][18], false, true); }	// *OTL*
 		}
 		$this->_saveTextBuffer($blockpre.$inlinepre."\n".$inlinepost.$blockpost);
 	}	// *TABLES*
@@ -16654,7 +16671,7 @@
 
 
 	$p = $this->cssmgr->PreviewBlockCSS($tag,$attr);
-	if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') { 
+	if(isset($p['DISPLAY']) && strtolower(($p['DISPLAY'] ?? ''))=='none') { 
 		$this->blklvl++;
 		$this->blk[$this->blklvl]['hide'] = true; 
 		$this->blk[$this->blklvl]['tag'] = $tag; 	// mPDF 6
@@ -16662,10 +16679,10 @@
 	}
 	if($tag == 'CAPTION') {
 		// position is written in AdjstHTML
-		if (isset($attr['POSITION']) && strtolower($attr['POSITION'])=='bottom') { $divpos = 'B'; }
+		if (isset($attr['POSITION']) && strtolower(($attr['POSITION'] ?? ''))=='bottom') { $divpos = 'B'; }
 		else { $divpos = 'T'; }
-		if (isset($attr['ALIGN']) && strtolower($attr['ALIGN'])=='bottom') { $cappos = 'B'; }
-		else if (isset($p['CAPTION-SIDE']) && strtolower($p['CAPTION-SIDE'])=='bottom') { $cappos = 'B'; }
+		if (isset($attr['ALIGN']) && strtolower(($attr['ALIGN'] ?? ''))=='bottom') { $cappos = 'B'; }
+		else if (isset($p['CAPTION-SIDE']) && strtolower(($p['CAPTION-SIDE'] ?? ''))=='bottom') { $cappos = 'B'; }
 		else { $cappos = 'T'; }
 		if (isset($attr['ALIGN'])) { unset($attr['ALIGN']); }
 		if ($cappos != $divpos) {
@@ -16678,7 +16695,7 @@
 
 /*-- FORMS --*/
 	if($tag == 'FORM') {
-		if (isset($attr['METHOD']) && strtolower($attr['METHOD'])=='get') { $this->mpdfform->formMethod = 'GET'; }
+		if (isset($attr['METHOD']) && strtolower(($attr['METHOD'] ?? ''))=='get') { $this->mpdfform->formMethod = 'GET'; }
 		else { $this->mpdfform->formMethod = 'POST'; }
 		if (isset($attr['ACTION'])) { $this->mpdfform->formAction = $attr['ACTION']; }
 		else { $this->mpdfform->formAction = ''; }
@@ -16687,7 +16704,7 @@
 
 
 /*-- CSS-POSITION --*/
-	if ((isset($p['POSITION']) && (strtolower($p['POSITION'])=='fixed' || strtolower($p['POSITION'])=='absolute')) && $this->blklvl==0) {
+	if ((isset($p['POSITION']) && (strtolower(($p['POSITION'] ?? ''))=='fixed' || strtolower(($p['POSITION'] ?? ''))=='absolute')) && $this->blklvl==0) {
 		if ($this->inFixedPosBlock) {
 			$this->Error("Cannot nest block with position:fixed or position:absolute"); 
 		}
@@ -16698,7 +16715,7 @@
 	// Start Block
 	$this->ignorefollowingspaces = true; 
 
-	if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
+	if ($this->blockjustfinished && !count(($this->textbuffer ?? [])) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
 	else { $lastbottommargin = 0; }
 	$this->lastblockbottommargin = 0;
 	$this->blockjustfinished=false;
@@ -16828,9 +16845,9 @@
 		$this->_preForcedPagebreak($pagebreaktype);
 
 		if (isset($p['PAGE-BREAK-BEFORE'])) {
-			if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
-			else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'LEFT') { $this->AddPage($this->CurOrientation,'NEXT-EVEN','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
-			else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'ALWAYS') { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+			if (strtoupper(($p['PAGE-BREAK-BEFORE'] ?? '')) == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+			else if (strtoupper(($p['PAGE-BREAK-BEFORE'] ?? '')) == 'LEFT') { $this->AddPage($this->CurOrientation,'NEXT-EVEN','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+			else if (strtoupper(($p['PAGE-BREAK-BEFORE'] ?? '')) == 'ALWAYS') { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
 			else if ($this->page_box['current'] != $pagesel) { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }	// *CSS-PAGE*
 		}
 /*-- CSS-PAGE --*/
@@ -16856,7 +16873,7 @@
 	$properties = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);	// mPDF 6 - moved to after page-break-before
 
 	// mPDF 6 page-break-inside:avoid
-	if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && !$this->ColActive && !$this->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) {	// avoid re-iterating using PAGEBREAKAVOIDCHECKED; set in CloseTag
+	if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper(($properties['PAGE-BREAK-INSIDE'] ?? '')) == 'AVOID' && !$this->ColActive && !$this->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) {	// avoid re-iterating using PAGEBREAKAVOIDCHECKED; set in CloseTag
 		$currblk['keep_block_together'] = 1;
 		$currblk['array_i'] = $ihtml;	// mPDF 6
 		$this->kt_y00 = $this->y;
@@ -16904,7 +16921,7 @@
 	$currblk['InlineProperties'] = $this->saveInlineProperties();
 
 	if (isset($properties['VISIBILITY'])) {
-		$v = strtolower($properties['VISIBILITY']);
+		$v = strtolower(($properties['VISIBILITY'] ?? ''));
 		if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible' && !$this->tableLevel) { 
 			$currblk['visibility'] = $v; 
 			$this->SetVisibility($v);
@@ -16912,7 +16929,7 @@
 	}
 
 	// mPDF 6
-	if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; }
+	if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower(($attr['ALIGN'] ?? ''))]; }
 
 
 	if (isset($properties['HEIGHT'])) { 
@@ -16925,7 +16942,7 @@
 	// Added mPDF 3.0 Float DIV
 	if (isset($prevblk['blockContext'])) { $currblk['blockContext'] = $prevblk['blockContext'] ; }	// *CSS-FLOAT*
 
-	if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper($properties['CLEAR']), $this->blklvl-1); }	// *CSS-FLOAT*
+	if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper(($properties['CLEAR'] ?? '')), $this->blklvl-1); }	// *CSS-FLOAT*
 
 	$container_w = $prevblk['inner_width'];
 	$bdr = $currblk['border_right']['w'];
@@ -16937,7 +16954,7 @@
 	else { $setwidth = 0; }
 
 /*-- CSS-FLOAT --*/
-	if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'RIGHT' && !$this->ColActive) {
+	if (isset($properties['FLOAT']) && strtoupper(($properties['FLOAT'] ?? '')) == 'RIGHT' && !$this->ColActive) {
 		// Cancel Keep-Block-together
 		$currblk['keep_block_together'] = false;
 		$this->kt_y00 = '';
@@ -16980,7 +16997,7 @@
 			$currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
 		}
 	}
-	else if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'LEFT' && !$this->ColActive) {
+	else if (isset($properties['FLOAT']) && strtoupper(($properties['FLOAT'] ?? '')) == 'LEFT' && !$this->ColActive) {
 		// Cancel Keep-Block-together
 		$currblk['keep_block_together'] = false;
 		$this->kt_y00 = '';
@@ -17099,7 +17116,7 @@
 	}
 
 	if (isset($currblk['css_set_width'])) {
-	  if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') { 
+	  if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto' && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto') { 
 		  // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width)
 		  $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
 		  if ($anyextra>0) {
@@ -17109,14 +17126,14 @@
 			$currblk['margin_left'] = $currblk['margin_right'] = 0;
 		  }
 	  }
-	  else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') { 
+	  else if (isset($properties['MARGIN-LEFT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto') { 
 		  // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
 		  $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']);
 		  if ($currblk['margin_left'] < 0) {
 			$currblk['margin_left'] = 0;
 		  }
 	  }
-	  else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') { 
+	  else if (isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto') { 
 		  // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
 		  $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
 		  if ($currblk['margin_right'] < 0) {
@@ -17229,7 +17246,7 @@
 		if (!isset($currblk['list_style_position']) || !$currblk['list_style_position']) { $currblk['list_style_position'] = 'outside'; }
 
 		// Default indentation using padding
-		if (strtolower($this->list_auto_mode) == 'mpdf' && isset($currblk['list_style_position']) && $currblk['list_style_position'] == 'outside' && isset($currblk['list_style_image']) && $currblk['list_style_image'] == 'none' && (!isset($currblk['list_style_type']) ||!preg_match('/U\+([a-fA-F0-9]+)/i',$currblk['list_style_type'])) ) { 
+		if (strtolower(($this->list_auto_mode ?? '')) == 'mpdf' && isset($currblk['list_style_position']) && $currblk['list_style_position'] == 'outside' && isset($currblk['list_style_image']) && $currblk['list_style_image'] == 'none' && (!isset($currblk['list_style_type']) ||!preg_match('/U\+([a-fA-F0-9]+)/i',($currblk['list_style_type'] ?? ''))) ) { 
 			$autopadding = $this->_getListMarkerWidth($currblk,$ahtml,$ihtml);
 			if ($this->listlvl > 1 || $this->list_indent_first_level) { $autopadding += $this->ConvertSize($this->list_indent_default_mpdf,$currblk['inner_width'],$this->FontSize,false); }
 			// autopadding value is applied to left or right according
@@ -17267,16 +17284,16 @@
 	// Get current direction
 	if (isset($currblk['direction'])) { $currdir = $currblk['direction']; }
 	else { $currdir = 'ltr'; }
-	if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower($attr['DIR']); }
-	if(isset($properties['DIRECTION'])) { $currdir = strtolower($properties['DIRECTION']); }
+	if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower(($attr['DIR'] ?? '')); }
+	if(isset($properties['DIRECTION'])) { $currdir = strtolower(($properties['DIRECTION'] ?? '')); }
 
 	// mPDF 6 bidi
 	// cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
-	if(isset($properties ['UNICODE-BIDI']) && (strtolower($properties ['UNICODE-BIDI'])=='bidi-override' || strtolower($properties ['UNICODE-BIDI'])=='isolate-override')) { 
+	if(isset($properties ['UNICODE-BIDI']) && (strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='bidi-override' || strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='isolate-override')) { 
 		if ($currdir == 'rtl') { $bdf = 0x202E;  $popd = 'RLOPDF';}	// U+202E RLO
 		else { $bdf = 0x202D; $popd = 'LROPDF'; }	// U+202D LRO
 	}
-	else if(isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI'])=='plaintext') { 
+	else if(isset($properties ['UNICODE-BIDI']) && strtolower(($properties ['UNICODE-BIDI'] ?? ''))=='plaintext') { 
 		$bdf = 0x2068; $popd = 'FSIPDI';	// U+2068 FSI
 	}
 	if ($bdf) {
@@ -17294,7 +17311,7 @@
 	// Added mPDF 3.0 Float DIV - CLEAR
 	if (isset($attr['STYLE'])) {
 		$properties = $this->cssmgr->readInlineCSS($attr['STYLE']);
-		if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper($properties['CLEAR']),$this->blklvl); }	// *CSS-FLOAT*
+		if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper(($properties['CLEAR'] ?? '')),$this->blklvl); }	// *CSS-FLOAT*
 	}
 
 	$this->ignorefollowingspaces = true; 
@@ -17315,15 +17332,15 @@
 	if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
 	if (isset($properties['WIDTH'])) { $objattr['width'] = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']); }
 	else if(isset($attr['WIDTH']) && $attr['WIDTH'] != '') $objattr['width'] = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->blklvl]['inner_width']);
-	if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
-	else if(isset($attr['ALIGN']) && $attr['ALIGN'] != '') $objattr['align'] = $align[strtolower($attr['ALIGN'])];
-
-	if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') { 
+	if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower(($properties['TEXT-ALIGN'] ?? ''))]; }
+	else if(isset($attr['ALIGN']) && $attr['ALIGN'] != '') $objattr['align'] = $align[strtolower(($attr['ALIGN'] ?? ''))];
+
+	if (isset($properties['MARGIN-LEFT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto') { 
 		$objattr['align'] = 'R';
 	}
-	if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') { 
+	if (isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto') { 
 		$objattr['align'] = 'L';
-		if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') { 
+		if (isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto' && isset($properties['MARGIN-LEFT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto') { 
 			$objattr['align'] = 'C';
 		}
 	}
@@ -17396,13 +17413,13 @@
      		$objattr['code'] = $attr['CODE'];
 
 		if(isset($attr['TYPE'])) {
-			$objattr['btype'] = trim(strtoupper($attr['TYPE']));
+			$objattr['btype'] = trim((strtoupper(($attr['TYPE'] ?? '')) ?? ''));
 		}
 		else { $objattr['btype'] = 'EAN13'; }	// default
-		if (preg_match('/^(EAN13|ISBN|ISSN|EAN8|UPCA|UPCE)P([25])$/',$objattr['btype'],$m)) {
+		if (preg_match('/^(EAN13|ISBN|ISSN|EAN8|UPCA|UPCE)P([25])$/',($objattr['btype'] ?? ''),$m)) {
 			$objattr['btype'] = $m[1];
 			$objattr['bsupp'] = $m[2];
-			if (preg_match('/^(\S+)\s+(.*)$/',$objattr['code'],$mm)) {
+			if (preg_match('/^(\S+)\s+(.*)$/',($objattr['code'] ?? ''),$mm)) {
 				$objattr['code'] = $mm[1];
 				$objattr['bsupp_code'] = $mm[2];
 			}
@@ -17418,7 +17435,7 @@
 		if(isset($attr['PR']) && $attr['PR']>0) { $objattr['pr_ratio'] = $attr['PR']; }
 		else { $objattr['pr_ratio'] = ''; }
 		$properties = $this->cssmgr->MergeCSS('',$tag,$attr);
-		if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') { 
+		if(isset($properties ['DISPLAY']) && strtolower(($properties ['DISPLAY'] ?? ''))=='none') { 
 			return; 
 		}
 		if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top']=$this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
@@ -17436,7 +17453,7 @@
 		if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
 		if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->border_details($properties['BORDER-RIGHT']); }
 
-		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
 		if (isset($properties['COLOR']) && $properties['COLOR'] != '') { $objattr['color'] = $this->ConvertColor($properties['COLOR']); }
 		else { $objattr['color'] = false; }
 		if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
@@ -17448,7 +17465,7 @@
 		$this->barcode = new PDFBarcode();
 
 		if ($objattr['btype'] == 'EAN13' || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN' || $objattr['btype'] == 'UPCA' || $objattr['btype'] == 'UPCE' || $objattr['btype'] == 'EAN8') {
-			$code = preg_replace('/\-/','',$objattr['code']);
+			$code = preg_replace('/\-/','',($objattr['code'] ?? ''));
 			if ($objattr['btype'] == 'ISSN' || $objattr['btype'] == 'ISBN') {
 				$arrcode = $this->barcode->getBarcodeArray($code, 'EAN13');
 			}
@@ -17500,8 +17517,8 @@
 		$objattr['barcode_width'] = $w;
 /*-- CSS-IMAGE-FLOAT --*/
 		if (!$this->ColActive && !$this->tableLevel && !$this->listlvl && !$this->kwt) {
-		  if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
-			$objattr['float'] = substr(strtoupper($properties['FLOAT']),0,1);
+		  if (isset($properties['FLOAT']) && (strtoupper(($properties['FLOAT'] ?? '')) == 'RIGHT' || strtoupper(($properties['FLOAT'] ?? '')) == 'LEFT')) {
+			$objattr['float'] = substr((strtoupper(($properties['FLOAT'] ?? '')) ?? ''),0,1);
 		  }
 		}
 /*-- END CSS-IMAGE-FLOAT --*/
@@ -17541,7 +17558,7 @@
 		$mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
   		$this->SetFontSize($mmsize*_MPDFK,false);
 	}
-	if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK'])=='true') {
+	if (isset($attr['SPELLCHECK']) && strtolower(($attr['SPELLCHECK'] ?? ''))=='true') {
 		$this->selectoption['SPELLCHECK'] = true; 
 	}
 
@@ -17578,7 +17595,7 @@
 		$attr['VALUE'] = strcode2utf($attr['VALUE']);
 		$attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']);
 		if ($this->onlyCoreFonts)
-			$attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mb_enc,'UTF-8'); 
+			$attr['VALUE'] = mb_convert_encoding(($attr['VALUE'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 	}
 	$this->selectoption['currentVAL'] = $attr['VALUE'];
 	break;
@@ -17598,11 +17615,11 @@
 	if(isset($attr['DISABLED'])) { $objattr['disabled'] = true; }
 	if(isset($attr['READONLY'])) { $objattr['readonly'] = true; }
 	if(isset($attr['REQUIRED'])) { $objattr['required'] = true; }
-	if(isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK'])=='true') { $objattr['spellcheck'] = true; }
+	if(isset($attr['SPELLCHECK']) && strtolower(($attr['SPELLCHECK'] ?? ''))=='true') { $objattr['spellcheck'] = true; }
 	if(isset($attr['TITLE'])) { 
 		$objattr['title'] = $attr['TITLE']; 
 		if ($this->onlyCoreFonts)
-			$objattr['title'] = mb_convert_encoding($objattr['title'], $this->mb_enc,'UTF-8'); 
+			$objattr['title'] = mb_convert_encoding(($objattr['title'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 	}
 	if ($this->useActiveForms) {
 		if(isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; }
@@ -17627,9 +17644,9 @@
 	$objattr['fontfamily'] = $this->FontFamily;
 	$objattr['fontsize'] = $this->FontSizePt;
 	if ($this->useActiveForms) {
-		if(isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
-		else if(isset($attr['ALIGN'])) { $objattr['text_align'] =  $align[strtolower($attr['ALIGN'])]; }
-		if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW'])=='hidden') { $objattr['donotscroll'] = true; }
+		if(isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower(($properties['TEXT-ALIGN'] ?? ''))]; }
+		else if(isset($attr['ALIGN'])) { $objattr['text_align'] =  $align[strtolower(($attr['ALIGN'] ?? ''))]; }
+		if (isset($properties['OVERFLOW']) && strtolower(($properties['OVERFLOW'] ?? ''))=='hidden') { $objattr['donotscroll'] = true; }
 		if (isset($properties['BORDER-TOP-COLOR'])) { $objattr['border-col'] = $this->ConvertColor($properties['BORDER-TOP-COLOR']); }
 		if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
 	}
@@ -17639,7 +17656,7 @@
 	$h = 0;
 	if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
 	if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
-	if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+	if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
 
 	$colsize = 20; //HTML default value 
 	$rowsize = 2; //HTML default value
@@ -17688,14 +17705,14 @@
 	if(isset($attr['DISABLED'])) { $objattr['disabled'] = true; }
 	if(isset($attr['READONLY'])) { $objattr['readonly'] = true; }
 	if(isset($attr['REQUIRED'])) { $objattr['required'] = true; }
-	if(isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK'])=='true') { $objattr['spellcheck'] = true; }
+	if(isset($attr['SPELLCHECK']) && strtolower(($attr['SPELLCHECK'] ?? ''))=='true') { $objattr['spellcheck'] = true; }
 	if(isset($attr['TITLE'])) { $objattr['title'] = $attr['TITLE']; }
 	else if(isset($attr['ALT'])) { $objattr['title'] = $attr['ALT']; }
 	else $objattr['title'] = '';
 	$objattr['title'] = strcode2utf($objattr['title']);
 	$objattr['title'] = $this->lesser_entity_decode($objattr['title']);
 	if ($this->onlyCoreFonts)
-		$objattr['title'] = mb_convert_encoding($objattr['title'], $this->mb_enc,'UTF-8'); 
+		$objattr['title'] = mb_convert_encoding(($objattr['title'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 	if ($this->useActiveForms) {
 		if(isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; }
 	}
@@ -17703,7 +17720,7 @@
 		$attr['VALUE'] = strcode2utf($attr['VALUE']);
 		$attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']);
 		if ($this->onlyCoreFonts)
-			$attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mb_enc,'UTF-8'); 
+			$attr['VALUE'] = mb_convert_encoding(($attr['VALUE'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 		$objattr['value'] = $attr['VALUE']; 
 	}
 
@@ -17722,8 +17739,8 @@
 	$objattr['fontfamily'] = $this->FontFamily;
 	$objattr['fontsize'] = $this->FontSizePt;
 	if ($this->useActiveForms) {
-		if(isset($attr['ALIGN'])) { $objattr['text_align'] = $align[strtolower($attr['ALIGN'])]; }
-		else if(isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
+		if(isset($attr['ALIGN'])) { $objattr['text_align'] = $align[strtolower(($attr['ALIGN'] ?? ''))]; }
+		else if(isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower(($properties['TEXT-ALIGN'] ?? ''))]; }
 		if (isset($properties['BORDER-TOP-COLOR'])) { $objattr['border-col'] = $this->ConvertColor($properties['BORDER-TOP-COLOR']); }
 		if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
 	}
@@ -17737,9 +17754,9 @@
 	$w = 0;
 	if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']);
 
-	if ($properties['VERTICAL-ALIGN']) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
-
-	switch(strtoupper($attr['TYPE'])){
+	if ($properties['VERTICAL-ALIGN']) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
+
+	switch(strtoupper(($attr['TYPE'] ?? ''))){
 	   case 'HIDDEN':
       		$this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
 			if ($this->useActiveForms) {
@@ -17786,7 +17803,7 @@
 		$objattr['padding_left'] = 0;
 		$objattr['padding_right'] = 0;
 
-		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
 
 		$w = 0;
 		$h = 0;
@@ -17832,11 +17849,11 @@
 				$h=($info['h']/_MPDFK) * (72/$this->img_dpi);
 			}
 			if (isset($properties['IMAGE-RESOLUTION'])) { 
-				if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi']>0) {
+				if (preg_match('/from-image/i', ($properties['IMAGE-RESOLUTION'] ?? '')) && isset($info['set-dpi']) && $info['set-dpi']>0) {
 					$w *= $this->img_dpi / $info['set-dpi'];
 					$h *= $this->img_dpi / $info['set-dpi'];
 				}
-				else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
+				else if (preg_match('/(\d+)dpi/i', ($properties['IMAGE-RESOLUTION'] ?? ''), $m)) {
 					$dpi = $m[1]; 
 					if ($dpi > 0) {
 						$w *= $this->img_dpi / $dpi;
@@ -17896,11 +17913,11 @@
 	   case 'BUTTON': // Draw a button
 	   case 'SUBMIT': 
 	   case 'RESET': 
-			$type = strtoupper($attr['TYPE']);
+			$type = strtoupper(($attr['TYPE'] ?? ''));
 			if ($type=='IMAGE') { $type = 'BUTTON'; } // src path not found
 			if(isset($attr['NOPRINT'])) { $objattr['noprint'] = true; }
 			if (!isset($attr['VALUE'])) {
-				$objattr['value'] = ucfirst(strtolower($type));
+				$objattr['value'] = ucfirst((strtolower(($type ?? '')) ?? ''));
 			}
 
 			$texto = " " . $objattr['value'] . " ";
@@ -17915,10 +17932,10 @@
 	   case 'TEXT': 
 	   default:
                 if ($type == '') { $type = 'TEXT'; }
-		    if(strtoupper($attr['TYPE'])=='PASSWORD') { $type = 'PASSWORD'; }
+		    if(strtoupper(($attr['TYPE'] ?? ''))=='PASSWORD') { $type = 'PASSWORD'; }
                 if (isset($attr['VALUE'])) {
 			if ($type == 'PASSWORD') {
-                    $num_stars = mb_strlen($attr['VALUE'],$this->mb_enc );
+                    $num_stars = mb_strlen(($attr['VALUE'] ?? ''),$this->mb_enc );
                     $texto = str_repeat('*',$num_stars);
 			}
 			else { $texto = $attr['VALUE']; }
@@ -17971,9 +17988,9 @@
 	// *********** GRAPH  ********************
      case 'JPGRAPH':
 	if (!$this->useGraphs) { break; }
-	if ($attr['TABLE']) { $gid = strtoupper($attr['TABLE']); }
+	if ($attr['TABLE']) { $gid = strtoupper(($attr['TABLE'] ?? '')); }
 	else { $gid = '0'; }
-	if (!is_array($this->graphs[$gid]) || count($this->graphs[$gid])==0 ) { break; }
+	if (!is_array($this->graphs[$gid]) || count(($this->graphs[$gid] ?? []))==0 ) { break; }
 	$this->ignorefollowingspaces = false; 
 	include_once(_MPDF_PATH.'graph.php');
 	$this->graphs[$gid]['attr'] = $attr;
@@ -18025,7 +18042,7 @@
      		$srcpath = $attr['SRC'];
 		$orig_srcpath = (isset($attr['ORIG_SRC']) ? $attr['ORIG_SRC'] : '');
 		$properties = $this->cssmgr->MergeCSS('',$tag,$attr);
-		if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') { 
+		if(isset($properties ['DISPLAY']) && strtolower(($properties ['DISPLAY'] ?? ''))=='none') { 
 			return; 
 		}
 		if (isset($properties['Z-INDEX']) && $this->current_layer==0) {
@@ -18037,7 +18054,7 @@
 
 		$objattr['visibility'] = 'visible'; 
 		if (isset($properties['VISIBILITY'])) {
-			$v = strtolower($properties['VISIBILITY']);
+			$v = strtolower(($properties['VISIBILITY'] ?? ''));
 			if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') { 
 				$objattr['visibility'] = $v; 
 			}
@@ -18059,7 +18076,7 @@
 		if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
 		if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->border_details($properties['BORDER-RIGHT']); }
 
-		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+		if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
 		$w = 0;
 		$h = 0;
 		if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
@@ -18078,7 +18095,7 @@
 
 		if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; }
 		if ($this->HREF) {
-			if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+			if (strpos(($this->HREF ?? ''),".") === false && strpos(($this->HREF ?? ''),"@") !== 0) {
 				$href = $this->HREF;
 				while(array_key_exists($href,$this->internallink)) $href="#".$href;
 	    			$this->internallink[$href] = $this->AddLink();
@@ -18093,7 +18110,7 @@
 		if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
 
 /*-- BACKGROUNDS --*/
-		if(isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',$properties['GRADIENT-MASK'])) {
+		if(isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',($properties['GRADIENT-MASK'] ?? ''))) {
 	     		$objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK'];
 		}
 /*-- END BACKGROUNDS --*/
@@ -18101,10 +18118,10 @@
 		// mPDF 6
 		$interpolation = false;
 		if (isset($properties['IMAGE-RENDERING']) && $properties['IMAGE-RENDERING']) {
-			if (strtolower($properties['IMAGE-RENDERING']) == 'crisp-edges') { $interpolation = false; }
-			else if (strtolower($properties['IMAGE-RENDERING']) == 'optimizequality') { $interpolation = true; }
-			else if (strtolower($properties['IMAGE-RENDERING']) == 'smooth') { $interpolation = true; }
-			else if (strtolower($properties['IMAGE-RENDERING']) == 'auto') { $interpolation = $this->interpolateImages; }
+			if (strtolower(($properties['IMAGE-RENDERING'] ?? '')) == 'crisp-edges') { $interpolation = false; }
+			else if (strtolower(($properties['IMAGE-RENDERING'] ?? '')) == 'optimizequality') { $interpolation = true; }
+			else if (strtolower(($properties['IMAGE-RENDERING'] ?? '')) == 'smooth') { $interpolation = true; }
+			else if (strtolower(($properties['IMAGE-RENDERING'] ?? '')) == 'auto') { $interpolation = $this->interpolateImages; }
 			else { $interpolation = false; }
 			$info['interpolation'] = $interpolation;
 		}
@@ -18157,11 +18174,11 @@
 				$h=($info['h']/_MPDFK) * (72/$this->img_dpi);
 			}
 			if (isset($properties['IMAGE-RESOLUTION'])) { 
-				if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi']>0) {
+				if (preg_match('/from-image/i', ($properties['IMAGE-RESOLUTION'] ?? '')) && isset($info['set-dpi']) && $info['set-dpi']>0) {
 					$w *= $this->img_dpi / $info['set-dpi'];
 					$h *= $this->img_dpi / $info['set-dpi'];
 				}
-				else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
+				else if (preg_match('/(\d+)dpi/i', ($properties['IMAGE-RESOLUTION'] ?? ''), $m)) {
 					$dpi = $m[1]; 
 					if ($dpi > 0) {
 						$w *= $this->img_dpi / $dpi;
@@ -18214,8 +18231,8 @@
 		$objattr['image_width'] = $w;
 /*-- CSS-IMAGE-FLOAT --*/
 		if (!$this->ColActive && !$this->tableLevel && !$this->listlvl && !$this->kwt) {
-		  if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
-			$objattr['float'] = substr(strtoupper($properties['FLOAT']),0,1);
+		  if (isset($properties['FLOAT']) && (strtoupper(($properties['FLOAT'] ?? '')) == 'RIGHT' || strtoupper(($properties['FLOAT'] ?? '')) == 'LEFT')) {
+			$objattr['float'] = substr((strtoupper(($properties['FLOAT'] ?? '')) ?? ''),0,1);
 		  }
 		}
 /*-- END CSS-IMAGE-FLOAT --*/
@@ -18301,7 +18318,7 @@
 		$this->InlineProperties[$tag] = $this->saveInlineProperties();
 		$properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr);
 
-		if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') { 
+		if(isset($properties ['DISPLAY']) && strtolower(($properties ['DISPLAY'] ?? ''))=='none') { 
 			return; 
 		}
 		if (isset($attr['R'])) { $objattr['r']=$this->ConvertSize($attr['R'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
@@ -18309,13 +18326,13 @@
 			$objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
 			$objattr['top-text'] = $this->lesser_entity_decode($objattr['top-text']);
 			if ($this->onlyCoreFonts)
-				$objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mb_enc,'UTF-8'); 
+				$objattr['top-text'] = mb_convert_encoding(($objattr['top-text'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 		}
 		if(isset($attr['BOTTOM-TEXT'])) { 
 			$objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
 			$objattr['bottom-text'] = $this->lesser_entity_decode($objattr['bottom-text']);
 			if ($this->onlyCoreFonts)
-				$objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mb_enc,'UTF-8'); 
+				$objattr['bottom-text'] = mb_convert_encoding(($objattr['bottom-text'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 		}
 		if(isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) { $objattr['space-width'] = $attr['SPACE-WIDTH']; }
 		if(isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) { $objattr['char-width'] = $attr['CHAR-WIDTH']; }
@@ -18323,13 +18340,13 @@
 		// VISIBILITY
 		$objattr['visibility'] = 'visible'; 
 		if (isset($properties['VISIBILITY'])) {
-			$v = strtolower($properties['VISIBILITY']);
+			$v = strtolower(($properties['VISIBILITY'] ?? ''));
 			if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') { 
 				$objattr['visibility'] = $v; 
 			}
 		}
 		if (isset($properties['FONT-SIZE'])) { 
-		  if (strtolower($properties['FONT-SIZE'])=='auto') {
+		  if (strtolower(($properties['FONT-SIZE'] ?? ''))=='auto') {
 			if ($objattr['top-text'] && $objattr['bottom-text']) {
 				$objattr['fontsize'] = -2;
 			}
@@ -18347,7 +18364,7 @@
 			$objattr['divider'] = strcode2utf($attr['DIVIDER']);
 			$objattr['divider'] = $this->lesser_entity_decode($objattr['divider']);
 			if ($this->onlyCoreFonts)
-				$objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mb_enc,'UTF-8'); 
+				$objattr['divider'] = mb_convert_encoding(($objattr['divider'] ?? ''), ($this->mb_enc ?? ''),'UTF-8'); 
 
 		}
 
@@ -18355,10 +18372,10 @@
 
 		$objattr['fontstyle'] = '';
 		if (isset($properties['FONT-WEIGHT'])) {
-			if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD')	{ $objattr['fontstyle'] .= 'B'; }
+			if (strtoupper(($properties['FONT-WEIGHT'] ?? '')) == 'BOLD')	{ $objattr['fontstyle'] .= 'B'; }
 		}
 		if (isset($properties['FONT-STYLE'])) {
-			if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $objattr['fontstyle'] .= 'I'; }
+			if (strtoupper(($properties['FONT-STYLE'] ?? '')) == 'ITALIC') { $objattr['fontstyle'] .= 'I'; }
 		}
 
 		if (isset($properties['FONT-FAMILY'])) { 
@@ -18386,7 +18403,7 @@
 		if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
 		else { $objattr['bgcolor'] = false; }
 		if ($this->HREF) {
-			if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+			if (strpos(($this->HREF ?? ''),".") === false && strpos(($this->HREF ?? ''),"@") !== 0) {
 				$href = $this->HREF;
 				while(array_key_exists($href,$this->internallink)) $href="#".$href;
 	    			$this->internallink[$href] = $this->AddLink();
@@ -18436,11 +18453,11 @@
 	if ($this->lastblocklevelchange == 1) { $blockstate = 1; }	// Top margins/padding only
 	else if ($this->lastblocklevelchange < 1) { $blockstate = 0; }	// NO margins/padding
 	// called from block after new div e.g. <div> ... <table> ...    Outputs block top margin/border and padding
-	if (count($this->textbuffer) == 0 && $this->lastblocklevelchange == 1 && !$this->tableLevel && !$this->kwt) {
+	if (count(($this->textbuffer ?? [])) == 0 && $this->lastblocklevelchange == 1 && !$this->tableLevel && !$this->kwt) {
 		$this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,1,true, $this->blk[$this->blklvl]['direction']);
 		$this->finishFlowingBlock(true);	// true = END of flowing block
 	}
-	else if (!$this->tableLevel && count($this->textbuffer)) { $this->printbuffer($this->textbuffer,$blockstate); }
+	else if (!$this->tableLevel && count(($this->textbuffer ?? []))) { $this->printbuffer($this->textbuffer,$blockstate); }
 
 	$this->textbuffer=array();
 	$this->lastblocklevelchange = -1;
@@ -18538,7 +18555,7 @@
 	}
 
 
-	if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins && $this->tableLevel==1) { $lastbottommargin = $this->lastblockbottommargin; }
+	if ($this->blockjustfinished && !count(($this->textbuffer ?? [])) && $this->y != $this->tMargin && $this->collapseBlockMargins && $this->tableLevel==1) { $lastbottommargin = $this->lastblockbottommargin; }
 	else { $lastbottommargin = 0; }
 	$this->lastblockbottommargin = 0;
 	$this->blockjustfinished=false;
@@ -18561,22 +18578,22 @@
 	if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
 	else if (isset($attr['WIDTH']) && $attr['WIDTH']) { $w = $attr['WIDTH']; }
 
-	if (isset($attr['ALIGN']) && isset($align[strtolower($attr['ALIGN'])])) { $table['a'] = $align[strtolower($attr['ALIGN'])]; }
+	if (isset($attr['ALIGN']) && isset($align[strtolower(($attr['ALIGN'] ?? ''))])) { $table['a'] = $align[strtolower(($attr['ALIGN'] ?? ''))]; }
 	if (!$table['a']) { 
 		if ($table['direction'] == 'rtl' ) { $table['a'] = 'R'; }
 		else { $table['a'] = 'L'; }
 	}
 
-	if(isset($properties['DIRECTION']) && $properties['DIRECTION']) { $table['direction'] = strtolower($properties['DIRECTION']); }
-	else if(isset($attr['DIR']) && $attr['DIR']) { $table['direction'] = strtolower($attr['DIR']); }
+	if(isset($properties['DIRECTION']) && $properties['DIRECTION']) { $table['direction'] = strtolower(($properties['DIRECTION'] ?? '')); }
+	else if(isset($attr['DIR']) && $attr['DIR']) { $table['direction'] = strtolower(($attr['DIR'] ?? '')); }
 	else if ($this->tableLevel == 1) { $table['direction'] = $this->blk[$this->blklvl]['direction']; }
 
 	if (isset($properties['BACKGROUND-COLOR'])) { $table['bgcolor'][-1] = $properties['BACKGROUND-COLOR'];	}
 	else if (isset($properties['BACKGROUND'])) { $table['bgcolor'][-1] = $properties['BACKGROUND'];	}
 	else if (isset($attr['BGCOLOR'])) { $table['bgcolor'][-1]	= $attr['BGCOLOR']; }
 
-	if (isset($properties['VERTICAL-ALIGN']) && isset($align[strtolower($properties['VERTICAL-ALIGN'])])) { $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
-	if (isset($properties['TEXT-ALIGN']) && isset($align[strtolower($properties['TEXT-ALIGN'])])) { $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
+	if (isset($properties['VERTICAL-ALIGN']) && isset($align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))])) { $table['va'] = $align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
+	if (isset($properties['TEXT-ALIGN']) && isset($align[strtolower(($properties['TEXT-ALIGN'] ?? ''))])) { $table['txta'] = $align[strtolower(($properties['TEXT-ALIGN'] ?? ''))]; }
 
 	if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->tableLevel ==1)	{ 
 		$this->shrink_this_table_to_fit = $properties['AUTOSIZE']; 
@@ -18660,10 +18677,10 @@
 	$this->base_table_properties['FONT-SIZE'] = $this->FontSize.'mm';
 
 	if (isset($properties['FONT-WEIGHT'])) {
-		if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD')	{ $this->base_table_properties['FONT-WEIGHT'] = 'BOLD'; }
+		if (strtoupper(($properties['FONT-WEIGHT'] ?? '')) == 'BOLD')	{ $this->base_table_properties['FONT-WEIGHT'] = 'BOLD'; }
 	}
 	if (isset($properties['FONT-STYLE'])) {
-		if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->base_table_properties['FONT-STYLE'] = 'ITALIC'; }
+		if (strtoupper(($properties['FONT-STYLE'] ?? '')) == 'ITALIC') { $this->base_table_properties['FONT-STYLE'] = 'ITALIC'; }
 	}
 	if (isset($properties['COLOR'])) {
 		$this->base_table_properties['COLOR'] = $properties['COLOR'];
@@ -18684,11 +18701,11 @@
 	if(isset($properties['LINE-HEIGHT']) && $properties['LINE-HEIGHT']) { $table['cellLineHeight'] = $this->fixLineheight($properties['LINE-HEIGHT']); }
 	else if ($this->tableLevel == 1) { $table['cellLineHeight'] = $this->blk[$this->blklvl]['line_height']; }
 
-	if(isset($properties['LINE-STACKING-STRATEGY']) && $properties['LINE-STACKING-STRATEGY']) { $table['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']); }
+	if(isset($properties['LINE-STACKING-STRATEGY']) && $properties['LINE-STACKING-STRATEGY']) { $table['cellLineStackingStrategy'] = strtolower(($properties['LINE-STACKING-STRATEGY'] ?? '')); }
 	else if ($this->tableLevel == 1 && isset($this->blk[$this->blklvl]['line_stacking_strategy'])) { $table['cellLineStackingStrategy'] = $this->blk[$this->blklvl]['line_stacking_strategy']; }
 	else { $table['cellLineStackingStrategy'] = 'inline-line-height'; }
 
-	if(isset($properties['LINE-STACKING-SHIFT']) && $properties['LINE-STACKING-SHIFT']) { $table['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']); }
+	if(isset($properties['LINE-STACKING-SHIFT']) && $properties['LINE-STACKING-SHIFT']) { $table['cellLineStackingShift'] = strtolower(($properties['LINE-STACKING-SHIFT'] ?? '')); }
 	else if ($this->tableLevel == 1 && isset($this->blk[$this->blklvl]['line_stacking_shift'])) { $table['cellLineStackingShift'] = $this->blk[$this->blklvl]['line_stacking_shift']; }
 	else { $table['cellLineStackingShift'] = 'consider-shifts'; }
 
@@ -18724,17 +18741,17 @@
 	if (isset($properties['MARGIN-RIGHT'])) {
 		$table['margin']['R'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); 
 	}
-	if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') { 
+	if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto' && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto') { 
 		$table['a'] = 'C'; 
 	}
-	else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') { 
+	else if (isset($properties['MARGIN-LEFT']) && strtolower(($properties['MARGIN-LEFT'] ?? ''))=='auto') { 
 		$table['a'] = 'R'; 
 	}
-	else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') { 
+	else if (isset($properties['MARGIN-RIGHT']) && strtolower(($properties['MARGIN-RIGHT'] ?? ''))=='auto') { 
 		$table['a'] = 'L'; 
 	}
 
-	if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE'])=='SEPARATE') { 
+	if (isset($properties['BORDER-COLLAPSE']) && strtoupper(($properties['BORDER-COLLAPSE'] ?? ''))=='SEPARATE') { 
 		$table['borders_separate'] = true; 
 	}
 	else { 
@@ -18753,18 +18770,18 @@
 	if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; }
 
 	if (isset($properties['EMPTY-CELLS'])) { 
-		$table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); 	// 'hide'  or 'show'
+		$table['empty_cells'] = strtolower(($properties['EMPTY-CELLS'] ?? '')); 	// 'hide'  or 'show'
 	}
 	else { $table['empty_cells'] = ''; } 
 
-	if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE'])=='AVOID' && $this->tableLevel==1 && !$this->writingHTMLfooter) {
+	if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper(($properties['PAGE-BREAK-INSIDE'] ?? ''))=='AVOID' && $this->tableLevel==1 && !$this->writingHTMLfooter) {
 		$this->table_keep_together = true; 
 	}
 	else if ($this->tableLevel==1) { 
 		$this->table_keep_together = false; 
 	}
 	if (isset($properties['PAGE-BREAK-AFTER']) && $this->tableLevel==1) {
-		$table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
+		$table['page_break_after'] = strtoupper(($properties['PAGE-BREAK-AFTER'] ?? ''));
 	}
 
 /*-- BACKGROUNDS --*/
@@ -18777,7 +18794,7 @@
 /*-- END BACKGROUNDS --*/
 
 	if (isset($properties['OVERFLOW']))	{ 
-		$table['overflow'] = strtolower($properties['OVERFLOW']); 	// 'hidden' 'wrap' or 'visible' or 'auto'
+		$table['overflow'] = strtolower(($properties['OVERFLOW'] ?? '')); 	// 'hidden' 'wrap' or 'visible' or 'auto'
 		if (($this->ColActive || $this->tableLevel>1) && $table['overflow']=='visible') { unset($table['overflow']); }
 	}
 
@@ -18814,16 +18831,16 @@
 		else { 
 			$tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2;
 		}
-		if (strpos($w,'%') && $this->tableLevel == 1 && !$this->ignore_table_percents ) { 
+		if (strpos(($w ?? ''),'%') && $this->tableLevel == 1 && !$this->ignore_table_percents ) { 
 			// % needs to be of inner box without table margins etc.
 			$maxwidth -= $tblblw ;
 			$wmm = $this->ConvertSize($w,$maxwidth,$this->FontSize,false);
 			$table['w'] = $wmm + $tblblw ;
 		}
-		if (strpos($w,'%') && $this->tableLevel > 1 && !$this->ignore_table_percents && $this->keep_table_proportions) { 
+		if (strpos(($w ?? ''),'%') && $this->tableLevel > 1 && !$this->ignore_table_percents && $this->keep_table_proportions) { 
 			$table['wpercent'] = $w + 0; 	// makes 80% -> 80
 		}
-		if (!strpos($w,'%') && !$this->ignore_table_widths ) {
+		if (!strpos(($w ?? ''),'%') && !$this->ignore_table_widths ) {
 			$wmm = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
 			$table['w'] = $wmm + $tblblw ;
 		}
@@ -18856,7 +18873,7 @@
 	}
 
 	if ($this->tableLevel==1 && $this->useGraphs) { 
-		if (isset($attr['ID']) && $attr['ID']) { $this->currentGraphId = strtoupper($attr['ID']); }
+		if (isset($attr['ID']) && $attr['ID']) { $this->currentGraphId = strtoupper(($attr['ID'] ?? '')); }
 		else { $this->currentGraphId = '0'; }
 		$this->graphs[$this->currentGraphId] = array();
 	}
@@ -18872,16 +18889,16 @@
 	$this->tabletfoot = 0; 
 	$properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
 	if (isset($properties['FONT-WEIGHT'])) {
-		if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD')	{ $this->thead_font_weight = 'B'; }
+		if (strtoupper(($properties['FONT-WEIGHT'] ?? '')) == 'BOLD')	{ $this->thead_font_weight = 'B'; }
 		else { $this->thead_font_weight = ''; }
 	}
 
 	if (isset($properties['FONT-STYLE'])) {
-		if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->thead_font_style = 'I'; }
+		if (strtoupper(($properties['FONT-STYLE'] ?? '')) == 'ITALIC') { $this->thead_font_style = 'I'; }
 		else { $this->thead_font_style = ''; }
 	}
 	if (isset($properties['FONT-VARIANT'])) {
-		if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->thead_font_smCaps = 'S'; }
+		if (strtoupper(($properties['FONT-VARIANT'] ?? '')) == 'SMALL-CAPS') { $this->thead_font_smCaps = 'S'; }
 		else { $this->thead_font_smCaps = ''; }
 	}
 
@@ -18901,16 +18918,16 @@
 	$this->tablethead = 0;
 	$properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
 	if (isset($properties['FONT-WEIGHT'])) {
-		if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD')	{ $this->tfoot_font_weight = 'B'; }
+		if (strtoupper(($properties['FONT-WEIGHT'] ?? '')) == 'BOLD')	{ $this->tfoot_font_weight = 'B'; }
 		else { $this->tfoot_font_weight = ''; }
 	}
 
 	if (isset($properties['FONT-STYLE'])) {
-		if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->tfoot_font_style = 'I'; }
+		if (strtoupper(($properties['FONT-STYLE'] ?? '')) == 'ITALIC') { $this->tfoot_font_style = 'I'; }
 		else { $this->tfoot_font_style = ''; }
 	}
 	if (isset($properties['FONT-VARIANT'])) {	
-		if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->tfoot_font_smCaps = 'S'; }
+		if (strtoupper(($properties['FONT-VARIANT'] ?? '')) == 'SMALL-CAPS') { $this->tfoot_font_smCaps = 'S'; }
 		else { $this->tfoot_font_smCaps = ''; }
 	}
 
@@ -19073,8 +19090,8 @@
 	} 
 	// INHERITED THEAD CSS Properties
 	if ($this->tablethead) { 
-		if ($this->thead_valign_default) $c['va'] = $align[strtolower($this->thead_valign_default)]; 
-		if ($this->thead_textalign_default) $c['a'] = $align[strtolower($this->thead_textalign_default)]; 
+		if ($this->thead_valign_default) $c['va'] = $align[strtolower(($this->thead_valign_default ?? ''))]; 
+		if ($this->thead_textalign_default) $c['a'] = $align[strtolower(($this->thead_textalign_default ?? ''))]; 
 		if ($this->thead_font_weight == 'B') { $this->SetStyle('B',true); }
 		if ($this->thead_font_style == 'I') { $this->SetStyle('I',true); }
 		if ($this->thead_font_smCaps == 'S') { $this->textvar = ($this->textvar | FC_SMALLCAPS); }	// mPDF 5.7.1
@@ -19082,8 +19099,8 @@
 
 	// INHERITED TFOOT CSS Properties
 	if ($this->tabletfoot) { 
-		if ($this->tfoot_valign_default) $c['va'] = $align[strtolower($this->tfoot_valign_default)]; 
-		if ($this->tfoot_textalign_default) $c['a'] = $align[strtolower($this->tfoot_textalign_default)]; 
+		if ($this->tfoot_valign_default) $c['va'] = $align[strtolower(($this->tfoot_valign_default ?? ''))]; 
+		if ($this->tfoot_textalign_default) $c['a'] = $align[strtolower(($this->tfoot_textalign_default ?? ''))]; 
 		if ($this->tfoot_font_weight == 'B') { $this->SetStyle('B',true); }
 		if ($this->tfoot_font_style == 'I') { $this->SetStyle('I',true); }
 		if ($this->tfoot_font_style == 'S') { $this->textvar = ($this->textvar | FC_SMALLCAPS); }	// mPDF 5.7.1
@@ -19125,31 +19142,31 @@
 		if ($ret) { $c['background-image'] = $ret; }
 	}
 /*-- END BACKGROUNDS --*/
-	if (isset($properties['VERTICAL-ALIGN'])) { $c['va']=$align[strtolower($properties['VERTICAL-ALIGN'])]; }
-	else if (isset($attr['VALIGN'])) $c['va'] = $align[strtolower($attr['VALIGN'])];
+	if (isset($properties['VERTICAL-ALIGN'])) { $c['va']=$align[strtolower(($properties['VERTICAL-ALIGN'] ?? ''))]; }
+	else if (isset($attr['VALIGN'])) $c['va'] = $align[strtolower(($attr['VALIGN'] ?? ''))];
 
 
 	if (isset($properties['TEXT-ALIGN']) && $properties['TEXT-ALIGN']) {
-		if (substr($properties['TEXT-ALIGN'],0,1)=='D') { $c['a'] = $properties['TEXT-ALIGN']; }
-		else { $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
+		if (substr(($properties['TEXT-ALIGN'] ?? ''),0,1)=='D') { $c['a'] = $properties['TEXT-ALIGN']; }
+		else { $c['a'] = $align[strtolower(($properties['TEXT-ALIGN'] ?? ''))]; }
 	}
 	if (isset($attr['ALIGN']) && $attr['ALIGN']) {
-		if (strtolower($attr['ALIGN']) == 'char') { 
+		if (strtolower(($attr['ALIGN'] ?? '')) == 'char') { 
 			if (isset($attr['CHAR']) && $attr['CHAR']) {
-				$char = html_entity_decode($attr['CHAR']);
+				$char = html_entity_decode(($attr['CHAR'] ?? ''));
 				$char = strcode2utf($char);
 				$d = array_search($char,$this->decimal_align);
 				if ($d !== false) { $c['a'] = $d.'R'; }
 			}
 			else { $c['a'] = 'DPR'; }
 		}
-		else { $c['a'] = $align[strtolower($attr['ALIGN'])]; }
+		else { $c['a'] = $align[strtolower(($attr['ALIGN'] ?? ''))]; }
 	}
 
 	// mPDF 6
 	$c['direction'] = $table['direction'];
-	if (isset($attr['DIR']) and $attr['DIR'] != '') { $c['direction'] = strtolower($attr['DIR']); }
-	if(isset($properties['DIRECTION'])) { $c['direction'] = strtolower($properties['DIRECTION']); }
+	if (isset($attr['DIR']) and $attr['DIR'] != '') { $c['direction'] = strtolower(($attr['DIR'] ?? '')); }
+	if(isset($properties['DIRECTION'])) { $c['direction'] = strtolower(($properties['DIRECTION'] ?? '')); }
 
 	if (!$c['a']) {
 		if (isset($c['direction']) && $c['direction'] == 'rtl' ) { $c['a'] = 'R'; }
@@ -19160,10 +19177,10 @@
 	if(isset($properties['LINE-HEIGHT'])) { $c['cellLineHeight'] = $this->fixLineheight($properties['LINE-HEIGHT']); }
 
 	$c['cellLineStackingStrategy'] = $table['cellLineStackingStrategy'];
-	if(isset($properties['LINE-STACKING-STRATEGY'])) { $c['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']); }
+	if(isset($properties['LINE-STACKING-STRATEGY'])) { $c['cellLineStackingStrategy'] = strtolower(($properties['LINE-STACKING-STRATEGY'] ?? '')); }
 
 	$c['cellLineStackingShift'] = $table['cellLineStackingShift'];
-	if(isset($properties['LINE-STACKING-SHIFT'])) { $c['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']); }
+	if(isset($properties['LINE-STACKING-SHIFT'])) { $c['cellLineStackingShift'] = strtolower(($properties['LINE-STACKING-SHIFT'] ?? '')); }
 
 	if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE']==="0")){
 		$c['R'] = $properties['TEXT-ROTATE']; 
@@ -19266,15 +19283,15 @@
 	if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
 	else if (isset($attr['WIDTH'])) { $w = $attr['WIDTH']; }
 	if ($w) { 
-		if (strpos($w,'%') && !$this->ignore_table_percents ) { $c['wpercent'] = $w + 0; }	// makes 80% -> 80
-		else if (!strpos($w,'%') && !$this->ignore_table_widths ) { $c['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
-	}
-
-	if (isset($properties['HEIGHT']) && !strpos($properties['HEIGHT'],'%')) { $c['h'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
-	else if (isset($attr['HEIGHT']) && !strpos($attr['HEIGHT'],'%')) $c['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+		if (strpos(($w ?? ''),'%') && !$this->ignore_table_percents ) { $c['wpercent'] = $w + 0; }	// makes 80% -> 80
+		else if (!strpos(($w ?? ''),'%') && !$this->ignore_table_widths ) { $c['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+	}
+
+	if (isset($properties['HEIGHT']) && !strpos(($properties['HEIGHT'] ?? ''),'%')) { $c['h'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+	else if (isset($attr['HEIGHT']) && !strpos(($attr['HEIGHT'] ?? ''),'%')) $c['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
 
 	if (isset($properties['WHITE-SPACE'])) {
-		if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') { $c['nowrap']= 1; }
+		if (strtoupper(($properties['WHITE-SPACE'] ?? '')) == 'NOWRAP') { $c['nowrap']= 1; }
 	}
 	$properties = array();
 
@@ -19321,7 +19338,7 @@
 	$spacer = ' ';
 	// IMAGE
 	if ($listitemimage && $listitemimage != 'none') {
-		$listitemimage = trim(preg_replace('/url\(["\']*(.*?)["\']*\)/','\\1',$listitemimage));
+		$listitemimage = trim((preg_replace('/url\(["\']*(.*?)["\']*\)/','\\1',($listitemimage ?? '')) ?? ''));
 
 		// ? Restrict maximum height/width of list marker??
 		$maxWidth = 100;
@@ -19461,10 +19478,10 @@
 	//	}
 	}
 	// SYMBOL 2 (needs new font)
-	else if (preg_match('/U\+([a-fA-F0-9]+)/i',$listitemtype,$m)) {
+	else if (preg_match('/U\+([a-fA-F0-9]+)/i',($listitemtype ?? ''),$m)) {
 		if ($this->_charDefined($this->CurrentFont['cw'],hexdec($m[1]))) { $list_item_marker = codeHex2utf($m[1]); }
 		else { $list_item_marker = '-'; }
-		if (preg_match('/rgb\(.*?\)/',$listitemtype,$m)) {
+		if (preg_match('/rgb\(.*?\)/',($listitemtype ?? ''),$m)) {
 			$list_item_color = $this->ConvertColor($m[0]); 
 		}
 		else { $list_item_color = ''; }
@@ -19509,7 +19526,7 @@
 		else {
 			if (isset($this->blk[$this->blklvl]['direction']) && $this->blk[$this->blklvl]['direction'] == 'rtl') {
 				// REPLACE MIRRORED RTL $this->list_number_suffix  e.g. ) -> (  (NB could use UCDN::$mirror_pairs)
-				$m =  strtr($this->list_number_suffix, ")]}", "([{") . $num; 
+				$m =  strtr(($this->list_number_suffix ?? ''), ")]}", "([{") . $num; 
 			}
 			else { $m = $num . $this->list_number_suffix; }
 
@@ -19544,21 +19561,21 @@
 	$maxnum = $this->listcounter[$this->listlvl];
 	if ($currblk['list_style_type'] != 'disc' && $currblk['list_style_type'] != 'circle' && $currblk['list_style_type'] != 'square') {
 		$lvl = 1;
-		for($j=$i+2;$j<count($a);$j+=2) {
+		for($j=$i+2;$j<count(($a ?? []));$j+=2) {
 			$e = $a[$j];
 			if (!$e) { continue; }
 			if($e[0]=='/') {	// end tag
-				$e = strtoupper(substr($e,1));
+				$e = strtoupper((substr(($e ?? ''),1) ?? ''));
 				if ($e=='OL' || $e=='UL') { 
 					if ($lvl==1) { break; }
 					$lvl--;
 				}
 			}
 			else { // opening tag
-				if (strpos($e,' ')) {
-					$e = substr($e,0,strpos($e,' ')); 
-				}
-				$e = strtoupper($e);
+				if (strpos(($e ?? ''),' ')) {
+					$e = substr(($e ?? ''),0,strpos(($e ?? ''),' ')); 
+				}
+				$e = strtoupper(($e ?? ''));
 				if ($e=='LI') {
 					if ($lvl==1) { $maxnum++; }
 				}
@@ -19572,7 +19589,7 @@
 	switch($currblk['list_style_type']) {
 		case 'decimal':
 		case '1':
-			$blt_width = $this->GetStringWidth(str_repeat('5',strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat('5',strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'none':
   			$blt_width = 0;
@@ -19582,14 +19599,14 @@
 		case 'A':
 			$maxnumA = $this->dec2alpha($maxnum,true);
 			if ($maxnum < 13) { $blt_width = $this->GetStringWidth('D'.$this->list_number_suffix); }
-			else { $blt_width = $this->GetStringWidth(str_repeat('W',strlen($maxnumA)).$this->list_number_suffix); } 
+			else { $blt_width = $this->GetStringWidth(str_repeat('W',strlen(($maxnumA ?? ''))).$this->list_number_suffix); } 
 			break;
 		case 'lower-alpha':
 		case 'lower-latin':
 		case 'a':
 			$maxnuma = $this->dec2alpha($maxnum,false);
 			if ($maxnum < 13) { $blt_width = $this->GetStringWidth('b'.$this->list_number_suffix); }
-			else { $blt_width = $this->GetStringWidth(str_repeat('m',strlen($maxnuma)).$this->list_number_suffix); } 
+			else { $blt_width = $this->GetStringWidth(str_repeat('m',strlen(($maxnuma ?? ''))).$this->list_number_suffix); } 
 			break;
 		case 'upper-roman':
 		case 'I':
@@ -19635,44 +19652,44 @@
               	break;
 
 		case 'arabic-indic':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0660),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0660) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'persian':
 		case 'urdu':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x06F0),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x06F0) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'bengali':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x09E6),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x09E6) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'devanagari':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0966),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0966) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'gujarati':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0AE6),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0AE6) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'gurmukhi':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0A66),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0A66) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'kannada':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0CE6),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0CE6) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'malayalam':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(6, 0x0D66),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(6, 0x0D66) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'oriya':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0B66),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0B66) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'telugu':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, 0x0C66),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(3, 0x0C66) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'tamil':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(9, 0x0BE6),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(9, 0x0BE6) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		case 'thai':
-			$blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, 0x0E50),strlen($maxnum)).$this->list_number_suffix);
+			$blt_width = $this->GetStringWidth(str_repeat(($this->dec2other(5, 0x0E50) ?? ''),strlen(($maxnum ?? ''))).$this->list_number_suffix);
 			break;
 		default:
-	        $blt_width = $this->GetStringWidth(str_repeat('5',strlen($maxnum)).$this->list_number_suffix);
+	        $blt_width = $this->GetStringWidth(str_repeat('5',strlen(($maxnum ?? ''))).$this->list_number_suffix);
               break;
 	}
 
@@ -19691,7 +19708,7 @@
     if($tag=='TTS' or $tag=='TTA' or $tag=='TTZ') {
 	if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
 	unset($this->InlineProperties[$tag]);
-	$ltag = strtolower($tag);
+	$ltag = strtolower(($tag ?? ''));
 	$this->$ltag = false;
     }
 
@@ -19713,14 +19730,14 @@
 		unset($this->InlineAnnots[$tag]);	// *ANNOTATIONS*
 	}
 	else { 
-		if (isset($this->InlineProperties[$tag]) && count($this->InlineProperties[$tag])) { 
+		if (isset($this->InlineProperties[$tag]) && count(($this->InlineProperties[$tag] ?? []))) { 
 			$tmpProps = array_pop($this->InlineProperties[$tag]);	// mPDF 5.7.4
 			$this->restoreInlineProperties($tmpProps);
 		}
-		if (isset($this->InlineAnnots[$tag]) && count($this->InlineAnnots[$tag])) { 	// *ANNOTATIONS*
+		if (isset($this->InlineAnnots[$tag]) && count(($this->InlineAnnots[$tag] ?? []))) { 	// *ANNOTATIONS*
 			$annot = array_pop($this->InlineAnnots[$tag]); 	// *ANNOTATIONS*
 		}	// *ANNOTATIONS*
-		if (isset($this->InlineBDF[$tag]) && count($this->InlineBDF[$tag])) { 	// mPDF 6
+		if (isset($this->InlineBDF[$tag]) && count(($this->InlineBDF[$tag] ?? []))) { 	// mPDF 6
 			$bdfarr = array_pop($this->InlineBDF[$tag]);
 			$bdf = $bdfarr[0];
 		}
@@ -19762,9 +19779,9 @@
     }
 
     if($tag=='LEGEND') {
-	if (count($this->textbuffer) && !$this->tableLevel) { 
-		$leg = $this->textbuffer[(count($this->textbuffer)-1)]; 
-		unset($this->textbuffer[(count($this->textbuffer)-1)]);
+	if (count(($this->textbuffer ?? [])) && !$this->tableLevel) { 
+		$leg = $this->textbuffer[(count(($this->textbuffer ?? []))-1)]; 
+		unset($this->textbuffer[(count(($this->textbuffer ?? []))-1)]);
 		$this->textbuffer = array_values($this->textbuffer);
 		$this->blk[$this->blklvl]['border_legend'] = $leg;
 		$this->blk[$this->blklvl]['margin_top'] += ($leg[11]/2)/_MPDFK;
@@ -19882,13 +19899,13 @@
 		$this->listitem = array();
 	}
 
-	if (preg_match('/^H\d/',$tag) && !$this->tableLevel && !$this->writingToC) {
+	if (preg_match('/^H\d/',($tag ?? '')) && !$this->tableLevel && !$this->writingToC) {
 		if (isset($this->h2toc[$tag]) || isset($this->h2bookmarks[$tag])) {
 			$content = '';
-			if (count($this->textbuffer)==1) { $content = $this->textbuffer[0][0]; }
+			if (count(($this->textbuffer ?? []))==1) { $content = $this->textbuffer[0][0]; }
 			else {
-				for ($i=0;$i<count($this->textbuffer);$i++) {
-      				if (substr($this->textbuffer[$i][0],0,3) != "\xbb\xa4\xac") { //inline object
+				for ($i=0;$i<count(($this->textbuffer ?? []));$i++) {
+      				if (substr(($this->textbuffer[$i][0] ?? ''),0,3) != "\xbb\xa4\xac") { //inline object
 						$content .= $this->textbuffer[$i][0];
 					}
 				}
@@ -19898,7 +19915,7 @@
 				$objattr = array();
 				$objattr['type'] = 'toc';
 				$objattr['toclevel'] = $this->h2toc[$tag];
-				$objattr['CONTENT'] = htmlspecialchars($content);
+				$objattr['CONTENT'] = htmlspecialchars(($content ?? ''));
 				$e = "\xbb\xa4\xactype=toc,objattr=".serialize($objattr)."\xbb\xa4\xac";
 				array_unshift($this->textbuffer,array($e));
 			}
@@ -19943,7 +19960,7 @@
 		if ($old_page != $new_page) {
 			$s = $this->PrintPageBackgrounds();
 			// Writes after the marker so not overwritten later by page background etc.
-			$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+			$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 			$this->pageBackgrounds = array();
 			$this->page = $new_page;
 			$this->ResetMargins();
@@ -19960,22 +19977,22 @@
 	else if ($this->lastblocklevelchange == -1) { $blockstate = 2; }	// Bottom margins/padding only
 	else { $blockstate = 0; }
 	// called from after e.g. </table> </div> </div> ...    Outputs block margin/border and padding
-	if (count($this->textbuffer) && $this->textbuffer[count($this->textbuffer)-1]) {
-		if (substr($this->textbuffer[count($this->textbuffer)-1][0],0,3) != "\xbb\xa4\xac") {	// not special content
+	if (count(($this->textbuffer ?? [])) && $this->textbuffer[count(($this->textbuffer ?? []))-1]) {
+		if (substr(($this->textbuffer[count(($this->textbuffer ?? []))-1][0] ?? ''),0,3) != "\xbb\xa4\xac") {	// not special content
 			// Right trim last content and adjust OTLdata
-			if (preg_match('/[ ]+$/',$this->textbuffer[count($this->textbuffer)-1][0], $m)) {
-				$strip = strlen($m[0]);
-				$this->textbuffer[count($this->textbuffer)-1][0] = substr($this->textbuffer[count($this->textbuffer)-1][0],0,(strlen($this->textbuffer[count($this->textbuffer)-1][0])-$strip));
+			if (preg_match('/[ ]+$/',($this->textbuffer[count(($this->textbuffer ?? []))-1][0] ?? ''), $m)) {
+				$strip = strlen(($m[0] ?? ''));
+				$this->textbuffer[count(($this->textbuffer ?? []))-1][0] = substr(($this->textbuffer[count(($this->textbuffer ?? []))-1][0] ?? ''),0,(strlen(($this->textbuffer[count(($this->textbuffer ?? []))-1][0] ?? ''))-$strip));
 /*-- OTL --*/
 				if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
-					$this->otl->trimOTLdata($this->textbuffer[count($this->textbuffer)-1][18], false, true);	// mPDF 6  ZZZ99K
+					$this->otl->trimOTLdata($this->textbuffer[count(($this->textbuffer ?? []))-1][18], false, true);	// mPDF 6  ZZZ99K
 				}
 /*-- END OTL --*/
 			}
 		}
 	}
 
-	if (count($this->textbuffer) == 0 && $this->lastblocklevelchange != 0) {
+	if (count(($this->textbuffer ?? [])) == 0 && $this->lastblocklevelchange != 0) {
 		//$this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,2,true, (isset($this->blk[$this->blklvl]['direction']) ? $this->blk[$this->blklvl]['direction'] : 'ltr'));
 		$this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,$blockstate,true, (isset($this->blk[$this->blklvl]['direction']) ? $this->blk[$this->blklvl]['direction'] : 'ltr'));
 		$this->finishFlowingBlock(true);	// true = END of flowing block
@@ -20003,7 +20020,7 @@
 		// If width not set, here would need to adjust and output buffer
 		$s = $this->PrintPageBackgrounds();
 		// Writes after the marker so not overwritten later by page background etc.
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 		$this->pageBackgrounds = array();
 		$this->Reset();
 		$this->pageoutput[$this->page] = array();
@@ -20035,7 +20052,7 @@
 		// If width not set, here would need to adjust and output buffer
 		$s = $this->PrintPageBackgrounds();
 		// Writes after the marker so not overwritten later by page background etc.
-		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+		$this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
 		$this->pageBackgrounds = array();
 		$this->Reset();
 		$this->pageoutput[$this->page] = array();
@@ -20198,7 +20215,7 @@
 	}
 
 	// Remove last <br> if at end of cell
-	if (isset($this->cell[$this->row][$this->col]['textbuffer'])) { $ntb = count($this->cell[$this->row][$this->col]['textbuffer']); }
+	if (isset($this->cell[$this->row][$this->col]['textbuffer'])) { $ntb = count(($this->cell[$this->row][$this->col]['textbuffer'] ?? [])); }
 	else { $ntb = 0; }
 	if ($ntb>1 && $this->cell[$this->row][$this->col]['textbuffer'][$ntb-1][0] == "\n") {
 		unset($this->cell[$this->row][$this->col]['textbuffer'][$ntb-1]);
@@ -20326,7 +20343,7 @@
 	$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['hr'] = array_pad(array(),$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr'],0);
 
 	// Move table footer <tfoot> row to end of table
-	if (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) && count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'])) {
+	if (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) && count(($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'] ?? []))) {
 		$tfrows = array();
 		foreach($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'] AS $r=>$val) {
 			if ($val) { $tfrows[] = $r; }
@@ -20342,13 +20359,13 @@
 			}
 		}
 		$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'] = array();
-		for($i=count($temp) ; $i<(count($temp)+count($temptf)); $i++) {
+		for($i=count(($temp ?? [])) ; $i<(count(($temp ?? []))+count(($temptf ?? []))); $i++) {
 			$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$i] = true;
 		}
 		// Update nestedpos row references
-		if (isset($this->table[($this->tableLevel+1)]) && count($this->table[($this->tableLevel+1)])) {
+		if (isset($this->table[($this->tableLevel+1)]) && count(($this->table[($this->tableLevel+1)] ?? []))) {
 		  foreach($this->table[($this->tableLevel+1)] AS $nid=>$nested) {
-			$this->table[($this->tableLevel+1)][$nid]['nestedpos'][0] -= count($temptf);
+			$this->table[($this->tableLevel+1)][$nid]['nestedpos'][0] -= count(($temptf ?? []));
 		  }
 		} 
 		$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = array_merge($temp, $temptf);
@@ -21015,7 +21032,7 @@
 	// If Kerning set for OTL, and useOTL has positive value, but has not set for this particular script,
 	// set for kerning via kern table
 	// e.g. Latin script when useOTL set as 0x80
-	if (isset($this->OTLtags['Plus']) && strpos($this->OTLtags['Plus'],'kern')!==false && empty($this->OTLdata['GPOSinfo'])) {
+	if (isset($this->OTLtags['Plus']) && strpos(($this->OTLtags['Plus'] ?? ''),'kern')!==false && empty($this->OTLdata['GPOSinfo'])) {
 		$this->textvar = ($this->textvar | FC_KERNING); 
 	}
 	$arr[8] = $this->textvar;	// mPDF 5.7.1
@@ -21050,7 +21067,7 @@
 	// If Kerning set for OTL, and useOTL has positive value, but has not set for this particular script,
 	// set for kerning via kern table
 	// e.g. Latin script when useOTL set as 0x80
-	if (isset($this->OTLtags['Plus']) && strpos($this->OTLtags['Plus'],'kern')!==false && empty($this->OTLdata['GPOSinfo'])) {
+	if (isset($this->OTLtags['Plus']) && strpos(($this->OTLtags['Plus'] ?? ''),'kern')!==false && empty($this->OTLdata['GPOSinfo'])) {
 		$this->textvar = ($this->textvar | FC_KERNING); 
 	}
 	$arr[8] = $this->textvar;	// mPDF 5.7.1
@@ -21080,7 +21097,7 @@
 	$this->spanborddet = array();
 	$paint_ht_corr = 0;
 /*-- CSS-FLOAT --*/
-	if (count($this->floatDivs)) {
+	if (count(($this->floatDivs ?? []))) {
 		list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
 		if (($this->blk[$this->blklvl]['inner_width']-$l_width-$r_width) < (2*$this->GetCharWidth('W',false))) {
 			// Too narrow to fit - try to move down past L or R float
@@ -21125,7 +21142,7 @@
 
     $this->newFlowingBlock( $this->divwidth,$this->divheight,$align,$is_table,$blockstate,true,$blockdir,$table_draft);
 
-    $array_size = count($arrayaux);
+    $array_size = count(($arrayaux ?? []));
 
 	// Added - Otherwise <div><div><p> did not output top margins/padding for 1st/2nd div
     if ($array_size == 0) { $this->finishFlowingBlock(true); }	// true = END of flowing block
@@ -21135,7 +21152,7 @@
 	// First make sure each element/chunk has the OTLdata for Bidi set.
 	for($i=0;$i < $array_size; $i++) {
 		if (empty($arrayaux[$i][18])) {
-			if (substr($arrayaux[$i][0],0,3) == "\xbb\xa4\xac") { // object identifier has been identified!
+			if (substr(($arrayaux[$i][0] ?? ''),0,3) == "\xbb\xa4\xac") { // object identifier has been identified!
 				$unicode = array(0xFFFC);	// Object replacement character
 			}
 			else { $unicode = $this->UTF8StringToArray($arrayaux[$i][0], false); }
@@ -21153,7 +21170,7 @@
 		if (!class_exists('otl', false)) { include(_MPDF_PATH.'classes/otl.php'); }
 		if (empty($this->otl)) { $this->otl = new otl($this); }
 		$this->otl->_bidiPrepare($arrayaux, $blockdir);
-		$array_size = count($arrayaux);
+		$array_size = count(($arrayaux ?? []));
 	}
 
 
@@ -21192,7 +21209,7 @@
 	$oldcolumn = $this->CurrCol;
 	$vetor = $arrayaux[$i];
 	if ($i == 0 and $vetor[0] != "\n" and !$this->ispre) {
-		$vetor[0] = ltrim($vetor[0]);
+		$vetor[0] = ltrim(($vetor[0] ?? ''));
 		if (!empty($vetor[18])) { $this->otl->trimOTLdata($vetor[18], true, false); }	// *OTL*
 	}
 
@@ -21224,13 +21241,13 @@
 
 	if(isset($vetor[15])) { 	 // Word spacing
 		$this->wSpacingCSS = $vetor[15];
-		if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { 
+		if ($this->wSpacingCSS && strtoupper(($this->wSpacingCSS ?? '')) != 'NORMAL') { 
 			$this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3
 		}
 	}
 	if(isset($vetor[14])) { 	 // Letter spacing
 		$this->lSpacingCSS = $vetor[14]; 
-		if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
+		if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper(($this->lSpacingCSS ?? '')) != 'NORMAL') {
 			$this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 
 		}
 	}
@@ -21291,7 +21308,7 @@
 	}
 	if(isset($vetor[1]) and $vetor[1] != '') //LINK
 	{
-	  if (strpos($vetor[1],".") === false && strpos($vetor[1],"@") !== 0) //assuming every external link has a dot indicating extension (e.g: .html .txt .zip www.somewhere.com etc.) 
+	  if (strpos(($vetor[1] ?? ''),".") === false && strpos(($vetor[1] ?? ''),"@") !== 0) //assuming every external link has a dot indicating extension (e.g: .html .txt .zip www.somewhere.com etc.) 
 	  {
 	    //Repeated reference to same anchor?
 	    while(array_key_exists($vetor[1],$this->internallink)) $vetor[1]="#".$vetor[1];
@@ -21304,7 +21321,7 @@
 	// SPECIAL CONTENT - IMAGES & FORM OBJECTS
 	//Print-out special content
 
-	if (substr($vetor[0],0,3) == "\xbb\xa4\xac") { //identifier has been identified!
+	if (substr(($vetor[0] ?? ''),0,3) == "\xbb\xa4\xac") { //identifier has been identified!
 	  
 	  $objattr = $this->_getObjAttr($vetor[0]);
 
@@ -21408,7 +21425,7 @@
 
 	  		// Added to correct Images already set on line before page advanced
 			// i.e. if second inline image on line is higher than first and forces new page
-			if (count($this->objectbuffer)) {
+			if (count(($this->objectbuffer ?? []))) {
 				$yadj = $iby - $this->y;
 				foreach($this->objectbuffer AS $ib=>$val) {
 					if ($this->objectbuffer[$ib]['OUTER-Y'] ) $this->objectbuffer[$ib]['OUTER-Y'] -= $yadj;
@@ -21520,7 +21537,7 @@
 		  			$this->floatmargins['R']['y1'] = $fy + $h;
 		 			if ($skipln == 1) {
 		 			 	$this->floatmargins['R']['skipline'] = true;
-		 			 	$this->floatmargins['R']['id'] = count($this->floatbuffer)+0;
+		 			 	$this->floatmargins['R']['id'] = count(($this->floatbuffer ?? []))+0;
 						$objattr['skipline'] = true;
 					}
 					$this->floatbuffer[] = $objattr;
@@ -21533,7 +21550,7 @@
 		  		$this->floatmargins['R']['y1'] = $fy + $h;
 		 		if ($skipln == 1) {
 		 		 	$this->floatmargins['R']['skipline'] = true;
-		 		 	$this->floatmargins['R']['id'] = count($this->floatbuffer)+0;
+		 		 	$this->floatmargins['R']['id'] = count(($this->floatbuffer ?? []))+0;
 					$objattr['skipline'] = true;
 				}
 				$this->floatbuffer[] = $objattr;
@@ -21560,7 +21577,7 @@
 		  			$this->floatmargins['L']['y1'] = $fy + $h;
 		 			if ($skipln == 1) {
 		 			 	$this->floatmargins['L']['skipline'] = true;
-		 			 	$this->floatmargins['L']['id'] = count($this->floatbuffer)+0;
+		 			 	$this->floatmargins['L']['id'] = count(($this->floatbuffer ?? []))+0;
 						$objattr['skipline'] = true;
 					}
 					$this->floatbuffer[] = $objattr;
@@ -21573,7 +21590,7 @@
 		  		$this->floatmargins['L']['y1'] = $fy + $h;
 		 		if ($skipln == 1) {
 		 		 	$this->floatmargins['L']['skipline'] = true;
-		 		 	$this->floatmargins['L']['id'] = count($this->floatbuffer)+0;
+		 		 	$this->floatmargins['L']['id'] = count(($this->floatbuffer ?? []))+0;
 					$objattr['skipline'] = true;
 				}
 				$this->floatbuffer[] = $objattr;
@@ -21792,10 +21809,10 @@
 	$this->SetLineWidth($b['w']/$k);
 	$this->SetDColor($b['c']);
 	if ($b['c'][0]==5) {	// RGBa
-		$this->SetAlpha(ord($b['c'][4])/100, 'Normal', false, 'S')."\n";	// mPDF 5.7.2
+		$this->SetAlpha(ord(($b['c'][4] ?? ''))/100, 'Normal', false, 'S')."\n";	// mPDF 5.7.2
 	}
 	else if ($b['c'][0]==6) {	// CMYKa
-		$this->SetAlpha(ord($b['c'][5])/100, 'Normal', false, 'S')."\n";	// mPDF 5.7.2
+		$this->SetAlpha(ord(($b['c'][5] ?? ''))/100, 'Normal', false, 'S')."\n";	// mPDF 5.7.2
 	}
 }
 
@@ -21916,7 +21933,7 @@
 		// BORDER LEGEND
 		if (isset($this->blk[$blvl]['border_legend']) && $this->blk[$blvl]['border_legend']) { 
 			$legend = $this->blk[$blvl]['border_legend'];	// Same structure array as textbuffer
-			$txt = $legend[0] = ltrim($legend[0]);
+			$txt = $legend[0] = ltrim(($legend[0] ?? ''));
 			if (!empty($legend[18])) { $this->otl->trimOTLdata($legend[18], true, false); }	// *OTL*
 
 			//Set font, size, style, color
@@ -22344,23 +22361,23 @@
 	if (isset($this->blk[$blvl]['box_shadow']) && $this->blk[$blvl]['box_shadow'] && $h > 0) {
 		foreach($this->blk[$blvl]['box_shadow'] AS $sh) {
 			// Colors
-			if ($sh['col']{0}==1) {
+			if ($sh['col'][0]==1) {
 				$colspace = 'Gray';
-				if ($sh['col']{2}==1) { $col1 = '1'.$sh['col'][1].'1'.$sh['col'][3]; }
+				if ($sh['col'][2]==1) { $col1 = '1'.$sh['col'][1].'1'.$sh['col'][3]; }
 				else { $col1 = '1'.$sh['col'][1].'1'.chr(100); }
 				$col2 = '1'.$sh['col'][1].'1'.chr(0);
 			}
-			else if ($sh['col']{0}==4) {	// CMYK
+			else if ($sh['col'][0]==4) {	// CMYK
 				$colspace = 'CMYK';
 				$col1 = '6'.$sh['col'][1].$sh['col'][2].$sh['col'][3].$sh['col'][4].chr(100);
 				$col2 = '6'.$sh['col'][1].$sh['col'][2].$sh['col'][3].$sh['col'][4].chr(0);
 			}
-			else if ($sh['col']{0}==5) {	// RGBa
+			else if ($sh['col'][0]==5) {	// RGBa
 				$colspace = 'RGB';
 				$col1 = '5'.$sh['col'][1].$sh['col'][2].$sh['col'][3].$sh['col'][4];
 				$col2 = '5'.$sh['col'][1].$sh['col'][2].$sh['col'][3].chr(0);
 			}
-			else if ($sh['col']{0}==6) {	// CMYKa
+			else if ($sh['col'][0]==6) {	// CMYKa
 				$colspace = 'CMYK';
 				$col1 = '6'.$sh['col'][1].$sh['col'][2].$sh['col'][3].$sh['col'][4].$sh['col'][5];
 				$col2 = '6'.$sh['col'][1].$sh['col'][2].$sh['col'][3].$sh['col'][4].chr(0);
@@ -22389,14 +22406,14 @@
 			// Set path for INNER shadow
 			$shadow .= ' q 0 w ';
 			$shadow .= $this->SetFColor($col1, true)."\n";
-			if ($col1{0}==5 && ord($col1{4})<100) {	// RGBa
-				$shadow .= $this->SetAlpha(ord($col1{4})/100, 'Normal', true, 'F')."\n"; 
-			}
-			else if ($col1{0}==6 && ord($col1{5})<100) {	// CMYKa
-				$shadow .= $this->SetAlpha(ord($col1{5})/100, 'Normal', true, 'F')."\n"; 
-			}
-			else if ($col1{0}==1 && $col1{2}==1 && ord($col1{3})<100) {	// Gray
-				$shadow .= $this->SetAlpha(ord($col1{3})/100, 'Normal', true, 'F')."\n"; 
+			if ($col1[0]==5 && ord(($col1[4] ?? ''))<100) {	// RGBa
+				$shadow .= $this->SetAlpha(ord(($col1[4] ?? ''))/100, 'Normal', true, 'F')."\n"; 
+			}
+			else if ($col1[0]==6 && ord(($col1[5] ?? ''))<100) {	// CMYKa
+				$shadow .= $this->SetAlpha(ord(($col1[5] ?? ''))/100, 'Normal', true, 'F')."\n"; 
+			}
+			else if ($col1[0]==1 && $col1[2]==1 && ord(($col1[3] ?? ''))<100) {	// Gray
+				$shadow .= $this->SetAlpha(ord(($col1[3] ?? ''))/100, 'Normal', true, 'F')."\n"; 
 			}
 
 			// Blur edges
@@ -22656,7 +22673,7 @@
 		}
 	}
 	if (isset($this->blk[$blvl]['background-image'])) { 
-	   if (isset($this->blk[$blvl]['background-image']['gradient']) && $this->blk[$blvl]['background-image']['gradient']  && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $this->blk[$blvl]['background-image']['gradient'] )) {
+	   if (isset($this->blk[$blvl]['background-image']['gradient']) && $this->blk[$blvl]['background-image']['gradient']  && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($this->blk[$blvl]['background-image']['gradient'] ?? '') )) {
 		$g = $this->grad->parseMozGradient( $this->blk[$blvl]['background-image']['gradient'] );
 		if ($g) {
 			$gx = $x0;
@@ -22824,7 +22841,7 @@
 
 
 
-function PaintDivLnBorder($state=0,$blvl=0,$h) {
+function PaintDivLnBorder($state,$blvl,$h) {
 	// $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
 	$this->ColDetails[$this->CurrCol]['bottom_margin'] = $this->y + $h; 
 
@@ -23062,17 +23079,17 @@
 function ReadMetaTags($html) {
 	// changes anykey=anyvalue to anykey="anyvalue" (only do this when this happens inside tags)
 	$regexp = '/ (\\w+?)=([^\\s>"]+)/si'; 
- 	$html = preg_replace($regexp," \$1=\"\$2\"",$html);
-	if (preg_match('/<title>(.*?)<\/title>/si',$html,$m)) {
+ 	$html = preg_replace(($regexp ?? '')," \$1=\"\$2\"",($html ?? ''));
+	if (preg_match('/<title>(.*?)<\/title>/si',($html ?? ''),$m)) {
 		$this->SetTitle($m[1]); 
 	}
-	preg_match_all('/<meta [^>]*?(name|content)="([^>]*?)" [^>]*?(name|content)="([^>]*?)".*?>/si',$html,$aux);
+	preg_match_all('/<meta [^>]*?(name|content)="([^>]*?)" [^>]*?(name|content)="([^>]*?)".*?>/si',($html ?? ''),$aux);
 	$firstattr = $aux[1];
 	$secondattr = $aux[3];
-	for( $i = 0 ; $i < count($aux[0]) ; $i++) {
-
-		$name = ( strtoupper($firstattr[$i]) == "NAME" )? strtoupper($aux[2][$i]) : strtoupper($aux[4][$i]);
-		$content = ( strtoupper($firstattr[$i]) == "CONTENT" )? $aux[2][$i] : $aux[4][$i];
+	for( $i = 0 ; $i < count(($aux[0] ?? [])) ; $i++) {
+
+		$name = ( strtoupper(($firstattr[$i] ?? '')) == "NAME" )? strtoupper(($aux[2][$i] ?? '')) : strtoupper(($aux[4][$i] ?? ''));
+		$content = ( strtoupper(($firstattr[$i] ?? '')) == "CONTENT" )? $aux[2][$i] : $aux[4][$i];
 		switch($name) {
 			case "KEYWORDS": $this->SetKeywords($content); break;
 			case "AUTHOR": $this->SetAuthor($content); break;
@@ -23085,9 +23102,9 @@
 function ReadCharset($html) {
 	// Charset conversion
 	if ($this->allow_charset_conversion) {
-	   if (preg_match('/<head.*charset=([^\'\"\s]*).*<\/head>/si',$html,$m)) {
-		if (strtoupper($m[1]) != 'UTF-8') {
-			$this->charset_in = strtoupper($m[1]); 
+	   if (preg_match('/<head.*charset=([^\'\"\s]*).*<\/head>/si',($html ?? ''),$m)) {
+		if (strtoupper(($m[1] ?? '')) != 'UTF-8') {
+			$this->charset_in = strtoupper(($m[1] ?? '')); 
 		}
 	   }
 	}
@@ -23120,7 +23137,7 @@
 			$this->SetFontSize( $mmsize*(_MPDFK),false ); //Get size in points (pt)
 		}
 		else{
-  			$v = strtoupper($v);
+  			$v = strtoupper(($v ?? ''));
 			if (isset($this->fontsizes[$v])) { 
 				$this->SetFontSize( $this->fontsizes[$v]* $this->default_font_size,false);
 			}
@@ -23144,13 +23161,13 @@
 	if (isset($arrayaux['FONT-FAMILY'])) {
 		$v = $arrayaux['FONT-FAMILY'];
 		//If it is a font list, get all font types
-		$aux_fontlist = explode(",",$v);
+		$aux_fontlist = explode(",",($v ?? ''));
 		$found = 0;
 		foreach($aux_fontlist AS $f) {
-			$fonttype = trim($f);
-			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-			$fonttype = preg_replace('/ /','',$fonttype);
-			$v = strtolower(trim($fonttype));
+			$fonttype = trim(($f ?? ''));
+			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+			$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+			$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 			if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
 			if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) || 
 				in_array($v,array('ccourier','ctimes','chelvetica')) ||
@@ -23163,10 +23180,10 @@
 		}
 		if (!$found) {
 		   foreach($aux_fontlist AS $f) {
-			$fonttype = trim($f);
-			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-			$fonttype = preg_replace('/ /','',$fonttype);
-			$v = strtolower(trim($fonttype));
+			$fonttype = trim(($f ?? ''));
+			$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+			$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+			$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 			if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
 			if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) { 
 				$fonttype = $v; 
@@ -23283,23 +23300,23 @@
 			break;
 
 		case 'BACKGROUND-CLIP':
-			if (strtoupper($v) == 'PADDING-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'padding-box'; }
-			else if (strtoupper($v) == 'CONTENT-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'content-box'; }
+			if (strtoupper(($v ?? '')) == 'PADDING-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'padding-box'; }
+			else if (strtoupper(($v ?? '')) == 'CONTENT-BOX') { $this->blk[$this->blklvl]['background_clip'] = 'content-box'; }
 			break;
 
 		case 'PAGE-BREAK-AFTER':
-			if (strtoupper($v) == 'AVOID') { $this->blk[$this->blklvl]['page_break_after_avoid'] = true; }
-			else if (strtoupper($v) == 'ALWAYS' || strtoupper($v) == 'LEFT' || strtoupper($v) == 'RIGHT') { $this->blk[$this->blklvl]['page_break_after'] = strtoupper($v) ; }
+			if (strtoupper(($v ?? '')) == 'AVOID') { $this->blk[$this->blklvl]['page_break_after_avoid'] = true; }
+			else if (strtoupper(($v ?? '')) == 'ALWAYS' || strtoupper(($v ?? '')) == 'LEFT' || strtoupper(($v ?? '')) == 'RIGHT') { $this->blk[$this->blklvl]['page_break_after'] = strtoupper(($v ?? '')) ; }
 			break;
 
 		// mPDF 6 pagebreaktype
 		case 'BOX-DECORATION-BREAK':
-			if (strtoupper($v) == 'CLONE') { $this->blk[$this->blklvl]['box_decoration_break'] = 'clone'; }
-			else if (strtoupper($v) == 'SLICE') { $this->blk[$this->blklvl]['box_decoration_break'] = 'slice'; }
+			if (strtoupper(($v ?? '')) == 'CLONE') { $this->blk[$this->blklvl]['box_decoration_break'] = 'clone'; }
+			else if (strtoupper(($v ?? '')) == 'SLICE') { $this->blk[$this->blklvl]['box_decoration_break'] = 'slice'; }
 			break;
 
 		case 'WIDTH':
-			if (strtoupper($v) != 'AUTO') { 
+			if (strtoupper(($v ?? '')) != 'AUTO') { 
 				$this->blk[$this->blklvl]['css_set_width'] = $this->ConvertSize($v,$this->blk[$prevlevel]['inner_width'],$this->FontSize,false); 
 			}
 			break;
@@ -23307,13 +23324,13 @@
 		// mPDF 6  Lists
 		// LISTS
 		case 'LIST-STYLE-TYPE':
-			$this->blk[$this->blklvl]['list_style_type'] = strtolower($v);
+			$this->blk[$this->blklvl]['list_style_type'] = strtolower(($v ?? ''));
 			break;
 		case 'LIST-STYLE-IMAGE':
-			$this->blk[$this->blklvl]['list_style_image'] = strtolower($v);
+			$this->blk[$this->blklvl]['list_style_image'] = strtolower(($v ?? ''));
 			break;
 		case 'LIST-STYLE-POSITION':
-			$this->blk[$this->blklvl]['list_style_position'] = strtolower($v);
+			$this->blk[$this->blklvl]['list_style_position'] = strtolower(($v ?? ''));
 			break;
 
 
@@ -23330,7 +23347,7 @@
 			break;
 
 		case 'MARGIN-COLLAPSE':	// Custom tag to collapse margins at top and bottom of page
-			if (strtoupper($v) == 'COLLAPSE') { $this->blk[$this->blklvl]['margin_collapse'] = true; }
+			if (strtoupper(($v ?? '')) == 'COLLAPSE') { $this->blk[$this->blklvl]['margin_collapse'] = true; }
 			break;
 
 		case 'LINE-HEIGHT':
@@ -23340,15 +23357,15 @@
 
 		// mPDF 6
 		case 'LINE-STACKING-STRATEGY':
-			$this->blk[$this->blklvl]['line_stacking_strategy'] = strtolower($v);
+			$this->blk[$this->blklvl]['line_stacking_strategy'] = strtolower(($v ?? ''));
 			break;
 
 		case 'LINE-STACKING-SHIFT':
-			$this->blk[$this->blklvl]['line_stacking_shift'] = strtolower($v);
+			$this->blk[$this->blklvl]['line_stacking_shift'] = strtolower(($v ?? ''));
 			break;
 
 		case 'TEXT-ALIGN': //left right center justify
-			switch (strtoupper($v)) {
+			switch (strtoupper(($v ?? ''))) {
 				case 'LEFT': 
                         $this->blk[$this->blklvl]['align']="L";
                         break;
@@ -23373,7 +23390,7 @@
 /*-- END BACKGROUNDS --*/
 
 		case 'DIRECTION': 
-			if ($v) { $this->blk[$this->blklvl]['direction'] = strtolower($v); }
+			if ($v) { $this->blk[$this->blklvl]['direction'] = strtolower(($v ?? '')); }
 			break;
 
 	  }//end of switch($k)
@@ -23383,7 +23400,7 @@
 	if ($type == 'INLINE') {
 	  switch($k){
 		case 'DISPLAY':
-			if (strtoupper($v) == 'NONE') { $this->inlineDisplayOff = true; }
+			if (strtoupper(($v ?? '')) == 'NONE') { $this->inlineDisplayOff = true; }
 			break;
 		case 'DIRECTION': 
 			break;
@@ -23414,7 +23431,7 @@
 			$spanbordset = true;
 			break;
 		case 'VISIBILITY':	// block is set in OpenTag
-			$v = strtolower($v);
+			$v = strtolower(($v ?? ''));
 			if ($v == 'visible' || $v == 'hidden' || $v == 'printonly' || $v == 'screenonly') { 
 				$this->textparam['visibility'] = $v;
 			}
@@ -23426,7 +23443,7 @@
 	// FOR INLINE and BLOCK
 	  switch($k){
 		case 'TEXT-ALIGN': //left right center justify
-			if (strtoupper($v) == 'NOJUSTIFY' && $this->blk[$this->blklvl]['align']=="J") {
+			if (strtoupper(($v ?? '')) == 'NOJUSTIFY' && $this->blk[$this->blklvl]['align']=="J") {
                         $this->blk[$this->blklvl]['align']="";
 			}
 			break;
@@ -23457,7 +23474,7 @@
 			break;
 
 		case 'VERTICAL-ALIGN': //super and sub only dealt with here e.g. <SUB> and <SUP>
-			switch (strtoupper($v)) {
+			switch (strtoupper(($v ?? ''))) {
 			   case 'SUPER': 
 				$this->textvar = ($this->textvar | FA_SUPERSCRIPT);	// mPDF 5.7.1
 				$this->textvar = ($this->textvar & ~FA_SUBSCRIPT);
@@ -23505,20 +23522,20 @@
 	  switch($k){
 		case 'LETTER-SPACING': 
 			$this->lSpacingCSS = $v;
-			if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') { 
+			if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper(($this->lSpacingCSS ?? '')) != 'NORMAL') { 
 				$this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
 			}
 			break;
 
 		case 'WORD-SPACING': 
 			$this->wSpacingCSS = $v;
-			if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
+			if ($this->wSpacingCSS && strtoupper(($this->wSpacingCSS ?? '')) != 'NORMAL') {
 				$this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
 			}
 			break;
 
 		case 'FONT-STYLE': // italic normal oblique
-			switch (strtoupper($v)) {
+			switch (strtoupper(($v ?? ''))) {
 				case 'ITALIC': 
 				case 'OBLIQUE': 
             			$this->SetStyle('I',true);
@@ -23530,7 +23547,7 @@
 			break;
 
 		case 'FONT-WEIGHT': // normal bold //Does not support: bolder, lighter, 100..900(step value=100)
-			switch (strtoupper($v))	{
+			switch (strtoupper(($v ?? '')))	{
 				case 'BOLD': 
             			$this->SetStyle('B',true);
 					break;
@@ -23541,7 +23558,7 @@
 			break;
 
 		case 'FONT-KERNING':
-			if (strtoupper($v) == 'NORMAL' || (strtoupper($v) == 'AUTO' && $this->useKerning)) {
+			if (strtoupper(($v ?? '')) == 'NORMAL' || (strtoupper(($v ?? '')) == 'AUTO' && $this->useKerning)) {
 /*-- OTL --*/
 				if ($this->CurrentFont['haskernGPOS']) { 
 					if (isset($this->OTLtags['Plus'])) { $this->OTLtags['Plus'] .= ' kern'; }
@@ -23552,24 +23569,24 @@
 					$this->textvar = ($this->textvar | FC_KERNING); 
 				}	// *OTL*
 			}
-			else if (strtoupper($v) == 'NONE' || (strtoupper($v) == 'AUTO' && !$this->useKerning)) {
-				if (isset($this->OTLtags['Plus'])) $this->OTLtags['Plus'] = str_replace('kern','', $this->OTLtags['Plus'] );	// *OTL*
-				if (isset($this->OTLtags['FFPlus'])) $this->OTLtags['FFPlus'] = preg_replace('/kern[\d]*/', '', $this->OTLtags['FFPlus'] ); 
+			else if (strtoupper(($v ?? '')) == 'NONE' || (strtoupper(($v ?? '')) == 'AUTO' && !$this->useKerning)) {
+				if (isset($this->OTLtags['Plus'])) $this->OTLtags['Plus'] = str_replace('kern','', ($this->OTLtags['Plus'] ?? '') );	// *OTL*
+				if (isset($this->OTLtags['FFPlus'])) $this->OTLtags['FFPlus'] = preg_replace('/kern[\d]*/', '', ($this->OTLtags['FFPlus'] ?? '') ); 
 				$this->textvar = ($this->textvar & ~FC_KERNING);
 			}
 			break;
 
 /*-- OTL --*/
 		case 'FONT-LANGUAGE-OVERRIDE':
-			$v =strtoupper($v);
-			if (strpos($v, 'NORMAL')!==false) { $this->fontLanguageOverride = ''; }
-			else { $this->fontLanguageOverride = trim($v); }
+			$v =strtoupper(($v ?? ''));
+			if (strpos(($v ?? ''), 'NORMAL')!==false) { $this->fontLanguageOverride = ''; }
+			else { $this->fontLanguageOverride = trim(($v ?? '')); }
 			break;
 
 
 		case 'FONT-VARIANT-POSITION':
-			if (isset($this->OTLtags['Plus'])) $this->OTLtags['Plus'] = str_replace(array('sups','subs'),'', $this->OTLtags['Plus']);
-			switch (strtoupper($v)) {
+			if (isset($this->OTLtags['Plus'])) $this->OTLtags['Plus'] = str_replace(array('sups','subs'),'', ($this->OTLtags['Plus'] ?? ''));
+			switch (strtoupper(($v ?? ''))) {
 				case 'SUPER': 
 				$this->OTLtags['Plus'] .= ' sups';
                        break;
@@ -23582,90 +23599,90 @@
 			break;
 
 		case 'FONT-VARIANT-CAPS':
-			$v =strtoupper($v);
+			$v =strtoupper(($v ?? ''));
 			if (!isset($this->OTLtags['Plus'])) { $this->OTLtags['Plus'] = ''; }
-			$this->OTLtags['Plus'] = str_replace(array('c2sc','smcp','c2pc','pcap','unic','titl'),'', $this->OTLtags['Plus']);
+			$this->OTLtags['Plus'] = str_replace(array('c2sc','smcp','c2pc','pcap','unic','titl'),'', ($this->OTLtags['Plus'] ?? ''));
 			$this->textvar = ($this->textvar & ~FC_SMALLCAPS);			// ?????????????? <small-caps>
-			if (strpos($v, 'ALL-SMALL-CAPS')!==false) { $this->OTLtags['Plus'] .= ' c2sc smcp'; }
-			else if (strpos($v, 'SMALL-CAPS')!==false) {
+			if (strpos(($v ?? ''), 'ALL-SMALL-CAPS')!==false) { $this->OTLtags['Plus'] .= ' c2sc smcp'; }
+			else if (strpos(($v ?? ''), 'SMALL-CAPS')!==false) {
 				if (isset($this->CurrentFont['hassmallcapsGSUB']) && $this->CurrentFont['hassmallcapsGSUB']) { $this->OTLtags['Plus'] .= ' smcp'; }
 				else { $this->textvar = ($this->textvar | FC_SMALLCAPS); }
 			}
-			else if (strpos($v, 'ALL-PETITE-CAPS')!==false) { $this->OTLtags['Plus'] .= ' c2pc pcap'; }
-			else if (strpos($v, 'PETITE-CAPS')!==false) { $this->OTLtags['Plus'] .= ' pcap'; }
-			else if (strpos($v, 'UNICASE')!==false) { $this->OTLtags['Plus'] .= ' unic'; }
-			else if (strpos($v, 'TITLING-CAPS')!==false) { $this->OTLtags['Plus'] .= ' titl'; }
+			else if (strpos(($v ?? ''), 'ALL-PETITE-CAPS')!==false) { $this->OTLtags['Plus'] .= ' c2pc pcap'; }
+			else if (strpos(($v ?? ''), 'PETITE-CAPS')!==false) { $this->OTLtags['Plus'] .= ' pcap'; }
+			else if (strpos(($v ?? ''), 'UNICASE')!==false) { $this->OTLtags['Plus'] .= ' unic'; }
+			else if (strpos(($v ?? ''), 'TITLING-CAPS')!==false) { $this->OTLtags['Plus'] .= ' titl'; }
 			break;
 
 		case 'FONT-VARIANT-LIGATURES':
-			$v =strtoupper($v);
+			$v =strtoupper(($v ?? ''));
 			if (!isset($this->OTLtags['Plus'])) { $this->OTLtags['Plus'] = ''; }
 			if (!isset($this->OTLtags['Minus'])) { $this->OTLtags['Minus'] = ''; }
-			if (strpos($v, 'NORMAL')!==false) { 
-				$this->OTLtags['Minus'] = str_replace(array('liga','clig','calt'),'', $this->OTLtags['Minus']);
-				$this->OTLtags['Plus'] = str_replace(array('dlig','hlig'),'', $this->OTLtags['Plus']);
-			}
-			else if (strpos($v, 'NONE')!==false) {
+			if (strpos(($v ?? ''), 'NORMAL')!==false) { 
+				$this->OTLtags['Minus'] = str_replace(array('liga','clig','calt'),'', ($this->OTLtags['Minus'] ?? ''));
+				$this->OTLtags['Plus'] = str_replace(array('dlig','hlig'),'', ($this->OTLtags['Plus'] ?? ''));
+			}
+			else if (strpos(($v ?? ''), 'NONE')!==false) {
 				$this->OTLtags['Minus'] .= ' liga clig calt'; 
-				$this->OTLtags['Plus'] = str_replace(array('dlig','hlig'),'', $this->OTLtags['Plus']);
-			}
-			if (strpos($v, 'NO-COMMON-LIGATURES')!==false) { $this->OTLtags['Minus'] .= ' liga clig'; }
-			else if (strpos($v, 'COMMON-LIGATURES')!==false) { $this->OTLtags['Minus'] = str_replace(array('liga','clig'),'', $this->OTLtags['Minus']); }
-			if (strpos($v, 'NO-CONTEXTUAL')!==false) { $this->OTLtags['Minus'] .= ' calt'; }
-			else if (strpos($v, 'CONTEXTUAL')!==false) { $this->OTLtags['Minus'] = str_replace('calt','', $this->OTLtags['Minus']); }
-			if (strpos($v, 'NO-DISCRETIONARY-LIGATURES')!==false) { $this->OTLtags['Plus'] = str_replace('dlig','', $this->OTLtags['Plus'] ); }
-			else if (strpos($v, 'DISCRETIONARY-LIGATURES')!==false) { $this->OTLtags['Plus'] .= ' dlig'; }
-			if (strpos($v, 'NO-HISTORICAL-LIGATURES')!==false) { $this->OTLtags['Plus'] = str_replace('hlig','', $this->OTLtags['Plus'] ); }
-			else if (strpos($v, 'HISTORICAL-LIGATURES')!==false) { $this->OTLtags['Plus'] .= ' hlig'; }
+				$this->OTLtags['Plus'] = str_replace(array('dlig','hlig'),'', ($this->OTLtags['Plus'] ?? ''));
+			}
+			if (strpos(($v ?? ''), 'NO-COMMON-LIGATURES')!==false) { $this->OTLtags['Minus'] .= ' liga clig'; }
+			else if (strpos(($v ?? ''), 'COMMON-LIGATURES')!==false) { $this->OTLtags['Minus'] = str_replace(array('liga','clig'),'', ($this->OTLtags['Minus'] ?? '')); }
+			if (strpos(($v ?? ''), 'NO-CONTEXTUAL')!==false) { $this->OTLtags['Minus'] .= ' calt'; }
+			else if (strpos(($v ?? ''), 'CONTEXTUAL')!==false) { $this->OTLtags['Minus'] = str_replace('calt','', ($this->OTLtags['Minus'] ?? '')); }
+			if (strpos(($v ?? ''), 'NO-DISCRETIONARY-LIGATURES')!==false) { $this->OTLtags['Plus'] = str_replace('dlig','', ($this->OTLtags['Plus'] ?? '') ); }
+			else if (strpos(($v ?? ''), 'DISCRETIONARY-LIGATURES')!==false) { $this->OTLtags['Plus'] .= ' dlig'; }
+			if (strpos(($v ?? ''), 'NO-HISTORICAL-LIGATURES')!==false) { $this->OTLtags['Plus'] = str_replace('hlig','', ($this->OTLtags['Plus'] ?? '') ); }
+			else if (strpos(($v ?? ''), 'HISTORICAL-LIGATURES')!==false) { $this->OTLtags['Plus'] .= ' hlig'; }
 
 			break;
 
 		case 'FONT-VARIANT-NUMERIC':
-			$v =strtoupper($v);
+			$v =strtoupper(($v ?? ''));
 			if (!isset($this->OTLtags['Plus'])) { $this->OTLtags['Plus'] = ''; }
-			if (strpos($v, 'NORMAL')!==false) {
-				$this->OTLtags['Plus'] = str_replace(array('ordn','zero','lnum','onum','pnum','tnum','frac','afrc'),'', $this->OTLtags['Plus']);
-			}
-			if (strpos($v, 'ORDINAL')!==false) { $this->OTLtags['Plus'] .= ' ordn'; }
-			if (strpos($v, 'SLASHED-ZERO')!==false) { $this->OTLtags['Plus'] .= ' zero'; }
-			if (strpos($v, 'LINING-NUMS')!==false) { $this->OTLtags['Plus'] .= ' lnum'; $this->OTLtags['Plus'] = str_replace('onum','', $this->OTLtags['Plus'] ); }
-			else if (strpos($v, 'OLDSTYLE-NUMS')!==false) { $this->OTLtags['Plus'] .= ' onum'; $this->OTLtags['Plus'] = str_replace('lnum','', $this->OTLtags['Plus'] ); }
-			if (strpos($v, 'PROPORTIONAL-NUMS')!==false) { $this->OTLtags['Plus'] .= ' pnum'; $this->OTLtags['Plus'] = str_replace('tnum','', $this->OTLtags['Plus'] ); }
-			else if (strpos($v, 'TABULAR-NUMS')!==false) { $this->OTLtags['Plus'] .= ' tnum'; $this->OTLtags['Plus'] = str_replace('pnum','', $this->OTLtags['Plus'] ); }
-			if (strpos($v, 'DIAGONAL-FRACTIONS')!==false) { $this->OTLtags['Plus'] .= ' frac'; $this->OTLtags['Plus'] = str_replace('afrc','', $this->OTLtags['Plus'] ); }
-			else if (strpos($v, 'STACKED-FRACTIONS')!==false) { $this->OTLtags['Plus'] .= ' afrc'; $this->OTLtags['Plus'] = str_replace('frac','', $this->OTLtags['Plus'] ); }
+			if (strpos(($v ?? ''), 'NORMAL')!==false) {
+				$this->OTLtags['Plus'] = str_replace(array('ordn','zero','lnum','onum','pnum','tnum','frac','afrc'),'', ($this->OTLtags['Plus'] ?? ''));
+			}
+			if (strpos(($v ?? ''), 'ORDINAL')!==false) { $this->OTLtags['Plus'] .= ' ordn'; }
+			if (strpos(($v ?? ''), 'SLASHED-ZERO')!==false) { $this->OTLtags['Plus'] .= ' zero'; }
+			if (strpos(($v ?? ''), 'LINING-NUMS')!==false) { $this->OTLtags['Plus'] .= ' lnum'; $this->OTLtags['Plus'] = str_replace('onum','', ($this->OTLtags['Plus'] ?? '') ); }
+			else if (strpos(($v ?? ''), 'OLDSTYLE-NUMS')!==false) { $this->OTLtags['Plus'] .= ' onum'; $this->OTLtags['Plus'] = str_replace('lnum','', ($this->OTLtags['Plus'] ?? '') ); }
+			if (strpos(($v ?? ''), 'PROPORTIONAL-NUMS')!==false) { $this->OTLtags['Plus'] .= ' pnum'; $this->OTLtags['Plus'] = str_replace('tnum','', ($this->OTLtags['Plus'] ?? '') ); }
+			else if (strpos(($v ?? ''), 'TABULAR-NUMS')!==false) { $this->OTLtags['Plus'] .= ' tnum'; $this->OTLtags['Plus'] = str_replace('pnum','', ($this->OTLtags['Plus'] ?? '') ); }
+			if (strpos(($v ?? ''), 'DIAGONAL-FRACTIONS')!==false) { $this->OTLtags['Plus'] .= ' frac'; $this->OTLtags['Plus'] = str_replace('afrc','', ($this->OTLtags['Plus'] ?? '') ); }
+			else if (strpos(($v ?? ''), 'STACKED-FRACTIONS')!==false) { $this->OTLtags['Plus'] .= ' afrc'; $this->OTLtags['Plus'] = str_replace('frac','', ($this->OTLtags['Plus'] ?? '') ); }
 			break;
 
 		case 'FONT-VARIANT-ALTERNATES': 	// Only supports historical-forms
-			$v =strtoupper($v);
+			$v =strtoupper(($v ?? ''));
 			if (!isset($this->OTLtags['Plus'])) { $this->OTLtags['Plus'] = ''; }
-			if (strpos($v, 'NORMAL')!==false) {
-				$this->OTLtags['Plus'] = str_replace('hist','', $this->OTLtags['Plus']);
+			if (strpos(($v ?? ''), 'NORMAL')!==false) {
+				$this->OTLtags['Plus'] = str_replace('hist','', ($this->OTLtags['Plus'] ?? ''));
 			} 
-			if (strpos($v, 'HISTORICAL-FORMS')!==false) { $this->OTLtags['Plus'] .= ' hist'; }
+			if (strpos(($v ?? ''), 'HISTORICAL-FORMS')!==false) { $this->OTLtags['Plus'] .= ' hist'; }
 			break;
 
 
 		case 'FONT-FEATURE-SETTINGS':
-			$v =strtolower($v);
-			if (strpos($v, 'normal')!==false) {
+			$v =strtolower(($v ?? ''));
+			if (strpos(($v ?? ''), 'normal')!==false) {
 				$this->OTLtags['FFMinus'] = '';
 				$this->OTLtags['FFPlus'] = '';
 			}
 			else {
 				if (!isset($this->OTLtags['FFPlus'])) { $this->OTLtags['FFPlus'] = ''; }
 				if (!isset($this->OTLtags['FFMinus'])) { $this->OTLtags['FFMinus'] = ''; }
-				$tags = preg_split('/[,]/',$v);
+				$tags = preg_split('/[,]/',($v ?? ''));
 				foreach($tags AS $t) {
-					if(preg_match('/[\"\']([a-zA-Z0-9]{4})[\"\']\s*(on|off|\d*){0,1}/', $t, $m)) {
+					if(preg_match('/[\"\']([a-zA-Z0-9]{4})[\"\']\s*(on|off|\d*){0,1}/', ($t ?? ''), $m)) {
 						if ($m[2]=='off' || $m[2]==='0') {
-							if (strpos($this->OTLtags['FFMinus'],$m[1])===false) { $this->OTLtags['FFMinus'] .= ' '.$m[1]; }
-							$this->OTLtags['FFPlus'] = preg_replace('/'.$m[1].'[\d]*/', '', $this->OTLtags['FFPlus'] ); 
+							if (strpos(($this->OTLtags['FFMinus'] ?? ''),($m[1] ?? ''))===false) { $this->OTLtags['FFMinus'] .= ' '.$m[1]; }
+							$this->OTLtags['FFPlus'] = preg_replace('/'.$m[1].'[\d]*/', '', ($this->OTLtags['FFPlus'] ?? '') ); 
 						}
 						else {
 							if ($m[2]=='on') { $m[2] = '1'; }
-							if (strpos($this->OTLtags['FFPlus'],$m[1])===false) { $this->OTLtags['FFPlus'] .= ' '.$m[1].$m[2]; }
-							$this->OTLtags['FFMinus'] = str_replace($m[1],'', $this->OTLtags['FFMinus'] ); 
+							if (strpos(($this->OTLtags['FFPlus'] ?? ''),($m[1] ?? ''))===false) { $this->OTLtags['FFPlus'] .= ' '.$m[1].$m[2]; }
+							$this->OTLtags['FFMinus'] = str_replace(($m[1] ?? ''),'', ($this->OTLtags['FFMinus'] ?? '') ); 
 						}
 					}
 				}
@@ -23675,7 +23692,7 @@
 
 
 		case 'TEXT-TRANSFORM': // none uppercase lowercase //Does support: capitalize
-			switch (strtoupper($v)) { //Not working 100%
+			switch (strtoupper(($v ?? ''))) { //Not working 100%
 				case 'CAPITALIZE':
 					$this->textvar = ($this->textvar | FT_CAPITALIZE);	// mPDF 5.7.1
 					$this->textvar = ($this->textvar & ~FT_UPPERCASE);	// mPDF 5.7.1
@@ -23704,26 +23721,26 @@
 			break;
 
 		case 'HYPHENS':
-			if (strtoupper($v)=='NONE') {
+			if (strtoupper(($v ?? ''))=='NONE') {
 				$this->textparam['hyphens'] = 2;
 			}
-			else if (strtoupper($v)=='AUTO') {
+			else if (strtoupper(($v ?? ''))=='AUTO') {
 				$this->textparam['hyphens'] = 1;
 			}
-			else if (strtoupper($v)=='MANUAL') {
+			else if (strtoupper(($v ?? ''))=='MANUAL') {
 				$this->textparam['hyphens'] = 0;
 			}
 			break;
 
 		case 'TEXT-OUTLINE':
-			if (strtoupper($v)=='NONE') {
+			if (strtoupper(($v ?? ''))=='NONE') {
 				$this->textparam['outline-s'] = false;
 			}
 			break;
 
 		case 'TEXT-OUTLINE-WIDTH':
 		case 'OUTLINE-WIDTH': 
-			switch(strtoupper($v)) {
+			switch(strtoupper(($v ?? ''))) {
 				case 'THIN': $v = '0.03em'; break;
 				case 'MEDIUM': $v = '0.05em'; break;
 				case 'THICK': $v = '0.07em'; break;
@@ -23738,7 +23755,7 @@
 
 		case 'TEXT-OUTLINE-COLOR':
 		case 'OUTLINE-COLOR': 
-			if (strtoupper($v) == 'INVERT') {
+			if (strtoupper(($v ?? '')) == 'INVERT') {
 			   if ($this->colorarray) {
 				$cor = $this->colorarray;
 				$this->textparam['outline-COLOR'] = $this->_invertColor($cor);
@@ -23778,7 +23795,7 @@
 			else { $this->textparam['s-decoration']['baseline'] = 0; }
 			$this->textparam['s-decoration']['fontkey'] = $this->FontFamily . $this->FontStyle;
 			$this->textparam['s-decoration']['fontsize'] = $this->FontSize;
-			$this->textparam['s-decoration']['color'] = strtoupper($this->TextColor);	// change 0 0 0 rg to 0 0 0 RG
+			$this->textparam['s-decoration']['color'] = strtoupper(($this->TextColor ?? ''));	// change 0 0 0 rg to 0 0 0 RG
 		}
 		if (stristr($v,'UNDERLINE')) {
             	$this->textvar = ($this->textvar | FD_UNDERLINE);
@@ -23787,7 +23804,7 @@
 			else { $this->textparam['u-decoration']['baseline'] = 0; }
 			$this->textparam['u-decoration']['fontkey'] = $this->FontFamily . $this->FontStyle;
 			$this->textparam['u-decoration']['fontsize'] = $this->FontSize;
-			$this->textparam['u-decoration']['color'] = strtoupper($this->TextColor);	// change 0 0 0 rg to 0 0 0 RG
+			$this->textparam['u-decoration']['color'] = strtoupper(($this->TextColor ?? ''));	// change 0 0 0 rg to 0 0 0 RG
 		}
 		if (stristr($v,'OVERLINE')) {
             	$this->textvar = ($this->textvar | FD_OVERLINE);
@@ -23796,7 +23813,7 @@
 			else { $this->textparam['o-decoration']['baseline'] = 0; }
 			$this->textparam['o-decoration']['fontkey'] = $this->FontFamily . $this->FontStyle;
 			$this->textparam['o-decoration']['fontsize'] = $this->FontSize;
-			$this->textparam['o-decoration']['color'] = strtoupper($this->TextColor);	// change 0 0 0 rg to 0 0 0 RG
+			$this->textparam['o-decoration']['color'] = strtoupper(($this->TextColor ?? ''));	// change 0 0 0 rg to 0 0 0 RG
 		}
 		if (stristr($v,'NONE')) {
 			$this->textvar = ($this->textvar & ~FD_UNDERLINE);
@@ -23861,7 +23878,7 @@
 function SetStyles($str) {
 	$style='';
 	foreach(array('B','I') as $s) {
-		if (strpos($str,$s) !== false) {
+		if (strpos(($str ?? ''),($s ?? '')) !== false) {
 			$this->$s = true;
 			$style.=$s;
 		}
@@ -23886,20 +23903,20 @@
 		$this->enabledtags = "<a><acronym><address><article><aside><b><bdi><bdo><big><blockquote><br><caption><center><cite><code><del><details><dd><div><dl><dt><em><fieldset><figcaption><figure><font><form><h1><h2><h3><h4><h5><h6><hgroup><hr><i><img><input><ins><kbd><legend><li><main><mark><meter><nav><ol><option><p><pre><progress><q><s><samp><section><select><small><span><strike><strong><sub><summary><sup><table><tbody><td><template><textarea><tfoot><th><thead><time><tr><tt><u><ul><var><footer><header><annotation><bookmark><jpgraph><textcircle><barcode><dottab><indexentry><indexinsert><watermarktext><watermarkimage><tts><ttz><tta><column_break><columnbreak><newcolumn><newpage><page_break><pagebreak><formfeed><columns><toc><tocentry><tocpagebreak><pageheader><pagefooter><setpageheader><setpagefooter><sethtmlpageheader><sethtmlpagefooter>";
 	}
 	else {
-		$str = explode(",",$str);
-		foreach($str as $v) $this->enabledtags = str_replace(trim($v),'',$this->enabledtags);
+		$str = explode(",",($str ?? ''));
+		foreach($str as $v) $this->enabledtags = str_replace((trim(($v ?? '')) ?? ''),'',($this->enabledtags ?? ''));
 	}
 }
 
 
 /*-- TABLES --*/
 
-function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer, $checkletter=false) {	// mPDF 6
+function TableCheckMinWidth($maxwidth, $forcewrap, $textbuffer, $checkletter=false) {	// mPDF 6
 	$acclength = 0;	// mPDF 6 (accumulated length across > 1 chunk)
 	$acclongest = 0;	// mPDF 6 (accumulated length max across > 1 chunk)
 	$biggestword=0;
 	$toonarrow=false;
-	if ((count($textbuffer) == 0) or ((count($textbuffer) == 1) && ($textbuffer[0][0] == ''))) { return 0; }
+	if ((count(($textbuffer ?? [])) == 0) or ((count(($textbuffer ?? [])) == 1) && ($textbuffer[0][0] == ''))) { return 0; }
 
 	foreach ($textbuffer as $chunk) {
 
@@ -23907,10 +23924,10 @@
 		$OTLdata = (isset($chunk[18]) ? $chunk[18] : NULL);
 
 		// mPDF ITERATION
-		if ($this->iterationCounter) $line = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/','\\1', $line);
+		if ($this->iterationCounter) $line = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/','\\1', ($line ?? ''));
 
 		// IMAGES & FORM ELEMENTS
-      	if (substr($line,0,3) == "\xbb\xa4\xac") { //inline object - FORM element or IMAGE!
+      	if (substr(($line ?? ''),0,3) == "\xbb\xa4\xac") { //inline object - FORM element or IMAGE!
 			$objattr = $this->_getObjAttr($line);
 			if ($objattr['type']!='hr' && isset($objattr['width']) && ($objattr['width']/$this->shrin_k) > ($maxwidth + 0.0001) ) { 
 				if (($objattr['width']/$this->shrin_k) > $biggestword) { $biggestword = ($objattr['width']/$this->shrin_k); }
@@ -23923,7 +23940,7 @@
 			$acclength = 0;	// mPDF 6 (accumulated length across > 1 chunk)
 			continue;
 		}
-    		$line = trim($line );
+    		$line = trim(($line ?? '') );
 		if (!empty($OTLdata)) { $this->otl->trimOTLdata($OTLdata, true, true); }	// *OTL*
 
 		// SET FONT SIZE/STYLE from $chunk[n]
@@ -23951,13 +23968,13 @@
 		}
 	      if(isset($chunk[15])) { 	 // Word spacing
 			$this->wSpacingCSS = $chunk[15]; 
-			if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { 
+			if ($this->wSpacingCSS && strtoupper(($this->wSpacingCSS ?? '')) != 'NORMAL') { 
 				$this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3
 			}
 		}
 	      if(isset($chunk[14])) { 	 // Letter spacing
 			$this->lSpacingCSS = $chunk[14]; 
-			if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
+			if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper(($this->lSpacingCSS ?? '')) != 'NORMAL') {
 				$this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 
 			}
 		}
@@ -23967,23 +23984,23 @@
 
 		// mPDF 6
 		// If overflow==wrap ($checkletter) OR (No word breaks and contains CJK)
-		if ($checkletter || (!preg_match('/(\xe2\x80\x8b| )/', trim($line)) &&  preg_match("/([".$this->pregCJKchars."])/u", $line) ) ) {
-			if (preg_match("/([".$this->pregCJKchars."])/u", $line) ) { $checkCJK = true; }
+		if ($checkletter || (!preg_match('/(\xe2\x80\x8b| )/', (trim(($line ?? '')) ?? '')) &&  preg_match("/([".$this->pregCJKchars."])/u", ($line ?? '')) ) ) {
+			if (preg_match("/([".$this->pregCJKchars."])/u", ($line ?? '')) ) { $checkCJK = true; }
 			else { $checkCJK = false; }
 
-			$letters = preg_split('//u', $line);
+			$letters = preg_split('//u', ($line ?? ''));
 			foreach ($letters as $k=>$letter) {
 
 				// mPDF 6
 				if ($checkCJK) {
-					if (preg_match("/[".$this->CJKleading."]/u", $letter) && $k>0) { $letter = $letters[$k-1].$letter; }
-					if (preg_match("/[".$this->CJKfollowing."]/u", $letter) && $k<(count($letters)-1)) { $letter = $letter.$letters[$k+1]; }
+					if (preg_match("/[".$this->CJKleading."]/u", ($letter ?? '')) && $k>0) { $letter = $letters[$k-1].$letter; }
+					if (preg_match("/[".$this->CJKfollowing."]/u", ($letter ?? '')) && $k<(count(($letters ?? []))-1)) { $letter = $letter.$letters[$k+1]; }
 				}
 
 				$letterwidth = $this->GetStringWidth($letter, false, false, $chunk[8]);	// Pass $textvar ($chunk[8]), but do OTLdata here
 																// so don't have to split OTLdata for each word
 				if ($k==0) { $letterwidth += $lbw; }
-				if ($k==(count($letters)-1)) { $letterwidth += $rbw; }
+				if ($k==(count(($letters ?? []))-1)) { $letterwidth += $rbw; }
 
 				//Warn user that maxwidth is insufficient
 				if ($letterwidth > $maxwidth + 0.0001) {
@@ -23998,7 +24015,7 @@
 			// Need to account for any XAdvance in GPOSinfo (OTLdata = $chunk[18])
 			$wordXAdvance = array();
 			if (isset($chunk[18]) && $chunk[18]) { 
-				preg_match_all ( '/(\xe2\x80\x8b| )/', $line, $spaces, PREG_OFFSET_CAPTURE );	// U+200B Zero Width word boundary, or space
+				preg_match_all ( '/(\xe2\x80\x8b| )/', ($line ?? ''), $spaces, PREG_OFFSET_CAPTURE );	// U+200B Zero Width word boundary, or space
 				$lastoffset = 0;
 				$k = -1;	// Added so that if no spaces found, "last word" later is calculated for the one and only word
 				foreach ($spaces[0] as $k=>$m) {
@@ -24023,22 +24040,22 @@
 				}
 			}
 
-			$words = preg_split('/(\xe2\x80\x8b| )/', $line);	// U+200B Zero Width word boundary, or space
+			$words = preg_split('/(\xe2\x80\x8b| )/', ($line ?? ''));	// U+200B Zero Width word boundary, or space
 			foreach ($words as $k=>$word) {
-				$word = trim($word);
+				$word = trim(($word ?? ''));
 				$wordwidth = $this->GetStringWidth($word, false, false, $chunk[8]);	// Pass $textvar ($chunk[8]), but do OTLdata here
 																// so don't have to split OTLdata for each word
 				if (isset($wordXAdvance[$k])) { $wordwidth += ($wordXAdvance[$k]* 1000/$this->CurrentFont['unitsPerEm']) * ($this->FontSize/ 1000); }
 				if ($k==0) { $wordwidth += $lbw; }
-				if ($k==(count($words)-1)) { $wordwidth += $rbw; }
+				if ($k==(count(($words ?? []))-1)) { $wordwidth += $rbw; }
 
 				// mPDF 6
-				if ( count($words)==1 && substr($chunk[0],0,1)!=' ') { $acclength += $wordwidth; }
-				else if (count($words)>1 && $k==0 && substr($chunk[0],0,1)!=' ') { $acclength += $wordwidth; }
+				if ( count(($words ?? []))==1 && substr(($chunk[0] ?? ''),0,1)!=' ') { $acclength += $wordwidth; }
+				else if (count(($words ?? []))>1 && $k==0 && substr(($chunk[0] ?? ''),0,1)!=' ') { $acclength += $wordwidth; }
 				else { $acclength = $wordwidth; }
 				$acclongest = max($acclongest,$acclength);
-				if (count($words)==1 && substr($chunk[0],-1,1)==' ') { $acclength = 0; }
-				else if (count($words)>1 && ($k!=(count($words)-1) || substr($chunk[0],-1,1)==' ')) { $acclength = 0; }
+				if (count(($words ?? []))==1 && substr(($chunk[0] ?? ''),-1,1)==' ') { $acclength = 0; }
+				else if (count(($words ?? []))>1 && ($k!=(count(($words ?? []))-1) || substr(($chunk[0] ?? ''),-1,1)==' ')) { $acclength = 0; }
 
 				//Warn user that maxwidth is insufficient
 				if ($wordwidth > $maxwidth + 0.0001) {
@@ -24194,7 +24211,7 @@
 
 function read_short(&$fh) {
 		$s = fread($fh,2);
-		$a = (ord($s[0])<<8) + ord($s[1]);
+		$a = (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -24271,26 +24288,26 @@
 	$cell['border'] = $bd['bord'];
 	$cell['border_details']['R']['s'] = $bd['rs'];
 	$cell['border_details']['R']['w'] = $bd['rw'];
-	$cell['border_details']['R']['c'] = str_pad($bd['rca'], 6, "\x00");
-	$cell['border_details']['R']['style'] = trim($bd['rst']);
+	$cell['border_details']['R']['c'] = str_pad(($bd['rca'] ?? ''), 6, "\x00");
+	$cell['border_details']['R']['style'] = trim(($bd['rst'] ?? ''));
 	$cell['border_details']['R']['dom'] = $bd['rd'];
 
 	$cell['border_details']['L']['s'] = $bd['ls'];
 	$cell['border_details']['L']['w'] = $bd['lw'];
-	$cell['border_details']['L']['c'] = str_pad($bd['lca'], 6, "\x00");
-	$cell['border_details']['L']['style'] = trim($bd['lst']);
+	$cell['border_details']['L']['c'] = str_pad(($bd['lca'] ?? ''), 6, "\x00");
+	$cell['border_details']['L']['style'] = trim(($bd['lst'] ?? ''));
 	$cell['border_details']['L']['dom'] = $bd['ld'];
 
 	$cell['border_details']['T']['s'] = $bd['ts'];
 	$cell['border_details']['T']['w'] = $bd['tw'];
-	$cell['border_details']['T']['c'] = str_pad($bd['tca'], 6, "\x00");
-	$cell['border_details']['T']['style'] = trim($bd['tst']);
+	$cell['border_details']['T']['c'] = str_pad(($bd['tca'] ?? ''), 6, "\x00");
+	$cell['border_details']['T']['style'] = trim(($bd['tst'] ?? ''));
 	$cell['border_details']['T']['dom'] = $bd['td'];
 
 	$cell['border_details']['B']['s'] = $bd['bs'];
 	$cell['border_details']['B']['w'] = $bd['bw'];
-	$cell['border_details']['B']['c'] = str_pad($bd['bca'], 6, "\x00");
-	$cell['border_details']['B']['style'] = trim($bd['bst']);
+	$cell['border_details']['B']['c'] = str_pad(($bd['bca'] ?? ''), 6, "\x00");
+	$cell['border_details']['B']['style'] = trim(($bd['bst'] ?? ''));
 	$cell['border_details']['B']['dom'] = $bd['bd'];
 
 	$cell['border_details']['mbw']['BL'] = $bd['mbl'];
@@ -24366,7 +24383,7 @@
 
 				//$mw = $this->GetStringWidth('W') + $extrcw ;
 				$mw = $extrcw ;	// mPDF 6
-				if(substr($c['a'],0,1) == 'D') {
+				if(substr(($c['a'] ?? ''),0,1) == 'D') {
 					$mw = $table['decimal_align'][$j]['maxs0'] + $table['decimal_align'][$j]['maxs1'] + $extrcw ;
 				}
 
@@ -24528,7 +24545,7 @@
 			if (!$wis) {
 				for($k=$j;$k<$lc;$k++) { $wc[$k]['miw'] = $c['miw']/$c['colspan']; }
 			}
-			else if (!count($list)) {
+			else if (!count(($list ?? []))) {
 				$wi = $c['miw'] - $wis;
 				for($k=$j;$k<$lc;$k++) { $wc[$k]['miw'] += ($wc[$k]['miw']/$wis)*$wi; }
 			}
@@ -24543,7 +24560,7 @@
 			if (!$wis) {
 				for($k=$j;$k<$lc;$k++) { $wc[$k]['maw'] = $c['maw']/$c['colspan']; }
 			}
-			else if (!count($list)) {
+			else if (!count(($list ?? []))) {
 				$wi = $c['maw'] - $was;
 				for($k=$j;$k<$lc;$k++) { $wc[$k]['maw'] += ($wc[$k]['maw']/$was)*$wi; }
 			}
@@ -24551,7 +24568,7 @@
 				$wi = $c['maw'] - $was;
 				// mPDF 5.7.4  Extra max width distributed evenly to all cells in colspan without a specified width
 				// cf. http://www.mpdf1.com/forum/discussion/2221/colspan-bug
-				foreach ($list as $k) { $wc[$k]['maw'] += $wi/count($list); }
+				foreach ($list as $k) { $wc[$k]['maw'] += $wi/count(($list ?? [])); }
 			}
 		}
 		unset($c);
@@ -24809,7 +24826,7 @@
 			}
 			// Now allocate surplus up to maximum width of each column
 			$surplus = 0;  $ttl = 0;	// number of surplus columns
-			if (!count($list)) {
+			if (!count(($list ?? []))) {
 				$wi = ($table['w']-($wis + $tblbw));	//	i.e. extra space to distribute
 				for($k=0;$k<$numcols;$k++) {
 					$spareratio = ($table['l'][$k] / $totaltextlength); //  gives ratio to divide up free space
@@ -24845,15 +24862,15 @@
 			// If surplus still left over apportion it across columns
 			if ($surplus) { 
 			   // if some are set only add to remaining - otherwise add to all of them
-			   if (count($notsetlist) && count($notsetlist) < $numcols) {
+			   if (count(($notsetlist ?? [])) && count(($notsetlist ?? [])) < $numcols) {
 				foreach ($notsetlist AS $i) {
 					if ($ttl) $widthcols[$i]['miw'] += $surplus * $table['l'][$i] / $ttl ;
 				}
 			   }
 			   // If some widths are defined, and others have been added up to their maxmum
-			   else if (count($list) && count($list) < $numcols) {
+			   else if (count(($list ?? [])) && count(($list ?? [])) < $numcols) {
 				foreach ($list AS $i) {
-					$widthcols[$i]['miw'] += $surplus / count($list) ;
+					$widthcols[$i]['miw'] += $surplus / count(($list ?? [])) ;
 				}
 			   }
 			   else if ($numcols) {	// If all columns
@@ -25031,7 +25048,7 @@
 				if ($c['R'] && isset($c['textbuffer'])) {
 					$str = '';
 					foreach($c['textbuffer'] AS $t) { $str .= $t[0].' '; }
-					$str = rtrim($str);
+					$str = rtrim(($str ?? ''));
 					$s_fs = $this->FontSizePt;
 					$s_f = $this->FontFamily;
 					$s_st = $this->FontStyle;
@@ -25166,13 +25183,13 @@
 			if (!$hs) {
 				for($k=$i;$k<$lr;$k++) $heightrow[$k] = $c['mih']/$c['rowspan'];
 			}
-			elseif (!count($list)) {	// no rows in the rowspan have a height specified, so share amongst all rows equally
+			elseif (!count(($list ?? []))) {	// no rows in the rowspan have a height specified, so share amongst all rows equally
 				$hi = $c['mih'] - $hs;
 				for($k=$i;$k<$lr;$k++) $heightrow[$k] += ($heightrow[$k]/$hs)*$hi;
 			}
 			else {
 				$hi = $c['mih'] - $hs;	// mPDF 6
-				foreach ($list as $k) $heightrow[$k] += $hi/(count($list));	// mPDF 6
+				foreach ($list as $k) $heightrow[$k] += $hi/(count(($list ?? [])));	// mPDF 6
 			}
 		}
 		unset($c);
@@ -25354,7 +25371,7 @@
 	else if ($bord){
 	   if (!$bSeparate && $buffer) {
 		$priority = 'LRTB';
-		for($p=0;$p<strlen($priority);$p++) {
+		for($p=0;$p<strlen(($priority ?? ''));$p++) {
 			$side = $priority[$p];
 			$details['p'] = $side ;
 
@@ -25366,8 +25383,8 @@
 			// Precedence to darker colours at joins
 			$coldom = 0;
 			if (isset($details[$side]['c']) && is_array($details[$side]['c'])) { 
-				if ($details[$side]['c']{0}==3) { 	// RGB
-					$coldom = 10-(((ord($details[$side]['c']{1})*1.00)+(ord($details[$side]['c']{2})*1.00)+(ord($details[$side]['c']{3})*1.00))/76.5); 
+				if ($details[$side]['c'][0]==3) { 	// RGB
+					$coldom = 10-(((ord(($details[$side]['c'][1] ?? ''))*1.00)+(ord(($details[$side]['c'][2] ?? ''))*1.00)+(ord(($details[$side]['c'][3] ?? ''))*1.00))/76.5); 
 				}
 			} // 10 black - 0 white
 			if ($coldom) { $dom += $coldom; }
@@ -25382,9 +25399,9 @@
 
 			if ($save) {
 				$this->cellBorderBuffer[] = pack("A16nCnda6A10d14",
-					str_pad(sprintf("%08.7f", $dom),16,"0",STR_PAD_LEFT),
+					str_pad((sprintf("%08.7f", $dom) ?? ''),16,"0",STR_PAD_LEFT),
 					$cbord,
-					ord($side),
+					ord(($side ?? '')),
 					$details[$side]['s'],
 					$details[$side]['w'],
 					$details[$side]['c'],
@@ -25404,9 +25421,9 @@
 			   if ($details[$side]['style'] == 'ridge' || $details[$side]['style'] == 'groove' || $details[$side]['style'] == 'inset' || $details[$side]['style'] == 'outset' || $details[$side]['style'] == 'double' ) {
 				$details[$side]['overlay'] = true;
 				$this->cellBorderBuffer[] = pack("A16nCnda6A10d14",
-					str_pad(sprintf("%08.7f", ($dom+4)),16,"0",STR_PAD_LEFT),
+					str_pad((sprintf("%08.7f", ($dom+4)) ?? ''),16,"0",STR_PAD_LEFT),
 					$cbord,
-					ord($side),
+					ord(($side ?? '')),
 					$details[$side]['s'],
 					$details[$side]['w'],
 					$details[$side]['c'],
@@ -25429,7 +25446,7 @@
 		return;
 	   }
 
-	   if (isset($details['p']) && strlen($details['p'])>1) { $priority = $details['p']; }
+	   if (isset($details['p']) && strlen(($details['p'] ?? ''))>1) { $priority = $details['p']; }
 	   else { $priority='LTRB'; }
 	   $Tw = 0; 
 	   $Rw = 0; 
@@ -25443,7 +25460,7 @@
 	   $x2 = $x + $w; $y2 = $y + $h;
 	   $oldlinewidth = $this->LineWidth;
 
-	   for($p=0;$p<strlen($priority);$p++) {
+	   for($p=0;$p<strlen(($priority ?? ''));$p++) {
 		$side = $priority[$p];
 		$xadj = 0;
 		$xadj2 = 0;
@@ -25456,12 +25473,12 @@
 			$lx1 = $x;
 			$lx2 = $x2;
 			$this->SetLineWidth($Tw);
-			if ($cort == 'cell' || strpos($tablecorner,'L')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'L')!==false) {
 				if ($Tw > $Lw) $xadj = ($Tw - $Lw)/2;
 				if ($Tw < $Lw) $xadj = ($Tw + $Lw)/2;
 			}
 			else { $xadj = $Tw/2 - $bsh/2; }
-			if ($cort == 'cell' || strpos($tablecorner,'R')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'R')!==false) {
 				if ($Tw > $Rw) $xadj2 = ($Tw - $Rw)/2;
 				if ($Tw < $Rw) $xadj2 = ($Tw + $Rw)/2;
 			}
@@ -25480,12 +25497,12 @@
 			$lx1 = $x;
 			$lx2 = $x;
 			$this->SetLineWidth($Lw);
-			if ($cort == 'cell' || strpos($tablecorner,'T')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'T')!==false) {
 				if ($Lw > $Tw) $yadj = ($Lw - $Tw)/2;
 				if ($Lw < $Tw) $yadj = ($Lw + $Tw)/2;
 			}
 			else { $yadj = $Lw/2 - $bsv/2; }
-			if ($cort == 'cell' || strpos($tablecorner,'B')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'B')!==false) {
 				if ($Lw > $Bw) $yadj2 = ($Lw - $Bw)/2;
 				if ($Lw < $Bw) $yadj2 = ($Lw + $Bw)/2;
 			}
@@ -25504,13 +25521,13 @@
 			$lx1 = $x2;
 			$lx2 = $x2;
 			$this->SetLineWidth($Rw);
-			if ($cort == 'cell' || strpos($tablecorner,'T')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'T')!==false) {
 				if ($Rw < $Tw) $yadj = ($Rw + $Tw)/2;
 				if ($Rw > $Tw) $yadj = ($Rw - $Tw)/2;
 			}
 			else { $yadj = $Rw/2 - $bsv/2; }
 
-			if ($cort == 'cell' || strpos($tablecorner,'B')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'B')!==false) {
 				if ($Rw > $Bw) $yadj2 = ($Rw - $Bw)/2;
 				if ($Rw < $Bw) $yadj2 = ($Rw + $Bw)/2;
 			}
@@ -25530,12 +25547,12 @@
 			$lx1 = $x;
 			$lx2 = $x2;
 			$this->SetLineWidth($Bw);
-			if ($cort == 'cell' || strpos($tablecorner,'L')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'L')!==false) {
 				if ($Bw > $Lw) $xadj = ($Bw - $Lw)/2;
 				if ($Bw < $Lw) $xadj = ($Bw + $Lw)/2;
 			}
 			else { $xadj = $Bw/2 - $bsh/2; }
-			if ($cort == 'cell' || strpos($tablecorner,'R')!==false) {
+			if ($cort == 'cell' || strpos(($tablecorner ?? ''),'R')!==false) {
 				if ($Bw > $Rw) $xadj2 = ($Bw - $Rw)/2;
 				if ($Bw < $Rw) $xadj2 = ($Bw + $Rw)/2;
 			}
@@ -25798,7 +25815,7 @@
 		}
 	   }
 
-	   if ($bSeparate && count($cellBorderOverlay)) {
+	   if ($bSeparate && count(($cellBorderOverlay ?? []))) {
 		foreach($cellBorderOverlay AS $cbo) {
 			$this->SetLineWidth($cbo['lw']);
 			$this->SetDColor($cbo['col']); 
@@ -25816,17 +25833,17 @@
 /*-- TABLES-ADVANCED-BORDERS --*/
 function _lightenColor($c) {
 	if (is_array($c)) { die('Color error in _lightencolor'); }
-	if ($c{0}==3 || $c{0}==5) { 	// RGB
-		list($h,$s,$l) = $this->rgb2hsl(ord($c{1})/255,ord($c{2})/255,ord($c{3})/255);
+	if ($c[0]==3 || $c[0]==5) { 	// RGB
+		list($h,$s,$l) = $this->rgb2hsl(ord(($c[1] ?? ''))/255,ord(($c[2] ?? ''))/255,ord(($c[3] ?? ''))/255);
 		$l += ((1 - $l)*0.8);
 		list($r,$g,$b) = $this->hsl2rgb($h,$s,$l);
 		$ret = array(3,$r,$g,$b);
 	}
-	else if ($c{0}==4 || $c{0}==6) { 	// CMYK
-		$ret = array(4, max(0,(ord($c{1})-20)), max(0,(ord($c{2})-20)), max(0,(ord($c{3})-20)), max(0,(ord($c{4})-20)) );
-	}
-	else if ($c{0}==1) {	// Grayscale
-		$ret = array(1,min(255,(ord($c{1})+32)));
+	else if ($c[0]==4 || $c[0]==6) { 	// CMYK
+		$ret = array(4, max(0,(ord(($c[1] ?? ''))-20)), max(0,(ord(($c[2] ?? ''))-20)), max(0,(ord(($c[3] ?? ''))-20)), max(0,(ord(($c[4] ?? ''))-20)) );
+	}
+	else if ($c[0]==1) {	// Grayscale
+		$ret = array(1,min(255,(ord(($c[1] ?? ''))+32)));
 	}
 	$c = array_pad($ret, 6, 0);
 	$cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF) ); 
@@ -25836,18 +25853,18 @@
 
 function _darkenColor($c) {
 	if (is_array($c)) { die('Color error in _darkenColor'); }
-	if ($c{0}==3 || $c{0}==5) { 	// RGB
-		list($h,$s,$l) = $this->rgb2hsl(ord($c{1})/255,ord($c{2})/255,ord($c{3})/255);
+	if ($c[0]==3 || $c[0]==5) { 	// RGB
+		list($h,$s,$l) = $this->rgb2hsl(ord(($c[1] ?? ''))/255,ord(($c[2] ?? ''))/255,ord(($c[3] ?? ''))/255);
 		$s *= 0.25;
 		$l *= 0.75;
 		list($r,$g,$b) = $this->hsl2rgb($h,$s,$l);
 		$ret = array(3,$r,$g,$b);
  	}
-	else if ($c{0}==4 || $c{0}==6) { 	// CMYK
-		$ret = array(4, min(100,(ord($c{1})+20)), min(100,(ord($c{2})+20)), min(100,(ord($c{3})+20)), min(100,(ord($c{4})+20)) );
+	else if ($c[0]==4 || $c[0]==6) { 	// CMYK
+		$ret = array(4, min(100,(ord(($c[1] ?? ''))+20)), min(100,(ord(($c[2] ?? ''))+20)), min(100,(ord(($c[3] ?? ''))+20)), min(100,(ord(($c[4] ?? ''))+20)) );
  	}
-	else if ($c{0}==1) {	// Grayscale
-		$ret = array(1,max(0,(ord($c{1})-32)));
+	else if ($c[0]==1) {	// Grayscale
+		$ret = array(1,max(0,(ord(($c[1] ?? ''))-32)));
  	}
 	$c = array_pad($ret, 6, 0);
 	$cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF) ); 
@@ -26303,9 +26320,9 @@
 				if (isset($cell['colspan']) && $cell['colspan'] > 1) { $col -= ($cell['colspan']-1); }
 				// Nested content
 				if (isset($cell['textbuffer'])) {
-					for ($n=0; $n < count($cell['textbuffer']); $n++) {
+					for ($n=0; $n < count(($cell['textbuffer'] ?? [])); $n++) {
 						$t = $cell['textbuffer'][$n][0];
-						if (substr($t,0,19) == "\xbb\xa4\xactype=nestedtable") {
+						if (substr(($t ?? ''),0,19) == "\xbb\xa4\xactype=nestedtable") {
 							$objattr = $this->_getObjAttr($t);
 							$objattr['col'] = $col;
 							$cell['textbuffer'][$n][0] = "\xbb\xa4\xactype=nestedtable,objattr=".serialize($objattr)."\xbb\xa4\xac";
@@ -26347,7 +26364,7 @@
 		}
 		// Advance down page by half width of top border
 		if ($table['borders_separate']) { 
-			if ($startrow>0 && (!isset($table['is_thead']) || count($table['is_thead'])==0))
+			if ($startrow>0 && (!isset($table['is_thead']) || count(($table['is_thead'] ?? []))==0))
 				$adv = $table['border_spacing_V']/2; 
 			else 
 				$adv = $table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2; 
@@ -26505,7 +26522,7 @@
 	//Draw Table Contents and Borders
 	for( $i = 0; $i < $numrows ; $i++ ) { //Rows
 	  if ($split && $startrow > 0) { 
-		$thnr = (isset($table['is_thead']) ? count($table['is_thead']) : 0);
+		$thnr = (isset($table['is_thead']) ? count(($table['is_thead'] ?? [])) : 0);
 		if ($i >= $thnr && $i < $startrow) { continue; }
 		if ($i == $startrow){ $returny = $rety - $tableheaderrowheight; }
 	  }
@@ -26719,7 +26736,7 @@
 							}
 
 							if (isset($table['background-image'])) { 
-							   if ($table['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $table['background-image']['gradient'] )) {
+							   if ($table['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($table['background-image']['gradient'] ?? '') )) {
 								$g = $this->grad->parseMozGradient( $table['background-image']['gradient'] );
 								if ($g) {
 								   $this->tableBackgrounds[$level*9+1][] = array('gradient'=>true, 'x'=>$bx, 'y'=>$by, 'w'=>$bw, 'h'=>$bh, 'gradtype'=>$g['type'], 'stops'=>$g['stops'], 'colorspace'=>$g['colorspace'], 'coords'=>$g['coords'], 'extend'=>$g['extend'], 'clippath'=>'');
@@ -26746,12 +26763,12 @@
 						if ($this->tableBackgrounds) {
 						   $s = $this->PrintTableBackgrounds();
 	   					   if ($this->bufferoutput) {
-							$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer);
-							$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer );
+							$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->headerbuffer ?? ''));
+							$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", ($this->headerbuffer ?? '') );
 						   }
 						   else {
-							$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
-							$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]);
+							$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
+							$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", ($this->pages[$this->page] ?? ''));
 						   }
 						   $this->tableBackgrounds = array();
 						}
@@ -27082,7 +27099,7 @@
 			}
 
 			if (isset($cell['background-image']) && $paintcell) {
-			  if (isset($cell['background-image']['gradient']) && $cell['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $cell['background-image']['gradient'] )) {
+			  if (isset($cell['background-image']['gradient']) && $cell['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($cell['background-image']['gradient'] ?? '') )) {
 				$g = $this->grad->parseMozGradient( $cell['background-image']['gradient'] );
 				if ($g) {
  				  if ($table['borders_separate']) { 
@@ -27106,7 +27123,7 @@
 				}
 			  }
 			  else if (isset($cell['background-image']['image_id']) && $cell['background-image']['image_id']) {	// Background pattern
-				$n = count($this->patterns)+1;
+				$n = count(($this->patterns ?? []))+1;
  				if ($table['borders_separate']) { 
  					$px = $x+ ($table['border_spacing_H']/2);
 					$py = $y+ ($table['border_spacing_V']/2);
@@ -27231,25 +27248,25 @@
 				$this->cellLineStackingShift = $cell['cellLineStackingShift'];
 				if ($level==1) {
 					if (isset($table['is_tfoot'][$i]) && $table['is_tfoot'][$i]) {
-						if (preg_match('/{colsum([0-9]*)[_]*}/', $cell['textbuffer'][0][0], $m)) {
+						if (preg_match('/{colsum([0-9]*)[_]*}/', ($cell['textbuffer'][0][0] ?? ''), $m)) {
 							$rep = sprintf("%01.".intval($m[1])."f", $this->colsums[$j]);
-							$cell['textbuffer'][0][0] = preg_replace('/{colsum[0-9_]*}/', $rep ,$cell['textbuffer'][0][0]);
+							$cell['textbuffer'][0][0] = preg_replace('/{colsum[0-9_]*}/', ($rep ?? '') ,($cell['textbuffer'][0][0] ?? ''));
 						}
 					}
 					else if (!isset($table['is_thead'][$i])) { 
-						if (isset($this->colsums[$j])) { $this->colsums[$j] += floatval(preg_replace('/^[^0-9\.\,]*/','',$cell['textbuffer'][0][0])); }
-						else { $this->colsums[$j] = floatval(preg_replace('/^[^0-9\.\,]*/','',$cell['textbuffer'][0][0])); }
+						if (isset($this->colsums[$j])) { $this->colsums[$j] += floatval(preg_replace('/^[^0-9\.\,]*/','',($cell['textbuffer'][0][0] ?? ''))); }
+						else { $this->colsums[$j] = floatval(preg_replace('/^[^0-9\.\,]*/','',($cell['textbuffer'][0][0] ?? ''))); }
 					}
 				}
 				$opy = $this->y;
 				// mPDF ITERATION
 				if ($this->iterationCounter) {
 				   foreach($cell['textbuffer'] AS $k=>$t) {
-					if (preg_match('/{iteration ([a-zA-Z0-9_]+)}/',$t[0], $m)) {
+					if (preg_match('/{iteration ([a-zA-Z0-9_]+)}/',($t[0] ?? ''), $m)) {
 						$vname = '__'.$m[1].'_';
 						if (!isset($this->$vname)) { $this->$vname = 1; }
 						else { $this->$vname++; }
-						$cell['textbuffer'][$k][0] = preg_replace('/{iteration '.$m[1].'}/', $this->$vname, $cell['textbuffer'][$k][0]);
+						$cell['textbuffer'][$k][0] = preg_replace('/{iteration '.$m[1].'}/', ($this->$vname ?? ''), ($cell['textbuffer'][$k][0] ?? ''));
 					}
 				   }
 				}
@@ -27277,7 +27294,7 @@
 					}
 					$str = '';
 					foreach($cell['textbuffer'] AS $t) { $str .= $t[0].' '; }
-					$str = rtrim($str);
+					$str = rtrim(($str ?? ''));
 					if (!isset($cell['va']) || $cell['va']=='M') { 
 						$this->y -= ($h-$cell['mih'])/2; //Undo what was added earlier VERTICAL ALIGN
 						if ($angle > 0) { $this->y += (($h-$cell['mih'])/2) + $cell['padding']['T'] + ($cell['mih']-($cell['padding']['T'] + $cell['padding']['B'])); }
@@ -27346,16 +27363,16 @@
 					   }
 					}
 					$this->decimal_offset = 0;
-					if(substr($cell['a'],0,1) == 'D') {
-						if (isset($cell['colspan']) && $cell['colspan'] > 1) { $this->cellTextAlign = $c['a'] = substr($cell['a'],2,1); }
+					if(substr(($cell['a'] ?? ''),0,1) == 'D') {
+						if (isset($cell['colspan']) && $cell['colspan'] > 1) { $this->cellTextAlign = $c['a'] = substr(($cell['a'] ?? ''),2,1); }
 						else {
 							$smax = $table['decimal_align'][$j]['maxs0'];
 							$d_content = $table['decimal_align'][$j]['maxs0'] + $table['decimal_align'][$j]['maxs1'];
 							$this->decimal_offset = $smax;
 							$extra = ($w - $d_content - $wadj);
 							if ($extra > 0) {
-								if(substr($cell['a'],2,1) == 'R') { $this->decimal_offset += $extra; }
-								else if(substr($cell['a'],2,1) == 'C') { $this->decimal_offset += ($extra)/2; }
+								if(substr(($cell['a'] ?? ''),2,1) == 'R') { $this->decimal_offset += $extra; }
+								else if(substr(($cell['a'] ?? ''),2,1) == 'C') { $this->decimal_offset += ($extra)/2; }
 							}
 						}
 					}
@@ -27393,7 +27410,7 @@
 				}
 			    }
 			    if (isset($table['trbackground-images'][$i]) && ($j==0 || $table['borders_separate'])) {
-			    if (isset($table['trbackground-images'][$i]['gradient']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $table['trbackground-images'][$i]['gradient'] )) {
+			    if (isset($table['trbackground-images'][$i]['gradient']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($table['trbackground-images'][$i]['gradient'] ?? '') )) {
 				$g = $this->grad->parseMozGradient( $table['trbackground-images'][$i]['gradient'] );
 				if ($g) {
 					$gx = $x0;
@@ -27501,7 +27518,7 @@
 /*-- COLUMNS --*/
 	  if ($this->ColActive) {
 		if (!$this->table_keep_together && $i < $numrows-1 && $level==1) { $this->breakpoints[$this->CurrCol][] = $y + $h; }	// mPDF 6
-		if (count($this->cellBorderBuffer)) { $this->printcellbuffer(); }
+		if (count(($this->cellBorderBuffer ?? []))) { $this->printcellbuffer(); }
 	  }
 /*-- END COLUMNS --*/
 
@@ -27516,7 +27533,7 @@
 
 	if ($this->progressBar) { $this->UpdateProgressBar(7,70,' '); }	// *PROGRESS-BAR*
 
-	if (count($this->cellBorderBuffer)) { $this->printcellbuffer(); }
+	if (count(($this->cellBorderBuffer ?? []))) { $this->printcellbuffer(); }
 
  
 	if ($this->tableClipPath ) { $this->_out("Q"); }
@@ -27592,7 +27609,7 @@
 		}
 
 		if (isset($table['background-image'])) { 
-		   if (isset($table['background-image']['gradient']) && $table['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $table['background-image']['gradient'] )) {
+		   if (isset($table['background-image']['gradient']) && $table['background-image']['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', ($table['background-image']['gradient'] ?? '') )) {
 			$g = $this->grad->parseMozGradient( $table['background-image']['gradient'] );
 			if ($g) {
 			   $this->tableBackgrounds[$level*9+1][] = array('gradient'=>true, 'x'=>$bx, 'y'=>$by, 'w'=>$bw, 'h'=>$bh, 'gradtype'=>$g['type'], 'stops'=>$g['stops'], 'colorspace'=>$g['colorspace'], 'coords'=>$g['coords'], 'extend'=>$g['extend'], 'clippath'=>'');
@@ -27618,16 +27635,16 @@
 	if ($this->tableBackgrounds && $level == 1) {
 	   $s = $this->PrintTableBackgrounds();
 	   if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) {
-		$this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->tablebuffer);
-		if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->tablebuffer); }
+		$this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->tablebuffer ?? ''));
+		if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", ($this->tablebuffer ?? '')); }
 	   }
 	   else if ($this->bufferoutput) {
-		$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer);
-		if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer ); }
+		$this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->headerbuffer ?? ''));
+		if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", ($this->headerbuffer ?? '') ); }
 	   }
 	   else {
-		$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
-		if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]); }
+		$this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", ($this->pages[$this->page] ?? ''));
+		if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", ($this->pages[$this->page] ?? '')); }
 	   }
 	   $this->tableBackgrounds = array();
 	}
@@ -27664,7 +27681,7 @@
 /*-- END TABLES --*/
 
 function _putextgstates() {
-	for ($i = 1; $i <= count($this->extgstates); $i++) {
+	for ($i = 1; $i <= count(($this->extgstates ?? [])); $i++) {
             $this->_newobj();
             $this->extgstates[$i]['n'] = $this->n;
             $this->_out('<</Type /ExtGState');
@@ -27693,7 +27710,7 @@
 		$this->_out('/Usage <</Print <</PrintState /OFF>> /View <</ViewState /OFF>>>>>>');
 		$this->_out('endobj');
 	}
-	if (count($this->layers)) {
+	if (count(($this->layers ?? []))) {
 		ksort($this->layers);
 		foreach($this->layers as $id=>$layer) {
 			$this->_newobj();
@@ -27713,7 +27730,7 @@
 
 	// from mPDFI
 	function _putimportedobjects() {
-		if (is_array($this->parsers) && count($this->parsers) > 0) {
+		if (is_array($this->parsers) && count(($this->parsers ?? [])) > 0) {
 			foreach($this->parsers AS $filename => $p) {
 				$this->current_parser =& $this->parsers[$filename];
 				if (is_array($this->_obj_stack[$filename])) {
@@ -27765,21 +27782,21 @@
 				$this->pdf_write_value($tpl['resources']);
 			} else {
 				$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
-					if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
+					if (isset($this->_res['tpl'][$tplidx]['fonts']) && count(($this->_res['tpl'][$tplidx]['fonts'] ?? []))) {
 						$this->_out('/Font <<');
 						foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
 							$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
 						$this->_out('>>');
 				}
-					if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || 
-					   isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
+					if(isset($this->_res['tpl'][$tplidx]['images']) && count(($this->_res['tpl'][$tplidx]['images'] ?? [])) || 
+					   isset($this->_res['tpl'][$tplidx]['tpls']) && count(($this->_res['tpl'][$tplidx]['tpls'] ?? [])))
 					{
 						$this->_out('/XObject <<');
-						if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
+						if (isset($this->_res['tpl'][$tplidx]['images']) && count(($this->_res['tpl'][$tplidx]['images'] ?? []))) {
 							foreach($this->_res['tpl'][$tplidx]['images'] as $image)
 								$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
 						}
-						if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
+						if (isset($this->_res['tpl'][$tplidx]['tpls']) && count(($this->_res['tpl'][$tplidx]['tpls'] ?? []))) {
 							foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $itpl)
 								$this->_out($this->tplprefix.$i.' '.$itpl['n'].' 0 R');
 						}
@@ -27788,7 +27805,7 @@
 					$this->_out('>>');
 			}
 
-			$this->_out('/Length '.strlen($p).' >>');
+			$this->_out('/Length '.strlen(($p ?? '')).' >>');
 			$this->_putstream($p);
 			$this->_out('endobj');
 		}
@@ -27798,7 +27815,7 @@
 
 
 function _putpatterns() {
-	for ($i = 1; $i <= count($this->patterns); $i++) {
+	for ($i = 1; $i <= count(($this->patterns ?? [])); $i++) {
 		$x = $this->patterns[$i]['x'];
 		$y = $this->patterns[$i]['y']; 
 		$w = $this->patterns[$i]['w'];
@@ -27861,7 +27878,7 @@
 			// Set in classes/svg array['fo'] = true
 			// Required that _putshaders comes before _putpatterns in _putresources
 			// This adds any resources associated with any FormObject to every Formobject - overkill but works!
-			if (count($this->extgstates)) {
+			if (count(($this->extgstates ?? []))) {
 				$this->_out('/ExtGState <<');
 				foreach($this->extgstates as $k=>$extgstate)
 				   if (isset($extgstate['fo']) && $extgstate['fo']) {
@@ -27871,7 +27888,7 @@
 				$this->_out('>>');
 			}
 /*-- BACKGROUNDS --*/
-			if (isset($this->gradients) AND (count($this->gradients) > 0)) {
+			if (isset($this->gradients) AND (count(($this->gradients ?? [])) > 0)) {
 				$this->_out('/Shading <<');
 				foreach ($this->gradients as $id => $grad) {
 				   if (isset($grad['fo']) && $grad['fo']) {
@@ -27927,7 +27944,7 @@
 			$this->_out('/Filter /FlateDecode');
 			$s = gzcompress($s);
 		}
-		$this->_out('/Length '.strlen($s).'>>');
+		$this->_out('/Length '.strlen(($s ?? '')).'>>');
 		$this->_putstream($s);
 		$this->_out('endobj');
 	}
@@ -27935,7 +27952,7 @@
 
 /*-- BACKGROUNDS --*/
 function _putshaders() {
-			$maxid = count($this->gradients); //index for transparency gradients
+			$maxid = count(($this->gradients ?? [])); //index for transparency gradients
 			foreach ($this->gradients as $id => $grad) {  
 				if (($grad['type'] == 2 || $grad['type'] == 3) && empty($grad['is_mask'])) {
 					$this->_newobj();
@@ -27945,7 +27962,7 @@
 					$fn = array();
 					$bd = array();
 					$en = array();
-					for($i=0; $i<(count($grad['stops'])-1); $i++) {
+					for($i=0; $i<(count(($grad['stops'] ?? []))-1); $i++) {
 						$fn[] = ($this->n+1+$i).' 0 R';
 						$en[] = '0 1';
 						if ($i>0) { $bd[] = sprintf('%.3F', $grad['stops'][$i]['offset']); }
@@ -27956,7 +27973,7 @@
 					$this->_out('>>');
 					$this->_out('endobj');
 					$f1 = $this->n;
-					for($i=0; $i<(count($grad['stops'])-1); $i++) {
+					for($i=0; $i<(count(($grad['stops'] ?? []))-1); $i++) {
 						$this->_newobj();
 						$this->_out('<<');
 						$this->_out('/FunctionType 2');
@@ -27977,7 +27994,7 @@
 					$fn = array();
 					$bd = array();
 					$en = array();
-					for($i=0; $i<(count($grad['stops'])-1); $i++) {
+					for($i=0; $i<(count(($grad['stops'] ?? []))-1); $i++) {
 						$fn[] = ($this->n+1+$i).' 0 R';
 						$en[] = '0 1';
 						if ($i>0) { $bd[] = sprintf('%.3F', $grad['stops'][$i]['offset']); }
@@ -27988,7 +28005,7 @@
 					$this->_out('>>');
 					$this->_out('endobj');
 					$f2 = $this->n;
-					for($i=0; $i<(count($grad['stops'])-1); $i++) {
+					for($i=0; $i<(count(($grad['stops'] ?? []))-1); $i++) {
 						$this->_newobj();
 						$this->_out('<<');
 						$this->_out('/FunctionType 2');
@@ -28034,7 +28051,7 @@
 						else if ($grad['colorspace'] == 'Gray') { $this->_out('/Decode[0 1 0 1 0 1]'); }
 						else { $this->_out('/Decode[0 1 0 1 0 1 0 1 0 1]'); }
 						$this->_out('/BitsPerFlag 8');
-						$this->_out('/Length '.strlen($grad['stream']));
+						$this->_out('/Length '.strlen(($grad['stream'] ?? '')));
 						$this->_out('>>');
 						$this->_putstream($grad['stream']);
 					}
@@ -28082,7 +28099,7 @@
 						$this->_out('/BitsPerComponent 8');
 						$this->_out('/Decode[0 1 0 1 0 1]');
 						$this->_out('/BitsPerFlag 8');
-						$this->_out('/Length '.strlen($grad['stream_trans']));
+						$this->_out('/Length '.strlen(($grad['stream_trans'] ?? '')));
 						$this->_out('>>');
 						$this->_putstream($grad['stream_trans']);
 					}
@@ -28101,7 +28118,7 @@
 					$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
 					$p=($this->compress) ? gzcompress($str) : $str;
 					$this->_out('<< /Type /XObject /Subtype /Form /FormType 1 '.$filter);
-					$this->_out('/Length '.strlen($p));
+					$this->_out('/Length '.strlen(($p ?? '')));
 					$this->_out('/BBox [-'.($this->wPt/2).' -'.($this->hPt/2).' '.(2*$this->wPt).' '.(2*$this->hPt).']');	
 					$this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceGray >>');
 					$this->_out('/Resources <<');
@@ -28125,7 +28142,7 @@
 function _putspotcolors() {
 	foreach($this->spotColors as $name=>$color) {
 		$this->_newobj();
-		$this->_out('[/Separation /'.str_replace(' ','#20',$name));
+		$this->_out('[/Separation /'.str_replace(' ','#20',($name ?? '')));
 		$this->_out('/DeviceCMYK <<');
 		$this->_out('/Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0] ');
 		$this->_out(sprintf('/C1 [%.3F %.3F %.3F %.3F] ',$color['c']/100,$color['m']/100,$color['y']/100,$color['k']/100));
@@ -28137,7 +28154,7 @@
 
 
 function _putresources() {
-	if ($this->hasOC || count($this->layers))
+	if ($this->hasOC || count(($this->layers ?? [])))
 		$this->_putocg();
 	$this->_putextgstates();
 	$this->_putspotcolors();
@@ -28161,7 +28178,7 @@
 
 
 	//Resource dictionary
-	$this->offsets[2]=strlen($this->buffer);
+	$this->offsets[2]=strlen(($this->buffer ?? ''));
 	$this->_out('2 0 obj');
 	$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
 
@@ -28179,14 +28196,14 @@
 	}
 	$this->_out('>>');
 
-	if (count($this->spotColors)) {
+	if (count(($this->spotColors ?? []))) {
 		$this->_out('/ColorSpace <<');
 		foreach($this->spotColors as $color)
 			$this->_out('/CS'.$color['i'].' '.$color['n'].' 0 R');
 		$this->_out('>>');
 	}
 
-	if (count($this->extgstates)) {
+	if (count(($this->extgstates ?? []))) {
 		$this->_out('/ExtGState <<');
 		foreach($this->extgstates as $k=>$extgstate)
 			if (isset($extgstate['trans']))  $this->_out('/'.$extgstate['trans'].' '.$extgstate['n'].' 0 R');
@@ -28195,7 +28212,7 @@
 	}
 
 /*-- BACKGROUNDS --*/
-	if ((isset($this->gradients) AND (count($this->gradients) > 0)) || ($this->enableImports && count($this->tpls))) {	// mPDF 5.7.3
+	if ((isset($this->gradients) AND (count(($this->gradients ?? [])) > 0)) || ($this->enableImports && count(($this->tpls ?? [])))) {	// mPDF 5.7.3
 		$this->_out('/Shading <<');
 		foreach ($this->gradients as $id => $grad) {
 			$this->_out('/Sh'.$id.' '.$grad['id'].' 0 R');
@@ -28204,14 +28221,14 @@
 		// If a shading dictionary is in an object (tpl) imported from another PDF, it needs to be included
 		// in the document resources, as well as the object resources
 		// Otherwise get an error in some PDF viewers
-		if ($this->enableImports && count($this->tpls)) {
+		if ($this->enableImports && count(($this->tpls ?? []))) {
 			foreach($this->tpls as $tplidx => $tpl) {
 				if (isset($tpl['resources'])) {
 					$this->current_parser =& $tpl['parser'];
 					reset ($tpl['resources'][1]);
-					while (list($k, $v) = each($tpl['resources'][1])) {
+					foreach ($tpl['resources'][1] as $k => $v) {
 						if ($k == '/Shading') {
-							while (list($k2, $v2) = each($v[1])) {
+							foreach ($v[1] as $k2 => $v2) {
 								$this->_out($k2 . " ",false);
 								$this->pdf_write_value($v2);
 							}
@@ -28236,14 +28253,14 @@
 /*-- END BACKGROUNDS --*/
 
 
-	if(count($this->images) || count($this->formobjects) || ($this->enableImports && count($this->tpls))) {
+	if(count(($this->images ?? [])) || count(($this->formobjects ?? [])) || ($this->enableImports && count(($this->tpls ?? [])))) {
 		$this->_out('/XObject <<');
 		foreach($this->images as $image)
 			$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
             foreach($this->formobjects as $formobject)
                 $this->_out('/FO'.$formobject['i'].' '.$formobject['n'].' 0 R');
 /*-- IMPORTS --*/
-		if ($this->enableImports && count($this->tpls)) {
+		if ($this->enableImports && count(($this->tpls ?? []))) {
 			foreach($this->tpls as $tplidx => $tpl) {
 				$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
 			}
@@ -28254,7 +28271,7 @@
 
 /*-- BACKGROUNDS --*/
 
-	if (count($this->patterns)) {
+	if (count(($this->patterns ?? []))) {
 		$this->_out('/Pattern <<');
 		foreach($this->patterns as $k=>$patterns)
 			$this->_out('/P'.$k.' '.$patterns['n'].' 0 R');
@@ -28262,12 +28279,12 @@
 	}
 /*-- END BACKGROUNDS --*/
 
-	if ($this->hasOC || count($this->layers)) { 
+	if ($this->hasOC || count(($this->layers ?? []))) { 
 		$this->_out('/Properties <<');
 		if ($this->hasOC) { 
 			$this->_out('/OC1 '.$this->n_ocg_print.' 0 R /OC2 '.$this->n_ocg_view.' 0 R /OC3 '.$this->n_ocg_hidden.' 0 R ');
 		}
-		if (count($this->layers)) {
+		if (count(($this->layers ?? []))) {
 			foreach($this->layers as $id=>$layer)
 				$this->_out('/ZI'.$id.' '.$layer['n'].' 0 R');
 		}
@@ -28354,7 +28371,7 @@
 /*-- ENCRYPTION --*/
 function SetProtection($permissions=array(),$user_pass='',$owner_pass=null, $length=40)	{
 		$this->encrypted=false;
-		if (is_string($permissions) && strlen($permissions)>0) { $permissions = array($permissions); }
+		if (is_string($permissions) && strlen(($permissions ?? ''))>0) { $permissions = array($permissions); }
 		else if (!is_array($permissions)) { return 0; }
 		$this->last_rc4_key='';
 		$this->padding="\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08".
@@ -28395,18 +28412,18 @@
 		$len = 16;
 	else
 		$len = 10;
-	return substr($this->_md5_16($this->encryption_key.pack('VXxx',$n)),0,$len);
+	return substr(($this->_md5_16($this->encryption_key.pack('VXxx',$n)) ?? ''),0,$len);
 }
 
 // RC4 is the standard encryption algorithm used in PDF format
 function _RC4($key, $text) {
 	if ($this->last_rc4_key != $key) {
-		$k = str_repeat($key, 256/strlen($key)+1);
+		$k = str_repeat(($key ?? ''), 256/strlen(($key ?? ''))+1);
 		$rc4 = range(0,255);
 		$j = 0;
 		for ($i=0; $i<256; $i++){
 			$t = $rc4[$i];
-			$j = ($j + $t + ord($k[$i])) % 256;
+			$j = ($j + $t + ord(($k[$i] ?? ''))) % 256;
 			$rc4[$i] = $rc4[$j];
 			$rc4[$j] = $t;
 		}
@@ -28416,7 +28433,7 @@
 		$rc4 = $this->last_rc4_key_c;
 	}
 
-	$len = strlen($text);
+	$len = strlen(($text ?? ''));
 	$a = 0;
 	$b = 0;
 	$out = '';
@@ -28427,14 +28444,14 @@
 		$rc4[$a] = $rc4[$b];
 		$rc4[$b] = $t;
 		$k = $rc4[($rc4[$a]+$rc4[$b])%256];
-		$out.= chr(ord($text[$i]) ^ $k);
+		$out.= chr((int) (ord(($text[$i] ?? '')) ^ $k));
 	}
 	return $out;
 }
 
 // Get MD5 as binary string
 function _md5_16($string) {
-	return pack('H*',md5($string));
+	return pack('H*',md5(($string ?? '')));
 }
 
 // Compute O value
@@ -28449,14 +28466,14 @@
 		$keybytelen = (128 / 8);
 	else 
 		$keybytelen = (40 / 8);
-	$owner_RC4_key = substr($tmp,0,$keybytelen);
+	$owner_RC4_key = substr(($tmp ?? ''),0,$keybytelen);
 	$enc = $this->_RC4($owner_RC4_key, $user_pass);
 	if ($this->useRC128encryption) {
-		$len = strlen($owner_RC4_key);
+		$len = strlen(($owner_RC4_key ?? ''));
 		for ($i = 1; $i <= 19; ++$i) {
 			$key = '';
 			for ($j = 0; $j < $len; ++$j) {
-				$key .= chr(ord($owner_RC4_key{$j}) ^ $i);
+				$key .= chr((int) (ord(($owner_RC4_key[$j] ?? '')) ^ $i));
 			}
 			$enc = $this->_RC4($key, $enc);
 		}
@@ -28469,16 +28486,16 @@
 	if ($this->useRC128encryption) {
 		$tmp = $this->_md5_16($this->padding.$this->_hexToString($this->uniqid));
 		$enc = $this->_RC4($this->encryption_key, $tmp);
-		$len = strlen($tmp);
+		$len = strlen(($tmp ?? ''));
 		for ($i=1; $i<=19; ++$i) {
 			$key = '';
 			for ($j=0; $j<$len; ++$j) {
-				$key .= chr(ord($this->encryption_key{$j}) ^ $i);
+				$key .= chr((int) (ord(($this->encryption_key[$j] ?? '')) ^ $i));
 			}
 			$enc = $this->_RC4($key, $enc);
 		}
 		$enc .= str_repeat("\x00", 16);
-		return substr($enc, 0, 32);
+		return substr(($enc ?? ''), 0, 32);
 	}
 	else {
 		return $this->_RC4($this->encryption_key, $this->padding);
@@ -28492,8 +28509,8 @@
 	$owner_pass = substr($owner_pass.$this->padding,0,32);
 	$chars = 'ABCDEF1234567890';
 	$id = '';
-	for ($i=0; $i<32; $i++) { $id .= $chars{rand(0, 15)}; }
-	$this->uniqid = md5($id);
+	for ($i=0; $i<32; $i++) { $id .= $chars[rand(0, 15)]; }
+	$this->uniqid = md5(($id ?? ''));
 	// Compute O value
 	$this->Ovalue = $this->_Ovalue($user_pass,$owner_pass);
 	// Compute encyption key
@@ -28502,17 +28519,17 @@
 	else 
 		$keybytelen = (40/8);
 	$prot = sprintf('%032b', $protection);
-	$perms = chr(bindec(substr($prot,24,8)));
-	$perms .= chr(bindec(substr($prot,16,8)));
-	$perms .= chr(bindec(substr($prot,8,8)));
-	$perms .= chr(bindec(substr($prot,0,8)));
+	$perms = chr((int) (bindec(substr(($prot ?? ''),24,8))));
+	$perms .= chr((int) (bindec(substr(($prot ?? ''),16,8))));
+	$perms .= chr((int) (bindec(substr(($prot ?? ''),8,8))));
+	$perms .= chr((int) (bindec(substr(($prot ?? ''),0,8))));
 	$tmp = $this->_md5_16($user_pass.$this->Ovalue.$perms.$this->_hexToString($this->uniqid));
 	if ($this->useRC128encryption) {
 		for ($i=0; $i<50; ++$i) {
-			$tmp = $this->_md5_16(substr($tmp, 0, $keybytelen));
-		}
-	}
-	$this->encryption_key = substr($tmp,0,$keybytelen);
+			$tmp = $this->_md5_16(substr(($tmp ?? ''), 0, $keybytelen));
+		}
+	}
+	$this->encryption_key = substr(($tmp ?? ''),0,$keybytelen);
 	// Compute U value
 	$this->Uvalue = $this->_Uvalue();
 	// Compute P value
@@ -28522,13 +28539,13 @@
 
 function _hexToString($hs) {
 	$s = '';
-	$len = strlen($hs);
+	$len = strlen(($hs ?? ''));
 	if (($len % 2) != 0) {
 		$hs .= '0';
 		++$len;
 	}
 	for ($i = 0; $i < $len; $i += 2) {
-		$s .= chr(hexdec($hs{$i}.$hs{($i + 1)}));
+		$s .= chr((int) (hexdec($hs[$i].$hs[($i + 1)])));
 	}
 	return $s;
 }
@@ -28573,14 +28590,14 @@
 
 function _putbookmarks()
 {
-	$nb=count($this->BMoutlines);
+	$nb=count(($this->BMoutlines ?? []));
 	if($nb==0)
 		return;
 
 	$bmo = $this->BMoutlines;
 	$this->BMoutlines = array();
 	$lastlevel = -1;
-	for($i=0;$i<count($bmo);$i++) {
+	for($i=0;$i<count(($bmo ?? []));$i++) {
 		if ($bmo[$i]['l']>0) {
 			while($bmo[$i]['l']-$lastlevel > 1) {	// If jump down more than one level, insert a new entry
 				$new = $bmo[$i];
@@ -28593,7 +28610,7 @@
 		$this->BMoutlines[] = $bmo[$i];
 		$lastlevel = $bmo[$i]['l'];
 	}
-	$nb=count($this->BMoutlines);
+	$nb=count(($this->BMoutlines ?? []));
 
 	$lru=array();
 	$level=0;
@@ -28646,12 +28663,12 @@
 			// font style
 			$bms = $this->bookmarkStyles[$o['l']]['style'];
 			$style = 0;
-			if (strpos($bms,'B') !== false) { $style += 2; }
-			if (strpos($bms,'I') !== false) { $style += 1; }
+			if (strpos(($bms ?? ''),'B') !== false) { $style += 2; }
+			if (strpos(($bms ?? ''),'I') !== false) { $style += 1; }
 			$this->_out(sprintf('/F %d', $style));
 			// Colour
 			$col = $this->bookmarkStyles[$o['l']]['color'];
-			if (isset($col) && is_array($col) && count($col)==3) {
+			if (isset($col) && is_array($col) && count(($col ?? []))==3) {
 				$this->_out(sprintf('/C [%.3F %.3F %.3F]', ($col[0]/255), ($col[1]/255), ($col[2]/255)));
 			} 
 		}
@@ -28744,7 +28761,7 @@
 		if($this->state==0) $this->AddPage();
 		if ($this->y == $this->tMargin && (!$this->mirrorMargins ||($this->mirrorMargins && $this->page % 2==1))) {
 			// Don't add a page
-			if ($this->page==1 && count($this->PageNumSubstitutions)==0) { 
+			if ($this->page==1 && count(($this->PageNumSubstitutions ?? []))==0) { 
 				if (!$suppress) { $suppress = 'off'; }
 				//$this->PageNumSubstitutions[] = array('from'=>1, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=> $suppress);
 			}
@@ -28770,9 +28787,9 @@
 		$this->internallink['#'.$uid] = $linkn;
 		$this->SetLink($linkn,$ily,$this->page);
 
-		if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
+		if (strtoupper(($toc_id ?? ''))=='ALL') { $toc_id = '_mpdf_all'; }
 		else if (!$toc_id) { $toc_id = 0; }
-		else { $toc_id = strtolower($toc_id); }
+		else { $toc_id = strtolower(($toc_id ?? '')); }
 		$btoc = array('t'=>$txt,'l'=>$level,'p'=>$this->page, 'link'=>$linkn, 'toc_id'=>$toc_id);
 		if ($this->keep_block_together) {
 			// do nothing
@@ -28802,7 +28819,7 @@
 		$n_toc = $end_page - $start_page + 1;
 
 		// Set/Update PageNumSubstitutions changes before moving anything
-		if (count($this->PageNumSubstitutions)) {
+		if (count(($this->PageNumSubstitutions ?? []))) {
 			$tp_present = false;
 			$sp_present = false;
 			$ep_present = false;
@@ -28862,12 +28879,12 @@
 /*-- END BOOKMARKS --*/
 
 		// Update Page Links
-		if (count($this->PageLinks)) {
+		if (count(($this->PageLinks ?? []))) {
 		   $newarr = array();
 		   foreach($this->PageLinks as $i=>$o) {
 			foreach($this->PageLinks[$i] as $key => $pl) {
-				if (strpos($pl[4],'@')===0) {
-					$p=substr($pl[4],1);
+				if (strpos(($pl[4] ?? ''),'@')===0) {
+					$p=substr(($pl[4] ?? ''),1);
 					if($p>=$start_page && $p<=$end_page) {
 						$this->PageLinks[$i][$key][4] = '@'.($p + ($target_page - $start_page));
 					}
@@ -28890,7 +28907,7 @@
 		}
 
 		// OrientationChanges
-		if (count($this->OrientationChanges)) {
+		if (count(($this->OrientationChanges ?? []))) {
 			$newarr = array();
 			foreach($this->OrientationChanges AS $p=>$v) {
 				if($p>=$start_page && $p<=$end_page) { $newarr[($p + ($target_page - $start_page))] = $this->OrientationChanges[$p]; }
@@ -28902,7 +28919,7 @@
 		}
 
 		// Page Dimensions
-		if (count($this->pageDim)) {
+		if (count(($this->pageDim ?? []))) {
 			$newarr = array();
 			foreach($this->pageDim AS $p=>$v) {
 				if($p>=$start_page && $p<=$end_page) { $newarr[($p + ($target_page - $start_page))] = $this->pageDim[$p]; }
@@ -28914,7 +28931,7 @@
 		}
 
 		// HTML Headers & Footers
-		if (count($this->saveHTMLHeader)) {
+		if (count(($this->saveHTMLHeader ?? []))) {
 			$newarr = array();
 			foreach($this->saveHTMLHeader AS $p=>$v) {
 				if($p>=$start_page && $p<=$end_page) { $newarr[($p + ($target_page - $start_page))] = $this->saveHTMLHeader[$p]; }
@@ -28924,7 +28941,7 @@
 			ksort($newarr);
 			$this->saveHTMLHeader = $newarr;
 		}
-		if (count($this->saveHTMLFooter)) {
+		if (count(($this->saveHTMLFooter ?? []))) {
 			$newarr = array();
 			foreach($this->saveHTMLFooter AS $p=>$v) {
 				if($p>=$start_page && $p<=$end_page) { $newarr[($p + ($target_page - $start_page))] = $this->saveHTMLFooter[$p]; }
@@ -28936,7 +28953,7 @@
 		}
 
 		// Update Internal Links
-		if (count($this->internallink)) {
+		if (count(($this->internallink ?? []))) {
 		   foreach($this->internallink as $key=>$o) {
 			if($o['PAGE']>=$start_page && $o['PAGE']<=$end_page) {
 				$this->internallink[$key]['PAGE'] += ($target_page - $start_page);
@@ -28948,7 +28965,7 @@
 		}
 
 		// Update Links
-		if (count($this->links)) {
+		if (count(($this->links ?? []))) {
 		   foreach($this->links as $key=>$o) {
 			if($o[0]>=$start_page && $o[0]<=$end_page) {
 				$this->links[$key][0] += ($target_page - $start_page);
@@ -28960,7 +28977,7 @@
 		}
 
 		// Update Form fields
-		if (count($this->mpdfform->forms)) {
+		if (count(($this->mpdfform->forms ?? []))) {
 		   foreach($this->mpdfform->forms as $key=>$f) {
 			if($f['page']>=$start_page && $f['page']<=$end_page) {
 				$this->mpdfform->forms[$key]['page'] += ($target_page - $start_page);
@@ -28973,7 +28990,7 @@
 
 /*-- ANNOTATIONS --*/
 		// Update Annotations
-		if (count($this->PageAnnots)) {
+		if (count(($this->PageAnnots ?? []))) {
 		   $newarr = array();
 		   foreach($this->PageAnnots as $p=>$anno) {
 			if($p>=$start_page && $p<=$end_page) {
@@ -28998,7 +29015,7 @@
 /*-- END ANNOTATIONS --*/
 
 		// Update PageNumSubstitutions
-		if (count($this->PageNumSubstitutions)) {
+		if (count(($this->PageNumSubstitutions ?? []))) {
 			$newarr = array();
 			foreach($this->PageNumSubstitutions AS $k=>$v) {
 				if($this->PageNumSubstitutions[$k]['from']>=$start_page && $this->PageNumSubstitutions[$k]['from']<=$end_page) { 
@@ -29020,7 +29037,7 @@
 			if (!$tp_present) {
 					$newarr[($target_page + $n_toc)] = array('from'=>($target_page+$n_toc), 'suppress'=>$tp_suppress, 'reset'=>$tp_reset, 'type'=>$tp_type); 
 			}
-			if (!$ep_present && $end_page>count($this->pages)) {
+			if (!$ep_present && $end_page>count(($this->pages ?? []))) {
 					$newarr[($end_page+1)] = array('from'=>($end_page+1), 'suppress'=>$ep_suppress, 'reset'=>$ep_reset, 'type'=>$ep_type); 
 			}
 			ksort($newarr);
@@ -29036,7 +29053,7 @@
 	// move a page/pages EARLIER in the document
 		if ($end_page<1) { $end_page = $start_page; }
 		$n_tod = $end_page - $start_page + 1;
-		$last_page = count($this->pages);
+		$last_page = count(($this->pages ?? []));
 		$n_atend = $last_page - $end_page + 1;
 
 		//move pages
@@ -29057,12 +29074,12 @@
 /*-- END BOOKMARKS --*/
 
 		// Update Page Links
-		if (count($this->PageLinks)) {
+		if (count(($this->PageLinks ?? []))) {
 		   $newarr = array();
 		   foreach($this->PageLinks as $i=>$o) {
 			foreach($this->PageLinks[$i] as $key => $pl) {
-				if (strpos($pl[4],'@')===0) {
-					$p=substr($pl[4],1);
+				if (strpos(($pl[4] ?? ''),'@')===0) {
+					$p=substr(($pl[4] ?? ''),1);
 					if($p>$end_page) { $this->PageLinks[$i][$key][4] = '@'.($p - $n_tod); }
 					else if($p<$start_page) { unset($this->PageLinks[$i][$key]); }
 				}
@@ -29074,7 +29091,7 @@
 		}
 
 		// OrientationChanges
-		if (count($this->OrientationChanges)) {
+		if (count(($this->OrientationChanges ?? []))) {
 			$newarr = array();
 			foreach($this->OrientationChanges AS $p=>$v) {
 				if($p>$end_page) { $newarr[($p - $t_tod)] = $this->OrientationChanges[$p]; }
@@ -29085,7 +29102,7 @@
 		}
 
 		// Page Dimensions
-		if (count($this->pageDim)) {
+		if (count(($this->pageDim ?? []))) {
 			$newarr = array();
 			foreach($this->pageDim AS $p=>$v) {
 				if($p>$end_page) { $newarr[($p - $n_tod)] = $this->pageDim[$p]; }
@@ -29096,7 +29113,7 @@
 		}
 
 		// HTML Headers & Footers
-		if (count($this->saveHTMLHeader)) {
+		if (count(($this->saveHTMLHeader ?? []))) {
 			foreach($this->saveHTMLHeader AS $p=>$v) {
 				if($p>$end_page) { $newarr[($p - $n_tod)] = $this->saveHTMLHeader[$p]; }	// mPDF 5.7.3
 				else if($p<$start_page) { $newarr[$p] = $this->saveHTMLHeader[$p]; }
@@ -29104,7 +29121,7 @@
 			ksort($newarr);
 			$this->saveHTMLHeader = $newarr;
 		}
-		if (count($this->saveHTMLFooter)) {
+		if (count(($this->saveHTMLFooter ?? []))) {
 			$newarr = array();
 			foreach($this->saveHTMLFooter AS $p=>$v) {
 				if($p>$end_page) { $newarr[($p - $n_tod)] = $this->saveHTMLFooter[$p]; }
@@ -29134,7 +29151,7 @@
 
 /*-- ANNOTATIONS --*/
 		// Update Annotations
-		if (count($this->PageAnnots)) {
+		if (count(($this->PageAnnots ?? []))) {
 		   $newarr = array();
 		   foreach($this->PageAnnots as $p=>$anno) {
 			if($p>$end_page) { foreach($anno as $o) { $newarr[($p - $n_tod)][] = $o; } }
@@ -29152,7 +29169,7 @@
 		}
 
 	unset($newarr);
-	$this->page = count($this->pages);
+	$this->page = count(($this->pages ?? []));
 }
 
 
@@ -29174,7 +29191,7 @@
 	}
 /*-- TABLES --*/
 	else if ($this->kwt) {
-		$size=count($this->kwt_Reference);
+		$size=count(($this->kwt_Reference ?? []));
 		for ($i=0;$i<$size;$i++){
 			if (isset($this->kwt_Reference[$i]['t']) && $this->kwt_Reference[$i]['t']==$txt){
 				$Present = true;
@@ -29189,7 +29206,7 @@
 	}
 /*-- END TABLES --*/
 	else {
-		$size=count($this->Reference);
+		$size=count(($this->Reference ?? []));
 		for ($i=0;$i<$size;$i++){
 			if (isset($this->Reference[$i]['t']) && $this->Reference[$i]['t']==$txt){
 				$Present = true;
@@ -29209,19 +29226,19 @@
 function IndexEntrySee($txta,$txtb) {
 	if ($this->directionality == 'rtl') {	// *OTL*
 		// ONLY DO THIS IF NOT IN TAGS
-		if ($txta == strip_tags($txta)) $txta = str_replace(':',' - ',$txta);	// *OTL*
-		if ($txtb == strip_tags($txtb)) $txtb = str_replace(':',' - ',$txtb);	// *OTL*
+		if ($txta == strip_tags($txta)) $txta = str_replace(':',' - ',($txta ?? ''));	// *OTL*
+		if ($txtb == strip_tags($txtb)) $txtb = str_replace(':',' - ',($txtb ?? ''));	// *OTL*
 	}	// *OTL*
 	else {	// *OTL*
-		if ($txta == strip_tags($txta)) $txta = str_replace(':',', ',$txta);
-		if ($txtb == strip_tags($txtb)) $txtb = str_replace(':',', ',$txtb);
+		if ($txta == strip_tags($txta)) $txta = str_replace(':',', ',($txta ?? ''));
+		if ($txtb == strip_tags($txtb)) $txtb = str_replace(':',', ',($txtb ?? ''));
 	}	// *OTL*
 	$this->Reference[]=array('t'=>$txta.' - see '.$txtb,'p'=>array());
 }
 
 
 function InsertIndex($usedivletters=1, $useLinking=false, $indexCollationLocale='', $indexCollationGroup='') {
-	$size=count($this->Reference);
+	$size=count(($this->Reference ?? []));
 	if ($size == 0) { return false; }
 
 	// $spacer used after named entry
@@ -29251,7 +29268,7 @@
 		else { $collation = array(); }
 		for ($i=0;$i<$size;$i++){
 	  	 	if ($this->Reference[$i]['uf']) { 
-				$l = mb_substr($this->Reference[$i]['uf'],0,1,'UTF-8');
+				$l = mb_substr(($this->Reference[$i]['uf'] ?? ''),0,1,'UTF-8');
 				if (isset($this->indexCollationGroup) && $this->indexCollationGroup) {
 					$uni = $this->UTF8StringToArray($l);
 					$ucode = $uni[0];
@@ -29265,7 +29282,7 @@
 
 	if (!function_exists('cmp')) {
 		function cmp ($a, $b) {
-		    return strcoll(strtolower($a['uf']), strtolower($b['uf']));
+		    return strcoll(strtolower(($a['uf'] ?? '')), strtolower(($b['uf'] ?? '')));
 		}
 	}
 	//Alphabetic sort of the references
@@ -29289,17 +29306,17 @@
 
 			// Sub-entries e.g. Mammals:elephant
 			// But allow for tags e.g. <b>Mammal</b>:elephants
-			$a=preg_split('/(<.*?>)/',$txt,-1,PREG_SPLIT_DELIM_CAPTURE);
+			$a=preg_split('/(<.*?>)/',($txt ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 			$txt = '';
 			$marker = false;
 			foreach($a as $k => $e) {
 				if($k%2==0 && !$marker) {
-					if (strpos($e, ':')!==false) {	// == SubEntry
+					if (strpos(($e ?? ''), ':')!==false) {	// == SubEntry
 						if ($this->indexUseSubentries) {
 
 							// If the Main entry does not have any page numbers associated with it
 							// create and insert an entry
-							list($txtmain,$sub) = preg_split('/[:]/', $e, 2);
+							list($txtmain,$sub) = preg_split('/[:]/', ($e ?? ''), 2);
 							if (strip_tags($txt.$txtmain) != $mainentry) {
 								$html .= '<div class="mpdf_index_entry">'.$txt.$txtmain.'</div>';
 								$mainentry = strip_tags($txt.$txtmain); 
@@ -29309,7 +29326,7 @@
 							$e = $sub;	// Only replace first one
 						}
 						else {
-							$e = preg_replace('/[:]/', $subEntrySeparator, $e, 1);	// Only replace first one
+							$e = preg_replace('/[:]/', ($subEntrySeparator ?? ''), ($e ?? ''), 1);	// Only replace first one
 						}
 						$marker = true;	// Don't replace any more once the subentry marker has been found
 					}
@@ -29322,7 +29339,7 @@
 			$html .= '<div class="mpdf_index_entry">';
 			$html .= $txt;
 			$ppp = $this->Reference[$i]['p'];	// = array of page numbers to point to
-			if (count($ppp)) { 
+			if (count(($ppp ?? []))) { 
 			 sort($ppp);
 			 $newarr = array();
 			 $range_start = $ppp[0];
@@ -29330,7 +29347,7 @@
 
 			 $html .= $spacer;
 
-			 for ($zi=1;$zi<count($ppp);$zi++) {
+			 for ($zi=1;$zi<count(($ppp ?? []));$zi++) {
 			  if ($ppp[$zi] == ($ppp[($zi-1)]+1)) {
 				$range_end = $ppp[$zi];
 			  }
@@ -29377,8 +29394,8 @@
 
 			 }
 			 else {
-				if ($useLinking) { $html .= '<a class="mpdf_index_link" href="@'.$ppp[(count($ppp)-1)].'">'; } 
-				$html .= $this->docPageNum($ppp[(count($ppp)-1)]);
+				if ($useLinking) { $html .= '<a class="mpdf_index_link" href="@'.$ppp[(count(($ppp ?? []))-1)].'">'; } 
+				$html .= $this->docPageNum($ppp[(count(($ppp ?? []))-1)]);
 				if ($useLinking) { $html .= '</a>'; } 
 			 }
 			}
@@ -29397,7 +29414,7 @@
 
 
 function AcceptPageBreak() {
-	if (count($this->cellBorderBuffer)) { $this->printcellbuffer(); }	// *TABLES*
+	if (count(($this->cellBorderBuffer ?? []))) { $this->printcellbuffer(); }	// *TABLES*
 /*-- COLUMNS --*/
 	if ($this->ColActive==1) {
 	    if($this->CurrCol<$this->NbCol-1) {
@@ -29414,7 +29431,7 @@
 	   }
 	   else {
     		//Go back to the first column - NEW PAGE
-		if (count($this->columnbuffer)) { $this->printcolumnbuffer(); }
+		if (count(($this->columnbuffer ?? []))) { $this->printcolumnbuffer(); }
 		$this->SetCol(0);
 		$this->y0 = $this->tMargin;
         	$this->ChangeColumn= -($this->NbCol-1);
@@ -29448,7 +29465,7 @@
 	if ($NbCol<2) {	// SET COLUMNS OFF
 		if ($this->ColActive) { 
 			$this->ColActive=0;
-			if (count($this->columnbuffer)) { $this->printcolumnbuffer(); }
+			if (count(($this->columnbuffer ?? []))) { $this->printcolumnbuffer(); }
 			$this->NbCol=1;
 			$this->ResetMargins(); 
 			$this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
@@ -29468,7 +29485,7 @@
 	else {	// SET COLUMNS ON
 		if ($this->ColActive) { 
 			$this->ColActive=0;
-			if (count($this->columnbuffer)) { $this->printcolumnbuffer(); }
+			if (count(($this->columnbuffer ?? []))) { $this->printcolumnbuffer(); }
 			$this->ResetMargins(); 
 		}
 		if (isset($this->y) && $this->y>$this->tMargin) $this->Ln();
@@ -29485,7 +29502,7 @@
 		$this->col_BMoutlines = array();
 		$this->col_toc = array();
 		$this->breakpoints = array();
-		if ((strtoupper($vAlign) == 'J') || (strtoupper($vAlign) == 'JUSTIFY')) { $vAlign = 'J'; } 
+		if ((strtoupper(($vAlign ?? '')) == 'J') || (strtoupper(($vAlign ?? '')) == 'JUSTIFY')) { $vAlign = 'J'; } 
 		else { $vAlign = ''; }
 		$this->colvAlign = $vAlign;
 		//Save the ordinate
@@ -29548,7 +29565,7 @@
     		else {
     		//Go back to the first column
         	//Page break
-		if (count($this->columnbuffer)) { $this->printcolumnbuffer(); }
+		if (count(($this->columnbuffer ?? []))) { $this->printcolumnbuffer(); }
 		$this->AddPage($this->CurOrientation);
 		$this->SetCol(0);
 		$this->y0 = $this->tMargin;
@@ -29584,22 +29601,22 @@
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 			$this->columnbuffer[$key]['s'] = '';
 		}
-		else if (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',$t)) {
+		else if (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',($t ?? ''))) {
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
-		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',$t)) {
+		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',($t ?? ''))) {
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
-		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',$t)) {
+		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',($t ?? ''))) {
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
-		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',$t)) {
+		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',($t ?? ''))) {
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
-		else if (preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',$t)) { 
+		else if (preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',($t ?? ''))) { 
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
-		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',$t)) {
+		else if (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',($t ?? ''))) {
 			$this->columnbuffer[$key]['rel_y'] = $s['y'] + $this->ColDetails[$s['col']]['add_y'] - $this->y0;
 		}
 	}
@@ -29830,11 +29847,11 @@
 	foreach($this->columnbuffer AS $key=>$s) { 
 	   // Only process output data
 	   $t = $s['s'];
-	   if ($t == 'ACROFORM' || (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',$t)) || (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',$t)) ||
-		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',$t)) || 
-		(preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',$t)) || 
-		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',$t)) || 
-		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',$t)) ) { 
+	   if ($t == 'ACROFORM' || (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',($t ?? ''))) || (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',($t ?? ''))) ||
+		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',($t ?? ''))) || 
+		(preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',($t ?? ''))) || 
+		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',($t ?? ''))) || 
+		(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',($t ?? ''))) ) { 
 
 		$clb = $s['y'] + $s['h'];
 		if ((isset($this->ColDetails[$s['col']]['max_bottom']) && $clb > $this->ColDetails[$s['col']]['max_bottom']) || !isset($this->ColDetails[$s['col']]['max_bottom'])) { $this->ColDetails[$s['col']]['max_bottom'] = $clb; }
@@ -29934,11 +29951,11 @@
 		foreach($this->columnbuffer AS $key=>$s) { 
 		   // Only process output data
 		   $t = $s['s'];
-		   if ($t == 'ACROFORM' || (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',$t)) || (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',$t)) ||
-			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',$t)) || 
-			(preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',$t)) || 
-			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',$t)) || 
-			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',$t)) ) { 
+		   if ($t == 'ACROFORM' || (preg_match('/BT \d+\.\d\d+ (\d+\.\d\d+) Td/',($t ?? ''))) || (preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ [\-]{0,1}\d+\.\d\d+ re/',($t ?? ''))) ||
+			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) l/',($t ?? ''))) || 
+			(preg_match('/q \d+\.\d\d+ 0 0 \d+\.\d\d+ \d+\.\d\d+ (\d+\.\d\d+) cm \/(I|FO)\d+ Do Q/',($t ?? ''))) || 
+			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) m/',($t ?? ''))) || 
+			(preg_match('/\d+\.\d\d+ (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ \d+\.\d\d+ c/',($t ?? ''))) ) { 
 
 			$clb = $s['y'] + $s['h'];
 			if ($clb > $this->ColDetails[$s['col']]['max_bottom']) { $this->ColDetails[$s['col']]['max_bottom'] = $clb; }
@@ -29982,13 +29999,13 @@
 
 // mPDF 5.7+
 function columnAdjustPregReplace($type, $xadj, $yadj, $pattern, $subject) {
-	preg_match($pattern, $subject, $matches);
-	if (!count($matches)) { return $subject; }
+	preg_match(($pattern ?? ''), ($subject ?? ''), $matches);
+	if (!count(($matches ?? []))) { return $subject; }
 	if (!isset($matches[3])) { $matches[3] = 0; }
 	if (!isset($matches[4])) { $matches[4] = 0; }
 	if (!isset($matches[5])) { $matches[5] = 0; }
 	if (!isset($matches[6])) { $matches[6] = 0; }
-	return str_replace($matches[0], $this->columnAdjustAdd($type, _MPDFK, $xadj, $yadj, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]), $subject);
+	return str_replace(($matches[0] ?? ''), ($this->columnAdjustAdd($type, _MPDFK, $xadj, $yadj, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]) ?? ''), ($subject ?? ''));
 }
 
 /*-- END COLUMNS --*/
@@ -29997,18 +30014,18 @@
 //==================================================================
 /*-- TABLES --*/
 function printcellbuffer() {
-	if (count($this->cellBorderBuffer )) {
+	if (count(($this->cellBorderBuffer ?? []) )) {
 		sort($this->cellBorderBuffer);
 		foreach($this->cellBorderBuffer AS $cbb) {
 			$cba = unpack("A16dom/nbord/A1side/ns/dbw/a6ca/A10style/dx/dy/dw/dh/dmbl/dmbr/dmrt/dmrb/dmtl/dmtr/dmlt/dmlb/dcpd/dover/", $cbb);
 			$side = $cba['side'];
-			$color = str_pad($cba['ca'], 6, "\x00");
+			$color = str_pad(($cba['ca'] ?? ''), 6, "\x00");
 			$details = array();
 			$details[$side]['dom'] = (float) $cba['dom'];
 			$details[$side]['s'] = $cba['s'];
 			$details[$side]['w'] = $cba['bw'];
 			$details[$side]['c'] = $color;
-			$details[$side]['style'] = trim($cba['style']);
+			$details[$side]['style'] = trim(($cba['style'] ?? ''));
 			$details['mbw']['BL'] = $cba['mbl'];
 			$details['mbw']['BR'] = $cba['mbr'];
 			$details['mbw']['RT'] = $cba['mrt'];
@@ -30218,7 +30235,7 @@
 	      // Output Reference (index)
 	      foreach($this->kwt_Reference AS $v) {
 			$Present=0;
-			for ($i=0;$i<count($this->Reference);$i++){
+			for ($i=0;$i<count(($this->Reference ?? []));$i++){
 				if ($this->Reference[$i]['t']==$v['t']){
 					$Present=1;
 					if (!in_array($v['op'],$this->Reference[$i]['p'])) {
@@ -30314,7 +30331,7 @@
 	foreach($this->kwt_Reference AS $v) {
 		$Present=0;
 		//Search the reference (AND Ref/PageNo) in the array
-		for ($i=0;$i<count($this->Reference);$i++){
+		for ($i=0;$i<count(($this->Reference ?? []));$i++){
 			if ($this->Reference[$i]['t']==$v['t']){
 				$Present=1;
 				if (!in_array($this->page,$this->Reference[$i]['p'])) {
@@ -30360,7 +30377,7 @@
 //==================================================================
 
 function printfloatbuffer() {
-	if (count($this->floatbuffer)) {
+	if (count(($this->floatbuffer ?? []))) {
 		$this->objectbuffer = $this->floatbuffer;
 		$this->printobjectbuffer(false);
 		$this->objectbuffer = array();
@@ -30403,10 +30420,10 @@
 	if ($this->text_input_as_HTML) {
 		$text = $this->all_entities_to_utf8($text);
 	}
-	if ($this->usingCoreFont) { $text = mb_convert_encoding($text,$this->mb_enc,'UTF-8'); }
+	if ($this->usingCoreFont) { $text = mb_convert_encoding(($text ?? ''),($this->mb_enc ?? ''),'UTF-8'); }
 
 	// DIRECTIONALITY
-	if (preg_match("/([".$this->pregRTLchars."])/u", $text)) { $this->biDirectional = true; }	// *OTL*
+	if (preg_match("/([".$this->pregRTLchars."])/u", ($text ?? ''))) { $this->biDirectional = true; }	// *OTL*
 
 	$textvar = 0;
 	$save_OTLtags = $this->OTLtags;
@@ -30458,7 +30475,7 @@
 		// including any added from OTL tables (in PUA)
 		$pregRTLchars = $this->pregRTLchars;
 		if (isset($this->CurrentFont['rtlPUAstr']) && $this->CurrentFont['rtlPUAstr']) { $pregRTLchars .= $this->CurrentFont['rtlPUAstr']; }
-		if (!preg_match("/[".$pregRTLchars."]/u",$chunk) && $dir!='rtl') { return 0; }   // Chunk doesn't contain RTL characters
+		if (!preg_match("/[".$pregRTLchars."]/u",($chunk ?? '')) && $dir!='rtl') { return 0; }   // Chunk doesn't contain RTL characters
 
 		$unicode = $this->UTF8StringToArray($chunk, false);
 
@@ -30495,22 +30512,22 @@
 	}
 }
 
-function _setBidiCodes($mode='start', $bdf) {
+function _setBidiCodes($mode, $bdf) {
 	$s = '';
 	if ($mode=='end') {
 		// PDF comes before PDI to close isolate-override (e.g. "LRILROPDFPDI")
-		if (strpos($bdf, 'PDF')!==false) { $s .= code2utf(0x202C); }	// POP DIRECTIONAL FORMATTING
-		if (strpos($bdf, 'PDI')!==false) { $s .= code2utf(0x2069); }	// POP DIRECTIONAL ISOLATE
+		if (strpos(($bdf ?? ''), 'PDF')!==false) { $s .= code2utf(0x202C); }	// POP DIRECTIONAL FORMATTING
+		if (strpos(($bdf ?? ''), 'PDI')!==false) { $s .= code2utf(0x2069); }	// POP DIRECTIONAL ISOLATE
 	}
 	else if ($mode=='start') {
 		// LRI comes before LRO to open isolate-override (e.g. "LRILROPDFPDI")
-		if (strpos($bdf, 'LRI')!==false) { $s .= code2utf(0x2066); }	// U+2066 LRI  
-		else if (strpos($bdf, 'RLI')!==false) { $s .= code2utf(0x2067); }	// U+2067 RLI 
-		else if (strpos($bdf, 'FSI')!==false) { $s .= code2utf(0x2068); }	// U+2068 FSI
-		if (strpos($bdf, 'LRO')!==false) { $s .= code2utf(0x202D); }	// U+202D LRO
-		else if (strpos($bdf, 'RLO')!==false) { $s .= code2utf(0x202E); }	// U+202E RLO
-		else if (strpos($bdf, 'LRE')!==false) { $s .= code2utf(0x202A); }	// U+202A LRE
-		else if (strpos($bdf, 'RLE')!==false) { $s .= code2utf(0x202B); }	// U+202B RLE
+		if (strpos(($bdf ?? ''), 'LRI')!==false) { $s .= code2utf(0x2066); }	// U+2066 LRI  
+		else if (strpos(($bdf ?? ''), 'RLI')!==false) { $s .= code2utf(0x2067); }	// U+2067 RLI 
+		else if (strpos(($bdf ?? ''), 'FSI')!==false) { $s .= code2utf(0x2068); }	// U+2068 FSI
+		if (strpos(($bdf ?? ''), 'LRO')!==false) { $s .= code2utf(0x202D); }	// U+202D LRO
+		else if (strpos(($bdf ?? ''), 'RLO')!==false) { $s .= code2utf(0x202E); }	// U+202E RLO
+		else if (strpos(($bdf ?? ''), 'LRE')!==false) { $s .= code2utf(0x202A); }	// U+202A LRE
+		else if (strpos(($bdf ?? ''), 'RLE')!==false) { $s .= code2utf(0x202B); }	// U+202B RLE
 	}
 	return $s;
 }
@@ -30535,12 +30552,12 @@
 
 function SubstituteChars($html) {
 	// only substitute characters between tags
-	if (count($this->substitute)) {
-		$a=preg_split('/(<.*?>)/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+	if (count(($this->substitute ?? []))) {
+		$a=preg_split('/(<.*?>)/ms',($html ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 		$html = '';
 		foreach($a as $i => $e) {
 			if($i%2==0) {
-			   $e = strtr($e, $this->substitute);
+			   $e = strtr(($e ?? ''), ($this->substitute ?? ''));
 			}
 			$html .= $e;
 		}
@@ -30550,7 +30567,7 @@
 
 
 function SubstituteCharsSIP(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
-	if (preg_match("/^(.*?)([\x{20000}-\x{2FFFF}]+)(.*)/u", $writehtml_e, $m)) { 
+	if (preg_match("/^(.*?)([\x{20000}-\x{2FFFF}]+)(.*)/u", ($writehtml_e ?? ''), $m)) { 
 	   if (isset($this->CurrentFont['sipext']) && $this->CurrentFont['sipext']) {
 		$font = $this->CurrentFont['sipext']; 
 		if (!in_array($font, $this->available_unifonts)) { return 0; }
@@ -30566,8 +30583,8 @@
 // If core font is selected in document which is not onlyCoreFonts - substitute with non-core font
 function SubstituteCharsNonCore(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
 	// Ignore if in Textarea
-	if ($writehtml_i > 0 && strtolower(substr($writehtml_a[$writehtml_i-1],0,8)) == 'textarea') { return 0; }
-	if (mb_convert_encoding(mb_convert_encoding($writehtml_e, $this->mb_enc, "UTF-8"), "UTF-8", $this->mb_enc) == $writehtml_e) {
+	if ($writehtml_i > 0 && strtolower((substr(($writehtml_a[$writehtml_i-1] ?? ''),0,8) ?? '')) == 'textarea') { return 0; }
+	if (mb_convert_encoding((mb_convert_encoding(($writehtml_e ?? ''), ($this->mb_enc ?? ''), "UTF-8") ?? ''), "UTF-8", $this->mb_enc) == $writehtml_e) {
 		return 0;
 	}
 	$cw = &$this->CurrentFont['cw'];
@@ -30591,7 +30608,7 @@
 		}
 		else if ($flag>0) { $end=$c-1; break; }
 	}
-	if ($flag>0 && !$end) { $end=count($unicode)-1; }
+	if ($flag>0 && !$end) { $end=count(($unicode ?? []))-1; }
 	if ($start==-1) { return 0; }
 	// TRY IN BACKUP SUBS FONT
 	if (!is_array($this->backupSubsFont)) { $this->backupSubsFont = array("$this->backupSubsFont"); }
@@ -30618,9 +30635,9 @@
 				$l++;
 			}
 			else {
-				if ($l==0 && $bsfctr == (count($this->backupSubsFont)-1)) {	// Not found even in last backup font
-					$cont = mb_substr($writehtml_e, $start+1);
-					$writehtml_e = mb_substr($writehtml_e, 0, $start+1, 'UTF-8');
+				if ($l==0 && $bsfctr == (count(($this->backupSubsFont ?? []))-1)) {	// Not found even in last backup font
+					$cont = mb_substr(($writehtml_e ?? ''), $start+1);
+					$writehtml_e = mb_substr(($writehtml_e ?? ''), 0, $start+1, 'UTF-8');
 					array_splice($writehtml_a, $writehtml_i+1, 0, array('', $cont));
 					$this->subPos = $writehtml_i+1;
 					return 2;
@@ -30629,8 +30646,8 @@
 			}
 		}
 		if ($l > 0) {
-			$patt = mb_substr($writehtml_e, $start, $l, 'UTF-8');
-			if (preg_match("/(.*?)(".preg_quote($patt,'/').")(.*)/u", $writehtml_e, $m)) {
+			$patt = mb_substr(($writehtml_e ?? ''), $start, $l, 'UTF-8');
+			if (preg_match("/(.*?)(".preg_quote(($patt ?? ''),'/').")(.*)/u", ($writehtml_e ?? ''), $m)) {
 				$writehtml_e = $m[1];
 				array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
 				$this->subPos = $writehtml_i+3;
@@ -30646,7 +30663,7 @@
 
 function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
 	// Ignore if in Textarea
-	if ($writehtml_i > 0 && strtolower(substr($writehtml_a[$writehtml_i-1],0,8)) == 'textarea') { return 0; }
+	if ($writehtml_i > 0 && strtolower((substr(($writehtml_a[$writehtml_i-1] ?? ''),0,8) ?? '')) == 'textarea') { return 0; }
 	$cw = &$this->CurrentFont['cw'];
 	$unicode = $this->UTF8StringToArray($writehtml_e, false);
 	$start = -1;
@@ -30669,7 +30686,7 @@
 		}
 		else if ($flag>0) { $end=$c-1; break; }
 	}
-	if ($flag>0 && !$end) { $end=count($unicode)-1; }
+	if ($flag>0 && !$end) { $end=count(($unicode ?? []))-1; }
 	if ($start==-1) { return 0; }
 	if ($flag == 2) { 	// SIP
 		// Check if current CJK font has a ext-B related font
@@ -30696,8 +30713,8 @@
 			else { break; }
 		}
 		if ($l > 0) {
-			$patt = mb_substr($writehtml_e, $start, $l);
-			if (preg_match("/(.*?)(".preg_quote($patt,'/').")(.*)/u", $writehtml_e, $m)) {
+			$patt = mb_substr(($writehtml_e ?? ''), $start, $l);
+			if (preg_match("/(.*?)(".preg_quote(($patt ?? ''),'/').")(.*)/u", ($writehtml_e ?? ''), $m)) {
 				$writehtml_e = $m[1];
 				array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
 				$this->subPos = $writehtml_i+3;
@@ -30730,8 +30747,8 @@
 			else { break; }
 		}
 		if ($l > 0) {
-			$patt = mb_substr($writehtml_e, $start, $l);
-			if (preg_match("/(.*?)(".preg_quote($patt,'/').")(.*)/u", $writehtml_e, $m)) {
+			$patt = mb_substr(($writehtml_e ?? ''), $start, $l);
+			if (preg_match("/(.*?)(".preg_quote(($patt ?? ''),'/').")(.*)/u", ($writehtml_e ?? ''), $m)) {
 				$writehtml_e = $m[1];
 				array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
 				$this->subPos = $writehtml_i+3;
@@ -30774,8 +30791,8 @@
 		}
 	  }
 	  if ($ftype=='C') {
-		$patt = mb_substr($writehtml_e, $start, count($repl));
-		if (preg_match("/(.*?)(".preg_quote($patt,'/').")(.*)/u", $writehtml_e, $m)) {
+		$patt = mb_substr(($writehtml_e ?? ''), $start, count(($repl ?? [])));
+		if (preg_match("/(.*?)(".preg_quote(($patt ?? ''),'/').")(.*)/u", ($writehtml_e ?? ''), $m)) {
 			$writehtml_e = $m[1];
 			array_splice($writehtml_a, $writehtml_i+1, 0, array($font, implode('|', $repl), '/'.$font, $m[3]));	// e.g. <tts>
 			$this->subPos = $writehtml_i+3;
@@ -30809,9 +30826,9 @@
 				$l++;
 			}
 			else {
-				if ($l==0 && $bsfctr == (count($this->backupSubsFont)-1)) {	// Not found even in last backup font
-					$cont = mb_substr($writehtml_e, $start+1);
-					$writehtml_e = mb_substr($writehtml_e, 0, $start+1);
+				if ($l==0 && $bsfctr == (count(($this->backupSubsFont ?? []))-1)) {	// Not found even in last backup font
+					$cont = mb_substr(($writehtml_e ?? ''), $start+1);
+					$writehtml_e = mb_substr(($writehtml_e ?? ''), 0, $start+1);
 					array_splice($writehtml_a, $writehtml_i+1, 0, array('', $cont));
 					$this->subPos = $writehtml_i+1;
 					return 2;
@@ -30820,8 +30837,8 @@
 			}
 		}
 		if ($l > 0) {
-			$patt = mb_substr($writehtml_e, $start, $l);
-			if (preg_match("/(.*?)(".preg_quote($patt,'/').")(.*)/u", $writehtml_e, $m)) {
+			$patt = mb_substr(($writehtml_e ?? ''), $start, $l);
+			if (preg_match("/(.*?)(".preg_quote(($patt ?? ''),'/').")(.*)/u", ($writehtml_e ?? ''), $m)) {
 				$writehtml_e = $m[1];
 				array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
 				$this->subPos = $writehtml_i+3;
@@ -30882,8 +30899,8 @@
 function SubstituteHiEntities($html) {
 	// converts html_entities > ASCII 127 to unicode
 	// Leaves in particular &lt; to distinguish from tag marker
-	if (count($this->entsearch)) {
-		$html = str_replace($this->entsearch,$this->entsubstitute,$html);
+	if (count(($this->entsearch ?? []))) {
+		$html = str_replace(($this->entsearch ?? ''),($this->entsubstitute ?? ''),($html ?? ''));
 	}
 	return $html;
 }
@@ -30891,12 +30908,12 @@
 
 // Edited v1.2 Pass by reference; option to continue if invalid UTF-8 chars
 function is_utf8(&$string) {
-	if ($string === mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32")) {
+	if ($string === mb_convert_encoding((mb_convert_encoding(($string ?? ''), "UTF-32", "UTF-8") ?? ''), "UTF-8", "UTF-32")) {
 		return true;
 	} 
 	else {
 	  if ($this->ignore_invalid_utf8) {
-		$string = mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") ;
+		$string = mb_convert_encoding((mb_convert_encoding(($string ?? ''), "UTF-32", "UTF-8") ?? ''), "UTF-8", "UTF-32") ;
 		return true;
 	  }
 	  else {
@@ -30914,22 +30931,22 @@
 	// Leaves in particular &lt; to distinguish from tag marker
 	if (!$this->is_utf8($html)) { 
 		echo "<p><b>HTML contains invalid UTF-8 character(s)</b></p>"; 
-		while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") != $html) {
-			$a = iconv('UTF-8', 'UTF-8', $html);
+		while (mb_convert_encoding((mb_convert_encoding(($html ?? ''), "UTF-32", "UTF-8") ?? ''), "UTF-8", "UTF-32") != $html) {
+			$a = iconv('UTF-8', 'UTF-8', ($html ?? ''));
 			echo ($a);
-			$pos = $start = strlen($a);
+			$pos = $start = strlen(($a ?? ''));
 			$err = '';
-			while ( ord(substr($html,$pos,1)) > 128 ) {
-				$err .= '[[#'.ord(substr($html,$pos,1)).']]';
+			while ( ord((substr(($html ?? ''),$pos,1) ?? '')) > 128 ) {
+				$err .= '[[#'.ord((substr(($html ?? ''),$pos,1) ?? '')).']]';
 				$pos++;
 			}
 			echo '<span style="color:red; font-weight:bold">'.$err.'</span>';
-			$html = substr($html, $pos);
+			$html = substr(($html ?? ''), $pos);
 		}
 		echo $html;
 		$this->Error(""); 
 	}
-	$html = preg_replace("/\r/", "", $html );
+	$html = preg_replace("/\r/", "", ($html ?? '') );
 
 	// converts html_entities > ASCII 127 to UTF-8 
 	// Leaves in particular &lt; to distinguish from tag marker
@@ -30946,7 +30963,7 @@
 	// Make sure UTF-8 string of characters
 	if (!$this->is_utf8($txt)) { $this->Error("Text contains invalid UTF-8 character(s)"); }
 
-	$txt = preg_replace("/\r/", "", $txt );
+	$txt = preg_replace("/\r/", "", ($txt ?? '') );
 
 	return ($txt);
 }
@@ -30973,7 +30990,7 @@
 				return;
 			}
 			$codestr = $code;
-			$code = preg_replace('/\-/','',$code);
+			$code = preg_replace('/\-/','',($code ?? ''));
 
 			if (!class_exists('PDFBarcode', false)) { 
 				include(_MPDF_PATH.'classes/barcode.php'); 
@@ -30985,8 +31002,8 @@
 			else { $arrcode = $this->barcode->getBarcodeArray($code, $btype); }
 
 			if ($arrcode === false) { $this->Error('Error in barcode string: '.$codestr); }
-			if((($btype=='EAN13' || $btype=='ISBN' || $btype=='ISSN') && strlen($code) == 12) || ($btype=='UPCA' && strlen($code) == 11)
-				|| ($btype=='UPCE' && strlen($code) == 11) || ($btype=='EAN8' && strlen($code) == 7)) {
+			if((($btype=='EAN13' || $btype=='ISBN' || $btype=='ISSN') && strlen(($code ?? '')) == 12) || ($btype=='UPCA' && strlen(($code ?? '')) == 11)
+				|| ($btype=='UPCE' && strlen(($code ?? '')) == 11) || ($btype=='EAN8' && strlen(($code ?? '')) == 7)) {
 				$code .= $arrcode['checkdigit'];
 				if (stristr($codestr,'-')) { $codestr .= '-' . $arrcode['checkdigit']; }
 				else { $codestr .= $arrcode['checkdigit']; }
@@ -31101,7 +31118,7 @@
  			   // WORD SPACING
 			   if ($fbwi > $sz) {
 				$xtra =  $fbwi - $sz;
-				$charspacing = $xtra / (strlen($codestr)-1);
+				$charspacing = $xtra / (strlen(($codestr ?? ''))-1);
 				if ($charspacing) { $this->_out(sprintf('BT %.3F Tc ET',$charspacing*_MPDFK)); }
 			   }
 			   $this->y = $y + $paddingT - ($codestr_fontsize ) - $tisbnm ; 
@@ -31127,9 +31144,9 @@
 				$innerp = $xres * 2.5;
 				$textw = ($bcw*0.5) - $outerp - $innerp;
 				$chars = 6; // number of numerals in each half
-				$charLO = substr($code,0,1); // Left Outer
-				$charLI = substr($code,1,6); // Left Inner
-				$charRI = substr($code,7,6); // Right Inner
+				$charLO = substr(($code ?? ''),0,1); // Left Outer
+				$charLI = substr(($code ?? ''),1,6); // Left Inner
+				$charRI = substr(($code ?? ''),7,6); // Right Inner
 				if (!$supplement) $charRO = '>'; // Right Outer
 			}
 			else if ($btype=='UPCA') {
@@ -31138,10 +31155,10 @@
 				$innerp = $xres * 2.5;
 				$textw = ($bcw*0.5) - $outerp - $innerp;
 				$chars = 5; 
-				$charLO = substr($code,0,1); // Left Outer
-				$charLI = substr($code,1,5); // Left Inner
-				$charRI = substr($code,6,5); // Right Inner
-				$charRO = substr($code,11,1); // Right Outer
+				$charLO = substr(($code ?? ''),0,1); // Left Outer
+				$charLI = substr(($code ?? ''),1,5); // Left Inner
+				$charRI = substr(($code ?? ''),6,5); // Right Inner
+				$charRO = substr(($code ?? ''),11,1); // Right Outer
 			}
 			else if ($btype=='UPCE') {
 				$outerfontsize = 2.3;	// Inner fontsize = 3
@@ -31150,10 +31167,10 @@
 				$textw = ($bcw*0.5) - $outerp - $innerp;
 				$chars = 3; 
 				$upce_code = $arrcode['code'];
-				$charLO = substr($code,0,1); // Left Outer
-				$charLI = substr($upce_code,0,3); // Left Inner
-				$charRI = substr($upce_code,3,3); // Right Inner
-				$charRO = substr($code,11,1); // Right Outer
+				$charLO = substr(($code ?? ''),0,1); // Left Outer
+				$charLI = substr(($upce_code ?? ''),0,3); // Left Inner
+				$charRI = substr(($upce_code ?? ''),3,3); // Right Inner
+				$charRO = substr(($code ?? ''),11,1); // Right Outer
 			}
 			else if ($btype=='EAN8') {
 				$outerfontsize = 3;	// Inner fontsize = 3
@@ -31162,8 +31179,8 @@
 				$textw = ($bcw*0.5) - $outerp - $innerp;
 				$chars = 4; 
 				$charLO = '<'; // Left Outer
-				$charLI = substr($code,0,4); // Left Inner
-				$charRI = substr($code,4,4); // Right Inner
+				$charLI = substr(($code ?? ''),0,4); // Left Inner
+				$charRI = substr(($code ?? ''),4,4); // Right Inner
 				if (!$supplement) $charRO = '>'; // Right Outer
 			}
 
@@ -31213,7 +31230,7 @@
 				// PRINT BARS
 				$supparrcode = $this->barcode->getBarcodeArray($supplement_code, 'EAN'.$supplement);
 				if ($supparrcode === false) { $this->Error('Error in barcode string (supplement): '.$codestr.' '.$supplement_code); }
-				if(strlen($supplement_code) != $supplement) {
+				if(strlen(($supplement_code ?? '')) != $supplement) {
 					$this->Error('Barcode supplement incorrect: '.$supplement_code);
 				}
 				$llm = $fbw - (($arrcode['lightmR'] - $supparrcode['sepM'])  * $arrcode['nom-X'] * $size);	// Left Light margin
@@ -31471,11 +31488,11 @@
 	}
 
 	$n = '';
-	$a=preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+	$a=preg_split('/<(.*?)>/ms',($html ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 	foreach($a as $i => $e) {
 	   if($i%2==0) {
 		//ignore if in Textarea
-		if ($i > 0 && strtolower(substr($a[$i-1],1,8)) == 'textarea') { $a[$i] = $e; continue; }
+		if ($i > 0 && strtolower((substr(($a[$i-1] ?? ''),1,8) ?? '')) == 'textarea') { $a[$i] = $e; continue; }
 		$e = strcode2utf($e);
 		$e = $this->lesser_entity_decode($e);
 
@@ -31513,7 +31530,7 @@
 		// Move common script from end of x to start of x+1
 		for($sch=0;$sch<$subchunk;$sch++) {
 			if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->baseScript && $scriptblocks[$sch+1] == $this->baseScript) {
-				$end = count($chardata[$sch])-1;
+				$end = count(($chardata[$sch] ?? []))-1;
 				while($chardata[$sch][$end]['script'] == 0 && $end > 1) {	// common script
 					$tmp = array_pop($chardata[$sch]);
 					array_unshift($chardata[$sch+1],$tmp);
@@ -31526,30 +31543,30 @@
 		for($sch=0;$sch<=$subchunk;$sch++) {
 		   if (isset($chardata[$sch])) { 
 			$s = '';
-			for ($j=0;$j<count($chardata[$sch]);$j++) {
+			for ($j=0;$j<count(($chardata[$sch] ?? []));$j++) {
 				$s.=code2utf($chardata[$sch][$j]['uni']);
 			}
 			// ZZZ99 Undo lesser_entity_decode as above - but only for <>&
- 			$s = str_replace("&","&amp;",$s);
- 			$s = str_replace("<","&lt;",$s);
- 			$s = str_replace(">","&gt;",$s);
+ 			$s = str_replace("&","&amp;",($s ?? ''));
+ 			$s = str_replace("<","&lt;",($s ?? ''));
+ 			$s = str_replace(">","&gt;",($s ?? ''));
 
 			// Check Vietnamese if Latin script - even if Basescript
-			if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->autoVietnamese && preg_match("/([".$this->viet."])/u", $s)) {
+			if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->autoVietnamese && preg_match("/([".$this->viet."])/u", ($s ?? ''))) {
 				$o .= '<span lang="vi" class="lang_vi">'.$s.'</span>';
 			}
 			// Check Arabic for different languages if Arabic script - even if Basescript
 			else if ($scriptblocks[$sch] == UCDN::SCRIPT_ARABIC && $this->autoArabic) {
-				if (preg_match("/[".$this->sindhi ."]/u", $s) ) {
+				if (preg_match("/[".$this->sindhi ."]/u", ($s ?? '')) ) {
 					$o .= '<span lang="sd" class="lang_sd">'.$s.'</span>';
 				}
-				else if (preg_match("/[".$this->urdu ."]/u", $s) ) {
+				else if (preg_match("/[".$this->urdu ."]/u", ($s ?? '')) ) {
 					$o .= '<span lang="ur" class="lang_ur">'.$s.'</span>';
 				}
-				else if (preg_match("/[".$this->pashto ."]/u", $s) ) {
+				else if (preg_match("/[".$this->pashto ."]/u", ($s ?? '')) ) {
 					$o .= '<span lang="ps" class="lang_ps">'.$s.'</span>';
 				}
-				else if (preg_match("/[".$this->persian ."]/u", $s) ) {
+				else if (preg_match("/[".$this->persian ."]/u", ($s ?? '')) ) {
 					$o .= '<span lang="fa" class="lang_fa">'.$s.'</span>';
 				}
 				else if ($this->baseScript != UCDN::SCRIPT_ARABIC  && isset($this->script2lang[$scriptblocks[$sch]])) {
@@ -31597,7 +31614,7 @@
 }
 function mb_strrev($str, $enc = 'utf-8'){
 	$ch = array();
-	$ch = preg_split('//u',$str);
+	$ch = preg_split('//u',($str ?? ''));
 	$revch = array_reverse($ch);
 	return implode('',$revch);
 }
@@ -31645,28 +31662,28 @@
 
 
 function ConvertColor($color="#000000"){
-	$color = trim(strtolower($color));
+	$color = trim((strtolower(($color ?? '')) ?? ''));
 	$c = false;
 	$cstr = '';
 	if ($color=='transparent') { return false; }
 	else if ($color=='inherit') { return false; }
 	else if (isset($this->SVGcolors[$color])) $color = $this->SVGcolors[$color];
 
-	if (preg_match('/^[\d]+$/',$color)) { $c = (array(1,$color)); }	// i.e. integer only
+	if (preg_match('/^[\d]+$/',($color ?? ''))) { $c = (array(1,$color)); }	// i.e. integer only
 	else if ($color[0] == '#') { //case of #nnnnnn or #nnn
-		$cor = preg_replace('/\s+.*/','',$color);	// in case of Background: #CCC url() x-repeat etc.
-  		if (strlen($cor) == 4) { // Turn #RGB into #RRGGBB
+		$cor = preg_replace('/\s+.*/','',($color ?? ''));	// in case of Background: #CCC url() x-repeat etc.
+  		if (strlen(($cor ?? '')) == 4) { // Turn #RGB into #RRGGBB
 		 	  $cor = "#" . $cor[1] . $cor[1] . $cor[2] . $cor[2] . $cor[3] . $cor[3];
 		}  
-		$r = hexdec(substr($cor, 1, 2));
-		$g = hexdec(substr($cor, 3, 2));
-		$b = hexdec(substr($cor, 5, 2));
+		$r = hexdec(substr(($cor ?? ''), 1, 2));
+		$g = hexdec(substr(($cor ?? ''), 3, 2));
+		$b = hexdec(substr(($cor ?? ''), 5, 2));
 		$c = array(3,$r,$g,$b);
 	}
-	else if (preg_match('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\((.*?)\)/',$color,$m)) {
+	else if (preg_match('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\((.*?)\)/',($color ?? ''),$m)) {
 		$type= $m[1];
-		$cores = explode(",", $m[2]);
-		$ncores = count($cores);
+		$cores = explode(",", ($m[2] ?? ''));
+		$ncores = count(($cores ?? []));
 		if (stristr($cores[0],'%') ) { 
 			$cores[0] += 0; 
 			if ($type=='rgb' || $type=='rgba') { $cores[0] = intval($cores[0]*255/100); }
@@ -31695,7 +31712,7 @@
 			else if ($type=='hsla') { $c = array(5,$conv[0],$conv[1],$conv[2],$cores[3]*100); }
 		}
 		else if ($type=='spot') { 
-			$name = strtoupper(trim($cores[0]));
+			$name = strtoupper((trim(($cores[0] ?? '')) ?? ''));
 			if(!isset($this->spotColors[$name])) {
 				if (isset($cores[5])) { $this->AddSpotColor($cores[0],$cores[2],$cores[3],$cores[4],$cores[5]); }
 				else { $this->Error('Undefined spot color: '.$name); }
@@ -31889,12 +31906,12 @@
 
 function _colAtoString($cor) {
 	$s = '';
-	if ($cor{0}==1) $s = 'rgb('.ord($cor{1}).','.ord($cor{1}).','.ord($cor{1}).')';
-	else if ($cor{0}==2) $s = 'spot('.ord($cor{1}).','.ord($cor{2}).')';		// SPOT COLOR
-	else if ($cor{0}==3) $s = 'rgb('.ord($cor{1}).','.ord($cor{2}).','.ord($cor{3}).')';
-	else if ($cor{0}==4) $s = 'cmyk('.ord($cor{1}).','.ord($cor{2}).','.ord($cor{3}).','.ord($cor{4}).')';
-	else if ($cor{0}==5) $s = 'rgba('.ord($cor{1}).','.ord($cor{2}).','.ord($cor{3}).','.sprintf('%0.2F',ord($cor{4})/100).')';
-	else if ($cor{0}==6) $s = 'cmyka('.ord($cor{1}).','.ord($cor{2}).','.ord($cor{3}).','.ord($cor{4}).','.sprintf('%0.2F',ord($cor{5})/100).')';
+	if ($cor[0]==1) $s = 'rgb('.ord(($cor[1] ?? '')).','.ord(($cor[1] ?? '')).','.ord(($cor[1] ?? '')).')';
+	else if ($cor[0]==2) $s = 'spot('.ord(($cor[1] ?? '')).','.ord(($cor[2] ?? '')).')';		// SPOT COLOR
+	else if ($cor[0]==3) $s = 'rgb('.ord(($cor[1] ?? '')).','.ord(($cor[2] ?? '')).','.ord(($cor[3] ?? '')).')';
+	else if ($cor[0]==4) $s = 'cmyk('.ord(($cor[1] ?? '')).','.ord(($cor[2] ?? '')).','.ord(($cor[3] ?? '')).','.ord(($cor[4] ?? '')).')';
+	else if ($cor[0]==5) $s = 'rgba('.ord(($cor[1] ?? '')).','.ord(($cor[2] ?? '')).','.ord(($cor[3] ?? '')).','.sprintf('%0.2F',ord(($cor[4] ?? ''))/100).')';
+	else if ($cor[0]==6) $s = 'cmyka('.ord(($cor[1] ?? '')).','.ord(($cor[2] ?? '')).','.ord(($cor[3] ?? '')).','.ord(($cor[4] ?? '')).','.sprintf('%0.2F',ord(($cor[5] ?? ''))/100).')';
 	return $s;
 }
 
@@ -31904,76 +31921,76 @@
 // For text $maxsize = Fontsize
 // Setting e.g. margin % will use maxsize (pagewidth) and em will use fontsize
 // Returns values using 'mm' units
-	$size = trim(strtolower($size));
+	$size = trim((strtolower((string) $size) ?? ''));
 
   if ( $size == 'thin' ) $size = 1*(25.4/$this->dpi); //1 pixel width for table borders
-  elseif ( stristr($size,'px') ) $size *= (25.4/$this->dpi); //pixels
-  elseif ( stristr($size,'cm') ) $size *= 10; //centimeters
-  elseif ( stristr($size,'mm') ) $size += 0; //millimeters
-  elseif ( stristr($size,'pt') ) $size *= 25.4/72; //72 pts/inch
+  elseif ( stristr($size,'px') ) $size = (float) $size * (25.4/$this->dpi); //pixels
+  elseif ( stristr($size,'cm') ) $size = (float) $size * 10; //centimeters
+  elseif ( stristr($size,'mm') ) $size = (float) $size; //millimeters
+  elseif ( stristr($size,'pt') ) $size = (float) $size * 25.4/72; //72 pts/inch
   elseif ( stristr($size,'rem') ) {
-  	$size += 0; //make "0.83rem" become simply "0.83" 
-	$size *= ($this->default_font_size / _MPDFK);
+  	$size = (float) $size; //make "0.83rem" become simply "0.83" 
+	$size = (float) $size * ($this->default_font_size / _MPDFK);
   }
   elseif ( stristr($size,'em') ) {
-  	$size += 0; //make "0.83em" become simply "0.83" 
-	if ($fontsize) { $size *= $fontsize; }
-	else { $size *= $maxsize; }
+  	$size = (float) $size; //make "0.83em" become simply "0.83" 
+	if ($fontsize) { $size = (float) $size * $fontsize; }
+	else { $size = (float) $size * $maxsize; }
   }
   elseif ( stristr($size,'%') ) {
-  	$size += 0; //make "90%" become simply "90" 
-	if ($fontsize && $usefontsize) { $size *= $fontsize/100; }
-	else { $size *= $maxsize/100; }
+  	$size = (float) $size; //make "90%" become simply "90" 
+	if ($fontsize && $usefontsize) { $size = (float) $size * $fontsize/100; }
+	else { $size = (float) $size * $maxsize/100; }
   }
-  elseif ( stristr($size,'in') ) $size *= 25.4; //inches 
-  elseif ( stristr($size,'pc') ) $size *= 38.1/9; //PostScript picas 
+  elseif ( stristr($size,'in') ) $size = (float) $size * 25.4; //inches 
+  elseif ( stristr($size,'pc') ) $size = (float) $size * 38.1/9; //PostScript picas 
   elseif ( stristr($size,'ex') ) {	// Approximates "ex" as half of font height
-  	$size += 0; //make "3.5ex" become simply "3.5" 
-	if ($fontsize) { $size *= $fontsize/2; }
-	else { $size *= $maxsize/2; }
+  	$size = (float) $size; //make "3.5ex" become simply "3.5" 
+	if ($fontsize) { $size = (float) $size * $fontsize/2; }
+	else { $size = (float) $size * $maxsize/2; }
   }
   elseif ( $size == 'medium' ) $size = 3*(25.4/$this->dpi); //3 pixel width for table borders
   elseif ( $size == 'thick' ) $size = 5*(25.4/$this->dpi); //5 pixel width for table borders
   elseif ($size == 'xx-small') {
-	if ($fontsize) { $size *= $fontsize*0.7; }
-	else { $size *= $maxsize*0.7; }
+	if ($fontsize) { $size = (float) $size * $fontsize*0.7; }
+	else { $size = (float) $size * $maxsize*0.7; }
   }
   elseif ($size == 'x-small') {
-	if ($fontsize) { $size *= $fontsize*0.77; }
-	else { $size *= $maxsize*0.77; }
+	if ($fontsize) { $size = (float) $size * $fontsize*0.77; }
+	else { $size = (float) $size * $maxsize*0.77; }
   }
   elseif ($size == 'small') {
-	if ($fontsize) { $size *= $fontsize*0.86; }
-	else { $size *= $maxsize*0.86; }
+	if ($fontsize) { $size = (float) $size * $fontsize*0.86; }
+	else { $size = (float) $size * $maxsize*0.86; }
   }
   elseif ($size == 'medium') {
-	if ($fontsize) { $size *= $fontsize; }
-	else { $size *= $maxsize; }
+	if ($fontsize) { $size = (float) $size * $fontsize; }
+	else { $size = (float) $size * $maxsize; }
   }
   elseif ($size == 'large') {
-	if ($fontsize) { $size *= $fontsize*1.2; }
-	else { $size *= $maxsize*1.2; }
+	if ($fontsize) { $size = (float) $size * $fontsize*1.2; }
+	else { $size = (float) $size * $maxsize*1.2; }
   }
   elseif ($size == 'x-large') {
-	if ($fontsize) { $size *= $fontsize*1.5; }
-	else { $size *= $maxsize*1.5; }
+	if ($fontsize) { $size = (float) $size * $fontsize*1.5; }
+	else { $size = (float) $size * $maxsize*1.5; }
   }
   elseif ($size == 'xx-large') {
-	if ($fontsize) { $size *= $fontsize*2; }
-	else { $size *= $maxsize*2; }
+	if ($fontsize) { $size = (float) $size * $fontsize*2; }
+	else { $size = (float) $size * $maxsize*2; }
   }
-  else $size *= (25.4/$this->dpi); //nothing == px
+  else $size = (float) $size * (25.4/$this->dpi); //nothing == px
   
   return $size;
 }
 
 // mPDF 5.7.3 TRANSFORMS
 function ConvertAngle($s, $makepositive=true) {
-	if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$s,$m)) {
+	if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',($s ?? ''),$m)) {
 		$angle = $m[1] + 0;
-		if (strtolower($m[2])=='deg') { $angle = $angle; }
-		else if (strtolower($m[2])=='grad') { $angle *= (360/400); }
-		else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); }
+		if (strtolower(($m[2] ?? ''))=='deg') { $angle = $angle; }
+		else if (strtolower(($m[2] ?? ''))=='grad') { $angle *= (360/400); }
+		else if (strtolower(($m[2] ?? ''))=='rad') { $angle = rad2deg($angle); }
 		while($angle >= 360) { $angle -= 360; }
 		while($angle <= -360) { $angle += 360; }
 		if ($makepositive) {	// always returns an angle between 0 and 360deg
@@ -31986,161 +32003,161 @@
 
 function lesser_entity_decode($html) {
   //supports the most used entity codes (only does ascii safe characters)
- 	$html = str_replace("&lt;","<",$html);
- 	$html = str_replace("&gt;",">",$html);
-
- 	$html = str_replace("&apos;","'",$html);
- 	$html = str_replace("&quot;",'"',$html);
- 	$html = str_replace("&amp;","&",$html);
+ 	$html = str_replace("&lt;","<",($html ?? ''));
+ 	$html = str_replace("&gt;",">",($html ?? ''));
+
+ 	$html = str_replace("&apos;","'",($html ?? ''));
+ 	$html = str_replace("&quot;",'"',($html ?? ''));
+ 	$html = str_replace("&amp;","&",($html ?? ''));
 	return $html;
 }
 
 function AdjustHTML($html, $tabSpaces=8) {
 	//Try to make the html text more manageable (turning it into XHTML)
 	if (PHP_VERSION_ID < 50307) {
-		if (strlen($html) > 100000) {
+		if (strlen(($html ?? '')) > 100000) {
 			if (PHP_VERSION_ID < 50200) $this->Error("The HTML code is more than 100,000 characters. You should use WriteHTML() with smaller string lengths.");
 			else ini_set("pcre.backtrack_limit","1000000");
 		}
 	}
 
 /*-- ANNOTATIONS --*/
-	preg_match_all("/(<annotation.*?>)/si", $html, $m);
-	if (count($m[1])) { 
-		for($i=0;$i<count($m[1]);$i++) {
-			$sub = preg_replace("/\n/si", "\xbb\xa4\xac", $m[1][$i]);
-			$html = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $html); 
+	preg_match_all("/(<annotation.*?>)/si", ($html ?? ''), $m);
+	if (count(($m[1] ?? []))) { 
+		for($i=0;$i<count(($m[1] ?? []));$i++) {
+			$sub = preg_replace("/\n/si", "\xbb\xa4\xac", ($m[1][$i] ?? ''));
+			$html = preg_replace('/'.preg_quote(($m[1][$i] ?? ''), '/').'/si', ($sub ?? ''), ($html ?? '')); 
 		}
 	}
 /*-- END ANNOTATIONS --*/
 
-	preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
-	if (count($svgi[0])) { 
-		for($i=0;$i<count($svgi[0]);$i++) {
+	preg_match_all("/(<svg.*?<\/svg>)/si", ($html ?? ''), $svgi);
+	if (count(($svgi[0] ?? []))) { 
+		for($i=0;$i<count(($svgi[0] ?? []));$i++) {
 			$file = _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.$i.'.svg';
 			//Save to local file
 			file_put_contents($file, $svgi[0][$i]);
-			$html = str_replace($svgi[0][$i], '<img src="'.$file.'" />', $html); 
+			$html = str_replace(($svgi[0][$i] ?? ''), '<img src="'.$file.'" />', ($html ?? '')); 
 		}
 	}
 
 	//Remove javascript code from HTML (should not appear in the PDF file)
-	$html = preg_replace('/<script.*?<\/script>/is','',$html);
+	$html = preg_replace('/<script.*?<\/script>/is','',($html ?? ''));
 
 	//Remove special comments
-	$html = preg_replace('/<!--mpdf/i','',$html);
-	$html = preg_replace('/mpdf-->/i','',$html);
+	$html = preg_replace('/<!--mpdf/i','',($html ?? ''));
+	$html = preg_replace('/mpdf-->/i','',($html ?? ''));
 
 	//Remove comments from HTML (should not appear in the PDF file)
-	$html = preg_replace('/<!--.*?-->/s','',$html);
-
-	$html = preg_replace('/\f/','',$html); //replace formfeed by nothing
-	$html = preg_replace('/\r/','',$html); //replace carriage return by nothing
+	$html = preg_replace('/<!--.*?-->/s','',($html ?? ''));
+
+	$html = preg_replace('/\f/','',($html ?? '')); //replace formfeed by nothing
+	$html = preg_replace('/\r/','',($html ?? '')); //replace carriage return by nothing
 
 	// Well formed XHTML end tags
-	$html = preg_replace('/<(br|hr)>/i',"<\\1 />",$html);	// mPDF 6
-	$html = preg_replace('/<(br|hr)\/>/i',"<\\1 />",$html);
+	$html = preg_replace('/<(br|hr)>/i',"<\\1 />",($html ?? ''));	// mPDF 6
+	$html = preg_replace('/<(br|hr)\/>/i',"<\\1 />",($html ?? ''));
 	// Get rid of empty <thead></thead> etc
-	$html = preg_replace('/<tr>\s*<\/tr>/i','',$html);
-	$html = preg_replace('/<thead>\s*<\/thead>/i','',$html);
-	$html = preg_replace('/<tfoot>\s*<\/tfoot>/i','',$html);
-	$html = preg_replace('/<table[^>]*>\s*<\/table>/i','',$html);
+	$html = preg_replace('/<tr>\s*<\/tr>/i','',($html ?? ''));
+	$html = preg_replace('/<thead>\s*<\/thead>/i','',($html ?? ''));
+	$html = preg_replace('/<tfoot>\s*<\/tfoot>/i','',($html ?? ''));
+	$html = preg_replace('/<table[^>]*>\s*<\/table>/i','',($html ?? ''));
 
 	// Remove spaces at end of table cells
-	$html = preg_replace("/[ \n\r]+<\/t(d|h)/",'</t\\1',$html);	
-
-	$html = preg_replace("/[ ]*<dottab\s*[\/]*>[ ]*/",'<dottab />',$html);
+	$html = preg_replace("/[ \n\r]+<\/t(d|h)/",'</t\\1',($html ?? ''));	
+
+	$html = preg_replace("/[ ]*<dottab\s*[\/]*>[ ]*/",'<dottab />',($html ?? ''));
 
 	// Concatenates any Substitute characters from symbols/dingbats
-	$html = str_replace('</tts><tts>','|',$html);
-	$html = str_replace('</ttz><ttz>','|',$html);
-	$html = str_replace('</tta><tta>','|',$html);
-
-	$html = preg_replace('/<br \/>\s*/is',"<br />",$html);
-
-	$html = preg_replace('/<wbr[ \/]*>\s*/is',"&#173;",$html);
+	$html = str_replace('</tts><tts>','|',($html ?? ''));
+	$html = str_replace('</ttz><ttz>','|',($html ?? ''));
+	$html = str_replace('</tta><tta>','|',($html ?? ''));
+
+	$html = preg_replace('/<br \/>\s*/is',"<br />",($html ?? ''));
+
+	$html = preg_replace('/<wbr[ \/]*>\s*/is',"&#173;",($html ?? ''));
 
 	// Preserve '\n's in content between the tags <pre> and </pre>
-	if (preg_match('/<pre/',$html)) {
-		$html_a = preg_split('/(\<\/?pre[^\>]*\>)/', $html, -1, 2);
+	if (preg_match('/<pre/',($html ?? ''))) {
+		$html_a = preg_split('/(\<\/?pre[^\>]*\>)/', ($html ?? ''), -1, 2);
 		$h = array();
 		$c=0;
 		foreach($html_a AS $s) {
-			if ($c>1 && preg_match('/^<\/pre/i',$s)) { $c--; $s=preg_replace('/<\/pre/i','</innerpre',$s); }
-			else if ($c>0 && preg_match('/^<pre/i',$s)) { $c++; $s=preg_replace('/<pre/i','<innerpre',$s); }
-			else if (preg_match('/^<pre/i',$s)) { $c++; }
-			else if (preg_match('/^<\/pre/i',$s)) { $c--; }
+			if ($c>1 && preg_match('/^<\/pre/i',($s ?? ''))) { $c--; $s=preg_replace('/<\/pre/i','</innerpre',($s ?? '')); }
+			else if ($c>0 && preg_match('/^<pre/i',($s ?? ''))) { $c++; $s=preg_replace('/<pre/i','<innerpre',($s ?? '')); }
+			else if (preg_match('/^<pre/i',($s ?? ''))) { $c++; }
+			else if (preg_match('/^<\/pre/i',($s ?? ''))) { $c--; }
 			array_push($h, $s);
 		}
 		$html = implode("", $h);
 	}
-	$thereispre = preg_match_all('#<pre(.*?)>(.*?)</pre>#si',$html,$temp);
+	$thereispre = preg_match_all('#<pre(.*?)>(.*?)</pre>#si',($html ?? ''),$temp);
 	// Preserve '\n's in content between the tags <textarea> and </textarea>
-	$thereistextarea = preg_match_all('#<textarea(.*?)>(.*?)</textarea>#si',$html,$temp2);
-	$html = preg_replace('/[\n]/',' ',$html); //replace linefeed by spaces
-	$html = preg_replace('/[\t]/',' ',$html); //replace tabs by spaces
+	$thereistextarea = preg_match_all('#<textarea(.*?)>(.*?)</textarea>#si',($html ?? ''),$temp2);
+	$html = preg_replace('/[\n]/',' ',($html ?? '')); //replace linefeed by spaces
+	$html = preg_replace('/[\t]/',' ',($html ?? '')); //replace tabs by spaces
 
 	// Converts < to &lt; when not a tag
-	$html = preg_replace('/<([^!\/a-zA-Z_:])/i','&lt;\\1',$html);	// mPDF 5.7.3
-	$html = preg_replace("/[ ]+/",' ',$html);
-
-	$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',$html);
-	$html = preg_replace('/\/(u|o)l>\s+<\/li/i','/\\1l></li',$html);
-	$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',$html);
-	$html = preg_replace('/\/li>\s+<li/i','/li><li',$html);
-	$html = preg_replace('/<(u|o)l([^>]*)>[ ]+/i','<\\1l\\2>',$html);
-	$html = preg_replace('/[ ]+<(u|o)l/i','<\\1l',$html);
+	$html = preg_replace('/<([^!\/a-zA-Z_:])/i','&lt;\\1',($html ?? ''));	// mPDF 5.7.3
+	$html = preg_replace("/[ ]+/",' ',($html ?? ''));
+
+	$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',($html ?? ''));
+	$html = preg_replace('/\/(u|o)l>\s+<\/li/i','/\\1l></li',($html ?? ''));
+	$html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',($html ?? ''));
+	$html = preg_replace('/\/li>\s+<li/i','/li><li',($html ?? ''));
+	$html = preg_replace('/<(u|o)l([^>]*)>[ ]+/i','<\\1l\\2>',($html ?? ''));
+	$html = preg_replace('/[ ]+<(u|o)l/i','<\\1l',($html ?? ''));
 
 	// Make self closing tabs valid XHTML
 	// Tags which are self-closing: 1) Replaceable and 2) Non-replaced items
 	$selftabs = 'input|hr|img|br|jpgraph|barcode|dottab';
 	$selftabs2 = 'indexentry|indexinsert|bookmark|watermarktext|watermarkimage|column_break|columnbreak|newcolumn|newpage|page_break|pagebreak|formfeed|columns|toc|tocpagebreak|setpageheader|setpagefooter|sethtmlpageheader|sethtmlpagefooter|annotation';
-	$html = preg_replace('/(<('.$selftabs.'|'.$selftabs2.')[^>\/]*)>/i','\\1 />',$html);
+	$html = preg_replace('/(<('.$selftabs.'|'.$selftabs2.')[^>\/]*)>/i','\\1 />',($html ?? ''));
 
 	$iterator = 0;
 	while($thereispre) //Recover <pre attributes>content</pre>
 	{
-		$temp[2][$iterator] = preg_replace('/<([^!\/a-zA-Z_:])/','&lt;\\1',$temp[2][$iterator]);	// mPDF 5.7.2	// mPDF 5.7.3
-
-		$temp[2][$iterator] = preg_replace_callback("/^([^\n\t]*?)\t/m", array($this, 'tabs2spaces_callback'), $temp[2][$iterator]);	// mPDF 5.7+
-		$temp[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp[2][$iterator]);
-
-		$temp[2][$iterator] = preg_replace('/\n/',"<br />",$temp[2][$iterator]);
-		$temp[2][$iterator] = str_replace('\\',"\\\\",$temp[2][$iterator]);
+		$temp[2][$iterator] = preg_replace('/<([^!\/a-zA-Z_:])/','&lt;\\1',($temp[2][$iterator] ?? ''));	// mPDF 5.7.2	// mPDF 5.7.3
+
+		$temp[2][$iterator] = preg_replace_callback("/^([^\n\t]*?)\t/m", array($this, 'tabs2spaces_callback'), ($temp[2][$iterator] ?? ''));	// mPDF 5.7+
+		$temp[2][$iterator] = preg_replace('/\t/',(str_repeat(" ",$tabSpaces) ?? ''),($temp[2][$iterator] ?? ''));
+
+		$temp[2][$iterator] = preg_replace('/\n/',"<br />",($temp[2][$iterator] ?? ''));
+		$temp[2][$iterator] = str_replace('\\',"\\\\",($temp[2][$iterator] ?? ''));
 		//$html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.$temp[2][$iterator].'</erp>',$html,1);
-		$html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.str_replace('$','\$',$temp[2][$iterator]).'</erp>',$html,1);	// mPDF 5.7+
+		$html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.str_replace('$','\$',($temp[2][$iterator] ?? '')).'</erp>',($html ?? ''),1);	// mPDF 5.7+
 		$thereispre--;
 		$iterator++;
 	}
 	$iterator = 0;
 	while($thereistextarea) //Recover <textarea attributes>content</textarea>
 	{
-		$temp2[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp2[2][$iterator]);
-		$temp2[2][$iterator] = str_replace('\\',"\\\\",$temp2[2][$iterator]);
-		$html = preg_replace('#<textarea(.*?)>(.*?)</textarea>#si','<aeratxet'.$temp2[1][$iterator].'>'.trim($temp2[2][$iterator]) .'</aeratxet>',$html,1);
+		$temp2[2][$iterator] = preg_replace('/\t/',(str_repeat(" ",$tabSpaces) ?? ''),($temp2[2][$iterator] ?? ''));
+		$temp2[2][$iterator] = str_replace('\\',"\\\\",($temp2[2][$iterator] ?? ''));
+		$html = preg_replace('#<textarea(.*?)>(.*?)</textarea>#si','<aeratxet'.$temp2[1][$iterator].'>'.trim(($temp2[2][$iterator] ?? '')) .'</aeratxet>',($html ?? ''),1);
 		$thereistextarea--;
 		$iterator++;
 	}
 	//Restore original tag names
-	$html = str_replace("<erp","<pre",$html);
-	$html = str_replace("</erp>","</pre>",$html);
-	$html = str_replace("<aeratxet","<textarea",$html);
-	$html = str_replace("</aeratxet>","</textarea>",$html);
-	$html = str_replace("</innerpre","</pre",$html); 
-	$html = str_replace("<innerpre","<pre",$html); 
-
-	$html = preg_replace('/<textarea([^>]*)><\/textarea>/si','<textarea\\1> </textarea>',$html);
-	$html = preg_replace('/(<table[^>]*>)\s*(<caption)(.*?<\/caption>)(.*?<\/table>)/si','\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3',$html);	// *TABLES*
-	$html = preg_replace('/<(h[1-6])([^>]*)(>(?:(?!h[1-6]).)*?<\/\\1>\s*<table)/si','<\\1\\2 keep-with-table="1"\\3',$html);	// *TABLES*
-	$html = preg_replace("/\xbb\xa4\xac/", "\n", $html);
+	$html = str_replace("<erp","<pre",($html ?? ''));
+	$html = str_replace("</erp>","</pre>",($html ?? ''));
+	$html = str_replace("<aeratxet","<textarea",($html ?? ''));
+	$html = str_replace("</aeratxet>","</textarea>",($html ?? ''));
+	$html = str_replace("</innerpre","</pre",($html ?? '')); 
+	$html = str_replace("<innerpre","<pre",($html ?? '')); 
+
+	$html = preg_replace('/<textarea([^>]*)><\/textarea>/si','<textarea\\1> </textarea>',($html ?? ''));
+	$html = preg_replace('/(<table[^>]*>)\s*(<caption)(.*?<\/caption>)(.*?<\/table>)/si','\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3',($html ?? ''));	// *TABLES*
+	$html = preg_replace('/<(h[1-6])([^>]*)(>(?:(?!h[1-6]).)*?<\/\\1>\s*<table)/si','<\\1\\2 keep-with-table="1"\\3',($html ?? ''));	// *TABLES*
+	$html = preg_replace("/\xbb\xa4\xac/", "\n", ($html ?? ''));
 
 	// Fixes <p>&#8377</p> which browser copes with even though it is wrong!
-	$html = preg_replace("/(&#[x]{0,1}[0-9a-f]{1,5})</i", "\\1;<", $html);
+	$html = preg_replace("/(&#[x]{0,1}[0-9a-f]{1,5})</i", "\\1;<", ($html ?? ''));
 	return $html;
 }
 // mPDF 5.7+
 function tabs2spaces_callback($matches) {
-	return (stripslashes($matches[1]) . str_repeat(' ', $this->tabSpaces - (mb_strlen(stripslashes($matches[1])) % $this->tabSpaces)));
+	return (stripslashes($matches[1]) . str_repeat(' ', $this->tabSpaces - (mb_strlen((stripslashes($matches[1]) ?? '')) % $this->tabSpaces)));
 }
 // mPDF 5.7+
 function date_callback($matches) {
@@ -32153,7 +32170,7 @@
 	// From docPageNum: font is not set, so no check
 	$nstr = (string) $num;
 	$rnum = '';
-	for ($i=0;$i<strlen($nstr);$i++) { 
+	for ($i=0;$i<strlen(($nstr ?? ''));$i++) { 
 		if (!$check || $this->_charDefined($this->CurrentFont['cw'],$cp+intval($nstr[$i]))) {
 			$rnum .= code2utf($cp+intval($nstr[$i]));
 		}
@@ -32166,7 +32183,7 @@
 	$nstr = (string) $num;
 	$rnum = '';
 	$glyphs = array(0x3007, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D);
-	for ($i=0;$i<strlen($nstr);$i++) { 
+	for ($i=0;$i<strlen(($nstr ?? ''));$i++) { 
 		$rnum .= code2utf($glyphs[intval($nstr[$i])]);
 	}
 	return $rnum;
@@ -32193,10 +32210,10 @@
   {
       $c1 = (64 + $valor);
   }
-  $alpha = chr($c1);
-  if ($c2 != '') $alpha .= chr($c2);
-  if ($c3 != '') $alpha .= chr($c3);
-  if (!$toupper) $alpha = strtolower($alpha);
+  $alpha = chr((int) ($c1));
+  if ($c2 != '') $alpha .= chr((int) ($c2));
+  if ($c3 != '') $alpha .= chr((int) ($c3));
+  if (!$toupper) $alpha = strtolower(($alpha ?? ''));
   return $alpha;
 }
 
@@ -32219,7 +32236,7 @@
 	if ($i==0) { return '0'; }
 
 	// Otherwise, while I is greater than 0 and there are elements left in the glyph list:
-	for ($t=0; $t<count($additive_nums); $t++) {
+	for ($t=0; $t<count(($additive_nums ?? [])); $t++) {
 
 		// Pop the first additive tuple from the glyph list. This is the current tuple.
 		$ct = $additive_nums[$t];
@@ -32305,7 +32322,7 @@
 	default: break;
   }
   $roman = $r1.$r2.$r3.$r4;
-  if (!$toupper) $roman = strtolower($roman);
+  if (!$toupper) $roman = strtolower(($roman ?? ''));
   return $roman;
 }
 
@@ -32313,7 +32330,7 @@
 /*-- IMPORTS --*/
 function SetImportUse() {
 	$this->enableImports = true;
-	ini_set('auto_detect_line_endings',1);
+	false;
 	require_once(_MPDF_PATH."mpdfi/pdf_context.php");
 	require_once(_MPDF_PATH."mpdfi/pdf_parser.php");
 	require_once(_MPDF_PATH."mpdfi/fpdi_pdf_parser.php");
@@ -32321,7 +32338,7 @@
 
 // from mPDFI
 function hex2str($hex) {
-	return pack("H*", str_replace(array("\r","\n"," "),"", $hex));
+	return pack("H*", str_replace(array("\r","\n"," "),"", ($hex ?? '')));
 }
     
 function str2hex($str) {
@@ -32342,7 +32359,7 @@
 			// An array. Output the proper
 			// structure and move on.
 			$this->_out("[",false);
-			for ($i = 0; $i < count($value[1]); $i++) {
+			for ($i = 0; $i < count(($value[1] ?? [])); $i++) {
 				$this->pdf_write_value($value[1][$i]);
 			}
 			$this->_out("]");
@@ -32352,7 +32369,7 @@
 			// A dictionary.
 			$this->_out("<<",false);
 			reset ($value[1]);
-			while (list($k, $v) = each($value[1])) {
+			foreach ($value[1] as $k => $v) {
 				$this->_out($k . " ",false);
 				$this->pdf_write_value($v);
 			}
@@ -32413,7 +32430,7 @@
 
 // ========== OVERWRITE SEARCH STRING IN A PDF FILE ================
 function OverWrite($file_in, $search, $replacement, $dest="D", $file_out="mpdf" ) {
-	$pdf = file_get_contents($file_in);
+	$pdf = file_get_contents(($file_in ?? ''));
 
 	if (!is_array($search)) {
 		$x = $search;
@@ -32434,30 +32451,30 @@
 	}
 	else {
 	  foreach($replacement AS $k=>$val) {
-		$replacement[$k] = mb_convert_encoding($replacement[$k],$this->mb_enc,'utf-8'); 
+		$replacement[$k] = mb_convert_encoding(($replacement[$k] ?? ''),($this->mb_enc ?? ''),'utf-8'); 
 		$replacement[$k] = $this->_escape($replacement[$k]); 
 	  }
 	}
 
 	// Get xref into array
 	$xref = array();
-	preg_match("/xref\n0 (\d+)\n(.*?)\ntrailer/s",$pdf,$m);
+	preg_match("/xref\n0 (\d+)\n(.*?)\ntrailer/s",($pdf ?? ''),$m);
 	$xref_objid = $m[1];
-	preg_match_all('/(\d{10}) (\d{5}) (f|n)/',$m[2],$x);
-	for($i=0; $i<count($x[0]); $i++) {
+	preg_match_all('/(\d{10}) (\d{5}) (f|n)/',($m[2] ?? ''),$x);
+	for($i=0; $i<count(($x[0] ?? [])); $i++) {
 		$xref[] = array(intval($x[1][$i]), $x[2][$i], $x[3][$i]);
 	}
 
 	$changes = array();
-	preg_match("/<<\s*\/Type\s*\/Pages\s*\/Kids\s*\[(.*?)\]\s*\/Count/s",$pdf,$m);
-	preg_match_all("/(\d+) 0 R /s",$m[1],$o);
+	preg_match("/<<\s*\/Type\s*\/Pages\s*\/Kids\s*\[(.*?)\]\s*\/Count/s",($pdf ?? ''),$m);
+	preg_match_all("/(\d+) 0 R /s",($m[1] ?? ''),$o);
 	$objlist = $o[1];
 	foreach($objlist AS $obj) {
 	  if ($this->compress) {
-	  	preg_match("/".($obj+1)." 0 obj\n<<\s*\/Filter\s*\/FlateDecode\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s",$pdf,$m);
+	  	preg_match("/".($obj+1)." 0 obj\n<<\s*\/Filter\s*\/FlateDecode\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s",($pdf ?? ''),$m);
 	  }
 	  else {
-	  	preg_match("/".($obj+1)." 0 obj\n<<\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s",$pdf,$m);
+	  	preg_match("/".($obj+1)." 0 obj\n<<\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s",($pdf ?? ''),$m);
 	  }
 	  $s = $m[2];
 	  if (!$s) { continue; }
@@ -32469,7 +32486,7 @@
 	  	$s = gzuncompress($s);
 	  }
   	  foreach($search AS $k=>$val) {
-		$s = str_replace($search[$k],$replacement[$k],$s);
+		$s = str_replace(($search[$k] ?? ''),($replacement[$k] ?? ''),($s ?? ''));
 	  }
 	  if ($this->compress) {
 		$s = gzcompress($s);
@@ -32477,15 +32494,15 @@
 	  if ($this->encrypted) {
 		$s = $this->_RC4($this->_objectkey($obj+1), $s);
 	  }
-	  $newlen = strlen($s);
-	  $changes[($xref[$obj+1][0])] = ($newlen - $oldlen) + (strlen($newlen) - strlen($oldlen ));
+	  $newlen = strlen(($s ?? ''));
+	  $changes[($xref[$obj+1][0])] = ($newlen - $oldlen) + (strlen(($newlen ?? '')) - strlen(($oldlen ?? '') ));
 	  if ($this->compress) {
 	  	$newstr = ($obj+1) . " 0 obj\n<</Filter /FlateDecode /Length ".$newlen.">>\nstream\n".$s."\nendstream\n";
 	  }
 	  else {
 	  	$newstr = ($obj+1) . " 0 obj\n<</Length ".$newlen.">>\nstream\n".$s."\nendstream\n";
 	  }
-	  $pdf = str_replace($m[0],$newstr,$pdf);
+	  $pdf = str_replace(($m[0] ?? ''),($newstr ?? ''),($pdf ?? ''));
 	}
 
 	// Update xref in PDF
@@ -32498,13 +32515,13 @@
 		$newxref .= sprintf('%010d',$v[0]) . ' ' . $v[1] . ' ' .$v[2] . " \n";
 	}
 	$newxref .= "trailer";
-	$pdf = preg_replace("/xref\n0 \d+\n.*?\ntrailer/s",$newxref,$pdf);
+	$pdf = preg_replace("/xref\n0 \d+\n.*?\ntrailer/s",($newxref ?? ''),($pdf ?? ''));
 
 	// Update startxref in PDF
-	preg_match("/startxref\n(\d+)\n%%EOF/s", $pdf, $m);
+	preg_match("/startxref\n(\d+)\n%%EOF/s", ($pdf ?? ''), $m);
 	$startxref = $m[1];
 	$startxref += array_sum($changes);
-	$pdf = preg_replace("/startxref\n(\d+)\n%%EOF/s","startxref\n".$startxref."\n%%EOF",$pdf);
+	$pdf = preg_replace("/startxref\n(\d+)\n%%EOF/s","startxref\n".$startxref."\n%%EOF",($pdf ?? ''));
 
 	// OUTPUT
 	switch($dest) {
@@ -32514,7 +32531,7 @@
 			{
 				//We send to a browser
 				Header('Content-Type: application/pdf');
-				Header('Content-Length: '.strlen($pdf));
+				Header('Content-Length: '.strlen(($pdf ?? '')));
 				Header('Content-disposition: inline; filename='.$file_out);
 			}
 			echo $pdf;
@@ -32524,7 +32541,7 @@
 			if (!$file_out) { $file_out = 'mpdf.pdf'; }
 			$f=fopen($file_out,'wb');
 			if(!$f) die('Unable to create output file: '.$file_out);
-			fwrite($f,$pdf,strlen($pdf));
+			fwrite($f,$pdf,strlen(($pdf ?? '')));
 			fclose($f);
 			break;
 		case 'S':
@@ -32533,11 +32550,11 @@
 		case 'D':
 		default:
 			//Download file
-			if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
+			if(isset($_SERVER['HTTP_USER_AGENT']) and strpos(($_SERVER['HTTP_USER_AGENT'] ?? ''),'MSIE'))
 				Header('Content-Type: application/force-download');
 			else
 				Header('Content-Type: application/octet-stream');
-			Header('Content-Length: '.strlen($pdf));
+			Header('Content-Length: '.strlen(($pdf ?? '')));
 			Header('Content-disposition: attachment; filename='.$file_out);
  			echo $pdf;
 			break;
--- a/intranet/mpdf60/graph.php
+++ b/intranet/mpdf60/graph.php
@@ -56,7 +56,7 @@
 	$hide_grid = false;
 	$hide_y_axis = false;
 
-	if (isset($g['attr']['TYPE']) && $g['attr']['TYPE']) { $type = strtolower($g['attr']['TYPE']); }
+	if (isset($g['attr']['TYPE']) && $g['attr']['TYPE']) { $type = strtolower(($g['attr']['TYPE'] ?? '')); }
 	if (!in_array($type,array('bar','horiz_bar','line','radar','pie','pie3d','xy','scatter'))) { $type = 'bar'; } // Default=bar
 
 	if (isset($g['attr']['STACKED']) && $g['attr']['STACKED']) { $stacked = true; }	// stacked for bar or horiz_bar
@@ -95,11 +95,11 @@
 	if (isset($g['attr']['LABEL-X']) && $g['attr']['LABEL-X']) { $xlabel = $g['attr']['LABEL-X']; }		// NOT IMPLEMENTED??????
 	if (isset($g['attr']['LABEL-Y']) && $g['attr']['LABEL-Y']) { $ylabel = $g['attr']['LABEL-Y']; }
 
-	if (isset($g['attr']['AXIS-X']) && $g['attr']['AXIS-X']) { $xaxis = strtolower($g['attr']['AXIS-X']); }
+	if (isset($g['attr']['AXIS-X']) && $g['attr']['AXIS-X']) { $xaxis = strtolower(($g['attr']['AXIS-X'] ?? '')); }
 	if (!in_array($xaxis,array('text','lin','linear','log'))) { $xaxis = 'text'; }	// Default=text
 	if ($xaxis == 'linear') { $xaxis = 'lin'; }
 
-	if (isset($g['attr']['AXIS-Y']) && $g['attr']['AXIS-Y']) { $yaxis = strtolower($g['attr']['AXIS-Y']); }
+	if (isset($g['attr']['AXIS-Y']) && $g['attr']['AXIS-Y']) { $yaxis = strtolower(($g['attr']['AXIS-Y'] ?? '')); }
 	if (!in_array($yaxis,array('lin','linear','log','percent'))) { $yaxis = 'lin'; }			// Default=lin
 	if ($yaxis == 'percent') { $show_percent = true; $yaxis = 'lin'; }	// Show percent sign on scales
 	if ($yaxis == 'linear') { $yaxis = 'lin'; }
@@ -112,7 +112,7 @@
 	if (isset($g['attr']['cHEIGHT']) && $g['attr']['cHEIGHT']) { $h=($g['attr']['cHEIGHT'] / 0.2645); }
 
 
-	if (isset($g['attr']['SERIES']) && strtolower($g['attr']['SERIES']) == 'rows') { $dataseries = 'rows'; }
+	if (isset($g['attr']['SERIES']) && strtolower(($g['attr']['SERIES'] ?? '')) == 'rows') { $dataseries = 'rows'; }
 	else { $dataseries = 'cols'; }
 
 	// Defaults - define data
@@ -132,7 +132,7 @@
 	if (isset($g['attr']['DATA-ROW-END']) && ($g['attr']['DATA-ROW-END'] === '0' || $g['attr']['DATA-ROW-END'] <> 0)) { $rowend = $g['attr']['DATA-ROW-END']; }
 	if (isset($g['attr']['DATA-COL-END']) && ($g['attr']['DATA-COL-END'] === '0' || $g['attr']['DATA-COL-END'] <> 0)) { $colend = $g['attr']['DATA-COL-END']; }
 
-	$nr = count($g['data']);
+	$nr = count(($g['data'] ?? []));
 	$nc = 0;
 	foreach($g['data'] AS $r) {
 		$cc=0;
@@ -170,8 +170,8 @@
 	}
 	// PERCENT
 	if ($percent && $type != 'pie' && $type != 'pie3d') {
-		for ($r=0;$r<count($data);$r++) {
-			for ($c=0;$c<count($data[$r]);$c++) {
+		for ($r=0;$r<count(($data ?? []));$r++) {
+			for ($c=0;$c<count(($data[$r] ?? []));$c++) {
 		    		$data[$r][$c] = $data[$r][$c]/$totals[$r]  * 100;
 			}
 		}
@@ -185,13 +185,13 @@
 		if ($colbegin>1) {
 			for ($r=($rowbegin-1);$r<$rowend;$r++) { 
 				$legends[($r+1-$rowbegin)] = $g['data'][$r][0] ;
-				$longestlegend = max($longestlegend, strlen( $g['data'][$r][0] ));
+				$longestlegend = max($longestlegend, strlen( ($g['data'][$r][0] ?? '') ));
 			}
 		}
 		if ($rowbegin>1) {
 			for ($c=($colbegin-1);$c<$colend;$c++) { 
 				$labels[($c+1-$colbegin)] = $g['data'][0][$c] ; 
-				$longestlabel = max($longestlabel , strlen( $g['data'][0][$c] ));
+				$longestlabel = max($longestlabel , strlen( ($g['data'][0][$c] ?? '') ));
 			}
 		}
 	}
@@ -199,13 +199,13 @@
 		if ($colbegin>1) {
 			for ($r=($rowbegin-1);$r<$rowend;$r++) { 
 				$labels[($r+1-$rowbegin)] = $g['data'][$r][0] ; 
-				$longestlabel = max($longestlabel , strlen( $g['data'][$r][0] ));
+				$longestlabel = max($longestlabel , strlen( ($g['data'][$r][0] ?? '') ));
 			}
 		}
 		if ($rowbegin>1) {
 			for ($c=($colbegin-1);$c<$colend;$c++) { 
 				$legends[($c+1-$colbegin)] = $g['data'][0][$c] ; 
-				$longestlegend = max($longestlegend, strlen( $g['data'][0][$c] ));
+				$longestlegend = max($longestlegend, strlen( ($g['data'][0][$c] ?? '') ));
 			}
 		}
 	}
@@ -227,7 +227,7 @@
    if (!$h && !$w) { $w = $defsize[$type]['w']; $h = $defsize[$type]['h']; }
 
 
-   if (count($data)>0 && $type) {
+   if (count(($data ?? []))>0 && $type) {
 	$figure_file = "graph_cache/".rand(11111,999999999).".".$img_type;
 	if ($bandw) { $colours = array('snow1','black','snow4','snow3','snow2','cadetblue4','cadetblue3','cadetblue1','bisque4','bisque2','beige'); }
 	else { $colours = array('cyan','darkorchid4','cadetblue3','khaki1','darkolivegreen2','cadetblue4','coral','cyan4','rosybrown3','wheat1'); }
@@ -298,7 +298,7 @@
 		$pmb = 50;
 		$xlangle = 0;
 		$ll = ($longestlegend * 5);	// 45 degrees 8pt fontsize
-		if ($ll > 5 || ($ll>3 && count($data)>10)) {
+		if ($ll > 5 || ($ll>3 && count(($data ?? []))>10)) {
 			$pmb = max($pmb, $ll + 30);
 			$xlangle = 50;
 		}
@@ -395,7 +395,7 @@
 			foreach($data AS $series => $dat) { 
 				$rdata = array();
 				foreach($data[$series] AS $row) { $rdata[] = $row;  }
-				if (count($rdata)<3) { die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points."); }
+				if (count(($rdata ?? []))<3) { die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points."); }
 				// Create the radar plot
 				$bplot = new RadarPlot($rdata);
 				$bplot->mark->SetType($markers[$series]);
@@ -605,7 +605,7 @@
 
 				$group[] = $bplot;
 			}
-			if (count($data)==1) {
+			if (count(($data ?? []))==1) {
 				$graph->Add($group[0]);
 			}
 			else {
@@ -689,7 +689,7 @@
 
 				$group[] = $bplot;
 			}
-			if (count($data)==1) {
+			if (count(($data ?? []))==1) {
 				$graph->Add($group[0]);
 			}
 			else {
@@ -705,7 +705,7 @@
 	}
 	if ($graph) {
 		$graph->Stroke( _MPDF_PATH.$figure_file);
-		$srcpath = str_replace("\\","/",dirname(__FILE__)) . "/";
+		$srcpath = str_replace("\\","/",(dirname(__FILE__) ?? '')) . "/";
 		$srcpath .= $figure_file;
 		return array('file'=>$srcpath, 'w'=>$w, 'h'=>$h);
 	}
--- a/intranet/mpdf60/qrcode/qrcode.class.php
+++ b/intranet/mpdf60/qrcode/qrcode.class.php
@@ -65,7 +65,7 @@
 			if (!in_array($level, array('L', 'M', 'Q', 'H')))
 				$this->ERROR('ECC non reconnu : L, M, Q, H');
 			
-			$this->length = strlen($value);
+			$this->length = strlen(($value ?? ''));
 			if (!$this->length)
 				$this->ERROR('pas de data...');
 
@@ -201,19 +201,19 @@
 			$s = $size/($s_max-$s_min);
 			 
 			// rectangle de fond
-			$im = imagecreatetruecolor($size,$size);
-			$c_case = imagecolorallocate($im,$color[0],$color[1],$color[2]);
-			$c_back = imagecolorallocate($im,$background[0],$background[1],$background[2]);
-			imagefilledrectangle($im,0,0,$size,$size,$c_back);
+			$im = imagecreatetruecolor((int) ($size),(int) ($size));
+			$c_case = imagecolorallocate($im,(int) ($color[0]),(int) ($color[1]),(int) ($color[2]));
+			$c_back = imagecolorallocate($im,(int) ($background[0]),(int) ($background[1]),(int) ($background[2]));
+			imagefilledrectangle($im,0,0,(int) ($size),(int) ($size),(int) ($c_back));
 		 
 			for($j=$s_min; $j<$s_max; $j++)
 				for($i=$s_min; $i<$s_max; $i++)
 					if ($this->final[$i + $j*$this->qr_size+1])
-						imagefilledrectangle($im,($i-$s_min)*$s,($j-$s_min)*$s,($i-$s_min+1)*$s-1,($j-$s_min+1)*$s-1,$c_case);
+						imagefilledrectangle($im,(int) (($i-$s_min)*$s),(int) (($j-$s_min)*$s),(int) (($i-$s_min+1)*$s-1),(int) (($j-$s_min+1)*$s-1),(int) ($c_case));
 		 
 			if ($filename)
 			{
-				imagepng($im, $filename, $quality);
+				imagepng($im, $filename, (int) ($quality));
 			}
 			else
 			{
@@ -248,9 +248,9 @@
 		private function encode()
 		{
 			// conversion des datas
-			if (preg_match('/[^0-9]/',$this->value))
-			{
-				if (preg_match('/[^0-9A-Z \$\*\%\+\-\.\/\:]/',$this->value))
+			if (preg_match('/[^0-9]/',($this->value ?? '')))
+			{
+				if (preg_match('/[^0-9A-Z \$\*\%\+\-\.\/\:]/',($this->value ?? '')))
 				{
 					// type : bin
 					$this->type = 'bin';
@@ -262,7 +262,7 @@
 					
 					// datas
 					for ($i=0; $i<$this->length; $i++)
-						$this->addData(ord(substr($this->value, $i, 1)), 8);
+						$this->addData(ord((substr(($this->value ?? ''), $i, 1) ?? '')), 8);
 				}
 				else
 				{
@@ -284,9 +284,9 @@
 					for ($i=0; $i<$this->length; $i++)
 					{
 						if (($i %2)==0)
-							$this->addData($an_hash[substr($this->value,$i,1)], 6, false);
+							$this->addData($an_hash[substr(($this->value ?? ''),$i,1)], 6, false);
 						else
-							$this->addData($this->data_val[$this->data_cur]*45+$an_hash[substr($this->value,$i,1)], 11, true);
+							$this->addData($this->data_val[$this->data_cur]*45+$an_hash[substr(($this->value ?? ''),$i,1)], 11, true);
 					}
 					unset($an_hash);
 					
@@ -308,11 +308,11 @@
 				for ($i=0; $i<$this->length; $i++)
 				{
 					if (($i % 3)==0)
-						$this->addData(substr($this->value,$i,1), 4, false);
+						$this->addData(substr(($this->value ?? ''),$i,1), 4, false);
 					else if (($i % 3)==1)
-						$this->addData($this->data_val[$this->data_cur]*10+substr($this->value,$i,1), 7, false);
+						$this->addData($this->data_val[$this->data_cur]*10+substr(($this->value ?? ''),$i,1), 7, false);
 					else
-						$this->addData($this->data_val[$this->data_cur]*10+substr($this->value,$i,1), 10);
+						$this->addData($this->data_val[$this->data_cur]*10+substr(($this->value ?? ''),$i,1), 10);
 				}
 				
 				if (isset($this->data_bit[$this->data_cur]))
@@ -464,7 +464,7 @@
 				$this->mask_array				= unpack("C*", fread($fp1,$this->byte_num));
 				$this->format_information_x2	= unpack("C*", fread($fp1,15));
 				$this->format_information_y2	= unpack("C*", fread($fp1,15));
-				$this->rs_ecc_codewords			= ord(fread($fp1,1));
+				$this->rs_ecc_codewords			= ord((fread($fp1,1) ?? ''));
 				$this->rs_block_order			= unpack("C*", fread($fp1,128));
 			fclose($fp1);
 			$this->format_information_x1 = array(0,1,2,3,4,5,7,8,8,8,8,8,8,8,8);
@@ -482,7 +482,7 @@
 				$rs_cal_table_array[$i]=fread ($fp0,$this->rs_ecc_codewords);
 			fclose ($fp0);	
 
-			$max_data_codewords = count($this->data_word);
+			$max_data_codewords = count(($this->data_word ?? []));
 
 			// preparation
 			$j=0;
@@ -490,7 +490,7 @@
 			$rs_temp[0]="";
 			for($i=0; $i<$max_data_codewords; $i++)
 			{
-				$rs_temp[$rs_block_number].=chr($this->data_word[$i]);
+				$rs_temp[$rs_block_number].=chr((int) ($this->data_word[$i]));
 				$j++;
 				if ($j>=$this->rs_block_order[$rs_block_number+1]-$this->rs_ecc_codewords)
 				{
@@ -501,29 +501,29 @@
 			}
 
 			// make
-			$rs_block_order_num=count($this->rs_block_order);
+			$rs_block_order_num=count(($this->rs_block_order ?? []));
 			
 			for($rs_block_number=0; $rs_block_number<$rs_block_order_num; $rs_block_number++)
 			{
 				$rs_codewords=$this->rs_block_order[$rs_block_number+1];
 				$rs_data_codewords=$rs_codewords-$this->rs_ecc_codewords;
 
-				$rstemp=$rs_temp[$rs_block_number].str_repeat(chr(0),$this->rs_ecc_codewords);
-				$padding_data=str_repeat(chr(0),$rs_data_codewords);
+				$rstemp=$rs_temp[$rs_block_number].str_repeat((chr(0) ?? ''),$this->rs_ecc_codewords);
+				$padding_data=str_repeat((chr(0) ?? ''),$rs_data_codewords);
 
 				$j=$rs_data_codewords;
 				while($j>0)
 				{
-					$first=ord(substr($rstemp,0,1));
+					$first=ord((substr(($rstemp ?? ''),0,1) ?? ''));
 
 					if ($first)
 					{
-						$left_chr=substr($rstemp,1);
+						$left_chr=substr(($rstemp ?? ''),1);
 						$cal=$rs_cal_table_array[$first].$padding_data;
 						$rstemp=$left_chr ^ $cal;
 					}
 					else
-						$rstemp=substr($rstemp,1);
+						$rstemp=substr(($rstemp ?? ''),1);
 					$j--;
 				}
 				
@@ -564,8 +564,8 @@
 				$l=0;
 				while($l<$this->size)
 				{
-					$hor_master=$hor_master.chr($this->matrix[$l][$k]);
-					$ver_master=$ver_master.chr($this->matrix[$k][$l]);
+					$hor_master=$hor_master.chr((int) ($this->matrix[$l][$k]));
+					$ver_master=$ver_master.chr((int) ($this->matrix[$k][$l]));
 					$l++;
 				}
 				$k++;
@@ -580,14 +580,14 @@
 				$ptn_temp=array();
 				$bit= 1<< $i;
 				$bit_r=(~$bit)&255;
-				$bit_mask=str_repeat(chr($bit),$all_matrix);
+				$bit_mask=str_repeat((chr((int) ($bit)) ?? ''),$all_matrix);
 				$hor = $hor_master & $bit_mask;
 				$ver = $ver_master & $bit_mask;
 
-				$ver_shift1=$ver.str_repeat(chr(170),$this->size);
-				$ver_shift2=str_repeat(chr(170),$this->size).$ver;
-				$ver_shift1_0=$ver.str_repeat(chr(0),$this->size);
-				$ver_shift2_0=str_repeat(chr(0),$this->size).$ver;
+				$ver_shift1=$ver.str_repeat((chr(170) ?? ''),$this->size);
+				$ver_shift2=str_repeat((chr(170) ?? ''),$this->size).$ver;
+				$ver_shift1_0=$ver.str_repeat((chr(0) ?? ''),$this->size);
+				$ver_shift2_0=str_repeat((chr(0) ?? ''),$this->size).$ver;
 				$ver_or=chunk_split(~($ver_shift1 | $ver_shift2),$this->size,chr(170));
 				$ver_and=chunk_split(~($ver_shift1_0 & $ver_shift2_0),$this->size,chr(170));
 
@@ -595,34 +595,34 @@
 				$ver=chunk_split(~$ver,$this->size,chr(170));
 				$hor=$hor.chr(170).$ver;
 
-				$n1_search="/".str_repeat(chr(255),5)."+|".str_repeat(chr($bit_r),5)."+/";
-				$n3_search=chr($bit_r).chr(255).chr($bit_r).chr($bit_r).chr($bit_r).chr(255).chr($bit_r);
+				$n1_search="/".str_repeat((chr(255) ?? ''),5)."+|".str_repeat((chr((int) ($bit_r)) ?? ''),5)."+/";
+				$n3_search=chr((int) ($bit_r)).chr(255).chr((int) ($bit_r)).chr((int) ($bit_r)).chr((int) ($bit_r)).chr(255).chr((int) ($bit_r));
 	
 				$demerit_n3=substr_count($hor,$n3_search)*40;
-				$demerit_n4=floor(abs(( (100* (substr_count($ver,chr($bit_r))/($this->byte_num)) )-50)/5))*10;
-
-				$n2_search1="/".chr($bit_r).chr($bit_r)."+/";
+				$demerit_n4=floor(abs(( (100* (substr_count($ver,chr((int) ($bit_r)))/($this->byte_num)) )-50)/5))*10;
+
+				$n2_search1="/".chr((int) ($bit_r)).chr((int) ($bit_r))."+/";
 				$n2_search2="/".chr(255).chr(255)."+/";
 				$demerit_n2=0;
-				preg_match_all($n2_search1,$ver_and,$ptn_temp);
+				preg_match_all(($n2_search1 ?? ''),($ver_and ?? ''),$ptn_temp);
 				foreach($ptn_temp[0] as $str_temp)
 				{
-					$demerit_n2+=(strlen($str_temp)-1);
+					$demerit_n2+=(strlen(($str_temp ?? ''))-1);
 				}
 				$ptn_temp=array();
-				preg_match_all($n2_search2,$ver_or,$ptn_temp);
+				preg_match_all(($n2_search2 ?? ''),($ver_or ?? ''),$ptn_temp);
 				foreach($ptn_temp[0] as $str_temp)
 				{
-					$demerit_n2+=(strlen($str_temp)-1);
+					$demerit_n2+=(strlen(($str_temp ?? ''))-1);
 				}
 				$demerit_n2*=3;
 				
 				$ptn_temp=array();
 				
-				preg_match_all($n1_search,$hor,$ptn_temp);
+				preg_match_all(($n1_search ?? ''),($hor ?? ''),$ptn_temp);
 				foreach($ptn_temp[0] as $str_temp)
 				{
-					$demerit_n1+=(strlen($str_temp)-2);
+					$demerit_n1+=(strlen(($str_temp ?? ''))-2);
 				}	
 				$demerit_score=$demerit_n1+$demerit_n2+$demerit_n3+$demerit_n4;
 	
@@ -650,7 +650,7 @@
 
 			for($i=0; $i<15; $i++)
 			{
-				$content=substr($format_information_array[$format_information_value],$i,1);
+				$content=substr(($format_information_array[$format_information_value] ?? ''),$i,1);
 				
 				$this->matrix[$this->format_information_x1[$i]][$this->format_information_y1[$i]]=$content * 255;
 				$this->matrix[$this->format_information_x2[$i+1]][$this->format_information_y2[$i+1]]=$content * 255;
--- a/intranet/mpdf60/qrcode/image.php
+++ b/intranet/mpdf60/qrcode/image.php
@@ -8,7 +8,7 @@
 	
 	require_once('qrcode.class.php');
 	
-	$qrcode = new QRcode(utf8_encode($msg), $err);
+	$qrcode = new QRcode(mb_convert_encoding(($msg ?? ''), 'UTF-8', 'ISO-8859-1'), $err);
 	$qrcode->disableBorder();
 	$qrcode->displayPNG(200);
 ?>
\ No newline at end of file
--- a/intranet/mpdf60/qrcode/index.php
+++ b/intranet/mpdf60/qrcode/index.php
@@ -44,7 +44,7 @@
 	<body>
 		<center>
 			<form method="GET" action="">
-				<textarea name="msg" cols="40" rows="7"><?php echo htmlentities($msg); ?></textarea><br>
+				<textarea name="msg" cols="40" rows="7"><?php echo htmlentities(($msg ?? '')); ?></textarea><br>
 				Correction d'erreur : 
 				<select name="err">
 					<option value="L" <?php echo $err=='L' ? 'selected' : ''; ?>>L</option>
@@ -57,12 +57,12 @@
 			<hr>
 			Génération d'un tableau HTML :<br> 
 <?php
-	$qrcode = new QRcode(utf8_encode($msg), $err);
+	$qrcode = new QRcode(mb_convert_encoding(($msg ?? ''), 'UTF-8', 'ISO-8859-1'), $err);
 	$qrcode->displayHTML();
 ?>
 			<br>
 			Génération d'une image PNG : <br>
-			<img src="./image.php?msg=<?php echo urlencode($msg); ?>&amp;err=<?php echo urlencode($err); ?>" alt="generation qr-code" style="border: solid 1px black;">
+			<img src="./image.php?msg=<?php echo urlencode(($msg ?? '')); ?>&amp;err=<?php echo urlencode(($err ?? '')); ?>" alt="generation qr-code" style="border: solid 1px black;">
 		</center>
 	</body>
 </html>
\ No newline at end of file
--- a/intranet/mpdf60/includes/functions.php
+++ b/intranet/mpdf60/includes/functions.php
@@ -8,9 +8,9 @@
         if(imageistruecolor($src)) {
             return(true);
         }
-        $dst = imagecreatetruecolor(imagesx($src), imagesy($src));
+        $dst = imagecreatetruecolor((int) (imagesx($src)), (int) (imagesy($src)));
 
-        imagecopy($dst, $src, 0, 0, 0, 0, imagesx($src), imagesy($src));
+        imagecopy($dst, $src, 0, 0, 0, 0, (int) (imagesx($src)), (int) (imagesy($src)));
         imagedestroy($src);
 
         $src = $dst;
@@ -31,7 +31,7 @@
 	if (is_array($array)) {
 		$array  = array_values($array);
 		$offset = intval($offset);
-		if ($offset < 0 || $offset >= count($array)) { array_push($array, $value); }
+		if ($offset < 0 || $offset >= count(($array ?? []))) { array_push($array, $value); }
 		else if ($offset == 0) { array_unshift($array, $value); }
 		else { 
 			$temp  = array_slice($array, 0, $offset);
@@ -41,20 +41,20 @@
 		}
 	}
 	else { $array = array($value); }
-	return count($array);
+	return count(($array ?? []));
 }
 
 // mPDF 5.7.4 URLs
 function urldecode_parts($url) {
 	$file=$url;
 	$query='';
-	if (preg_match('/[?]/',$url)) {
-		$bits = preg_split('/[?]/',$url,2);
+	if (preg_match('/[?]/',($url ?? ''))) {
+		$bits = preg_split('/[?]/',($url ?? ''),2);
 		$file=$bits[0];
 		$query='?'.$bits[1];
 	}
-	$file = rawurldecode($file);
-	$query = urldecode($query);
+	$file = rawurldecode(($file ?? ''));
+	$query = urldecode(($query ?? ''));
 	return $file.$query;
 }
 
@@ -89,9 +89,9 @@
 function _fgets (&$h, $force=false) {
 	$startpos = ftell($h);
 	$s = fgets($h, 1024);
-	if ($force && preg_match("/^([^\r\n]*[\r\n]{1,2})(.)/",trim($s), $ns)) {
+	if ($force && preg_match("/^([^\r\n]*[\r\n]{1,2})(.)/",(trim(($s ?? '')) ?? ''), $ns)) {
 		$s = $ns[1];
-		fseek($h,$startpos+strlen($s));
+		fseek($h,$startpos+strlen(($s ?? '')));
 	}
 	return $s;
 }
@@ -100,19 +100,19 @@
 // For PHP4 compatability
 if(!function_exists('str_ireplace')) {
   function str_ireplace($search,$replace,$subject) {
-	$search = preg_quote($search, "/");
-	return preg_replace("/".$search."/i", $replace, $subject); 
+	$search = preg_quote(($search ?? ''), "/");
+	return preg_replace("/".$search."/i", ($replace ?? ''), ($subject ?? '')); 
   }
 }
 if(!function_exists('htmlspecialchars_decode')) {
 	function htmlspecialchars_decode ($str) {
-		return strtr($str, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
+		return strtr(($str ?? ''), (array_flip(get_html_translation_table(HTML_SPECIALCHARS)) ?? ''));
 	}
 }
 
 function PreparePreText($text,$ff='//FF//') {
-	$text = htmlspecialchars($text);
-	if ($ff) { $text = str_replace($ff,'</pre><formfeed /><pre>',$text); }
+	$text = htmlspecialchars(($text ?? ''));
+	if ($ff) { $text = str_replace(($ff ?? ''),'</pre><formfeed /><pre>',($text ?? '')); }
 	return ('<pre>'.$text.'</pre>');
 }
 
@@ -121,12 +121,12 @@
 	//converts all the &#nnn; and &#xhhh; in a string to Unicode
 	// mPDF 5.7
 	if ($lo) {
-		$str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_lo_callback', $str);
-		$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_lo_callback', $str);
+		$str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_lo_callback', ($str ?? ''));
+		$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_lo_callback', ($str ?? ''));
 	}
 	else {
-		$str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_callback', $str);
-		$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_callback', $str);
+		$str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_callback', ($str ?? ''));
+		$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_callback', ($str ?? ''));
 	}
 	return $str;
   }
@@ -149,12 +149,12 @@
   function code2utf($num,$lo=true){
 	//Returns the utf string corresponding to the unicode value
 	if ($num<128) {
-		if ($lo) return chr($num);
+		if ($lo) return chr((int) ($num));
 		else return '&#'.$num.';';
 	}
-	if ($num<2048) return chr(($num>>6)+192).chr(($num&63)+128);
-	if ($num<65536) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
-	if ($num<2097152) return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
+	if ($num<2048) return chr((int) (($num>>6)+192)).chr((int) (($num&63)+128));
+	if ($num<65536) return chr((int) (($num>>12)+224)).chr((int) ((($num>>6)&63)+128)).chr((int) (($num&63)+128));
+	if ($num<2097152) return chr((int) (($num>>18)+240)).chr((int) ((($num>>12)&63)+128)).chr((int) ((($num>>6)&63)+128)) .chr((int) (($num&63)+128));
 	return '?';
   }
 }
--- a/intranet/mpdf60/classes/tocontents.php
+++ b/intranet/mpdf60/classes/tocontents.php
@@ -1,6 +1,9 @@
 <?php
 
 class tocontents {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $TOCsheetsize;
+
 
 var $mpdf = null;
 var $_toc;
@@ -32,7 +35,7 @@
 var $TOC_suppress;	// mPDF 6
 var $m_TOC; 
 
-function tocontents(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 	$this->_toc=array();
 	$this->TOCmark = 0;
@@ -40,11 +43,11 @@
 }
 
 function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging=true, $TOCuseLinking='', $toc_orientation='', $toc_mgl='',$toc_mgr='',$toc_mgt='',$toc_mgb='',$toc_mgh='',$toc_mgf='',$toc_ohname='',$toc_ehname='',$toc_ofname='',$toc_efname='',$toc_ohvalue=0,$toc_ehvalue=0,$toc_ofvalue=0, $toc_efvalue=0, $toc_preHTML='', $toc_postHTML='', $toc_bookmarkText='', $resetpagenum='', $pagenumstyle='', $suppress='', $orientation='', $mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='',$ohname='',$ehname='',$ofname='',$efname='',$ohvalue=0,$ehvalue=0,$ofvalue=0,$efvalue=0, $toc_id=0, $pagesel='', $toc_pagesel='', $sheetsize='', $toc_sheetsize='', $tocoutdent='', $toc_resetpagenum='', $toc_pagenumstyle='', $toc_suppress='') {	// mPDF 5.6.19	// mPDF 6
-		if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
+		if (strtoupper(($toc_id ?? ''))=='ALL') { $toc_id = '_mpdf_all'; }
 		else if (!$toc_id) { $toc_id = 0; }
-		else { $toc_id = strtolower($toc_id); }
-
-		if ($TOCusePaging === false || strtolower($TOCusePaging) == "off" || $TOCusePaging === 0 || $TOCusePaging === "0" || $TOCusePaging === "") { $TOCusePaging = false; }
+		else { $toc_id = strtolower(($toc_id ?? '')); }
+
+		if ($TOCusePaging === false || strtolower(($TOCusePaging ?? '')) == "off" || $TOCusePaging === 0 || $TOCusePaging === "0" || $TOCusePaging === "") { $TOCusePaging = false; }
 		else { $TOCusePaging = true; }
 		if (!$TOCuseLinking) { $TOCuseLinking = false; }
 		if ($toc_id) {
@@ -113,14 +116,14 @@
 
 // Initiate, and Mark a place for the Table of Contents to be inserted
 function TOC($tocfont='', $tocfontsize=0, $tocindent=0, $resetpagenum='', $pagenumstyle='', $suppress='', $toc_orientation='', $TOCusePaging=true, $TOCuseLinking=false, $toc_id=0, $tocoutdent='', $toc_resetpagenum='', $toc_pagenumstyle='', $toc_suppress='') {	// mPDF 5.6.19	// mPDF 6
-		if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; }
+		if (strtoupper(($toc_id ?? ''))=='ALL') { $toc_id = '_mpdf_all'; }
 		else if (!$toc_id) { $toc_id = 0; }
-		else { $toc_id = strtolower($toc_id); }
+		else { $toc_id = strtolower(($toc_id ?? '')); }
 		// To use odd and even pages
 		// Cannot start table of contents on an even page
 		if (($this->mpdf->mirrorMargins) && (($this->mpdf->page)%2==0)) {	// EVEN
 			if ($this->mpdf->ColActive) {
-				if (count($this->mpdf->columnbuffer)) { $this->mpdf->printcolumnbuffer(); }
+				if (count(($this->mpdf->columnbuffer ?? []))) { $this->mpdf->printcolumnbuffer(); }
 			}
 			$this->mpdf->AddPage($this->mpdf->CurOrientation,'',$resetpagenum, $pagenumstyle, $suppress);
 		}
@@ -153,11 +156,11 @@
 function insertTOC() {
 	$notocs = 0;
 	if ($this->TOCmark) { $notocs = 1; }
-	$notocs += count($this->m_TOC);
+	$notocs += count(($this->m_TOC ?? []));
 
 	if ($notocs==0) { return; }
 
-	if (count($this->m_TOC)) { reset($this->m_TOC); }
+	if (count(($this->m_TOC ?? []))) { reset($this->m_TOC); }
 	$added_toc_pages = 0;
 
 	if ($this->mpdf->ColActive) { $this->mpdf->SetColumns(0); }
@@ -250,7 +253,7 @@
 
 		$this->mpdf->writingToC = true;	// mPDF 5.6.38
 		// mPDF 5.6.31
-		$tocstart=count($this->mpdf->pages);
+		$tocstart=count(($this->mpdf->pages ?? []));
 		if (isset($toc_preHTML) && $toc_preHTML) { $this->mpdf->WriteHTML($toc_preHTML); }
 
 
@@ -297,7 +300,7 @@
 	$s .= $this->mpdf->PrintBodyBackgrounds();
 
 	$s .= $this->mpdf->PrintPageBackgrounds();
-	$this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->mpdf->uniqstr.')/', "\n".$s."\n".'\\1', $this->mpdf->pages[$this->mpdf->page]);
+	$this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->mpdf->uniqstr.')/', "\n".$s."\n".'\\1', ($this->mpdf->pages[$this->mpdf->page] ?? ''));
 	$this->mpdf->pageBackgrounds = array();
 
 	//Page footer
@@ -307,7 +310,7 @@
 
 	// 2nd time through to move pages etc.
 	$added_toc_pages = 0;
-	if (count($this->m_TOC)) { reset($this->m_TOC); }
+	if (count(($this->m_TOC ?? []))) { reset($this->m_TOC); }
 
 	for ($toci = 0; $toci<$notocs; $toci++) {
 		if ($toci==0 && $this->TOCmark) {
@@ -367,7 +370,7 @@
 
 	// Delete empty page that was inserted earlier
 	if ($extrapage) {
-		unset($this->mpdf->pages[count($this->mpdf->pages)]);
+		unset($this->mpdf->pages[count(($this->mpdf->pages ?? []))]);
 		$this->mpdf->page--;	// Reset page pointer
 	}
 
@@ -381,23 +384,23 @@
 	if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) { $pagenumstyle = $attr['PAGENUMSTYLE']; } else { $pagenumstyle= ''; }
 	if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) { $suppress = $attr['SUPPRESS']; } else { $suppress = ''; }
 	if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $toc_orientation = $attr['TOC-ORIENTATION']; } else { $toc_orientation = ''; }
-	if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $paging = false; }
+	if (isset($attr['PAGING']) && (strtoupper(($attr['PAGING'] ?? ''))=='OFF' || $attr['PAGING']==='0')) { $paging = false; }
 	else { $paging = true; }
-	if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $links = true; }
+	if (isset($attr['LINKS']) && (strtoupper(($attr['LINKS'] ?? ''))=='ON' || $attr['LINKS']==1)) { $links = true; }
 	else { $links = false; }
-	if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
+	if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower(($attr['NAME'] ?? '')); } else { $toc_id = 0; }
 	$this->TOC('',0,0,$resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id, $tocoutdent);  // mPDF 5.6.19 5.6.31 
 }
 
 
 function openTagTOCPAGEBREAK($attr) {
-	if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
+	if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower(($attr['NAME'] ?? '')); } else { $toc_id = 0; }
 	if ($toc_id) {
 	  if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $this->m_TOC[$toc_id]['TOCoutdent'] = $attr['OUTDENT']; } else { $this->m_TOC[$toc_id]['TOCoutdent'] = ''; }	// mPDF 5.6.19
 	  if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->m_TOC[$toc_id]['TOCorientation'] = $attr['TOC-ORIENTATION']; } else { $this->m_TOC[$toc_id]['TOCorientation'] = ''; }
-	  if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->m_TOC[$toc_id]['TOCusePaging'] = false; }
+	  if (isset($attr['PAGING']) && (strtoupper(($attr['PAGING'] ?? ''))=='OFF' || $attr['PAGING']==='0')) { $this->m_TOC[$toc_id]['TOCusePaging'] = false; }
 	  else { $this->m_TOC[$toc_id]['TOCusePaging'] = true; }
-	  if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->m_TOC[$toc_id]['TOCuseLinking'] = true; }
+	  if (isset($attr['LINKS']) && (strtoupper(($attr['LINKS'] ?? ''))=='ON' || $attr['LINKS']==1)) { $this->m_TOC[$toc_id]['TOCuseLinking'] = true; }
 	  else { $this->m_TOC[$toc_id]['TOCuseLinking'] = false; }
 
 	  $this->m_TOC[$toc_id]['TOC_margin_left'] = $this->m_TOC[$toc_id]['TOC_margin_right'] = $this->m_TOC[$toc_id]['TOC_margin_top'] = $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $this->m_TOC[$toc_id]['TOC_margin_header'] = $this->m_TOC[$toc_id]['TOC_margin_footer'] = '';
@@ -413,14 +416,14 @@
 	  if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) { $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $attr['TOC-ODD-FOOTER-NAME']; }
 	  if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) { $this->m_TOC[$toc_id]['TOC_even_footer_name'] = $attr['TOC-EVEN-FOOTER-NAME']; }
 	  $this->m_TOC[$toc_id]['TOC_odd_header_value'] = $this->m_TOC[$toc_id]['TOC_even_header_value'] = $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 0;
-	  if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = 1; }
-	  else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = -1; }
-	  if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = 1; }
-	  else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = -1; }
-	  if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = 1; }
-	  else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = -1; }
-	  if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 1; }
-	  else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = -1; }
+	  if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper(($attr['TOC-ODD-HEADER-VALUE'] ?? ''))=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = 1; }
+	  else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper(($attr['TOC-ODD-HEADER-VALUE'] ?? ''))=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = -1; }
+	  if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper(($attr['TOC-EVEN-HEADER-VALUE'] ?? ''))=='ON')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = 1; }
+	  else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper(($attr['TOC-EVEN-HEADER-VALUE'] ?? ''))=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = -1; }
+	  if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper(($attr['TOC-ODD-FOOTER-VALUE'] ?? ''))=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = 1; }
+	  else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper(($attr['TOC-ODD-FOOTER-VALUE'] ?? ''))=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = -1; }
+	  if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper(($attr['TOC-EVEN-FOOTER-VALUE'] ?? ''))=='ON')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 1; }
+	  else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper(($attr['TOC-EVEN-FOOTER-VALUE'] ?? ''))=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = -1; }
 	  if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) { $this->m_TOC[$toc_id]['TOC_resetpagenum'] = $attr['TOC-RESETPAGENUM']; }
 	  else { $this->m_TOC[$toc_id]['TOC_resetpagenum'] = ''; }	// mPDF 6
 	  if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) { $this->m_TOC[$toc_id]['TOC_pagenumstyle'] = $attr['TOC-PAGENUMSTYLE']; }
@@ -432,17 +435,17 @@
 	  if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->m_TOC[$toc_id]['TOCsheetsize'] = $attr['TOC-SHEET-SIZE']; } else { $this->m_TOC[$toc_id]['TOCsheetsize'] = ''; }
 
 
-	  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->m_TOC[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
-	  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->m_TOC[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
+	  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->m_TOC[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode(($attr['TOC-PREHTML'] ?? ''),ENT_QUOTES); }
+	  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->m_TOC[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode(($attr['TOC-POSTHTML'] ?? ''),ENT_QUOTES); }
 	  
-	  if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); }	// *BOOKMARKS*
+	  if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode(($attr['TOC-BOOKMARKTEXT'] ?? ''),ENT_QUOTES); }	// *BOOKMARKS*
 	}
 	else {
 	  if (isset($attr['OUTDENT']) && $attr['OUTDENT']) { $this->TOCoutdent = $attr['OUTDENT']; } else { $this->TOCoutdent = ''; }	// mPDF 5.6.19
 	  if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->TOCorientation = $attr['TOC-ORIENTATION']; } else { $this->TOCorientation = ''; }
-	  if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->TOCusePaging = false; }
+	  if (isset($attr['PAGING']) && (strtoupper(($attr['PAGING'] ?? ''))=='OFF' || $attr['PAGING']==='0')) { $this->TOCusePaging = false; }
 	  else { $this->TOCusePaging = true; }
-	  if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->TOCuseLinking = true; }
+	  if (isset($attr['LINKS']) && (strtoupper(($attr['LINKS'] ?? ''))=='ON' || $attr['LINKS']==1)) { $this->TOCuseLinking = true; }
 	  else { $this->TOCuseLinking = false; }
 
 	  $this->TOC_margin_left = $this->TOC_margin_right = $this->TOC_margin_top = $this->TOC_margin_bottom = $this->TOC_margin_header = $this->TOC_margin_footer = '';
@@ -458,15 +461,15 @@
 	  if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) { $this->TOC_odd_footer_name = $attr['TOC-ODD-FOOTER-NAME']; }
 	  if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) { $this->TOC_even_footer_name = $attr['TOC-EVEN-FOOTER-NAME']; }
 	  $this->TOC_odd_header_value = $this->TOC_even_header_value = $this->TOC_odd_footer_value = $this->TOC_even_footer_value = 0;
-	  if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='ON')) { $this->TOC_odd_header_value = 1; }
-	  else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='OFF')) { $this->TOC_odd_header_value = -1; }
-	  if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='ON')) { $this->TOC_even_header_value = 1; }
-	  else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='OFF')) { $this->TOC_even_header_value = -1; }
-
-	  if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='ON')) { $this->TOC_odd_footer_value = 1; }
-	  else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='OFF')) { $this->TOC_odd_footer_value = -1; }
-	  if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='ON')) { $this->TOC_even_footer_value = 1; }
-	  else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='OFF')) { $this->TOC_even_footer_value = -1; }
+	  if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper(($attr['TOC-ODD-HEADER-VALUE'] ?? ''))=='ON')) { $this->TOC_odd_header_value = 1; }
+	  else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper(($attr['TOC-ODD-HEADER-VALUE'] ?? ''))=='OFF')) { $this->TOC_odd_header_value = -1; }
+	  if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper(($attr['TOC-EVEN-HEADER-VALUE'] ?? ''))=='ON')) { $this->TOC_even_header_value = 1; }
+	  else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper(($attr['TOC-EVEN-HEADER-VALUE'] ?? ''))=='OFF')) { $this->TOC_even_header_value = -1; }
+
+	  if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper(($attr['TOC-ODD-FOOTER-VALUE'] ?? ''))=='ON')) { $this->TOC_odd_footer_value = 1; }
+	  else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper(($attr['TOC-ODD-FOOTER-VALUE'] ?? ''))=='OFF')) { $this->TOC_odd_footer_value = -1; }
+	  if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper(($attr['TOC-EVEN-FOOTER-VALUE'] ?? ''))=='ON')) { $this->TOC_even_footer_value = 1; }
+	  else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper(($attr['TOC-EVEN-FOOTER-VALUE'] ?? ''))=='OFF')) { $this->TOC_even_footer_value = -1; }
 	  if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->TOC_page_selector = $attr['TOC-PAGE-SELECTOR']; }
 	  else { $this->TOC_page_selector = ''; }
 	  if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) { $this->TOC_resetpagenum = $attr['TOC-RESETPAGENUM']; }
@@ -477,16 +480,16 @@
 	  else { $this->TOC_suppress = ''; }	// mPDF 6
 	  if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->TOCsheetsize = $attr['TOC-SHEET-SIZE']; } else { $this->TOCsheetsize = ''; }
 
-	  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
-	  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
-	  if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); }	
+	  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode(($attr['TOC-PREHTML'] ?? ''),ENT_QUOTES); }
+	  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode(($attr['TOC-POSTHTML'] ?? ''),ENT_QUOTES); }
+	  if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode(($attr['TOC-BOOKMARKTEXT'] ?? ''),ENT_QUOTES); }	
 	}
 
 	if ($this->mpdf->y == $this->mpdf->tMargin && (!$this->mpdf->mirrorMargins ||($this->mpdf->mirrorMargins && $this->mpdf->page % 2==1))) { 
 		if ($toc_id) { $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; }
 		else { $this->TOCmark = $this->mpdf->page; }
 		// Don't add a page
-		if ($this->mpdf->page==1 && count($this->mpdf->PageNumSubstitutions)==0) { 
+		if ($this->mpdf->page==1 && count(($this->mpdf->PageNumSubstitutions ?? []))==0) { 
 			$resetpagenum = '';
 			$pagenumstyle = '';
 			$suppress = '';
--- a/intranet/mpdf60/classes/grad.php
+++ b/intranet/mpdf60/classes/grad.php
@@ -4,7 +4,7 @@
 
 var $mpdf = null;
 
-function grad(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 }
 
@@ -13,15 +13,15 @@
 	$s=' q ';
 	$s.=sprintf(' %.3F %.3F %.3F %.3F re W n ', $x*_MPDFK, ($this->mpdf->h-$y)*_MPDFK, $w*_MPDFK, -$h*_MPDFK);
 	$s.=sprintf(' %.3F 0 0 %.3F %.3F %.3F cm ', $w*_MPDFK, $h*_MPDFK, $x*_MPDFK, ($this->mpdf->h-($y+$h))*_MPDFK);
-	$n = count($this->mpdf->gradients)+1;
+	$n = count(($this->mpdf->gradients ?? []))+1;
 	$this->mpdf->gradients[$n]['type'] = 6; //coons patch mesh
 	$this->mpdf->gradients[$n]['colorspace'] = $colspace; //coons patch mesh
 	$bpcd=65535; //16 BitsPerCoordinate
 	$trans = false;
 	$this->mpdf->gradients[$n]['stream']='';
-	for($i=0;$i<count($patch_array);$i++){
-		$this->mpdf->gradients[$n]['stream'].=chr($patch_array[$i]['f']); //start with the edge flag as 8 bit
-		for($j=0;$j<count($patch_array[$i]['points']);$j++){
+	for($i=0;$i<count(($patch_array ?? []));$i++){
+		$this->mpdf->gradients[$n]['stream'].=chr((int) ($patch_array[$i]['f'])); //start with the edge flag as 8 bit
+		for($j=0;$j<count(($patch_array[$i]['points'] ?? []));$j++){
 			//each point as 16 bit
 			if (($j % 2) == 1) {	// Y coordinate (adjusted as input is From top left)
 				$patch_array[$i]['points'][$j]=(($patch_array[$i]['points'][$j]-$y_min)/($y_max-$y_min))*$bpcd;
@@ -32,23 +32,23 @@
 			}
 			if($patch_array[$i]['points'][$j]<0) $patch_array[$i]['points'][$j]=0;
 			if($patch_array[$i]['points'][$j]>$bpcd) $patch_array[$i]['points'][$j]=$bpcd;
-			$this->mpdf->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j]/256));
-			$this->mpdf->gradients[$n]['stream'].=chr(floor($patch_array[$i]['points'][$j]%256));
-		}
-		for($j=0;$j<count($patch_array[$i]['colors']);$j++){
+			$this->mpdf->gradients[$n]['stream'].=chr((int) (floor($patch_array[$i]['points'][$j]/256)));
+			$this->mpdf->gradients[$n]['stream'].=chr((int) (floor($patch_array[$i]['points'][$j]%256)));
+		}
+		for($j=0;$j<count(($patch_array[$i]['colors'] ?? []));$j++){
 			//each color component as 8 bit
 			if ($colspace=='RGB') {
 				$this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][1]);
 				$this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][2]);
 				$this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][3]);
-				if (isset($patch_array[$i]['colors'][$j][4]) && ord($patch_array[$i]['colors'][$j][4])<100) { $trans = true; }
+				if (isset($patch_array[$i]['colors'][$j][4]) && ord(($patch_array[$i]['colors'][$j][4] ?? ''))<100) { $trans = true; }
 			}
 			else if ($colspace=='CMYK') {
-				$this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][1])*2.55);
-				$this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][2])*2.55);
-				$this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][3])*2.55);
-				$this->mpdf->gradients[$n]['stream'].=chr(ord($patch_array[$i]['colors'][$j][4])*2.55);
-				if (isset($patch_array[$i]['colors'][$j][5]) && ord($patch_array[$i]['colors'][$j][5])<100) { $trans = true; }
+				$this->mpdf->gradients[$n]['stream'].=chr((int) (ord(($patch_array[$i]['colors'][$j][1] ?? ''))*2.55));
+				$this->mpdf->gradients[$n]['stream'].=chr((int) (ord(($patch_array[$i]['colors'][$j][2] ?? ''))*2.55));
+				$this->mpdf->gradients[$n]['stream'].=chr((int) (ord(($patch_array[$i]['colors'][$j][3] ?? ''))*2.55));
+				$this->mpdf->gradients[$n]['stream'].=chr((int) (ord(($patch_array[$i]['colors'][$j][4] ?? ''))*2.55));
+				if (isset($patch_array[$i]['colors'][$j][5]) && ord(($patch_array[$i]['colors'][$j][5] ?? ''))<100) { $trans = true; }
 			}
 			else if ($colspace=='Gray') {
 				$this->mpdf->gradients[$n]['stream'].=($patch_array[$i]['colors'][$j][1]);
@@ -59,23 +59,23 @@
 	// TRANSPARENCY
 	if ($trans) { 
 		$this->mpdf->gradients[$n]['stream_trans']='';
-		for($i=0;$i<count($patch_array);$i++){
-			$this->mpdf->gradients[$n]['stream_trans'].=chr($patch_array[$i]['f']);
-			for($j=0;$j<count($patch_array[$i]['points']);$j++){
+		for($i=0;$i<count(($patch_array ?? []));$i++){
+			$this->mpdf->gradients[$n]['stream_trans'].=chr((int) ($patch_array[$i]['f']));
+			for($j=0;$j<count(($patch_array[$i]['points'] ?? []));$j++){
 				//each point as 16 bit
-				$this->mpdf->gradients[$n]['stream_trans'].=chr(floor($patch_array[$i]['points'][$j]/256));
-				$this->mpdf->gradients[$n]['stream_trans'].=chr(floor($patch_array[$i]['points'][$j]%256));
-			}
-			for($j=0;$j<count($patch_array[$i]['colors']);$j++){
+				$this->mpdf->gradients[$n]['stream_trans'].=chr((int) (floor($patch_array[$i]['points'][$j]/256)));
+				$this->mpdf->gradients[$n]['stream_trans'].=chr((int) (floor($patch_array[$i]['points'][$j]%256)));
+			}
+			for($j=0;$j<count(($patch_array[$i]['colors'] ?? []));$j++){
 				//each color component as 8 bit // OPACITY
 				if ($colspace=='RGB') {
-					$this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][4])*2.55));
+					$this->mpdf->gradients[$n]['stream_trans'].=chr((int) (intval(ord(($patch_array[$i]['colors'][$j][4] ?? ''))*2.55)));
 				}
 				else if ($colspace=='CMYK') {
-					$this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][5])*2.55));
+					$this->mpdf->gradients[$n]['stream_trans'].=chr((int) (intval(ord(($patch_array[$i]['colors'][$j][5] ?? ''))*2.55)));
 				}
 				else if ($colspace=='Gray') {
-					$this->mpdf->gradients[$n]['stream_trans'].=chr(intval(ord($patch_array[$i]['colors'][$j][3])*2.55));
+					$this->mpdf->gradients[$n]['stream_trans'].=chr((int) (intval(ord(($patch_array[$i]['colors'][$j][3] ?? ''))*2.55)));
 				}
 			}
 		}
@@ -100,8 +100,8 @@
 // $col = array(R,G,B/255); or array(G/255); or array(C,M,Y,K/100)
 // $stops = array('col'=>$col [, 'opacity'=>0-1] [, 'offset'=>0-1])
 function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coords='', $extend='', $return=false, $is_mask=false) {
-	if (strtoupper(substr($type,0,1)) == 'L') { $type = 2; }	// linear
-	else if (strtoupper(substr($type,0,1)) == 'R') { $type = 3; }	// radial
+	if (strtoupper((substr(($type ?? ''),0,1) ?? '')) == 'L') { $type = 2; }	// linear
+	else if (strtoupper((substr(($type ?? ''),0,1) ?? '')) == 'R') { $type = 3; }	// radial
 	if ($colorspace != 'CMYK' && $colorspace != 'Gray') {
 		$colorspace = 'RGB';
 	}
@@ -113,11 +113,11 @@
 	$useh = $bboxh;
 
 	if ($type < 1) { $type = 2; }
-	if ($coords[0]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[0],$m)) { 
+	if ($coords[0]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($coords[0] ?? ''),$m)) { 
 		$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 		if ($tmp) { $coords[0] = $tmp/$w; }
 	}
-	if ($coords[1]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[1],$m)) { 
+	if ($coords[1]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($coords[1] ?? ''),$m)) { 
 		$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 		if ($tmp) { $coords[1] = 1-($tmp/$h); }
 	}
@@ -325,15 +325,15 @@
 		$s .= sprintf(' %.3F 0 0 %.3F %.3F %.3F cm', $usew*_MPDFK, $useh*_MPDFK, $usex*_MPDFK, ($this->mpdf->h-($usey+$useh))*_MPDFK)."\n";
 	}
 
-	$n = count($this->mpdf->gradients) + 1;
+	$n = count(($this->mpdf->gradients ?? [])) + 1;
 	$this->mpdf->gradients[$n]['type'] = $type;
 	$this->mpdf->gradients[$n]['colorspace'] = $colorspace;
 	$trans = false;
 	$this->mpdf->gradients[$n]['is_mask'] = $is_mask;
 	if ($is_mask) { $trans = true; }
-	if (count($stops) == 1) { $stops[1] = $stops[0]; }
+	if (count(($stops ?? [])) == 1) { $stops[1] = $stops[0]; }
 	if (!isset($stops[0]['offset'])) { $stops[0]['offset'] = 0; }
-	if (!isset($stops[(count($stops)-1)]['offset'])) { $stops[(count($stops)-1)]['offset'] = 1; }
+	if (!isset($stops[(count(($stops ?? []))-1)]['offset'])) { $stops[(count(($stops ?? []))-1)]['offset'] = 1; }
 
 	// Fix stop-offsets set as absolute lengths
 	if ($type==2) {
@@ -343,8 +343,8 @@
 	}
 	else { $axis_length = $coords[4]*$usew; }	// Absolute lengths are meaningless for an ellipse - Firefox uses Width as reference
 
-	for($i=0;$i<count($stops);$i++) {
-	  if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$stops[$i]['offset'],$m)) { 
+	for($i=0;$i<count(($stops ?? []));$i++) {
+	  if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($stops[$i]['offset'] ?? ''),$m)) { 
 		$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 		$stops[$i]['offset'] = $tmp/$axis_length;
 	  }
@@ -356,26 +356,26 @@
 		$firststop['offset'] = 0;
 		array_unshift($stops, $firststop); 
 	}
-	if (!$repeat && isset($stops[(count($stops)-1)]['offset']) && $stops[(count($stops)-1)]['offset']<1) {
-		$endstop = $stops[(count($stops)-1)]; 
+	if (!$repeat && isset($stops[(count(($stops ?? []))-1)]['offset']) && $stops[(count(($stops ?? []))-1)]['offset']<1) {
+		$endstop = $stops[(count(($stops ?? []))-1)]; 
 		$endstop['offset'] = 1;
 		$stops[] = $endstop; 
 	}
-	if ($stops[0]['offset'] > $stops[(count($stops)-1)]['offset']) { 
+	if ($stops[0]['offset'] > $stops[(count(($stops ?? []))-1)]['offset']) { 
 		$stops[0]['offset'] = 0;
-		$stops[(count($stops)-1)]['offset'] = 1;
-	}
-
-	for($i=0;$i<count($stops);$i++) {
+		$stops[(count(($stops ?? []))-1)]['offset'] = 1;
+	}
+
+	for($i=0;$i<count(($stops ?? []));$i++) {
 		// mPDF 5.3.74
 		if ($colorspace == 'CMYK') {
-			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F %.3F', (ord($stops[$i]['col']{1})/100), (ord($stops[$i]['col']{2})/100), (ord($stops[$i]['col']{3})/100), (ord($stops[$i]['col']{4})/100));
+			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F %.3F', (ord(($stops[$i]['col'][1] ?? ''))/100), (ord(($stops[$i]['col'][2] ?? ''))/100), (ord(($stops[$i]['col'][3] ?? ''))/100), (ord(($stops[$i]['col'][4] ?? ''))/100));
 		}
 		else if ($colorspace == 'Gray') {
-			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F', (ord($stops[$i]['col']{1})/255));
+			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F', (ord(($stops[$i]['col'][1] ?? ''))/255));
 		}
 		else {
-			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F', (ord($stops[$i]['col']{1})/255), (ord($stops[$i]['col']{2})/255), (ord($stops[$i]['col']{3})/255));
+			$this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F', (ord(($stops[$i]['col'][1] ?? ''))/255), (ord(($stops[$i]['col'][2] ?? ''))/255), (ord(($stops[$i]['col'][3] ?? ''))/255));
 		}
 		if (!isset($stops[$i]['opacity'])) { $stops[$i]['opacity'] = 1; } 
 		else if ($stops[$i]['opacity'] > 1 || $stops[$i]['opacity'] < 0) { $stops[$i]['opacity'] = 1; } 
@@ -384,13 +384,13 @@
 		}
 		$this->mpdf->gradients[$n]['stops'][$i]['opacity'] = $stops[$i]['opacity'];
 		// OFFSET
-		if ($i>0 && $i<(count($stops)-1)) {
+		if ($i>0 && $i<(count(($stops ?? []))-1)) {
 		  if (!isset($stops[$i]['offset']) || (isset($stops[$i+1]['offset']) && $stops[$i]['offset']>$stops[$i+1]['offset']) || $stops[$i]['offset']<$stops[$i-1]['offset']) { 
 			if (isset($stops[$i-1]['offset']) && isset($stops[$i+1]['offset'])) { 
 				$stops[$i]['offset'] = ($stops[$i-1]['offset']+$stops[$i+1]['offset'])/2; 
 			}
 			else {
-				for($j=($i+1);$j<count($stops);$j++) {
+				for($j=($i+1);$j<count(($stops ?? []));$j++) {
 					if(isset($stops[$j]['offset'])) { break; }
 				}
 				$int = ($stops[$j]['offset'] - $stops[($i-1)]['offset'])/($j-$i+1);
@@ -405,7 +405,7 @@
 	}
 
 	if ($repeat) {
-		$ns = count($this->mpdf->gradients[$n]['stops']);
+		$ns = count(($this->mpdf->gradients[$n]['stops'] ?? []));
 		$offs = array();
 		for($i=0;$i<$ns;$i++) {
 			$offs[$i] = $this->mpdf->gradients[$n]['stops'][$i]['offset'];
@@ -431,7 +431,7 @@
 		$this->mpdf->gradients[$n]['trans'] = true;	
 		$s .= ' /TGS'.$n.' gs ';
 	}
-	if (!is_array($extend) || count($extend) <1) { 
+	if (!is_array($extend) || count(($extend ?? [])) <1) { 
 		$extend=array('true', 'true');	// These are supposed to be quoted - appear in PDF file as text
 	}
 	$this->mpdf->gradients[$n]['coords'] = $coords;
@@ -448,26 +448,26 @@
 function parseMozGradient($bg) {
    //	background[-image]: -moz-linear-gradient(left, #c7Fdde 20%, #FF0000 ); 
    //	background[-image]: linear-gradient(left, #c7Fdde 20%, #FF0000 ); // CSS3
-   if (preg_match('/repeating-/',$bg)) { $repeat = true; }
+   if (preg_match('/repeating-/',($bg ?? ''))) { $repeat = true; }
    else { $repeat = false; }
-   if (preg_match('/linear-gradient\((.*)\)/',$bg,$m)) {
+   if (preg_match('/linear-gradient\((.*)\)/',($bg ?? ''),$m)) {
 	$g = array();
 	$g['type'] = 2;
 	$g['colorspace'] = 'RGB';
 	$g['extend'] = array('true','true');
-	$v = trim($m[1]);
+	$v = trim(($m[1] ?? ''));
 	// Change commas inside e.g. rgb(x,x,x)
-	while(preg_match('/(\([^\)]*?),/',$v)) { $v = preg_replace('/(\([^\)]*?),/','\\1@',$v); }
+	while(preg_match('/(\([^\)]*?),/',($v ?? ''))) { $v = preg_replace('/(\([^\)]*?),/','\\1@',($v ?? '')); }
 	// Remove spaces inside e.g. rgb(x, x, x)
-	while(preg_match('/(\([^\)]*?)[ ]/',$v)) { $v = preg_replace('/(\([^\)]*?)[ ]/','\\1',$v); }
-	$bgr = preg_split('/\s*,\s*/',$v);
-	for($i=0;$i<count($bgr);$i++) { $bgr[$i] = preg_replace('/@/', ',', $bgr[$i]); }
+	while(preg_match('/(\([^\)]*?)[ ]/',($v ?? ''))) { $v = preg_replace('/(\([^\)]*?)[ ]/','\\1',($v ?? '')); }
+	$bgr = preg_split('/\s*,\s*/',($v ?? ''));
+	for($i=0;$i<count(($bgr ?? []));$i++) { $bgr[$i] = preg_replace('/@/', ',', ($bgr[$i] ?? '')); }
 	// Is first part $bgr[0] a valid point/angle?
-	$first = preg_split('/\s+/',trim($bgr[0]));
-	if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
+	$first = preg_split('/\s+/',(trim(($bgr[0] ?? '')) ?? ''));
+	if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',($bgr[0] ?? '')) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',($bgr[0] ?? ''))) {
 		$startStops = 1; 
 	}
-	else if (trim($first[(count($first)-1)]) === "0") {
+	else if (trim(($first[(count(($first ?? []))-1)] ?? '')) === "0") {
 		$startStops = 1;
 	}
 	else {
@@ -478,27 +478,27 @@
 	// first part a valid point/angle?
 	if ($startStops == 1) {	// default values
 		// [<point> || <angle>,] = [<% em px left center right bottom top> || <deg grad rad 0>,]
-		if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$bgr[0],$m)) {
+		if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',($bgr[0] ?? ''),$m)) {
 			$angle = $m[1] + 0;
-			if (strtolower($m[2])=='deg') { $angle = $angle; }
-			else if (strtolower($m[2])=='grad') { $angle *= (360/400); }
-			else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); }
+			if (strtolower(($m[2] ?? ''))=='deg') { $angle = $angle; }
+			else if (strtolower(($m[2] ?? ''))=='grad') { $angle *= (360/400); }
+			else if (strtolower(($m[2] ?? ''))=='rad') { $angle = rad2deg($angle); }
 			while($angle < 0) { $angle += 360; }
 			$angle = ($angle % 360);
 		}
-		else if (trim($first[(count($first)-1)]) === "0") { $angle = 0; }
-		if (preg_match('/left/i',$bgr[0])) { $startx = 0; }
-		else if (preg_match('/right/i',$bgr[0])) { $startx = 1; }
-		if (preg_match('/top/i',$bgr[0])) { $starty = 1; }
-		else if (preg_match('/bottom/i',$bgr[0])) { $starty = 0; }
+		else if (trim(($first[(count(($first ?? []))-1)] ?? '')) === "0") { $angle = 0; }
+		if (preg_match('/left/i',($bgr[0] ?? ''))) { $startx = 0; }
+		else if (preg_match('/right/i',($bgr[0] ?? ''))) { $startx = 1; }
+		if (preg_match('/top/i',($bgr[0] ?? ''))) { $starty = 1; }
+		else if (preg_match('/bottom/i',($bgr[0] ?? ''))) { $starty = 0; }
 		// Check for %? ?% or %%
-		if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
-		else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) { 
+		if (preg_match('/(\d+)[%]/i',($first[0] ?? ''),$m)) { $startx = $m[1]/100; }
+		else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($first[0] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			if ($tmp) { $startx = $m[1]; }
 		}
-		if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
-		else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) { 
+		if (isset($first[1]) && preg_match('/(\d+)[%]/i',($first[1] ?? ''),$m)) { $starty = 1 - ($m[1]/100); }
+		else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($first[1] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			if ($tmp) { $starty = $m[1]; }
 		}
@@ -519,60 +519,60 @@
 	if (!isset($angle)) { $angle = false; }
 	$g['coords'] = array($startx ,$starty ,$endx ,$endy, $angle, $repeat );
 	$g['stops'] = array();
-	for($i=$startStops;$i<count($bgr);$i++) {
+	for($i=$startStops;$i<count(($bgr ?? []));$i++) {
 		$stop = array();
 		// parse stops
-		$el = preg_split('/\s+/',trim($bgr[$i]));
+		$el = preg_split('/\s+/',(trim(($bgr[$i] ?? '')) ?? ''));
 		// mPDF 5.3.74
 		$col = $this->mpdf->ConvertColor($el[0]);
 		if ($col) { $stop['col'] = $col; }
 		else { $stop['col'] = $col = $this->mpdf->ConvertColor(255); }
-		if ($col{0}==1) $g['colorspace'] = 'Gray';
-		else if ($col{0}==4 || $col{0}==6) $g['colorspace'] = 'CMYK';
-		if ($col{0}==5) { $stop['opacity'] = ord($col{4})/100; }	// transparency from rgba()
-		else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; }	// transparency from cmyka()
-		else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; }	// transparency converted from rgba or cmyka()
-
-		if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) { 
+		if ($col[0]==1) $g['colorspace'] = 'Gray';
+		else if ($col[0]==4 || $col[0]==6) $g['colorspace'] = 'CMYK';
+		if ($col[0]==5) { $stop['opacity'] = ord(($col[4] ?? ''))/100; }	// transparency from rgba()
+		else if ($col[0]==6) { $stop['opacity'] = ord(($col[5] ?? ''))/100; }	// transparency from cmyka()
+		else if ($col[0]==1 && $col[2]==1) { $stop['opacity'] = ord(($col[3] ?? ''))/100; }	// transparency converted from rgba or cmyka()
+
+		if (isset($el[1]) && preg_match('/(\d+)[%]/',($el[1] ?? ''),$m)) { 
 			$stop['offset'] = $m[1]/100;
 			if ($stop['offset']>1) { unset($stop['offset']); }
 		}
-		else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) { 
+		else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($el[1] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			if ($tmp) { $stop['offset'] = $m[1]; }
 		}
 		$g['stops'][] = $stop;
 	}
-	if (count($g['stops'] )) { return $g; }
+	if (count(($g['stops'] ?? []) )) { return $g; }
    }
-   else if (preg_match('/radial-gradient\((.*)\)/',$bg,$m)) {
+   else if (preg_match('/radial-gradient\((.*)\)/',($bg ?? ''),$m)) {
 	$g = array();
 	$g['type'] = 3;
 	$g['colorspace'] = 'RGB';
 	$g['extend'] = array('true','true');
-	$v = trim($m[1]);
+	$v = trim(($m[1] ?? ''));
 	// Change commas inside e.g. rgb(x,x,x)
-	while(preg_match('/(\([^\)]*?),/',$v)) { $v = preg_replace('/(\([^\)]*?),/','\\1@',$v); }
+	while(preg_match('/(\([^\)]*?),/',($v ?? ''))) { $v = preg_replace('/(\([^\)]*?),/','\\1@',($v ?? '')); }
 	// Remove spaces inside e.g. rgb(x, x, x)
-	while(preg_match('/(\([^\)]*?)[ ]/',$v)) { $v = preg_replace('/(\([^\)]*?)[ ]/','\\1',$v); }
-	$bgr = preg_split('/\s*,\s*/',$v);
-	for($i=0;$i<count($bgr);$i++) { $bgr[$i] = preg_replace('/@/', ',', $bgr[$i]); }
+	while(preg_match('/(\([^\)]*?)[ ]/',($v ?? ''))) { $v = preg_replace('/(\([^\)]*?)[ ]/','\\1',($v ?? '')); }
+	$bgr = preg_split('/\s*,\s*/',($v ?? ''));
+	for($i=0;$i<count(($bgr ?? []));$i++) { $bgr[$i] = preg_replace('/@/', ',', ($bgr[$i] ?? '')); }
 
 	// Is first part $bgr[0] a valid point/angle?
 	$startStops = 0; 
 	$pos_angle = false;
 	$shape_size = false;
-	$first = preg_split('/\s+/',trim($bgr[0]));
+	$first = preg_split('/\s+/',(trim(($bgr[0] ?? '')) ?? ''));
 	$checkCol = $this->mpdf->ConvertColor($first[0]);
-	if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
+	if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',($bgr[0] ?? '')) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',($bgr[0] ?? ''))) {
 		$startStops=1; 
 		$pos_angle = $bgr[0];
 	}
-	else if (trim($first[(count($first)-1)]) === "0") {
+	else if (trim(($first[(count(($first ?? []))-1)] ?? '')) === "0") {
 		$startStops=1;
 		$pos_angle = $bgr[0];
 	}
-	else if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[0])) {
+	else if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',($bgr[0] ?? ''))) {
 		$startStops=1; 
 		$shape_size = $bgr[0];
 	}
@@ -580,7 +580,7 @@
 		$startStops=1;
  		$pos_angle = $bgr[0];
 	}
-	if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[1])) {
+	if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',($bgr[1] ?? ''))) {
 		$startStops=2; 
 		$shape_size = $bgr[1];
 	}
@@ -588,18 +588,18 @@
 	// If valid point/angle?
 	if ($pos_angle) {	// default values
 		// [<point> || <angle>,] = [<% em px left center right bottom top> || <deg grad rad 0>,]
-		if (preg_match('/left/i',$pos_angle)) { $startx = 0; }
-		else if (preg_match('/right/i',$pos_angle)) { $startx = 1; }
-		if (preg_match('/top/i',$pos_angle)) { $starty = 1; }
-		else if (preg_match('/bottom/i',$pos_angle)) { $starty = 0; }
+		if (preg_match('/left/i',($pos_angle ?? ''))) { $startx = 0; }
+		else if (preg_match('/right/i',($pos_angle ?? ''))) { $startx = 1; }
+		if (preg_match('/top/i',($pos_angle ?? ''))) { $starty = 1; }
+		else if (preg_match('/bottom/i',($pos_angle ?? ''))) { $starty = 0; }
 		// Check for %? ?% or %%
-		if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
-		else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) { 
+		if (preg_match('/(\d+)[%]/i',($first[0] ?? ''),$m)) { $startx = $m[1]/100; }
+		else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($first[0] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			if ($tmp) { $startx = $m[1]; }
 		}
-		if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
-		else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) { 
+		if (isset($first[1]) && preg_match('/(\d+)[%]/i',($first[1] ?? ''),$m)) { $starty = 1 - ($m[1]/100); }
+		else if (!isset($starty) && isset($first[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($first[1] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			if ($tmp) { $starty = $m[1]; }
 		}
@@ -629,10 +629,10 @@
 	$shape = 'ellipse';	// default
 	$size = 'farthest-corner';	// default
 	if ($shape_size) {	// default values
-		if (preg_match('/(circle|ellipse)/i',$shape_size, $m)) {
+		if (preg_match('/(circle|ellipse)/i',($shape_size ?? ''), $m)) {
 			$shape = $m[1];
 		}
-		if (preg_match('/(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$shape_size, $m)) {
+		if (preg_match('/(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',($shape_size ?? ''), $m)) {
 			$size = $m[1];
 			if ($size=='contain') { $size = 'closest-side'; }
 			else if ($size=='cover') { $size = 'farthest-corner'; }
@@ -649,31 +649,31 @@
 	$g['coords'] = array($startx ,$starty ,$endx ,$endy, $radius, $angle, $shape, $size, $repeat );
 
 	$g['stops'] = array();
-	for($i=$startStops;$i<count($bgr);$i++) {
+	for($i=$startStops;$i<count(($bgr ?? []));$i++) {
 		$stop = array();
 		// parse stops
-		$el = preg_split('/\s+/',trim($bgr[$i]));
+		$el = preg_split('/\s+/',(trim(($bgr[$i] ?? '')) ?? ''));
 		// mPDF 5.3.74
 		$col = $this->mpdf->ConvertColor($el[0]);
 		if ($col) { $stop['col'] = $col; }
 		else { $stop['col'] = $col = $this->mpdf->ConvertColor(255); }
-		if ($col{0}==1) $g['colorspace'] = 'Gray';
-		else if ($col{0}==4 || $col{0}==6) $g['colorspace'] = 'CMYK';
-		if ($col{0}==5) { $stop['opacity'] = ord($col{4})/100; }	// transparency from rgba()
-		else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; }	// transparency from cmyka()
-		else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; }	// transparency converted from rgba or cmyka()
-
-		if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) { 
+		if ($col[0]==1) $g['colorspace'] = 'Gray';
+		else if ($col[0]==4 || $col[0]==6) $g['colorspace'] = 'CMYK';
+		if ($col[0]==5) { $stop['opacity'] = ord(($col[4] ?? ''))/100; }	// transparency from rgba()
+		else if ($col[0]==6) { $stop['opacity'] = ord(($col[5] ?? ''))/100; }	// transparency from cmyka()
+		else if ($col[0]==1 && $col[2]==1) { $stop['opacity'] = ord(($col[3] ?? ''))/100; }	// transparency converted from rgba or cmyka()
+
+		if (isset($el[1]) && preg_match('/(\d+)[%]/',($el[1] ?? ''),$m)) { 
 			$stop['offset'] = $m[1]/100;
 			if ($stop['offset']>1) { unset($stop['offset']); }
 		}
-		else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) { 
+		else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',($el[1] ?? ''),$m)) { 
 			$tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
 			$stop['offset'] = $el[1];
 		}
 		$g['stops'][] = $stop;
 	}
-	if (count($g['stops'] )) { return $g; }
+	if (count(($g['stops'] ?? []) )) { return $g; }
    }
    return array();
 } 
@@ -682,18 +682,18 @@
 	// background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5;  or
 	// background-gradient: radial #00FFFF #FFFF00 0.5 0.5 1 1 1.2;
 
-	$v = trim($bg);
-	$bgr = preg_split('/\s+/',$v);
+	$v = trim(($bg ?? ''));
+	$bgr = preg_split('/\s+/',($v ?? ''));
 	$g = array();
-	if (count($bgr)> 6) {  
-		if (strtoupper(substr($bgr[0],0,1)) == 'L' && count($bgr)==7) {  // linear
+	if (count(($bgr ?? []))> 6) {  
+		if (strtoupper((substr(($bgr[0] ?? ''),0,1) ?? '')) == 'L' && count(($bgr ?? []))==7) {  // linear
 			$g['type'] = 2;
 			//$coords = array(0,0,1,1 );	// 0 0 1 0 or 0 1 1 1 is L 2 R; 1,1,0,1 is R2L; 1,1,1,0 is T2B; 1,0,1,1 is B2T
 			// Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). 
 			//    The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
 			$g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6]);
 		}
-		else if (count($bgr)==8) {	// radial
+		else if (count(($bgr ?? []))==8) {	// radial
 			$g['type'] = 3;
 			// Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1, 
 			//    (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). 
@@ -703,8 +703,8 @@
 		$g['colorspace'] = 'RGB';
 		// mPDF 5.3.74
 		$cor = $this->mpdf->ConvertColor($bgr[1]);
-		if ($cor{0}==1) $g['colorspace'] = 'Gray';
-		else if ($cor{0}==4 || $cor{0}==6) $g['colorspace'] = 'CMYK';
+		if ($cor[0]==1) $g['colorspace'] = 'Gray';
+		else if ($cor[0]==4 || $cor[0]==6) $g['colorspace'] = 'CMYK';
 		if ($cor) { $g['col'] = $cor; }
 		else { $g['col'] = $this->mpdf->ConvertColor(255); }
 		$cor = $this->mpdf->ConvertColor($bgr[2]);
--- a/intranet/mpdf60/classes/directw.php
+++ b/intranet/mpdf60/classes/directw.php
@@ -4,7 +4,7 @@
 
 var $mpdf = null;
 
-function directw(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 }
 
@@ -19,10 +19,10 @@
 	$w = $this->mpdf->w - $this->mpdf->rMargin - $this->mpdf->x; 
 
 	$wmax = ($w - ($this->mpdf->cMarginL+$this->mpdf->cMarginR));
-	$s=str_replace("\r",'',$txt);
-	if ($this->mpdf->usingCoreFont)  { $nb=strlen($s); }
+	$s=str_replace("\r",'',($txt ?? ''));
+	if ($this->mpdf->usingCoreFont)  { $nb=strlen(($s ?? '')); }
 	else {
-		$nb=mb_strlen($s, $this->mpdf->mb_enc );
+		$nb=mb_strlen(($s ?? ''), $this->mpdf->mb_enc );
 		// handle single space character
 		if(($nb==1) && $s == " ") {
 			$this->mpdf->x += $this->mpdf->GetStringWidth($s);
@@ -35,15 +35,15 @@
 	$l=0;
 	$nl=1;
 	if (!$this->mpdf->usingCoreFont) {
-		if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $txt)) { $this->mpdf->biDirectional = true; }	// *RTL*
+		if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", ($txt ?? ''))) { $this->mpdf->biDirectional = true; }	// *RTL*
 		while($i<$nb) {
 			//Get next character
-			$c = mb_substr($s,$i,1,$this->mpdf->mb_enc );
+			$c = mb_substr(($s ?? ''),$i,1,$this->mpdf->mb_enc );
 			if($c == "\n") {
 				// WORD SPACING
 				$this->mpdf->ResetSpacing();
 				//Explicit line break
-				$tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc));
+				$tmp = rtrim((mb_substr(($s ?? ''),$j,$i-$j,$this->mpdf->mb_enc) ?? ''));
 				$this->mpdf->Cell($w, $h, $tmp, 0, 2, $align, $fill, $link);
 				$i++;
 				$sep = -1;
@@ -77,24 +77,24 @@
 						continue;
 					}
 					if($i==$j) { $i++; }
-					$tmp = rtrim(mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc));
+					$tmp = rtrim((mb_substr(($s ?? ''),$j,$i-$j,$this->mpdf->mb_enc) ?? ''));
 					$this->mpdf->Cell($w, $h, $tmp, 0, 2, $align, $fill, $link);
 				}
 				else {
-					$tmp = rtrim(mb_substr($s,$j,$sep-$j,$this->mpdf->mb_enc));
+					$tmp = rtrim((mb_substr(($s ?? ''),$j,$sep-$j,$this->mpdf->mb_enc) ?? ''));
 
 					if($align=='J') {
 						//////////////////////////////////////////
 						// JUSTIFY J using Unicode fonts (Word spacing doesn't work)
 						// WORD SPACING
 						// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
-					      $tmp = str_replace(chr(194).chr(160),chr(32),$tmp ); 
+					      $tmp = str_replace(chr(194).chr(160),(chr(32) ?? ''),($tmp ?? '') ); 
 						$len_ligne = $this->mpdf->GetStringWidth($tmp );
-						$nb_carac = mb_strlen( $tmp , $this->mpdf->mb_enc ) ;  
+						$nb_carac = mb_strlen( ($tmp ?? '') , $this->mpdf->mb_enc ) ;  
 						$nb_spaces = mb_substr_count( $tmp ,' ', $this->mpdf->mb_enc ) ;  
 						$inclCursive=false;
 						if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
-							if (preg_match("/([".$this->mpdf->pregCURSchars."])/u", $tmp)) { $inclCursive = true; }
+							if (preg_match("/([".$this->mpdf->pregCURSchars."])/u", ($tmp ?? ''))) { $inclCursive = true; }
 						}
 						list($charspacing,$ws) = $this->mpdf->GetJspacing($nb_carac,$nb_spaces,((($w-2) - $len_ligne) * _MPDFK),$inclCursive);
 						$this->mpdf->SetSpacing($charspacing,$ws);
@@ -128,7 +128,7 @@
 				//Explicit line break
 				// WORD SPACING
 				$this->mpdf->ResetSpacing();
-				$this->mpdf->Cell($w, $h, substr($s, $j, $i-$j), 0, 2, $align, $fill, $link);
+				$this->mpdf->Cell($w, $h, substr(($s ?? ''), $j, $i-$j), 0, 2, $align, $fill, $link);
 				$i++;
 				$sep = -1;
 				$j = $i;
@@ -161,18 +161,18 @@
 						continue;
 					}
 					if($i==$j) { $i++; }
-					$this->mpdf->Cell($w, $h, substr($s, $j, $i-$j), 0, 2, $align, $fill, $link);
+					$this->mpdf->Cell($w, $h, substr(($s ?? ''), $j, $i-$j), 0, 2, $align, $fill, $link);
 				}
 				else {
-					$tmp = substr($s, $j, $sep-$j);
+					$tmp = substr(($s ?? ''), $j, $sep-$j);
 					if($align=='J') {
 						//////////////////////////////////////////
 						// JUSTIFY J using Unicode fonts
 						// WORD SPACING is not fully supported for complex scripts
 						// Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
-					      $tmp = str_replace(chr(160),chr(32),$tmp );
+					      $tmp = str_replace((chr(160) ?? ''),(chr(32) ?? ''),($tmp ?? '') );
 						$len_ligne = $this->mpdf->GetStringWidth($tmp );
-						$nb_carac = strlen( $tmp ) ;  
+						$nb_carac = strlen( ($tmp ?? '') ) ;  
 						$nb_spaces = substr_count( $tmp ,' ' ) ;  
 						list($charspacing,$ws) = $this->mpdf->GetJspacing($nb_carac,$nb_spaces,((($w-2) - $len_ligne) * _MPDFK),$false);
 						$this->mpdf->SetSpacing($charspacing,$ws);
@@ -203,8 +203,8 @@
 	if($i!=$j) {
 		if ($currentx != 0) $this->mpdf->x=$currentx;
 		else $this->mpdf->x=$this->mpdf->lMargin;	
-		if ($this->mpdf->usingCoreFont) { $tmp = substr($s,$j,$i-$j); }
-		else { $tmp = mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc); }
+		if ($this->mpdf->usingCoreFont) { $tmp = substr(($s ?? ''),$j,$i-$j); }
+		else { $tmp = mb_substr(($s ?? ''),$j,$i-$j,$this->mpdf->mb_enc); }
 		$this->mpdf->Cell($w,$h,$tmp,0,0,$align,$fill,$link);
 	}
 }
@@ -216,7 +216,7 @@
 	$fontwidth/=100;        
 	if($kerning==0) $this->mpdf->Error('Please use values unequal to zero for kerning (CircularText)');
 	if($fontwidth==0) $this->mpdf->Error('Please use values unequal to zero for font width (CircularText)');
-	$text=str_replace("\r",'',$text);
+	$text=str_replace("\r",'',($text ?? ''));
 	//circumference
 	$u=($r*2)*M_PI;
 	$checking = true;
@@ -225,7 +225,7 @@
 	   $t=0;
 	   $w = array();
 	   if ($this->mpdf->usingCoreFont)  {
-		$nb=strlen($text); 
+		$nb=strlen(($text ?? '')); 
 		for($i=0; $i<$nb; $i++){
 			$w[$i]=$this->mpdf->GetStringWidth($text[$i]);
 			$w[$i]*=$kerning*$fontwidth;
@@ -233,11 +233,11 @@
 		}
 	   }
 	   else { 
-		$nb=mb_strlen($text, $this->mpdf->mb_enc ); 
+		$nb=mb_strlen(($text ?? ''), $this->mpdf->mb_enc ); 
 		$lastchar = '';
 		$unicode = $this->mpdf->UTF8StringToArray($text);
 		for($i=0; $i<$nb; $i++){
-			$c = mb_substr($text,$i,1,$this->mpdf->mb_enc );
+			$c = mb_substr(($text ?? ''),$i,1,$this->mpdf->mb_enc );
 			$w[$i]=$this->mpdf->GetStringWidth($c);
 			$w[$i]*=$kerning*$fontwidth;
 			$char = $unicode[$i];
@@ -310,7 +310,7 @@
 			$this->mpdf->SetXY($x-$w[$i]/2, $y+$r-($this->mpdf->FontSize));
 		}
 		if ($this->mpdf->usingCoreFont) { $c=$text[$i]; }
-		else { $c = mb_substr($text,$i,1,$this->mpdf->mb_enc ); }
+		else { $c = mb_substr(($text ?? ''),$i,1,$this->mpdf->mb_enc ); }
 		$this->mpdf->Cell(($w[$i]),$this->mpdf->FontSize,$c,0,0,'C');	// mPDF 5.3.53
 		if($fontwidth!=1){
 			$this->mpdf->StopTransform();
@@ -349,11 +349,11 @@
 	if ($this->mpdf->text_input_as_HTML) {
 		$text = $this->mpdf->all_entities_to_utf8($text);
 	}
-	if ($this->mpdf->usingCoreFont) { $text = mb_convert_encoding($text,$this->mpdf->mb_enc,'UTF-8'); }
+	if ($this->mpdf->usingCoreFont) { $text = mb_convert_encoding(($text ?? ''),($this->mpdf->mb_enc ?? ''),'UTF-8'); }
 
 
 	// DIRECTIONALITY
-	if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $text)) { $this->mpdf->biDirectional = true; }	// *RTL*
+	if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", ($text ?? ''))) { $this->mpdf->biDirectional = true; }	// *RTL*
 
 	$textvar = 0;
 	$save_OTLtags = $this->mpdf->OTLtags;
--- a/intranet/mpdf60/classes/barcode.php
+++ b/intranet/mpdf60/classes/barcode.php
@@ -65,7 +65,7 @@
 
 	public function setBarcode($code, $type, $pr='') {
 		$this->print_ratio = 1;
-		switch (strtoupper($type)) {
+		switch (strtoupper(($type ?? ''))) {
 			case 'ISBN':
 			case 'ISSN':
 			case 'EAN13': { // EAN 13
@@ -214,8 +214,8 @@
 			}
 			case 'MSI':		// MSI (Variation of Plessey code)
 			case 'MSI+': {	// MSI + CHECKSUM (modulo 11)
-				if (strtoupper($type)=='MSI') { $arrcode = $this->barcode_msi($code, false); }
-				if (strtoupper($type)=='MSI+') { $arrcode = $this->barcode_msi($code, true); }
+				if (strtoupper(($type ?? ''))=='MSI') { $arrcode = $this->barcode_msi($code, false); }
+				if (strtoupper(($type ?? ''))=='MSI+') { $arrcode = $this->barcode_msi($code, true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -227,7 +227,7 @@
 			case 'CODABAR': {	// CODABAR
 				if ($pr > 0) { $this->print_ratio = $pr; }
 				else { $this->print_ratio = 2.5; }		// spec: Pr= 1:2 - 1:3 (>2.2 if X<0.50)
-				if (strtoupper($type)=='CODABAR') { $arrcode = $this->barcode_codabar($code); }
+				if (strtoupper(($type ?? ''))=='CODABAR') { $arrcode = $this->barcode_codabar($code); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -242,12 +242,12 @@
 			case 'EAN128A': 	// EAN 128 A
 			case 'EAN128B': 	// EAN 128 B
 			case 'EAN128C': {	// EAN 128 C
-				if (strtoupper($type)=='C128A') { $arrcode = $this->barcode_c128($code, 'A'); }
-				if (strtoupper($type)=='C128B') { $arrcode = $this->barcode_c128($code, 'B'); }
-				if (strtoupper($type)=='C128C') { $arrcode = $this->barcode_c128($code, 'C'); }
-				if (strtoupper($type)=='EAN128A') { $arrcode = $this->barcode_c128($code, 'A', true); }
-				if (strtoupper($type)=='EAN128B') { $arrcode = $this->barcode_c128($code, 'B', true); }
-				if (strtoupper($type)=='EAN128C') { $arrcode = $this->barcode_c128($code, 'C', true); }
+				if (strtoupper(($type ?? ''))=='C128A') { $arrcode = $this->barcode_c128($code, 'A'); }
+				if (strtoupper(($type ?? ''))=='C128B') { $arrcode = $this->barcode_c128($code, 'B'); }
+				if (strtoupper(($type ?? ''))=='C128C') { $arrcode = $this->barcode_c128($code, 'C'); }
+				if (strtoupper(($type ?? ''))=='EAN128A') { $arrcode = $this->barcode_c128($code, 'A', true); }
+				if (strtoupper(($type ?? ''))=='EAN128B') { $arrcode = $this->barcode_c128($code, 'B', true); }
+				if (strtoupper(($type ?? ''))=='EAN128C') { $arrcode = $this->barcode_c128($code, 'C', true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -262,12 +262,12 @@
 			case 'C39E+': {	// CODE 39 EXTENDED + CHECKSUM
 				if ($pr > 0) { $this->print_ratio = $pr; }
 				else { $this->print_ratio = 2.5; }	// spec: Pr= 1:2 - 1:3 (>2.2 if X<0.50)
-				$code = str_replace(chr(194).chr(160), ' ', $code);	// mPDF 5.3.95  (for utf-8 encoded)
-				$code = str_replace(chr(160), ' ', $code);	// mPDF 5.3.95	(for win-1252)
-				if (strtoupper($type)=='C39') { $arrcode = $this->barcode_code39($code, false, false); }
-				if (strtoupper($type)=='C39+') { $arrcode = $this->barcode_code39($code, false, true); }
-				if (strtoupper($type)=='C39E') { $arrcode = $this->barcode_code39($code, true, false); }
-				if (strtoupper($type)=='C39E+') { $arrcode = $this->barcode_code39($code, true, true); }
+				$code = str_replace(chr(194).chr(160), ' ', ($code ?? ''));	// mPDF 5.3.95  (for utf-8 encoded)
+				$code = str_replace((chr(160) ?? ''), ' ', ($code ?? ''));	// mPDF 5.3.95	(for win-1252)
+				if (strtoupper(($type ?? ''))=='C39') { $arrcode = $this->barcode_code39($code, false, false); }
+				if (strtoupper(($type ?? ''))=='C39+') { $arrcode = $this->barcode_code39($code, false, true); }
+				if (strtoupper(($type ?? ''))=='C39E') { $arrcode = $this->barcode_code39($code, true, false); }
+				if (strtoupper(($type ?? ''))=='C39E+') { $arrcode = $this->barcode_code39($code, true, true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -280,8 +280,8 @@
 			case 'S25+': {	// Standard 2 of 5 + CHECKSUM
 				if ($pr > 0) { $this->print_ratio = $pr; }
 				else { $this->print_ratio = 3; }		// spec: Pr=1:3/1:4.5
-				if (strtoupper($type)=='S25') { $arrcode = $this->barcode_s25($code, false); }
-				if (strtoupper($type)=='S25+') { $arrcode = $this->barcode_s25($code, true); }
+				if (strtoupper(($type ?? ''))=='S25') { $arrcode = $this->barcode_s25($code, false); }
+				if (strtoupper(($type ?? ''))=='S25+') { $arrcode = $this->barcode_s25($code, true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -294,8 +294,8 @@
 			case 'I25+': { // Interleaved 2 of 5 + CHECKSUM
 				if ($pr > 0) { $this->print_ratio = $pr; }
 				else { $this->print_ratio = 2.5; }	// spec: Pr= 1:2 - 1:3 (>2.2 if X<0.50)
-				if (strtoupper($type)=='I25') { $arrcode = $this->barcode_i25($code, false); }
-				if (strtoupper($type)=='I25+') { $arrcode = $this->barcode_i25($code, true); }
+				if (strtoupper(($type ?? ''))=='I25') { $arrcode = $this->barcode_i25($code, false); }
+				if (strtoupper(($type ?? ''))=='I25+') { $arrcode = $this->barcode_i25($code, true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -308,8 +308,8 @@
 			case 'I25B+': { // Interleaved 2 of 5 + CHECKSUM + Bearer bars
 				if ($pr > 0) { $this->print_ratio = $pr; }
 				else { $this->print_ratio = 2.5; }	// spec: Pr= 1:2 - 1:3 (>2.2 if X<0.50)
-				if (strtoupper($type)=='I25B') { $arrcode = $this->barcode_i25($code, false); }
-				if (strtoupper($type)=='I25B+') { $arrcode = $this->barcode_i25($code, true); }
+				if (strtoupper(($type ?? ''))=='I25B') { $arrcode = $this->barcode_i25($code, false); }
+				if (strtoupper(($type ?? ''))=='I25B+') { $arrcode = $this->barcode_i25($code, true); }
 				if ($arrcode == false) { break; }
 				$arrcode['nom-X'] = 0.381;	// Nominal value for X-dim (bar width) in mm (2 X min. spec.)
 				$arrcode['nom-H'] = 10;		// Nominal value for Height of Full bar in mm (non-spec.)
@@ -374,7 +374,7 @@
 		$chr['%'] = '111212121';
 		$chr['*'] = '121121211';
 		
-		$code = strtoupper($code);
+		$code = strtoupper(($code ?? ''));
 		$checkdigit = '';
 		if ($extended) {
 			// extended mode
@@ -393,7 +393,7 @@
 		
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
 			$char = $code[$i];
 			if(!isset($chr[$char])) {
@@ -460,9 +460,9 @@
 			chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P',
 			chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
 		$code_ext = '';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
-			if (ord($code[$i]) > 127) {
+			if (ord(($code[$i] ?? '')) > 127) {
 				return false;
 			}
 			$code_ext .= $encode[$code[$i]];
@@ -480,7 +480,7 @@
 			'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
 		$sum = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
 			$k = array_keys($chars, $code[$i]);
 			$sum += $k[0];
@@ -542,7 +542,7 @@
 		$chr[130] = '122211'; // (+)
 		$chr[131] = '312111'; // (%)
 		$chr[42] = '111141'; // start-stop
-		$code = strtoupper($code);
+		$code = strtoupper(($code ?? ''));
 		$encode = array(
 			chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
 			chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
@@ -577,12 +577,12 @@
 			chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
 			chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
 		$code_ext = '';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0 ; $i < $clen; ++$i) {
-			if (ord($code{$i}) > 127) {
+			if (ord(($code[$i] ?? '')) > 127) {
 				return false;
 			}
-			$code_ext .= $encode[$code{$i}];
+			$code_ext .= $encode[$code[$i]];
 		}
 		// checksum
 		$code_ext .= $this->checksum_code93($code_ext);
@@ -590,9 +590,9 @@
 		$code = '*'.$code_ext.'*';
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
-			$char = ord($code{$i});
+			$char = ord(($code[$i] ?? ''));
 			if(!isset($chr[$char])) {
 				// invalid character
 				return false;
@@ -603,7 +603,7 @@
 				} else {
 					$t = false; // space
 				}
-				$w = $chr[$char]{$j};
+				$w = $chr[$char][$j];
 				$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
 				$bararray['maxw'] += $w;
 				++$k;
@@ -626,13 +626,13 @@
 			'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%',
 			'<', '=', '>', '?');
 		// translate special characters
-		$code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?');
-		$len = strlen($code);
+		$code = strtr(($code ?? ''), chr(128).chr(131).chr(129).chr(130), '<=>?');
+		$len = strlen(($code ?? ''));
 		// calculate check digit C
 		$p = 1;
 		$check = 0;
 		for ($i = ($len - 1); $i >= 0; --$i) {
-			$k = array_keys($chars, $code{$i});
+			$k = array_keys($chars, $code[$i]);
 			$check += ($k[0] * $p);
 			++$p;
 			if ($p > 20) {
@@ -646,7 +646,7 @@
 		$p = 1;
 		$check = 0;
 		for ($i = $len; $i >= 0; --$i) {
-			$k = array_keys($chars, $code{$i});
+			$k = array_keys($chars, $code[$i]);
 			$check += ($k[0] * $p);
 			++$p;
 			if ($p > 15) {
@@ -657,7 +657,7 @@
 		$k = $chars[$check];
 		$checksum = $c.$k;
 		// resto respecial characters
-		$checksum = strtr($checksum, '<=>?', chr(128).chr(131).chr(129).chr(130));
+		$checksum = strtr(($checksum ?? ''), '<=>?', chr(128).chr(131).chr(129).chr(130));
 		return $checksum;
 	}
 	
@@ -665,7 +665,7 @@
 	 * Checksum for standard 2 of 5 barcodes.
 	 */
 	protected function checksum_s25($code) {
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		$sum = 0;
 		for ($i = 0; $i < $len; $i+=2) {
 			$sum += $code[$i];
@@ -706,7 +706,7 @@
 		$checkdigit = '';
 		if ($checksum) {
 			// add checksum
-			$clen = strlen($code);
+			$clen = strlen(($code ?? ''));
 			$p = 2;
 			$check = 0;
 			for ($i = ($clen - 1); $i >= 0; --$i) {
@@ -724,7 +724,7 @@
 			$checkdigit = $check;
 		}
 		$seq = '110'; // left guard
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
 			$digit = $code[$i];
 			if (!isset($chr[$digit])) {
@@ -761,12 +761,12 @@
 			$checkdigit = $this->checksum_s25($code);
 			$code .= $checkdigit ;
 		}
-		if((strlen($code) % 2) != 0) {
+		if((strlen(($code ?? '')) % 2) != 0) {
 			// add leading zero if code-length is odd
 			$code = '0'.$code;
 		}
 		$seq = '11011010';
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
 			$digit = $code[$i];
 			if (!isset($chr[$digit])) {
@@ -785,7 +785,7 @@
 	 * Convert binary barcode sequence to barcode array
 	 */
 	protected function binseq_to_array($seq, $bararray) {
-		$len = strlen($seq);
+		$len = strlen(($seq ?? ''));
 		$w = 0;
 		$k = 0;
 		for ($i = 0; $i < $len; ++$i) {
@@ -829,16 +829,16 @@
 			$checkdigit = $this->checksum_s25($code);
 			$code .= $checkdigit ;
 		}
-		if((strlen($code) % 2) != 0) {
+		if((strlen(($code ?? '')) % 2) != 0) {
 			// add leading zero if code-length is odd
 			$code = '0'.$code;
 		}
 		// add start and stop codes
-		$code = 'AA'.strtolower($code).'ZA';
+		$code = 'AA'.strtolower(($code ?? '')).'ZA';
 			
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; $i = ($i + 2)) {
 			$char_bar = $code[$i];
 			$char_space = $code[$i+1];
@@ -848,11 +848,11 @@
 			}
 			// create a bar-space sequence
 			$seq = '';
-			$chrlen = strlen($chr[$char_bar]);
+			$chrlen = strlen(($chr[$char_bar] ?? ''));
 			for ($s = 0; $s < $chrlen; $s++){
 				$seq .= $chr[$char_bar][$s] . $chr[$char_space][$s];
 			}
-			$seqlen = strlen($seq);
+			$seqlen = strlen(($seq ?? ''));
 			for ($j = 0; $j < $seqlen; ++$j) {
 				if (($j % 2) == 0) {
 					$t = true; // bar
@@ -989,12 +989,12 @@
 			'200000'  /* END */
 		);
 		$keys = '';
-		switch(strtoupper($type)) {
+		switch(strtoupper(($type ?? ''))) {
 			case 'A': {
 				$startid = 103;
 				$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
 				for ($i = 0; $i < 32; ++$i) {
-					$keys .= chr($i);
+					$keys .= chr((int) ($i));
 				}
 				break;
 			}
@@ -1006,17 +1006,17 @@
 			case 'C': {
 				$startid = 105;
 				$keys = '';
-				if ((strlen($code) % 2) != 0) {
+				if ((strlen(($code ?? '')) % 2) != 0) {
 					// The length of barcode value must be even ($code). You must pad the number with zeros
 					return false;
 				}
 				for ($i = 0; $i <= 99; ++$i) {
-					$keys .= chr($i);
+					$keys .= chr((int) ($i));
 				}
 				$new_code = '';
-				$hclen = (strlen($code) / 2);
+				$hclen = (strlen(($code ?? '')) / 2);
 				for ($i = 0; $i < $hclen; ++$i) {
-					$new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)}));
+					$new_code .= chr((int) (intval($code[(2 * $i)].$code[(2 * $i + 1)])));
 				}
 				$code = $new_code;
 				break;
@@ -1029,22 +1029,22 @@
 		// calculate check character
 		$sum = $startid;
 		if ($ean) { $code = chr(102) . $code; }	// Add FNC 1 - which identifies it as EAN-128
-		$clen = strlen($code);
+		$clen = strlen(($code ?? ''));
 		for ($i = 0; $i < $clen; ++$i) {
 			if ($ean && $i==0) { $sum += 102; }
-			else { $sum +=  (strpos($keys, $code[$i]) * ($i+1)); }
+			else { $sum +=  (strpos(($keys ?? ''), ($code[$i] ?? '')) * ($i+1)); }
 		}
 		$check = ($sum % 103);
 		$checkdigit = $check ;
 		// add start, check and stop codes
-		$code = chr($startid).$code.chr($check).chr(106).chr(107);
+		$code = chr((int) ($startid)).$code.chr((int) ($check)).chr(106).chr(107);
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
 		$k = 0;
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		for ($i = 0; $i < $len; ++$i) {
-			$ck = strpos($keys, $code[$i]);
+			$ck = strpos(($keys ?? ''), ($code[$i] ?? ''));
 			if (($i == 0) || ($ean && $i==1) | ($i > ($len-4))) {
-				$char_num = ord($code[$i]);
+				$char_num = ord(($code[$i] ?? ''));
 				$seq = $chr[$char_num];
 			} elseif(($ck >= 0) AND isset($chr[$ck])) {
 					$seq = $chr[$ck];
@@ -1083,8 +1083,8 @@
 		}
 		$data_len = $len - 1;
 		//Padding
-		$code = str_pad($code, $data_len, '0', STR_PAD_LEFT);
-		$code_len = strlen($code);
+		$code = str_pad(($code ?? ''), $data_len, '0', STR_PAD_LEFT);
+		$code_len = strlen(($code ?? ''));
 		// calculate check digit
 		$sum_a = 0;
 		for ($i = 1; $i < $data_len; $i+=2) {
@@ -1119,28 +1119,28 @@
 		}
 		if ($upce) {
 			// convert UPC-A to UPC-E
-			$tmp = substr($code, 4, 3);
-			$prod_code = intval(substr($code,7,5));	// product code
+			$tmp = substr(($code ?? ''), 4, 3);
+			$prod_code = intval(substr(($code ?? ''),7,5));	// product code
 			$invalid_upce = false;
 			if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
 				// manufacturer code ends in 000, 100, or 200
-				$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
+				$upce_code = substr(($code ?? ''), 2, 2).substr(($code ?? ''), 9, 3).substr(($code ?? ''), 4, 1);
 				if ($prod_code > 999) { $invalid_upce = true; }
 			} else {
-				$tmp = substr($code, 5, 2);
+				$tmp = substr(($code ?? ''), 5, 2);
 				if ($tmp == '00') {
 					// manufacturer code ends in 00
-					$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
+					$upce_code = substr(($code ?? ''), 2, 3).substr(($code ?? ''), 10, 2).'3';
 					if ($prod_code > 99) { $invalid_upce = true; }
 				} else {
-					$tmp = substr($code, 6, 1);
+					$tmp = substr(($code ?? ''), 6, 1);
 					if ($tmp == '0') {
 						// manufacturer code ends in 0
-						$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
+						$upce_code = substr(($code ?? ''), 2, 4).substr(($code ?? ''), 11, 1).'4';
 						if ($prod_code > 9) { $invalid_upce = true; }
 					} else {
 						// manufacturer code does not end in zero
-						$upce_code = substr($code, 2, 5).substr($code, 11, 1);
+						$upce_code = substr(($code ?? ''), 2, 5).substr(($code ?? ''), 11, 1);
 						if ($prod_code > 9) { $invalid_upce = true; }
 					}
 				}
@@ -1224,7 +1224,7 @@
 		$seq = '101'; // left guard bar
 		if ($upce) {
 			$bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
-			$p = $upce_parities[$code{1}][$r];
+			$p = $upce_parities[$code[1]][$r];
 			for ($i = 0; $i < 6; ++$i) {
 				$seq .= $codes[$p[$i]][$upce_code[$i]];
 			}
@@ -1237,7 +1237,7 @@
 					$seq .= $codes['A'][$code[$i]];
 				}
 			} else {
-				$p = $parities[$code{0}];
+				$p = $parities[$code[0]];
 				for ($i = 1; $i < $half_len; ++$i) {
 					$seq .= $codes[$p[$i-1]][$code[$i]];
 				}
@@ -1248,7 +1248,7 @@
 			}
 			$seq .= '101'; // right guard bar
 		}
-		$clen = strlen($seq);
+		$clen = strlen(($seq ?? ''));
 		$w = 0;
 		for ($i = 0; $i < $clen; ++$i) {
 			$w += 1;
@@ -1275,12 +1275,12 @@
 	 */
 	protected function barcode_eanext($code, $len=5) {
 		//Padding
-		$code = str_pad($code, $len, '0', STR_PAD_LEFT);
+		$code = str_pad(($code ?? ''), $len, '0', STR_PAD_LEFT);
 		// calculate check digit
 		if ($len == 2) {
 			$r = $code % 4;
 		} elseif ($len == 5) {
-			$r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3}));
+			$r = (3 * ($code[0] + $code[2] + $code[4])) + (9 * ($code[1] + $code[3]));
 			$r %= 10;
 		} else {
 			return false;
@@ -1331,7 +1331,7 @@
 		);	
 		$p = $parities[$len][$r];
 		$seq = '1011'; // left guard bar
-		$seq .= $codes[$p[0]][$code{0}];
+		$seq .= $codes[$p[0]][$code[0]];
 		for ($i = 1; $i < $len; ++$i) {
 			$seq .= '01'; // separator
 			$seq .= $codes[$p[$i]][$code[$i]];
@@ -1375,9 +1375,9 @@
 		}
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 5, 'bcode' => array());
 		$k = 0;
-		$code = str_replace('-', '', $code);
-		$code = str_replace(' ', '', $code);
-		$len = strlen($code);
+		$code = str_replace('-', '', ($code ?? ''));
+		$code = str_replace(' ', '', ($code ?? ''));
+		$len = strlen(($code ?? ''));
 		// calculate checksum
 		$sum = 0;
 		for ($i = 0; $i < $len; ++$i) {
@@ -1389,7 +1389,7 @@
 		}
 		$code .= $chkd;
 		$checkdigit = $chkd;
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		// start bar
 		$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 5, 'p' => 0);
 		$bararray['bcode'][$k++] = array('t' => 0, 'w' => $this->gapwidth , 'h' => 5, 'p' => 0);
@@ -1467,8 +1467,8 @@
 			'Y' => array(2,1,4,3),
 			'Z' => array(2,2,3,3)		
 		);
-		$code = strtoupper($code);
-		$len = strlen($code);
+		$code = strtoupper(($code ?? ''));
+		$len = strlen(($code ?? ''));
 		$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => $this->daft['F'], 'bcode' => array());
 		if ($notkix) {
 			// table for checksum calculation (row,col)
@@ -1603,8 +1603,8 @@
 		$k = 0;
 		$w = 0;
 		$seq = '';
-		$code = strtoupper($code);
-		$len = strlen($code);
+		$code = strtoupper(($code ?? ''));
+		$len = strlen(($code ?? ''));
 		for ($i = 0; $i < $len; ++$i) {
 			if (!isset($chr[$code[$i]])) {
 				return false;
@@ -1651,7 +1651,7 @@
 		$k = 0;
 		$w = 0;
 		$seq = '';
-		$len = strlen($code);
+		$len = strlen(($code ?? ''));
 		// calculate check digit C
 		$p = 1;
 		$check = 0;
@@ -1733,7 +1733,7 @@
 		$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
 		$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
 		$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
-		$code_arr = explode('-', $code);
+		$code_arr = explode('-', ($code ?? ''));
 		$tracking_number = $code_arr[0];
 		if (isset($code_arr[1])) {
 			$routing_code = $code_arr[1];
@@ -1741,7 +1741,7 @@
 			$routing_code = '';
 		}
 		// Conversion of Routing Code
-		switch (strlen($routing_code)) {
+		switch (strlen(($routing_code ?? ''))) {
 			case 0: {
 				$binary_code = 0;
 				break;
@@ -1764,23 +1764,23 @@
 			}
 		}
 		$binary_code = bcmul($binary_code, 10);
-		$binary_code = bcadd($binary_code, $tracking_number{0});
+		$binary_code = bcadd($binary_code, $tracking_number[0]);
 		$binary_code = bcmul($binary_code, 5);
-		$binary_code = bcadd($binary_code, $tracking_number{1});
-		$binary_code .= substr($tracking_number, 2, 18);
+		$binary_code = bcadd($binary_code, $tracking_number[1]);
+		$binary_code .= substr(($tracking_number ?? ''), 2, 18);
 		// convert to hexadecimal
 		$binary_code = $this->dec_to_hex($binary_code);
 		// pad to get 13 bytes
-		$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
+		$binary_code = str_pad(($binary_code ?? ''), 26, '0', STR_PAD_LEFT);
 		// convert string to array of bytes
 		$binary_code_arr = chunk_split($binary_code, 2, "\r");
-		$binary_code_arr = substr($binary_code_arr, 0, -1);
-		$binary_code_arr = explode("\r", $binary_code_arr);
+		$binary_code_arr = substr(($binary_code_arr ?? ''), 0, -1);
+		$binary_code_arr = explode("\r", ($binary_code_arr ?? ''));
 		// calculate frame check sequence
 		$fcs = $this->imb_crc11fcs($binary_code_arr);
 		// exclude first 2 bits from first byte
 		$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
-		$binary_code_102bit = $first_byte.substr($binary_code, 2);
+		$binary_code_102bit = $first_byte.substr(($binary_code ?? ''), 2);
 		// convert binary data to codewords
 		$codewords = array();
 		$data = $this->hex_to_dec($binary_code_102bit);
@@ -1861,7 +1861,7 @@
 			if($number == 0) {
 				array_push($hex, '0');
 			} else {
-				array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
+				array_push($hex, strtoupper((dechex(bcmod($number, '16')) ?? '')));
 				$number = bcdiv($number, '16', 0);
 			}
 		}
@@ -1876,7 +1876,7 @@
 	public function hex_to_dec($hex) {
 		$dec = 0;
 		$bitval = 1;
-		$len = strlen($hex);
+		$len = strlen(($hex ?? ''));
 		for($pos = ($len - 1); $pos >= 0; --$pos) {
 			$dec = bcadd($dec, bcmul(hexdec($hex[$pos]), $bitval));
 			$bitval = bcmul($bitval, 16);
--- a/intranet/mpdf60/classes/ttfontsuni_analysis.php
+++ b/intranet/mpdf60/classes/ttfontsuni_analysis.php
@@ -3,6 +3,10 @@
 require_once(_MPDF_PATH.'classes/ttfontsuni.php');
 
 class TTFontFile_Analysis EXTENDS TTFontFile {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $version;
+    public $fontRevision;
+
 
 	// Used to get font information from files in directory
 	function extractCoreInfo($file, $TTCfontID=0) {
@@ -115,7 +119,7 @@
 			$string_data_offset = $name_offset + $this->read_ushort();
 			$names = array(1=>'',2=>'',3=>'',4=>'',6=>'');
 			$K = array_keys($names);
-			$nameCount = count($names);
+			$nameCount = count(($names ?? []));
 			for ($i=0;$i<$numRecords; $i++) {
 				$platformId = $this->read_ushort();
 				$encodingId = $this->read_ushort();
@@ -134,7 +138,7 @@
 					$N = '';
 					while ($length > 0) {
 						$char = $this->read_ushort();
-						$N .= (chr($char));
+						$N .= (chr((int) ($char)));
 						$length -= 1;
 					}
 					$this->_pos = $opos;
@@ -153,11 +157,11 @@
 				}
 			}
 			if ($names[6])
-				$psName = preg_replace('/ /','-',$names[6]);
+				$psName = preg_replace('/ /','-',($names[6] ?? ''));
 			else if ($names[4])
-				$psName = preg_replace('/ /','-',$names[4]);
+				$psName = preg_replace('/ /','-',($names[4] ?? ''));
 			else if ($names[1])
-				$psName = preg_replace('/ /','-',$names[1]);
+				$psName = preg_replace('/ /','-',($names[1] ?? ''));
 			else
 				$psName = '';
 			if (!$names[1] && !$psName)
@@ -201,7 +205,7 @@
 			$this->_pos += 10;  //PANOSE = 10 byte length
 			$panose = fread($this->fh,10);
 			$this->panose = array();
-			for ($p=0;$p<strlen($panose);$p++) { $this->panose[] = ord($panose[$p]); }
+			for ($p=0;$p<strlen(($panose ?? ''));$p++) { $this->panose[] = ord(($panose[$p] ?? '')); }
 			$this->skip(20); 
 			$fsSelection = $this->read_short();
 		}
@@ -380,14 +384,14 @@
 		else if ($sFamily ==10) { $ftype = 'cursive'; }
 		// Use PANOSE
 		if ($panose) { 
-			$bFamilyType=ord($panose[0]); 
+			$bFamilyType=ord(($panose[0] ?? '')); 
 			if ($bFamilyType==2) {
-				$bSerifStyle=ord($panose[1]); 
+				$bSerifStyle=ord(($panose[1] ?? '')); 
 				if (!$ftype) { 
 					if ($bSerifStyle>1 && $bSerifStyle<11) { $ftype = 'serif'; }
 					else if ($bSerifStyle>10) { $ftype = 'sans'; }
 				}
-				$bProportion=ord($panose[3]);
+				$bProportion=ord(($panose[3] ?? ''));
 				if ($bProportion==9 || $bProportion==1) { $ftype = 'mono'; }	// ==1 i.e. No Fit needed for OCR-a and -b
 			}
 			else if ($bFamilyType==3) {
--- a/intranet/mpdf60/classes/cssmgr.php
+++ b/intranet/mpdf60/classes/cssmgr.php
@@ -1,6 +1,12 @@
 <?php
 
 class cssmgr {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $cell_border_dominance_L;
+    public $cell_border_dominance_R;
+    public $cell_border_dominance_T;
+    public $cell_border_dominance_B;
+
 
 var $mpdf = null;
 
@@ -10,7 +16,7 @@
 var $tbCSSlvl;
 
 
-function cssmgr(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 	$this->tablecascadeCSS = array();
 	$this->CSS=array();
@@ -19,16 +25,16 @@
 }
 
 function ReadCSS($html) {
-	preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
-	for($i=0; $i<count($m[0]); $i++) {
-		if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { 
-			$html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
-		}
-	}
-	preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
-	for($i=0; $i<count($m[0]); $i++) {
-		if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { 
-			$html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
+	preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',($html ?? ''),$m);
+	for($i=0; $i<count(($m[0] ?? [])); $i++) {
+		if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim(($this->mpdf->CSSselectMedia ?? '')).'|all)/i',($m[1][$i] ?? ''))) { 
+			$html = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/','',($html ?? ''));
+		}
+	}
+	preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',($html ?? ''),$m);
+	for($i=0; $i<count(($m[0] ?? [])); $i++) {
+		if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim(($this->mpdf->CSSselectMedia ?? '')).'|all)/i',($m[1][$i] ?? ''))) { 
+			$html = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/','',($html ?? ''));
 		}
 	}
 
@@ -37,21 +43,21 @@
 	// Remove Comment tags /* ...  */ inside CSS as <style> in HTML document
 	// But first, we replace upper and mixed case closing style tag with lower
 	// case so we can use str_replace later.
-	preg_replace('/<\/style>/i', '</style>', $html);
-	preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
-	if (count($m[1])) { 
-		for($i=0;$i<count($m[1]);$i++) {
+	preg_replace('/<\/style>/i', '</style>', ($html ?? ''));
+	preg_match_all('/<style.*?>(.*?)<\/style>/si',($html ?? ''),$m);
+	if (count(($m[1] ?? []))) { 
+		for($i=0;$i<count(($m[1] ?? []));$i++) {
 			// Remove comment tags 
-			$sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
-			$sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
-			$html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
-		}
-	}
-
-
-	$html = preg_replace('/<!--mpdf/i','',$html);
-	$html = preg_replace('/mpdf-->/i','',$html);
-	$html = preg_replace('/<\!\-\-.*?\-\->/s',' ',$html);
+			$sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',($m[1][$i] ?? ''));
+			$sub = '>'.preg_replace('|/\*.*?\*/|s',' ',($sub ?? '')).'</style>';
+			$html = str_replace('>'.$m[1][$i].'</style>', ($sub ?? ''), ($html ?? ''));
+		}
+	}
+
+
+	$html = preg_replace('/<!--mpdf/i','',($html ?? ''));
+	$html = preg_replace('/mpdf-->/i','',($html ?? ''));
+	$html = preg_replace('/<\!\-\-.*?\-\->/s',' ',($html ?? ''));
 
 	$match = 0; // no match for instance
 	$regexp = ''; // This helps debugging: showing what is the REAL string being processed
@@ -59,13 +65,13 @@
 
 	//CSS inside external files
 	$regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
-	$x = preg_match_all($regexp,$html,$cxt);
+	$x = preg_match_all(($regexp ?? ''),($html ?? ''),$cxt);
 	if ($x) { 
 		$match += $x; 
 		$CSSext = $cxt[1];
 	}
 	$regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
-	$x = preg_match_all($regexp,$html,$cxt);
+	$x = preg_match_all(($regexp ?? ''),($html ?? ''),$cxt);
 	if ($x) { 
 		$match += $x; 
 		$CSSext = array_merge($CSSext,$cxt[1]);
@@ -74,7 +80,7 @@
 	// look for @import stylesheets
 	//$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
 	$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
-	$x = preg_match_all($regexp,$html,$cxt);
+	$x = preg_match_all(($regexp ?? ''),($html ?? ''),$cxt);
 	if ($x) { 
 		$match += $x; 
 		$CSSext = array_merge($CSSext,$cxt[1]);
@@ -83,7 +89,7 @@
 	// look for @import without the url()
 	//$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
 	$regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
-	$x = preg_match_all($regexp,$html,$cxt);
+	$x = preg_match_all(($regexp ?? ''),($html ?? ''),$cxt);
 	if ($x) { 
 		$match += $x; 
 		$CSSext = array_merge($CSSext,$cxt[1]);
@@ -97,7 +103,7 @@
 	while($match){
 		$path = $CSSext[$ind];
 
-		$path = htmlspecialchars_decode($path);	// mPDF 6
+		$path = htmlspecialchars_decode(($path ?? ''));	// mPDF 6
 
 		$this->mpdf->GetFullPath($path); 
 		$CSSextblock = $this->mpdf->_get_file($path);
@@ -106,8 +112,8 @@
 			// and fix url paths (including background-images) relative to stylesheet
 			//$regexpem = '/@import url\([\'\"]{0,1}(.*?\.css)[\'\"]{0,1}\)/si';
 			$regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
-			$xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
-			$cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
+			$xem = preg_match_all(($regexpem ?? ''),($CSSextblock ?? ''),$cxtem);
+			$cssBasePath = preg_replace('/\/[^\/]*$/','',($path ?? '')) . '/';
 			if ($xem) { 
 				foreach($cxtem[1] AS $cxtembedded) {
 					// path is relative to original stlyesheet!!
@@ -117,14 +123,14 @@
 				}
 			}
 			$regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
-			$xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
+			$xem = preg_match_all(($regexpem ?? ''),($CSSextblock ?? ''),$cxtem);
 			if ($xem) { 
-				for ($i=0;$i<count($cxtem[0]);$i++) {
+				for ($i=0;$i<count(($cxtem[0] ?? []));$i++) {
 					// path is relative to original stlyesheet!!
 					$embedded = $cxtem[2][$i];
-					if (!preg_match('/^data:image/i', $embedded)) {	// mPDF 5.5.13
+					if (!preg_match('/^data:image/i', ($embedded ?? ''))) {	// mPDF 5.5.13
 						$this->mpdf->GetFullPath($embedded, $cssBasePath );
-						$CSSextblock = preg_replace('/'.preg_quote($cxtem[0][$i],'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), $CSSextblock);
+						$CSSextblock = preg_replace('/'.preg_quote(($cxtem[0][$i] ?? ''),'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), ($CSSextblock ?? ''));
 					}
 				}
 			}
@@ -137,72 +143,72 @@
 	$match = 0; // reset value, if needed
 	// CSS as <style> in HTML document
 	$regexp = '/<style.*?>(.*?)<\/style>/si'; 
-	$match = preg_match_all($regexp,$html,$CSSblock);
+	$match = preg_match_all(($regexp ?? ''),($html ?? ''),$CSSblock);
 	if ($match) {
 		$tmpCSSstr = implode(' ',$CSSblock[1]);
 		$regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
-		$xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
+		$xem = preg_match_all(($regexpem ?? ''),($tmpCSSstr ?? '') ,$cxtem);
 		if ($xem) { 
-		   for ($i=0;$i<count($cxtem[0]);$i++) {
+		   for ($i=0;$i<count(($cxtem[0] ?? []));$i++) {
 			$embedded = $cxtem[2][$i];
-			if (!preg_match('/^data:image/i', $embedded)) {	// mPDF 5.5.13
+			if (!preg_match('/^data:image/i', ($embedded ?? ''))) {	// mPDF 5.5.13
 				$this->mpdf->GetFullPath($embedded);
-				$tmpCSSstr = preg_replace('/'.preg_quote($cxtem[0][$i],'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), $tmpCSSstr );
+				$tmpCSSstr = preg_replace('/'.preg_quote(($cxtem[0][$i] ?? ''),'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), ($tmpCSSstr ?? '') );
 			}
 		   }
 		}
 		$CSSstr .= ' '.$tmpCSSstr;
 	}
 	// Remove comments
-	$CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
-	$CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
-
-	if (preg_match('/@media/',$CSSstr)) { 
-		preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
-		for($i=0; $i<count($m[0]); $i++) {
-			if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { 
-				$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
+	$CSSstr = preg_replace('|/\*.*?\*/|s',' ',($CSSstr ?? ''));
+	$CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',($CSSstr ?? ''));
+
+	if (preg_match('/@media/',($CSSstr ?? ''))) { 
+		preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',($CSSstr ?? ''),$m);
+		for($i=0; $i<count(($m[0] ?? [])); $i++) {
+			if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim(($this->mpdf->CSSselectMedia ?? '')).'|all)/i',($m[1][$i] ?? ''))) { 
+				$CSSstr = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/','',($CSSstr ?? ''));
 			}
 			else {
-				$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/',' '.$m[2][$i].' ',$CSSstr);
+				$CSSstr = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/',' '.$m[2][$i].' ',($CSSstr ?? ''));
 			}
 		}
 	}
 
 	// Replace any background: url(data:image... with temporary image file reference
-	preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata);	// mPDF 5.7.2
-	if (count($idata[0])) { 
-		for($i=0;$i<count($idata[0]);$i++) {
+	preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", ($CSSstr ?? ''), $idata);	// mPDF 5.7.2
+	if (count(($idata[0] ?? []))) { 
+		for($i=0;$i<count(($idata[0] ?? []));$i++) {
 			$file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
 			//Save to local file
-			file_put_contents($file, base64_decode($idata[3][$i]));
+			file_put_contents($file, base64_decode(($idata[3][$i] ?? '')));
 			// $this->mpdf->GetFullPath($file);	// ? is this needed - NO  mPDF 5.6.03
-			$CSSstr = str_replace($idata[0][$i], 'url("'.$file.'")', $CSSstr); 	// mPDF 5.5.17
-		}
-	}
-
-	$CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',$CSSstr);
+			$CSSstr = str_replace(($idata[0][$i] ?? ''), 'url("'.$file.'")', ($CSSstr ?? '')); 	// mPDF 5.5.17
+		}
+	}
+
+	$CSSstr = preg_replace('/(<\!\-\-|\-\->)/s',' ',($CSSstr ?? ''));
 
 	// mPDF 5.7.4 URLs
 	// Characters "(" ")" and ";" in url() e.g. background-image, cause problems parsing the CSS string
 	// URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ; 
 	// with a segment delimiter in the URI)
 	$tempmarker = '%ZZ';
-	if (strpos($CSSstr,'url(')!==false) {
-		preg_match_all( '/url\(\"(.*?)\"\)/', $CSSstr, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
-		}
-		preg_match_all( '/url\(\'(.*?)\'\)/', $CSSstr, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
-		}
-		preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $CSSstr, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $CSSstr);
+	if (strpos(($CSSstr ?? ''),'url(')!==false) {
+		preg_match_all( '/url\(\"(.*?)\"\)/', ($CSSstr ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$CSSstr = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($CSSstr ?? ''));
+		}
+		preg_match_all( '/url\(\'(.*?)\'\)/', ($CSSstr ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$CSSstr = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($CSSstr ?? ''));
+		}
+		preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', ($CSSstr ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$CSSstr = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($CSSstr ?? ''));
 		}
 	}
 
@@ -210,57 +216,57 @@
 
 	if ($CSSstr ) {
 		$classproperties = array();	// mPDF 6
-		preg_match_all('/(.*?)\{(.*?)\}/',$CSSstr,$styles);
-		for($i=0; $i < count($styles[1]) ; $i++)  {
+		preg_match_all('/(.*?)\{(.*?)\}/',($CSSstr ?? ''),$styles);
+		for($i=0; $i < count(($styles[1] ?? [])) ; $i++)  {
 			// SET array e.g. $classproperties['COLOR'] = '#ffffff';
-	 		$stylestr= trim($styles[2][$i]);
-			$stylearr = explode(';',$stylestr);
+	 		$stylestr= trim(($styles[2][$i] ?? ''));
+			$stylearr = explode(';',($stylestr ?? ''));
 			foreach($stylearr AS $sta) {
-				if (trim($sta)) { 
+				if (trim(($sta ?? ''))) { 
 					// Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
-					$tmp = explode(':',$sta,2);
+					$tmp = explode(':',($sta ?? ''),2);
 					$property = $tmp[0];
 					if (isset($tmp[1])) { $value = $tmp[1]; }
 					else { $value = ''; }
-					$value = str_replace($tempmarker,';',$value);	// mPDF 5.7.4 URLs
-					$property = trim($property);
-					$value = preg_replace('/\s*!important/i','',$value);
-					$value = trim($value);
+					$value = str_replace(($tempmarker ?? ''),';',($value ?? ''));	// mPDF 5.7.4 URLs
+					$property = trim(($property ?? ''));
+					$value = preg_replace('/\s*!important/i','',($value ?? ''));
+					$value = trim(($value ?? ''));
 					if ($property && ($value || $value==='0')) {
 					// Ignores -webkit-gradient so doesn't override -moz-
-						if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) { 
+						if ((strtoupper(($property ?? ''))=='BACKGROUND-IMAGE' || strtoupper(($property ?? ''))=='BACKGROUND') && preg_match('/-webkit-gradient/i',($value ?? ''))) { 
 							continue; 
 						}
-	  					$classproperties[strtoupper($property)] = $value;
+	  					$classproperties[strtoupper(($property ?? ''))] = $value;
 					}
 				}
 			}
 			$classproperties = $this->fixCSS($classproperties);
-			$tagstr = strtoupper(trim($styles[1][$i]));
-			$tagarr = explode(',',$tagstr);
+			$tagstr = strtoupper((trim(($styles[1][$i] ?? '')) ?? ''));
+			$tagarr = explode(',',($tagstr ?? ''));
 			$pageselectors = false;	// used to turn on $this->mpdf->mirrorMargins
 			foreach($tagarr AS $tg) {
 				// mPDF 5.7.4
-				if (preg_match('/NTH-CHILD\((\s*(([\-+]?\d*)N(\s*[\-+]\s*\d+)?|[\-+]?\d+|ODD|EVEN)\s*)\)/',$tg,$m) ) {
-					$tg = preg_replace('/NTH-CHILD\(.*\)/', 'NTH-CHILD('.str_replace(' ','',$m[1]).')', $tg);
-				}
-				$tags = preg_split('/\s+/',trim($tg));
-				$level = count($tags);
+				if (preg_match('/NTH-CHILD\((\s*(([\-+]?\d*)N(\s*[\-+]\s*\d+)?|[\-+]?\d+|ODD|EVEN)\s*)\)/',($tg ?? ''),$m) ) {
+					$tg = preg_replace('/NTH-CHILD\(.*\)/', 'NTH-CHILD('.str_replace(' ','',($m[1] ?? '')).')', ($tg ?? ''));
+				}
+				$tags = preg_split('/\s+/',(trim(($tg ?? '')) ?? ''));
+				$level = count(($tags ?? []));
 				$t = '';
 				$t2 = '';
 				$t3 = '';
-				if (trim($tags[0])=='@PAGE') {
-					if (isset($tags[0])) { $t = trim($tags[0]); }
-					if (isset($tags[1])) { $t2 = trim($tags[1]); }
-					if (isset($tags[2])) { $t3 = trim($tags[2]); }
+				if (trim(($tags[0] ?? ''))=='@PAGE') {
+					if (isset($tags[0])) { $t = trim(($tags[0] ?? '')); }
+					if (isset($tags[1])) { $t2 = trim(($tags[1] ?? '')); }
+					if (isset($tags[2])) { $t3 = trim(($tags[2] ?? '')); }
 					$tag = '';
 					if ($level==1) { $tag = $t; }
-					else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) { 
+					else if ($level==2 && preg_match('/^[:](.*)$/',($t2 ?? ''),$m)) { 
 						$tag = $t.'>>PSEUDO>>'.$m[1]; 
 						if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; }	// used to turn on $this->mpdf->mirrorMargins 
 					}
 					else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
-					else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) { 
+					else if ($level==3 && preg_match('/^[:](.*)$/',($t3 ?? ''),$m)) { 
 						$tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1]; 
 						if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; }	// used to turn on $this->mpdf->mirrorMargins
 					}
@@ -269,19 +275,19 @@
 				}
 
 				else if ($level == 1) {		// e.g. p or .class or #id or p.class or p#id
-				if (isset($tags[0])) { $t = trim($tags[0]); }
+				if (isset($tags[0])) { $t = trim(($tags[0] ?? '')); }
 					if ($t) {
 						$tag = '';
-						if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; }
-						else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; }
-						else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); }	// mPDF 6  Special case for lang as attribute selector
-						else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); }	// mPDF 6  Special case for lang as attribute selector
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); }	// mPDF 6  Special case for lang as attribute selector
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); }	// mPDF 6  Special case for lang as attribute selector
-						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; }
+						if (preg_match('/^[.](.*)$/',($t ?? ''),$m)) { $tag = 'CLASS>>'.$m[1]; }
+						else if (preg_match('/^[#](.*)$/',($t ?? ''),$m)) { $tag = 'ID>>'.$m[1]; }
+						else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',($t ?? ''),$m)) { $tag = 'LANG>>'.strtolower(($m[1] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+						else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',($t ?? ''),$m)) { $tag = 'LANG>>'.strtolower(($m[1] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',($t ?? ''),$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',($t ?? ''),$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',($t ?? ''),$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',($t ?? ''),$m)) { $tag = $m[1].'>>LANG>>'.strtolower(($m[2] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',($t ?? ''),$m)) { $tag = $m[1].'>>LANG>>'.strtolower(($m[2] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+						else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',($t ?? ''))) { $tag= $t; }
 						if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
 						else if ($tag) { $this->CSS[$tag] = $classproperties; }
 					}
@@ -289,20 +295,20 @@
 				else {
 					$tmp = array();
 					for($n=0;$n<$level;$n++) {
-						if (isset($tags[$n])) { $t = trim($tags[$n]); }
+						if (isset($tags[$n])) { $t = trim(($tags[$n] ?? '')); }
 						else { $t = ''; }
 						if ($t) {
 							$tag = '';
-							if (preg_match('/^[.](.*)$/',$t,$m)) { $tag = 'CLASS>>'.$m[1]; }
-							else if (preg_match('/^[#](.*)$/',$t,$m)) { $tag = 'ID>>'.$m[1]; }
-							else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); }	// mPDF 6  Special case for lang as attribute selector
-							else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = 'LANG>>'.strtolower($m[1]); }	// mPDF 6  Special case for lang as attribute selector
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',$t,$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',$t,$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',$t,$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); }	// mPDF 6  Special case for lang as attribute selector
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',$t,$m)) { $tag = $m[1].'>>LANG>>'.strtolower($m[2]); }	// mPDF 6  Special case for lang as attribute selector
-							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',$t)) { $tag= $t; }
+							if (preg_match('/^[.](.*)$/',($t ?? ''),$m)) { $tag = 'CLASS>>'.$m[1]; }
+							else if (preg_match('/^[#](.*)$/',($t ?? ''),$m)) { $tag = 'ID>>'.$m[1]; }
+							else if (preg_match('/^\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',($t ?? ''),$m)) { $tag = 'LANG>>'.strtolower(($m[1] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+							else if (preg_match('/^:LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',($t ?? ''),$m)) { $tag = 'LANG>>'.strtolower(($m[1] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[.](.*)$/',($t ?? ''),$m)) { $tag = $m[1].'>>CLASS>>'.$m[2]; }
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\s*:NTH-CHILD\((.*)\)$/',($t ?? ''),$m)) { $tag = $m[1].'>>SELECTORNTHCHILD>>'.$m[2]; }
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')[#](.*)$/',($t ?? ''),$m)) { $tag = $m[1].'>>ID>>'.$m[2]; }
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')\[LANG=[\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\]$/',($t ?? ''),$m)) { $tag = $m[1].'>>LANG>>'.strtolower(($m[2] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.'):LANG\([\'\"]{0,1}([A-Z\-]{2,11})[\'\"]{0,1}\)$/',($t ?? ''),$m)) { $tag = $m[1].'>>LANG>>'.strtolower(($m[2] ?? '')); }	// mPDF 6  Special case for lang as attribute selector
+							else if (preg_match('/^('.$this->mpdf->allowedCSStags.')$/',($t ?? ''))) { $tag= $t; }
 
 							if ($tag) $tmp[] = $tag;
 							else { break; }
@@ -325,7 +331,7 @@
 	} // end of if
 	//Remove CSS (tags and content), if any
 	$regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css"> 
-	$html = preg_replace($regexp,'',$html);
+	$html = preg_replace(($regexp ?? ''),'',($html ?? ''));
 //print_r($this->CSS); exit;
 //print_r($this->cascadeCSS); exit;
 	return $html;
@@ -334,46 +340,46 @@
 
 
 function readInlineCSS($html) {
-	$html=htmlspecialchars_decode($html);	// mPDF 5.7.4 URLs
+	$html=htmlspecialchars_decode(($html ?? ''));	// mPDF 5.7.4 URLs
 	// mPDF 5.7.4 URLs
 	// Characters "(" ")" and ";" in url() e.g. background-image, cause probems parsing the CSS string
 	// URLencode ( and ), but change ";" to a code which can be converted back after parsing (so as not to confuse ; 
 	// with a segment delimiter in the URI)
 	$tempmarker = '%ZZ';
-	if (strpos($html,'url(')!==false) {
-		preg_match_all( '/url\(\"(.*?)\"\)/', $html, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
-		}
-		preg_match_all( '/url\(\'(.*?)\'\)/', $html, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
-		}
-		preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', $html, $m);
-		for($i = 0; $i < count($m[1]) ; $i++) {
-			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),$m[1][$i]);
-			$html = preg_replace('/'.preg_quote($m[0][$i],'/').'/', 'url(\''.$tmp.'\')', $html);
+	if (strpos(($html ?? ''),'url(')!==false) {
+		preg_match_all( '/url\(\"(.*?)\"\)/', ($html ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$html = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($html ?? ''));
+		}
+		preg_match_all( '/url\(\'(.*?)\'\)/', ($html ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$html = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($html ?? ''));
+		}
+		preg_match_all( '/url\(([^\'\"].*?[^\'\"])\)/', ($html ?? ''), $m);
+		for($i = 0; $i < count(($m[1] ?? [])) ; $i++) {
+			$tmp = str_replace(array('(',')',';'),array('%28','%29',$tempmarker),($m[1][$i] ?? ''));
+			$html = preg_replace('/'.preg_quote(($m[0][$i] ?? ''),'/').'/', 'url(\''.$tmp.'\')', ($html ?? ''));
 		}
 	}
 	//Fix incomplete CSS code
-	$size = strlen($html)-1;
-	if (substr($html,$size,1) != ';') $html .= ';';
+	$size = strlen(($html ?? ''))-1;
+	if (substr(($html ?? ''),$size,1) != ';') $html .= ';';
 	//Make CSS[Name-of-the-class] = array(key => value)
 	$regexp = '|\\s*?(\\S+?):(.+?);|i';
-	preg_match_all( $regexp, $html, $styleinfo);
+	preg_match_all( ($regexp ?? ''), ($html ?? ''), $styleinfo);
 	$properties = $styleinfo[1];
 	$values = $styleinfo[2];
 	//Array-properties and Array-values must have the SAME SIZE!
 	$classproperties = array();
-	for($i = 0; $i < count($properties) ; $i++) {
+	for($i = 0; $i < count(($properties ?? [])) ; $i++) {
 		// Ignores -webkit-gradient so doesn't override -moz-
-		if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) { 
+		if ((strtoupper(($properties[$i] ?? ''))=='BACKGROUND-IMAGE' || strtoupper(($properties[$i] ?? ''))=='BACKGROUND') && preg_match('/-webkit-gradient/i',($values[$i] ?? ''))) { 
 			continue; 
 		}
-		$values[$i] = str_replace($tempmarker,';',$values[$i]);	// mPDF 5.7.4 URLs
-		$classproperties[strtoupper($properties[$i])] = trim($values[$i]);
+		$values[$i] = str_replace(($tempmarker ?? ''),';',($values[$i] ?? ''));	// mPDF 5.7.4 URLs
+		$classproperties[strtoupper(($properties[$i] ?? ''))] = trim(($values[$i] ?? ''));
 	}
 	return $this->fixCSS($classproperties);
 }
@@ -381,20 +387,20 @@
 
 
 function _fix_borderStr($bd) {
-	preg_match_all("/\((.*?)\)/", $bd, $m);
-	if (count($m[1])) { 
-		for($i=0;$i<count($m[1]);$i++) {
-			$sub = preg_replace("/ /", "", $m[1][$i]);
-			$bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd); 
-		}
-	}
-
-	$prop = preg_split('/\s+/',trim($bd));
+	preg_match_all("/\((.*?)\)/", ($bd ?? ''), $m);
+	if (count(($m[1] ?? []))) { 
+		for($i=0;$i<count(($m[1] ?? []));$i++) {
+			$sub = preg_replace("/ /", "", ($m[1][$i] ?? ''));
+			$bd = preg_replace('/'.preg_quote(($m[1][$i] ?? ''), '/').'/si', ($sub ?? ''), ($bd ?? '')); 
+		}
+	}
+
+	$prop = preg_split('/\s+/',(trim(($bd ?? '')) ?? ''));
 	$w = 'medium';
 	$c = '#000000';
 	$s = 'none';
 
-	if ( count($prop) == 1 ) { 
+	if ( count(($prop ?? [])) == 1 ) { 
 		// solid
 		if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
 		// #000000
@@ -402,7 +408,7 @@
 		// 1px 
 		else { $w = $prop[0]; }
 	}
-	else if (count($prop) == 2 ) { 
+	else if (count(($prop ?? [])) == 2 ) { 
 		// 1px solid 
 		if (in_array($prop[1],$this->mpdf->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
 		// solid #000000 
@@ -410,11 +416,11 @@
 		// 1px #000000 
 		else { $w = $prop[0]; $c = $prop[1]; }
 	}
-	else if ( count($prop) == 3 ) {
+	else if ( count(($prop ?? [])) == 3 ) {
 		// Change #000000 1px solid to 1px solid #000000 (proper)
-		if (substr($prop[0],0,1) == '#') { $c = $prop[0]; $w = $prop[1]; $s = $prop[2]; }
+		if (substr(($prop[0] ?? ''),0,1) == '#') { $c = $prop[0]; $w = $prop[1]; $s = $prop[2]; }
 		// Change solid #000000 1px to 1px solid #000000 (proper)
-		else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
+		else if (substr(($prop[0] ?? ''),1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
 		// Change solid 1px #000000 to 1px solid #000000 (proper)
 		else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { 
 			$s = $prop[0]; $w = $prop[1]; $c = $prop[2]; 
@@ -422,61 +428,61 @@
 		else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
 	}
 	else { return ''; } 
-	$s = strtolower($s);
+	$s = strtolower(($s ?? ''));
 	return $w.' '.$s.' '.$c;
 }
 
 
 
 function fixCSS($prop) {
-	if (!is_array($prop) || (count($prop)==0)) return array(); 
+	if (!is_array($prop) || (count(($prop ?? []))==0)) return array(); 
 	$newprop = array(); 
 	foreach($prop AS $k => $v) {
 		if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
-			$v = strtolower($v);
+			$v = strtolower(($v ?? ''));
 		}
 
 		if ($k == 'FONT') {
-			$s = trim($v);
-			preg_match_all('/\"(.*?)\"/',$s,$ff);
-			if (count($ff[1])) {
+			$s = trim(($v ?? ''));
+			preg_match_all('/\"(.*?)\"/',($s ?? ''),$ff);
+			if (count(($ff[1] ?? []))) {
 				foreach($ff[1] AS $ffp) { 
-					$w = preg_split('/\s+/',$ffp);
-					$s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s); 
-				}
-			}
-			preg_match_all('/\'(.*?)\'/',$s,$ff);
-			if (count($ff[1])) {
+					$w = preg_split('/\s+/',($ffp ?? ''));
+					$s = preg_replace('/\"'.$ffp.'\"/',($w[0] ?? ''),($s ?? '')); 
+				}
+			}
+			preg_match_all('/\'(.*?)\'/',($s ?? ''),$ff);
+			if (count(($ff[1] ?? []))) {
 				foreach($ff[1] AS $ffp) { 
-					$w = preg_split('/\s+/',$ffp);
-					$s = preg_replace('/\''.$ffp.'\'/',$w[0],$s); 
-				}
-			}
-			$s = preg_replace('/\s*,\s*/',',',$s); 
-			$bits = preg_split('/\s+/',$s);
-			if (count($bits)>1) {
-				$k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
-				$fs = $bits[(count($bits)-2)];
-				if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) { 
+					$w = preg_split('/\s+/',($ffp ?? ''));
+					$s = preg_replace('/\''.$ffp.'\'/',($w[0] ?? ''),($s ?? '')); 
+				}
+			}
+			$s = preg_replace('/\s*,\s*/',',',($s ?? '')); 
+			$bits = preg_split('/\s+/',($s ?? ''));
+			if (count(($bits ?? []))>1) {
+				$k = 'FONT-FAMILY'; $v = $bits[(count(($bits ?? []))-1)];
+				$fs = $bits[(count(($bits ?? []))-2)];
+				if (preg_match('/(.*?)\/(.*)/',($fs ?? ''), $fsp)) { 
 					$newprop['FONT-SIZE'] = $fsp[1];
 					$newprop['LINE-HEIGHT'] = $fsp[2];
 				}
 				else { $newprop['FONT-SIZE'] = $fs; } 
-				if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
+				if (preg_match('/(italic|oblique)/i',($s ?? ''))) { $newprop['FONT-STYLE'] = 'italic'; }
 				else { $newprop['FONT-STYLE'] = 'normal'; }
-				if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
+				if (preg_match('/bold/i',($s ?? ''))) { $newprop['FONT-WEIGHT'] = 'bold'; }
 				else { $newprop['FONT-WEIGHT'] = 'normal'; }
-				if (preg_match('/small-caps/i',$s)) { $newprop['TEXT-TRANSFORM'] = 'uppercase'; }
+				if (preg_match('/small-caps/i',($s ?? ''))) { $newprop['TEXT-TRANSFORM'] = 'uppercase'; }
 			}
 		}
 		else if ($k == 'FONT-FAMILY') {
-			$aux_fontlist = explode(",",$v);
+			$aux_fontlist = explode(",",($v ?? ''));
 			$found = 0;
 			foreach($aux_fontlist AS $f) {
-				$fonttype = trim($f);
-				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-				$fonttype = preg_replace('/ /','',$fonttype);
-				$v = strtolower(trim($fonttype));
+				$fonttype = trim(($f ?? ''));
+				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+				$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+				$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 				if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
 				if ((!$this->mpdf->onlyCoreFonts && in_array($v,$this->mpdf->available_unifonts)) || 
 					in_array($v,array('ccourier','ctimes','chelvetica')) ||
@@ -489,10 +495,10 @@
 			}
 			if (!$found) {
 			   foreach($aux_fontlist AS $f) {
-				$fonttype = trim($f);
-				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-				$fonttype = preg_replace('/ /','',$fonttype);
-				$v = strtolower(trim($fonttype));
+				$fonttype = trim(($f ?? ''));
+				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+				$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+				$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 				if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
 				if (in_array($v,$this->mpdf->sans_fonts) || in_array($v,$this->mpdf->serif_fonts) || in_array($v,$this->mpdf->mono_fonts) ) { 
 					$newprop[$k] = $v;
@@ -503,23 +509,23 @@
 		}
 		// mPDF 5.7.1
 		else if ($k == 'FONT-VARIANT') {
-			if (preg_match('/(normal|none)/',$v, $m)) {	// mPDF 6
+			if (preg_match('/(normal|none)/',($v ?? ''), $m)) {	// mPDF 6
 				$newprop['FONT-VARIANT-LIGATURES'] = $m[1];
 				$newprop['FONT-VARIANT-CAPS'] = $m[1];
 				$newprop['FONT-VARIANT-NUMERIC'] = $m[1];
 				$newprop['FONT-VARIANT-ALTERNATES'] = $m[1];
 			}
 			else {
-			  if (preg_match_all('/(no-common-ligatures|\bcommon-ligatures|no-discretionary-ligatures|\bdiscretionary-ligatures|no-historical-ligatures|\bhistorical-ligatures|no-contextual|\bcontextual)/i',$v, $m)) {
+			  if (preg_match_all('/(no-common-ligatures|\bcommon-ligatures|no-discretionary-ligatures|\bdiscretionary-ligatures|no-historical-ligatures|\bhistorical-ligatures|no-contextual|\bcontextual)/i',($v ?? ''), $m)) {
 				$newprop['FONT-VARIANT-LIGATURES'] = implode(' ',$m[1]);
 			  }
-			  if (preg_match('/(all-small-caps|\bsmall-caps|all-petite-caps|\bpetite-caps|unicase|titling-caps)/i',$v, $m)) {
+			  if (preg_match('/(all-small-caps|\bsmall-caps|all-petite-caps|\bpetite-caps|unicase|titling-caps)/i',($v ?? ''), $m)) {
 				$newprop['FONT-VARIANT-CAPS'] = $m[1];
 			  }
-			  if (preg_match_all('/(lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)/i',$v, $m)) {
+			  if (preg_match_all('/(lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)/i',($v ?? ''), $m)) {
 				$newprop['FONT-VARIANT-NUMERIC'] = implode(' ',$m[1]);
 			  }
-			  if (preg_match('/(historical-forms)/i',$v, $m)) {
+			  if (preg_match('/(historical-forms)/i',($v ?? ''), $m)) {
 				$newprop['FONT-VARIANT-ALTERNATES'] = $m[1];
 			  }
 			}
@@ -600,51 +606,51 @@
 		}
 
 		else if ($k == 'BORDER-SPACING') {
-			$prop = preg_split('/\s+/',trim($v));
-			if (count($prop) == 1 ) { 
+			$prop = preg_split('/\s+/',(trim(($v ?? '')) ?? ''));
+			if (count(($prop ?? [])) == 1 ) { 
 				$newprop['BORDER-SPACING-H'] = $prop[0];
 				$newprop['BORDER-SPACING-V'] = $prop[0];
 			}
-			else if (count($prop) == 2 ) { 
+			else if (count(($prop ?? [])) == 2 ) { 
 				$newprop['BORDER-SPACING-H'] = $prop[0];
 				$newprop['BORDER-SPACING-V'] = $prop[1];
 			}
 		}
 		else if ($k == 'TEXT-OUTLINE') {	// mPDF 5.6.07
-			$prop = preg_split('/\s+/',trim($v));
-			if (trim(strtolower($v)) == 'none' ) { 
+			$prop = preg_split('/\s+/',(trim(($v ?? '')) ?? ''));
+			if (trim((strtolower(($v ?? '')) ?? '')) == 'none' ) { 
 				$newprop['TEXT-OUTLINE'] = 'none';
 			}
-			else if (count($prop) == 2 ) { 
+			else if (count(($prop ?? [])) == 2 ) { 
 				$newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
 				$newprop['TEXT-OUTLINE-COLOR'] = $prop[1];
 			}
-			else if (count($prop) == 3 ) { 
+			else if (count(($prop ?? [])) == 3 ) { 
 				$newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
 				$newprop['TEXT-OUTLINE-COLOR'] = $prop[2];
 			}
 		}
 		else if ($k == 'SIZE') {
-			$prop = preg_split('/\s+/',trim($v));
-			if (preg_match('/(auto|portrait|landscape)/',$prop[0])) {
-				$newprop['SIZE'] = strtoupper($prop[0]);
-			}
-			else if (count($prop) == 1 ) {
+			$prop = preg_split('/\s+/',(trim(($v ?? '')) ?? ''));
+			if (preg_match('/(auto|portrait|landscape)/',($prop[0] ?? ''))) {
+				$newprop['SIZE'] = strtoupper(($prop[0] ?? ''));
+			}
+			else if (count(($prop ?? [])) == 1 ) {
 				$newprop['SIZE']['W'] = $this->mpdf->ConvertSize($prop[0]);
 				$newprop['SIZE']['H'] = $this->mpdf->ConvertSize($prop[0]);
 			}
-			else if (count($prop) == 2 ) {
+			else if (count(($prop ?? [])) == 2 ) {
 				$newprop['SIZE']['W'] = $this->mpdf->ConvertSize($prop[0]);
 				$newprop['SIZE']['H'] = $this->mpdf->ConvertSize($prop[1]);
 			}
 		}
 		else if ($k == 'SHEET-SIZE') {
-			$prop = preg_split('/\s+/',trim($v));
-			if (count($prop) == 2 ) {
+			$prop = preg_split('/\s+/',(trim(($v ?? '')) ?? ''));
+			if (count(($prop ?? [])) == 2 ) {
 				$newprop['SHEET-SIZE'] = array($this->mpdf->ConvertSize($prop[0]), $this->mpdf->ConvertSize($prop[1]));
 			}
 			else {
-				if(preg_match('/([0-9a-zA-Z]*)-L/i',$v,$m)) {	// e.g. A4-L = A$ landscape
+				if(preg_match('/([0-9a-zA-Z]*)-L/i',($v ?? ''),$m)) {	// e.g. A4-L = A$ landscape
 					$ft = $this->mpdf->_getPageFormat($m[1]);
 					$format = array($ft[1],$ft[0]);
 				}
@@ -667,34 +673,34 @@
 		}
 /*-- BACKGROUNDS --*/
 		else if ($k == 'BACKGROUND-IMAGE') {
-			if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$v,$m)) {
+			if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',($v ?? ''),$m)) {
 				$newprop['BACKGROUND-IMAGE'] = $m[0];
 				continue;
 			}
-			if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) {
+			if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',($v ?? ''),$m)) {
 				$newprop['BACKGROUND-IMAGE'] = $m[1];
 			}
 		 
-			else if (strtolower($v)=='none') { $newprop['BACKGROUND-IMAGE'] = ''; }
+			else if (strtolower(($v ?? ''))=='none') { $newprop['BACKGROUND-IMAGE'] = ''; }
 
 		}
 		else if ($k == 'BACKGROUND-REPEAT') {
-			if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) { 
-				$newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
+			if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',($v ?? ''),$m)) { 
+				$newprop['BACKGROUND-REPEAT'] = strtolower(($m[1] ?? ''));
 			}
 		}
 		else if ($k == 'BACKGROUND-POSITION') {
 			$s = $v;
-			$bits = preg_split('/\s+/',trim($s));
+			$bits = preg_split('/\s+/',(trim(($s ?? '')) ?? ''));
 			// These should be Position x1 or x2
-			if (count($bits)==1) {
-				if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
-				else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
+			if (count(($bits ?? []))==1) {
+				if (preg_match('/bottom/',($bits[0] ?? ''))) { $bg['p'] = '50% 100%'; }
+				else if (preg_match('/top/',($bits[0] ?? ''))) { $bg['p'] = '50% 0%'; }
 				else { $bg['p'] = $bits[0] . ' 50%'; }
 			}
-			else if (count($bits)==2) {
+			else if (count(($bits ?? []))==2) {
 				// Can be either right center or center right
-				if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) { 
+				if (preg_match('/(top|bottom)/',($bits[0] ?? '')) || preg_match('/(left|right)/',($bits[1] ?? ''))) { 
 					$bg['p'] = $bits[1] . ' '.$bits[0]; 
 				}
 				else { 
@@ -702,10 +708,10 @@
 				}
 			}
 			if ($bg['p']) {
-				$bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
-				$bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
-				$bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
-				if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
+				$bg['p'] = preg_replace('/(left|top)/','0%',($bg['p'] ?? ''));
+				$bg['p'] = preg_replace('/(right|bottom)/','100%',($bg['p'] ?? ''));
+				$bg['p'] = preg_replace('/(center)/','50%',($bg['p'] ?? ''));
+				if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',($bg['p'] ?? ''))) {
 					$bg['p'] = false;
 				}
 			}
@@ -713,11 +719,11 @@
 		}
 /*-- END BACKGROUNDS --*/
 		else if ($k == 'IMAGE-ORIENTATION') {
-			if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$v,$m)) {
+			if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',($v ?? ''),$m)) {
 				$angle = $m[1] + 0;
-				if (strtolower($m[2])=='deg') { $angle = $angle; }
-				else if (strtolower($m[2])=='grad') { $angle *= (360/400); }
-				else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); }
+				if (strtolower(($m[2] ?? ''))=='deg') { $angle = $angle; }
+				else if (strtolower(($m[2] ?? ''))=='grad') { $angle *= (360/400); }
+				else if (strtolower(($m[2] ?? ''))=='rad') { $angle = rad2deg($angle); }
 				while($angle < 0) { $angle += 360; }
 				$angle = ($angle % 360);
 				$angle /= 90;
@@ -726,38 +732,38 @@
 			}
 		}
 		else if ($k == 'TEXT-ALIGN') {
-			if (preg_match('/["\'](.){1}["\']/i',$v,$m)) { 
+			if (preg_match('/["\'](.){1}["\']/i',($v ?? ''),$m)) { 
 				$d = array_search($m[1],$this->mpdf->decimal_align);
 				if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
-				if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
+				if (preg_match('/(center|left|right)/i',($v ?? ''),$m)) { $newprop['TEXT-ALIGN'] .= strtoupper((substr(($m[1] ?? ''),0,1) ?? '')); }
 				else { $newprop['TEXT-ALIGN'] .= 'R'; }	// default = R
 			}
-			else if (preg_match('/["\'](\\\[a-fA-F0-9]{1,6})["\']/i',$v,$m)) { 
-				$utf8 = codeHex2utf(substr($m[1],1,6));
+			else if (preg_match('/["\'](\\\[a-fA-F0-9]{1,6})["\']/i',($v ?? ''),$m)) { 
+				$utf8 = codeHex2utf(substr(($m[1] ?? ''),1,6));
 				$d = array_search($utf8,$this->mpdf->decimal_align);
 				if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
-				if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
+				if (preg_match('/(center|left|right)/i',($v ?? ''),$m)) { $newprop['TEXT-ALIGN'] .= strtoupper((substr(($m[1] ?? ''),0,1) ?? '')); }
 				else { $newprop['TEXT-ALIGN'] .= 'R'; }	// default = R
 			}
 			else { $newprop[$k] = $v; }
 		}
 		// mpDF 6  Lists
 		else if ($k == 'LIST-STYLE') {
-			if (preg_match('/none/i',$v,$m)) { 
+			if (preg_match('/none/i',($v ?? ''),$m)) { 
 				$newprop['LIST-STYLE-TYPE'] = 'none';
 				$newprop['LIST-STYLE-IMAGE'] = 'none';
 			}
-			if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao|cjk-decimal|hebrew)/i',$v,$m)) { 
-				$newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
-			}
-			else if (preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) { 
-				$newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
-			}
-			if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) {
-				$newprop['LIST-STYLE-IMAGE'] = strtolower(trim($m[1]));
-			}
-			if (preg_match('/(inside|outside)/i',$v,$m)) { 
-				$newprop['LIST-STYLE-POSITION'] = strtolower(trim($m[1]));
+			if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao|cjk-decimal|hebrew)/i',($v ?? ''),$m)) { 
+				$newprop['LIST-STYLE-TYPE'] = strtolower((trim(($m[1] ?? '')) ?? ''));
+			}
+			else if (preg_match('/U\+([a-fA-F0-9]+)/i',($v ?? ''),$m)) { 
+				$newprop['LIST-STYLE-TYPE'] = strtolower((trim(($m[1] ?? '')) ?? ''));
+			}
+			if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',($v ?? ''),$m)) {
+				$newprop['LIST-STYLE-IMAGE'] = strtolower((trim(($m[1] ?? '')) ?? ''));
+			}
+			if (preg_match('/(inside|outside)/i',($v ?? ''),$m)) { 
+				$newprop['LIST-STYLE-POSITION'] = strtolower((trim(($m[1] ?? '')) ?? ''));
 			}
 		}
 
@@ -771,30 +777,30 @@
 
 function setCSSboxshadow($v) {
 	$sh = array();
-	$c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',$v,$x);	// mPDF 5.6.05
+	$c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',($v ?? ''),$x);	// mPDF 5.6.05
 	for($i=0; $i<$c; $i++) {
-		$col = preg_replace('/,/','*',$x[0][$i]);
-		$v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
-	}
-	$ss = explode(',',$v);
+		$col = preg_replace('/,/','*',($x[0][$i] ?? ''));
+		$v = preg_replace('/'.preg_quote(($x[0][$i] ?? ''),'/').'/',($col ?? ''),($v ?? ''));
+	}
+	$ss = explode(',',($v ?? ''));
 	foreach ($ss AS $s) {
 		$new = array('inset'=>false, 'blur'=>0, 'spread'=>0);
-		if (preg_match('/inset/i',$s)) { $new['inset'] = true; $s = preg_replace('/\s*inset\s*/','',$s); }
-		$p = explode(' ',trim($s));
-		if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
-		if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
+		if (preg_match('/inset/i',($s ?? ''))) { $new['inset'] = true; $s = preg_replace('/\s*inset\s*/','',($s ?? '')); }
+		$p = explode(' ',(trim(($s ?? '')) ?? ''));
+		if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim(($p[0] ?? '')),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
+		if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim(($p[1] ?? '')),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
 		if (isset($p[2])) {
-			if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
-				$new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); 
-			}
-			else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
+			if (preg_match('/^\s*[\.\-0-9]/',($p[2] ?? ''))) {
+				$new['blur'] = $this->mpdf->ConvertSize(trim(($p[2] ?? '')),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); 
+			}
+			else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',($p[2] ?? ''))); }
 			if (isset($p[3])) {
-				if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
-					$new['spread'] = $this->mpdf->ConvertSize(trim($p[3]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); 
-				}
-				else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); }
+				if (preg_match('/^\s*[\.\-0-9]/',($p[3] ?? ''))) {
+					$new['spread'] = $this->mpdf->ConvertSize(trim(($p[3] ?? '')),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); 
+				}
+				else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',($p[3] ?? ''))); }
 				if (isset($p[4])) {
-					$new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[4]));
+					$new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',($p[4] ?? '')));
 				}
 			}
 		}
@@ -806,24 +812,24 @@
 
 function setCSStextshadow($v) {
 	$sh = array();
-	$c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',$v,$x);	// mPDF 5.6.05
+	$c = preg_match_all('/(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl)\(.*?\)/',($v ?? ''),$x);	// mPDF 5.6.05
 	for($i=0; $i<$c; $i++) {
-		$col = preg_replace('/,/','*',$x[0][$i]);
-		$v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
-	}
-	$ss = explode(',',$v);
+		$col = preg_replace('/,/','*',($x[0][$i] ?? ''));
+		$v = preg_replace('/'.preg_quote(($x[0][$i] ?? ''),'/').'/',($col ?? ''),($v ?? ''));
+	}
+	$ss = explode(',',($v ?? ''));
 	foreach ($ss AS $s) {
 		$new = array('blur'=>0);
-		$p = explode(' ',trim($s));
-		if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim($p[0]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
-		if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
+		$p = explode(' ',(trim(($s ?? '')) ?? ''));
+		if (isset($p[0])) { $new['x'] = $this->mpdf->ConvertSize(trim(($p[0] ?? '')),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
+		if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim(($p[1] ?? '')),$this->mpdf->FontSize,$this->mpdf->FontSize,false); }
 		if (isset($p[2])) {
-			if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
-				$new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl]['inner_width'],$this->mpdf->FontSize,false); 
-			}
-			else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
+			if (preg_match('/^\s*[\.\-0-9]/',($p[2] ?? ''))) {
+				$new['blur'] = $this->mpdf->ConvertSize(trim(($p[2] ?? '')),$this->mpdf->blk[$this->mpdf->blklvl]['inner_width'],$this->mpdf->FontSize,false); 
+			}
+			else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',($p[2] ?? ''))); }
 			if (isset($p[3])) {
-				$new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3]));
+				$new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',($p[3] ?? '')));
 			}
 		}
 		if (!isset($new['col']) || !$new['col']) { $new['col'] = $this->mpdf->ConvertColor('#888888'); }
@@ -835,37 +841,37 @@
 function parseCSSbackground($s) {
 	$bg = array('c'=>false, 'i'=>false, 'r'=>false, 'p'=>false, );
 /*-- BACKGROUNDS --*/
-	if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$s,$m)) {
+	if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',($s ?? ''),$m)) {
 		$bg['i'] = $m[0];
 	}
 	else
 /*-- END BACKGROUNDS --*/
-	if (preg_match('/url\(/i',$s)) {
+	if (preg_match('/url\(/i',($s ?? ''))) {
 		// If color, set and strip it off
 		// mPDF 5.6.05
-		if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})\s+(url\(.*)/i',$s,$m)) {
-			$bg['c'] = strtolower($m[1]);
+		if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})\s+(url\(.*)/i',($s ?? ''),$m)) {
+			$bg['c'] = strtolower(($m[1] ?? ''));
 			$s = $m[3];
 		}
 /*-- BACKGROUNDS --*/
-		if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) {
+		if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',($s ?? ''),$m)) {
 			$bg['i'] = $m[1];
-			$s = strtolower($m[2]);
-			if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',$s,$m)) { 
+			$s = strtolower(($m[2] ?? ''));
+			if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',($s ?? ''),$m)) { 
 				$bg['r'] = $m[1];
 			}
 			// Remove repeat, attachment (discarded) and also any inherit
-			$s = preg_replace('/(repeat-x|repeat-y|no-repeat|repeat|scroll|fixed|inherit)/','',$s);
-			$bits = preg_split('/\s+/',trim($s));
+			$s = preg_replace('/(repeat-x|repeat-y|no-repeat|repeat|scroll|fixed|inherit)/','',($s ?? ''));
+			$bits = preg_split('/\s+/',(trim(($s ?? '')) ?? ''));
 			// These should be Position x1 or x2
-			if (count($bits)==1) {
-				if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
-				else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
+			if (count(($bits ?? []))==1) {
+				if (preg_match('/bottom/',($bits[0] ?? ''))) { $bg['p'] = '50% 100%'; }
+				else if (preg_match('/top/',($bits[0] ?? ''))) { $bg['p'] = '50% 0%'; }
 				else { $bg['p'] = $bits[0] . ' 50%'; }
 			}
-			else if (count($bits)==2) {
+			else if (count(($bits ?? []))==2) {
 				// Can be either right center or center right
-				if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) { 
+				if (preg_match('/(top|bottom)/',($bits[0] ?? '')) || preg_match('/(left|right)/',($bits[1] ?? ''))) { 
 					$bg['p'] = $bits[1] . ' '.$bits[0]; 
 				}
 				else { 
@@ -873,34 +879,34 @@
 				}
 			}
 			if ($bg['p']) {
-				$bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
-				$bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
-				$bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
-				if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
+				$bg['p'] = preg_replace('/(left|top)/','0%',($bg['p'] ?? ''));
+				$bg['p'] = preg_replace('/(right|bottom)/','100%',($bg['p'] ?? ''));
+				$bg['p'] = preg_replace('/(center)/','50%',($bg['p'] ?? ''));
+				if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',($bg['p'] ?? ''))) {
 					$bg['p'] = false;
 				}
 			}
 		}
 /*-- END BACKGROUNDS --*/
 	}
-	else if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})/i',$s,$m)) { $bg['c'] = strtolower($m[1]); }	// mPDF 5.6.05
+	else if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|device-cmyka|cmyka|device-cmyk|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})/i',($s ?? ''),$m)) { $bg['c'] = strtolower(($m[1] ?? '')); }	// mPDF 5.6.05
 	return ($bg);
 }
 
 
 function expand24($mp) {
-	$prop = preg_split('/\s+/',trim($mp));
-	if (count($prop) == 1 ) { 
+	$prop = preg_split('/\s+/',(trim(($mp ?? '')) ?? ''));
+	if (count(($prop ?? [])) == 1 ) { 
 		return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
 	}
-	if (count($prop) == 2 ) { 
+	if (count(($prop ?? [])) == 2 ) { 
 		return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
 	}
 
-	if (count($prop) == 3 ) { 
+	if (count(($prop ?? [])) == 3 ) { 
 		return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
 	}
-	if (count($prop) == 4 ) { 
+	if (count(($prop ?? [])) == 4 ) { 
 		return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
 	}
 	return array(); 
@@ -910,41 +916,41 @@
 function border_radius_expand($val,$k) {
 	$b = array();
 	if ($k == 'BORDER-RADIUS') {
-		$hv = explode('/',trim($val));
-		$prop = preg_split('/\s+/',trim($hv[0]));
-		if (count($prop)==1) {
+		$hv = explode('/',(trim(($val ?? '')) ?? ''));
+		$prop = preg_split('/\s+/',(trim(($hv[0] ?? '')) ?? ''));
+		if (count(($prop ?? []))==1) {
 			$b['TL-H'] = $b['TR-H'] = $b['BR-H'] = $b['BL-H'] = $prop[0];
 		}
-		else if (count($prop)==2) {
+		else if (count(($prop ?? []))==2) {
 			$b['TL-H'] = $b['BR-H'] = $prop[0];
 			$b['TR-H'] = $b['BL-H'] = $prop[1];
 		}
-		else if (count($prop)==3) {
+		else if (count(($prop ?? []))==3) {
 			$b['TL-H'] = $prop[0];
 			$b['TR-H'] = $b['BL-H'] = $prop[1];
 			$b['BR-H'] = $prop[2];
 		}
-		else if (count($prop)==4) {
+		else if (count(($prop ?? []))==4) {
 			$b['TL-H'] = $prop[0];
 			$b['TR-H'] = $prop[1];
 			$b['BR-H'] = $prop[2];
 			$b['BL-H'] = $prop[3];
 		}
-		if (count($hv)==2) {
-			$prop = preg_split('/\s+/',trim($hv[1]));
-			if (count($prop)==1) {
+		if (count(($hv ?? []))==2) {
+			$prop = preg_split('/\s+/',(trim(($hv[1] ?? '')) ?? ''));
+			if (count(($prop ?? []))==1) {
 				$b['TL-V'] = $b['TR-V'] = $b['BR-V'] = $b['BL-V'] = $prop[0];
 			}
-			else if (count($prop)==2) {
+			else if (count(($prop ?? []))==2) {
 				$b['TL-V'] = $b['BR-V'] = $prop[0];
 				$b['TR-V'] = $b['BL-V'] = $prop[1];
 			}
-			else if (count($prop)==3) {
+			else if (count(($prop ?? []))==3) {
 				$b['TL-V'] = $prop[0];
 				$b['TR-V'] = $b['BL-V'] = $prop[1];
 				$b['BR-V'] = $prop[2];
 			}
-			else if (count($prop)==4) {
+			else if (count(($prop ?? []))==4) {
 				$b['TL-V'] = $prop[0];
 				$b['TR-V'] = $prop[1];
 				$b['BR-V'] = $prop[2];
@@ -963,8 +969,8 @@
 	// Parse 2
 	$h = 0;
 	$v = 0;
-	$prop = preg_split('/\s+/',trim($val));
-	if (count($prop)==1) { $h = $v = $val; }
+	$prop = preg_split('/\s+/',(trim(($val ?? '')) ?? ''));
+	if (count(($prop ?? []))==1) { $h = $v = $val; }
 	else { $h = $prop[0]; $v = $prop[1]; }
 	if ($h==0 || $v==0) { $h = $v = 0; }
 	if ($k == 'BORDER-TOP-LEFT-RADIUS') {
@@ -1001,7 +1007,7 @@
 // for CSS handling
 function array_merge_recursive_unique($array1, $array2) {
     $arrays = func_get_args();
-    $narrays = count($arrays);
+    $narrays = count(($arrays ?? []));
     $ret = $arrays[0];
     for ($i = 1; $i < $narrays; $i ++) {
         foreach ($arrays[$i] as $key => $value) {
@@ -1032,20 +1038,20 @@
 		// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd)  td:nth-child(2n+1)
 		if ($tag=='TR' && isset($p) && $p)  {
 			foreach($p AS $k=>$val) {
-				if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
+				if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',($k ?? ''), $m)) {
 					$select = false;
 					if ($tag=='TR')  {
 						$row = $this->mpdf->row;
-						$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0);
-						$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0);
+						$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'] ?? [])) : 0);
+						$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] ?? [])) : 0);
 						if ($this->mpdf->tabletfoot) { $row -= $thnr; }
 						else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
-						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 							$select = $this->_nthchild($a, $row);
 						}
 					}
 					else if ($tag=='TD' || $tag=='TH')  {
-						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 							$select = $this->_nthchild($a, $this->mpdf->col);
 						}
 					}
@@ -1102,21 +1108,21 @@
   foreach(array('TOP','RIGHT','BOTTOM','LEFT') AS $side) {
     foreach(array('STYLE','WIDTH','COLOR') AS $el) {
 	if (isset($a['BORDER-'.$side.'-'.$el])) {	// e.g. $b['BORDER-TOP-STYLE']
-		$s = trim($a['BORDER-'.$side.'-'.$el]);
+		$s = trim(($a['BORDER-'.$side.'-'.$el] ?? ''));
 		if (isset($b['BORDER-'.$side])) {	// e.g. $b['BORDER-TOP']
-			$p = trim($b['BORDER-'.$side]);
+			$p = trim(($b['BORDER-'.$side] ?? ''));
 		}
 		else { $p = ''; }
 		if ($el=='STYLE') {
-			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 '.$s.' \\3', $p); }
+			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 '.$s.' \\3', ($p ?? '')); }
 			else { $b['BORDER-'.$side] = '0px '.$s.' #000000'; }
 		}
 		else if ($el=='WIDTH') {
-			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', $s.' \\2 \\3', $p); }
+			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', $s.' \\2 \\3', ($p ?? '')); }
 			else { $b['BORDER-'.$side] = $s.' none #000000'; }
 		}
 		else if ($el=='COLOR') {
-			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 \\2 '.$s, $p); }
+			if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 \\2 '.$s, ($p ?? '')); }
 			else { $b['BORDER-'.$side] = '0px none '.$s; }
 		}
 	}
@@ -1126,21 +1132,22 @@
 
 
 function MergeCSS($inherit,$tag,$attr) {
+	$attr = is_array($attr) ? $attr : array();
 	$p = array();
 	$zp = array(); 
 
 	$classes = array();
 	if (isset($attr['CLASS'])) {
-		$classes = preg_split('/\s+/',$attr['CLASS']);
+		$classes = preg_split('/\s+/',($attr['CLASS'] ?? ''));
 	}
 	if (!isset($attr['ID'])) { $attr['ID']=''; }
 	// mPDF 6
 	$shortlang = '';
 	if (!isset($attr['LANG'])) { $attr['LANG']=''; }
 	else { 
-		$attr['LANG'] = strtolower($attr['LANG']); 
-		if (strlen($attr['LANG']) == 5) {
-			$shortlang = substr($attr['LANG'],0,2);
+		$attr['LANG'] = strtolower(($attr['LANG'] ?? '')); 
+		if (strlen(($attr['LANG'] ?? '')) == 5) {
+			$shortlang = substr(($attr['LANG'] ?? ''),0,2);
 		}
 	}
 	//===============================================
@@ -1333,20 +1340,20 @@
 	// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd)  td:nth-child(2n+1)
 	if ($tag=='TR' || $tag=='TD' || $tag=='TH')  {
 		foreach($this->CSS AS $k=>$val) {
-			if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
+			if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',($k ?? ''), $m)) {
 				$select = false;
 				if ($tag=='TR')  {
 					$row = $this->mpdf->row;
-					$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0);
-					$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0);
+					$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'] ?? [])) : 0);
+					$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] ?? [])) : 0);
 					if ($this->mpdf->tabletfoot) { $row -= $thnr; }
 					else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
-					if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+					if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 						$select = $this->_nthchild($a, $row);
 					}
 				}
 				else  if ($tag=='TD' || $tag=='TH')  {
-					if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+					if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 						$select = $this->_nthchild($a, $this->mpdf->col);
 					}
 				}
@@ -1471,20 +1478,20 @@
 		// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd)  td:nth-child(2n+1)
 		if ($tag=='TR' || $tag=='TD' || $tag=='TH')  {
 			foreach($this->tablecascadeCSS[$this->tbCSSlvl-1] AS $k=>$val) {
-				if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
+				if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',($k ?? ''), $m)) {
 					$select = false;
 					if ($tag=='TR')  {
 						$row = $this->mpdf->row;
-						$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) : 0);
-						$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) : 0);
+						$thnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'] ?? [])) : 0);
+						$tfnr = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) ? count(($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] ?? [])) : 0);
 						if ($this->mpdf->tabletfoot) { $row -= $thnr; }
 						else if (!$this->mpdf->tablethead) { $row -= ($thnr + $tfnr); }
-						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 							$select = $this->_nthchild($a, $row);
 						}
 					}
 					else if ($tag=='TD' || $tag=='TH')  {
-						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',$m[1],$a)) {	// mPDF 5.7.4
+						if (preg_match('/(([\-+]?\d*)?N([\-+]\d+)?|[\-+]?\d+|ODD|EVEN)/',($m[1] ?? ''),$a)) {	// mPDF 5.7.4
 							$select = $this->_nthchild($a, $this->mpdf->col);
 						}
 					}
@@ -1580,21 +1587,21 @@
 	if (isset($bilp[ 'OTLtags' ]) && $bilp[ 'OTLtags' ]) {
 		$ffs = array();
 		if (isset($bilp['OTLtags']['Minus']) && $bilp['OTLtags']['Minus']) {
-			$f = preg_split('/\s+/', trim($bilp['OTLtags']['Minus']));
+			$f = preg_split('/\s+/', (trim(($bilp['OTLtags']['Minus'] ?? '')) ?? ''));
 			foreach($f AS $ff) { $ffs[] = "'".$ff."' 0"; }
 		}
 		if (isset($bilp['OTLtags']['FFMinus']) && $bilp['OTLtags']['FFMinus']) {
-			$f = preg_split('/\s+/', trim($bilp['OTLtags']['FFMinus']));
+			$f = preg_split('/\s+/', (trim(($bilp['OTLtags']['FFMinus'] ?? '')) ?? ''));
 			foreach($f AS $ff) { $ffs[] = "'".$ff."' 0"; }
 		}
 		if (isset($bilp['OTLtags']['Plus']) && $bilp['OTLtags']['Plus']) {
-			$f = preg_split('/\s+/', trim($bilp['OTLtags']['Plus']));
+			$f = preg_split('/\s+/', (trim(($bilp['OTLtags']['Plus'] ?? '')) ?? ''));
 			foreach($f AS $ff) { $ffs[] = "'".$ff."' 1"; }
 		}
 		if (isset($bilp['OTLtags']['FFPlus']) && $bilp['OTLtags']['FFPlus']) {	// May contain numeric value e.g. salt4
-			$f = preg_split('/\s+/', trim($bilp['OTLtags']['FFPlus']));
+			$f = preg_split('/\s+/', (trim(($bilp['OTLtags']['FFPlus'] ?? '')) ?? ''));
 			foreach($f AS $ff) { 
-				if (strlen($ff)>4) { $ffs[] = "'".substr($ff,0,4)."' ".substr($ff,4); }
+				if (strlen(($ff ?? ''))>4) { $ffs[] = "'".substr(($ff ?? ''),0,4)."' ".substr(($ff ?? ''),4); }
 				else { $ffs[] = "'".$ff."' 1";  }
 			}
 		}
@@ -1610,7 +1617,7 @@
 	$zp = array(); 
 	$oldcascadeCSS = $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'];
 	$classes = array();
-	if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
+	if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',($attr['CLASS'] ?? '')); }
 	//===============================================
 	// DEFAULT for this TAG set in DefaultCSS
 	if (isset($this->mpdf->defaultCSS[$tag])) { 
@@ -1688,14 +1695,14 @@
 	$a=1;  $b=1;
 	if ($f[0]=='ODD') { $a=2; $b=1; }
 	else if ($f[0]=='EVEN') { $a=2; $b=0; }
-	else if (count($f)==2) { $a=0; $b=$f[1]+0; }		// e.g. (+6) 
-	else if (count($f)==3) {		// e.g. (2N)
+	else if (count(($f ?? []))==2) { $a=0; $b=$f[1]+0; }		// e.g. (+6) 
+	else if (count(($f ?? []))==3) {		// e.g. (2N)
 		if ($f[2]=='') { $a=1; }
 		else if ($f[2]=='-') { $a=-1; }
 		else { $a=$f[2]+0; }
 		$b=0; 
 	}
-	else if (count($f)==4) { 	// e.g. (2N+6)
+	else if (count(($f ?? []))==4) { 	// e.g. (2N+6)
 		if ($f[2]=='') { $a=1; }
 		else if ($f[2]=='-') { $a=-1; }
 		else { $a=$f[2]+0; }
--- a/intranet/mpdf60/classes/svg.php
+++ b/intranet/mpdf60/classes/svg.php
@@ -31,6 +31,12 @@
 // and on returning size
 
 class SVG {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $dashesUsed;
+    public $kf;
+    public $lastcontrolpoints;
+    public $lastcommand;
+
 
 	var $svg_font;		//	array - holds content of SVG fonts defined in image	// mPDF 6
 	var $svg_gradient;	//	array - contient les infos sur les gradient fill du svg classé par id du svg
@@ -67,7 +73,7 @@
 	var $textjuststarted;	// mPDF 5.7.4
 	var $intext;		// mPDF 5.7.4
 
-	function SVG(&$mpdf){
+	function __construct(&$mpdf){
 		$this->svg_font = array();	// mPDF 6
 		$this->svg_gradient = array();
 		$this->svg_shadinglist = array();
@@ -152,7 +158,7 @@
 
      		$srcpath = $attribs['xlink:href'];
 		$orig_srcpath = '';
-		if (trim($srcpath) != '' && substr($srcpath,0,4)=='var:') { 
+		if (trim(($srcpath ?? '')) != '' && substr(($srcpath ?? ''),0,4)=='var:') { 
 			$orig_srcpath = $srcpath;
 			$this->mpdf_ref->GetFullPath($srcpath); 
 		}
@@ -170,7 +176,7 @@
 		$meetOrSlice = 'meet';
 
 		// preserveAspectRatio
-		$ar = preg_split('/\s+/', strtolower($par));
+		$ar = preg_split('/\s+/', (strtolower(($par ?? '')) ?? ''));
 		if ($ar[0]!='none') {	// If "none" need to do nothing
 			//  Force uniform scaling
 			if (isset($ar[1]) && $ar[1]=='slice') { $meetOrSlice = 'slice'; }
@@ -251,7 +257,7 @@
 
 
 	function svgGradient($gradient_info, $attribs, $element){
-		$n = count($this->mpdf_ref->gradients)+1;
+		$n = count(($this->mpdf_ref->gradients ?? []))+1;
 
 		// Get bounding dimensions of element
 		$w = 100;
@@ -277,10 +283,10 @@
 			$y_offset = $attribs['cy']-$attribs['r'];
 		}
 		else if ($element=='polygon') {
-			$pts = preg_split('/[ ,]+/', trim($attribs['points']));
+			$pts = preg_split('/[ ,]+/', (trim(($attribs['points'] ?? '')) ?? ''));
 			$maxr=$maxb=0;
 			$minl=$mint=999999;
-			for ($i=0;$i<count($pts); $i++) {
+			for ($i=0;$i<count(($pts ?? [])); $i++) {
 				if ($i % 2 == 0) {	// x values
 					$minl = min($minl,$pts[$i]);
 					$maxr = max($maxr,$pts[$i]);
@@ -303,15 +309,15 @@
 			$y_offset = $this->pathBBox[1];
 		  }
 		  else {
-			preg_match_all('/([a-z]|[A-Z])([ ,\-.\d]+)*/', $attribs['d'], $commands, PREG_SET_ORDER);
+			preg_match_all('/([a-z]|[A-Z])([ ,\-.\d]+)*/', ($attribs['d'] ?? ''), $commands, PREG_SET_ORDER);
 			$maxr=$maxb=0;
 			$minl=$mint=999999;
 			foreach($commands as $c){
-				if(count($c)==3){
+				if(count(($c ?? []))==3){
 					list($tmp, $cmd, $arg) = $c;
 					if ($cmd=='M' || $cmd=='L' || $cmd=='C' || $cmd=='S' || $cmd=='Q' || $cmd=='T') {
-						$pts = preg_split('/[ ,]+/', trim($arg));
-						for ($i=0;$i<count($pts); $i++) {
+						$pts = preg_split('/[ ,]+/', (trim(($arg ?? '')) ?? ''));
+						for ($i=0;$i<count(($pts ?? [])); $i++) {
 							if ($i % 2 == 0) {	// x values
 								$minl = min($minl,$pts[$i]);
 								$maxr = max($maxr,$pts[$i]);
@@ -346,49 +352,49 @@
 		// TRANSFORMATIONS
 		$transformations = '';
 		if (isset($gradient_info['transform'])){
-			preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',$gradient_info['transform'],$m);
-			if (count($m[0])) {
-				for($i=0; $i<count($m[0]); $i++) {
-					$c = strtolower($m[1][$i]);
-					$v = trim($m[2][$i]);
-					$vv = preg_split('/[ ,]+/',$v);
-					if ($c=='matrix' && count($vv)==6) {
+			preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',($gradient_info['transform'] ?? ''),$m);
+			if (count(($m[0] ?? []))) {
+				for($i=0; $i<count(($m[0] ?? [])); $i++) {
+					$c = strtolower(($m[1][$i] ?? ''));
+					$v = trim(($m[2][$i] ?? ''));
+					$vv = preg_split('/[ ,]+/',($v ?? ''));
+					if ($c=='matrix' && count(($vv ?? []))==6) {
 						// Note angle of rotation is reversed (from SVG to PDF), so vv[1] and vv[2] are negated
 						// cf svgDefineStyle()
 						$transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $vv[0], -$vv[1], -$vv[2], $vv[3], $vv[4]*$this->kp, -$vv[5]*$this->kp);	
 					}
-					else if ($c=='translate' && count($vv)) {
+					else if ($c=='translate' && count(($vv ?? []))) {
 						$tm[4] = $vv[0];
-						if (count($vv)==2) { $t_y = -$vv[1]; }
+						if (count(($vv ?? []))==2) { $t_y = -$vv[1]; }
 						else { $t_y = 0; }
 						$tm[5] = $t_y;
 						$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $tm[4]*$this->kp, $tm[5]*$this->kp);
 					}
-					else if ($c=='scale' && count($vv)) {
-						if (count($vv)==2) { $s_y = $vv[1]; }
+					else if ($c=='scale' && count(($vv ?? []))) {
+						if (count(($vv ?? []))==2) { $s_y = $vv[1]; }
 						else { $s_y = $vv[0]; }
 						$tm[0] = $vv[0];
 						$tm[3] = $s_y;
 						$transformations .= sprintf(' %.3F 0 0 %.3F 0 0 cm ', $tm[0], $tm[3]);
 					}
-					else if ($c=='rotate' && count($vv)) {
+					else if ($c=='rotate' && count(($vv ?? []))) {
 						$tm[0] = cos(deg2rad(-$vv[0]));
 						$tm[1] = sin(deg2rad(-$vv[0]));
 						$tm[2] = -$tm[1];
 						$tm[3] = $tm[0];
-						if (count($vv)==3) {
+						if (count(($vv ?? []))==3) {
 							$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $vv[1]*$this->kp, -$vv[2]*$this->kp);
 						}
 						$transformations .= sprintf(' %.3F %.3F %.3F %.3F 0 0 cm ', $tm[0], $tm[1], $tm[2], $tm[3]);
-						if (count($vv)==3) {
+						if (count(($vv ?? []))==3) {
 							$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', -$vv[1]*$this->kp, $vv[2]*$this->kp);
 						}
 					}
-					else if ($c=='skewx' && count($vv)) {
+					else if ($c=='skewx' && count(($vv ?? []))) {
 						$tm[2] = tan(deg2rad(-$vv[0]));
 						$transformations .= sprintf(' 1 0 %.3F 1 0 0 cm ', $tm[2]);
 					}
-					else if ($c=='skewy' && count($vv)) {
+					else if ($c=='skewy' && count(($vv ?? []))) {
 						$tm[1] = tan(deg2rad(-$vv[0]));
 						$transformations .= sprintf(' 1 %.3F 0 1 0 0 cm ', $tm[1]);
 					}
@@ -400,17 +406,17 @@
 
 		$return = "";
 
-		if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') {
+		if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='userspaceonuse') {
 			if ($transformations) { $return .= $transformations; }
 		}
 		$spread = 'P';  // pad
 		if (isset($gradient_info['spread'])) {
-			if (strtolower($gradient_info['spread'])=='reflect') { $spread = 'F'; } // reflect
-			else if (strtolower($gradient_info['spread'])=='repeat') { $spread = 'R'; } // repeat
+			if (strtolower(($gradient_info['spread'] ?? ''))=='reflect') { $spread = 'F'; } // reflect
+			else if (strtolower(($gradient_info['spread'] ?? ''))=='repeat') { $spread = 'R'; } // repeat
 		}	
 
 
-		for ($i=0; $i<(count($gradient_info['color'])); $i++) {
+		for ($i=0; $i<(count(($gradient_info['color'] ?? []))); $i++) {
 			if (stristr($gradient_info['color'][$i]['offset'], '%')!== false) { $gradient_info['color'][$i]['offset'] = ($gradient_info['color'][$i]['offset']+0)/100; }
 			if (isset($gradient_info['color'][($i+1)]['offset']) && stristr($gradient_info['color'][($i+1)]['offset'], '%')!== false) { $gradient_info['color'][($i+1)]['offset'] = ($gradient_info['color'][($i+1)]['offset']+0)/100; }
 			if ($gradient_info['color'][$i]['offset']<0) { $gradient_info['color'][$i]['offset'] = 0; }
@@ -426,19 +432,19 @@
 			array_unshift($gradient_info['color'], $gradient_info['color'][0]);
 			$gradient_info['color'][0]['offset'] = 0; 
 		}
-		$ns = count($gradient_info['color']);
+		$ns = count(($gradient_info['color'] ?? []));
 		if (isset($gradient_info['color'][($ns-1)]['offset']) && $gradient_info['color'][($ns-1)]['offset']<1) { 
 			$gradient_info['color'][] = $gradient_info['color'][($ns-1)];
 			$gradient_info['color'][($ns)]['offset'] = 1; 
 		}
-		$ns = count($gradient_info['color']);
+		$ns = count(($gradient_info['color'] ?? []));
 
 
 
 
 		if ($gradient_info['type'] == 'linear'){
 			// mPDF 4.4.003
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='userspaceonuse') {
 				if (isset($gradient_info['info']['x1'])) { $gradient_info['info']['x1'] = ($gradient_info['info']['x1']-$x_offset) / $w; }
 				if (isset($gradient_info['info']['y1'])) { $gradient_info['info']['y1'] = ($gradient_info['info']['y1']-$y_offset) / $h; }
 				if (isset($gradient_info['info']['x2'])) { $gradient_info['info']['x2'] = ($gradient_info['info']['x2']-$x_offset) / $w; }
@@ -465,7 +471,7 @@
 			$usey = $y_offset;
 			$usew = $bboxw;
 			$useh = $bboxh;
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='userspaceonuse') {
 				$angle = rad2deg(atan2(($gradient_info['info']['y2']-$gradient_info['info']['y1']), ($gradient_info['info']['x2']-$gradient_info['info']['x1'])));
 				if ($angle < 0) { $angle += 360; }
 				else if ($angle > 360) { $angle -= 360; }
@@ -489,7 +495,7 @@
 
 			$return .= sprintf('%.3F 0 0 %.3F %.3F %.3F cm ', $a*$this->kp, $d*$this->kp, $e*$this->kp, $f*$this->kp);
 
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='objectboundingbox') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='objectboundingbox') {
 				if ($transformations) { $return .= $transformations; }
 			}
 
@@ -581,10 +587,10 @@
 			}
 
 			// Gradient STOPs
-			$stops = count($gradient_info['color']);
+			$stops = count(($gradient_info['color'] ?? []));
 			if ($stops < 2) { return ''; }
 
-			$range = $gradient_info['color'][count($gradient_info['color'])-1]['offset']-$gradient_info['color'][0]['offset'];
+			$range = $gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset']-$gradient_info['color'][0]['offset'];
 			$min = $gradient_info['color'][0]['offset'];
 
 			for ($i=0; $i<($stops); $i++) {
@@ -602,8 +608,8 @@
 			}
 			$grx1 = $x1 + ($x2-$x1)*$gradient_info['color'][0]['offset'];
 			$gry1 = $y1 + ($y2-$y1)*$gradient_info['color'][0]['offset'];
-			$grx2 = $x1 + ($x2-$x1)*$gradient_info['color'][count($gradient_info['color'])-1]['offset'];
-			$gry2 = $y1 + ($y2-$y1)*$gradient_info['color'][count($gradient_info['color'])-1]['offset'];
+			$grx2 = $x1 + ($x2-$x1)*$gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset'];
+			$gry2 = $y1 + ($y2-$y1)*$gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset'];
 
 			$this->mpdf_ref->gradients[$n]['coords']=array($grx1, $gry1, $grx2, $gry2);
 
@@ -621,7 +627,7 @@
 			$return .= " Q\n";
 		}
 		else if ($gradient_info['type'] == 'radial'){
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='userspaceonuse') {
 				if ($w > $h) { $h = $w; }
 				else { $w = $h; }
 				if (isset($gradient_info['info']['x0'])) { $gradient_info['info']['x0'] = ($gradient_info['info']['x0']-$x_offset) / $w; }
@@ -660,7 +666,7 @@
 			$usey = $y_offset;
 			$usew = $bboxw;
 			$useh = $bboxh;
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='userspaceonuse') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='userspaceonuse') {
 				$angle = rad2deg(atan2(($gradient_info['info']['y0']-$gradient_info['info']['y1']), ($gradient_info['info']['x0']-$gradient_info['info']['x1'])));
 				if ($angle < 0) { $angle += 360; }
 				else if ($angle > 360) { $angle -= 360; }
@@ -692,7 +698,7 @@
 			$return .= sprintf('%.3F 0 0 %.3F %.3F %.3F cm ', $a*$this->kp, $d*$this->kp, $e*$this->kp, $f*$this->kp);
 
 			// mPDF 5.0.039
-			if (isset($gradient_info['units']) && strtolower($gradient_info['units'])=='objectboundingbox') {
+			if (isset($gradient_info['units']) && strtolower(($gradient_info['units'] ?? ''))=='objectboundingbox') {
 				if ($transformations) { $return .= $transformations; }
 			}
 
@@ -741,10 +747,10 @@
 			}
 
 			// Gradient STOPs
-			$stops = count($gradient_info['color']);
+			$stops = count(($gradient_info['color'] ?? []));
 			if ($stops < 2) { return ''; }
 
-			$range = $gradient_info['color'][count($gradient_info['color'])-1]['offset']-$gradient_info['color'][0]['offset'];
+			$range = $gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset']-$gradient_info['color'][0]['offset'];
 			$min = $gradient_info['color'][0]['offset'];
 
 			for ($i=0; $i<($stops); $i++) {
@@ -762,10 +768,10 @@
 			}
 			$grx1 = $x1 + ($x0-$x1)*$gradient_info['color'][0]['offset'];
 			$gry1 = $y1 + ($y0-$y1)*$gradient_info['color'][0]['offset'];
-			$grx2 = $x1 + ($x0-$x1)*$gradient_info['color'][count($gradient_info['color'])-1]['offset'];
-			$gry2 = $y1 + ($y0-$y1)*$gradient_info['color'][count($gradient_info['color'])-1]['offset'];
+			$grx2 = $x1 + ($x0-$x1)*$gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset'];
+			$gry2 = $y1 + ($y0-$y1)*$gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset'];
 			$grir = $r*$gradient_info['color'][0]['offset'];
-			$grr = $r*$gradient_info['color'][count($gradient_info['color'])-1]['offset'];
+			$grr = $r*$gradient_info['color'][count(($gradient_info['color'] ?? []))-1]['offset'];
 
 			$this->mpdf_ref->gradients[$n]['coords']=array($grx1, $gry1, $grx2, $gry2, abs($grr), abs($grir)  );
 
@@ -793,8 +799,8 @@
 		// save all <svg> tag attributes
 		$this->svg_attribs = $attribs;
 		if(isset($this->svg_attribs['viewBox'])) {
-			$vb = preg_split('/\s+/is', trim($this->svg_attribs['viewBox']));
-			if (count($vb)==4) {
+			$vb = preg_split('/\s+/is', (trim(($this->svg_attribs['viewBox'] ?? '')) ?? ''));
+			if (count(($vb ?? []))==4) {
 				$this->svg_info['x'] = $vb[0];
 				$this->svg_info['y'] = $vb[1];
 				$this->svg_info['w'] = $vb[2];
@@ -846,8 +852,8 @@
 			if($this->svg_attribs['overflow'] == 'hidden')
 			{
 				// Not sure if this is supposed to strip off units, but since I dont use any I will omlt this step
-				$svg_w = preg_replace("/([0-9\.]*)(.*)/i","$1",$this->svg_attribs['width']);
-				$svg_h = preg_replace("/([0-9\.]*)(.*)/i","$1",$this->svg_attribs['height']);
+				$svg_w = preg_replace("/([0-9\.]*)(.*)/i","$1",($this->svg_attribs['width'] ?? ''));
+				$svg_h = preg_replace("/([0-9\.]*)(.*)/i","$1",($this->svg_attribs['height'] ?? ''));
 				
 				// $xmax = floor($this->svg_attribs['width']);
 				$xmax = floor($svg_w);
@@ -872,7 +878,7 @@
 
 	function svgDefineStyle($critere_style){
 
-		$tmp = count($this->svg_style)-1;
+		$tmp = count(($this->svg_style ?? []))-1;
 		$current_style = $this->svg_style[$tmp];
 
 		unset($current_style['transformations']);
@@ -880,13 +886,13 @@
 		// TRANSFORM SCALE
 		$transformations = '';
 		if (isset($critere_style['transform'])){
-			preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',$critere_style['transform'],$m);
-			if (count($m[0])) {
-				for($i=0; $i<count($m[0]); $i++) {
-					$c = strtolower($m[1][$i]);
-					$v = trim($m[2][$i]);
-					$vv = preg_split('/[ ,]+/',$v);
-					if ($c=='matrix' && count($vv)==6) {
+			preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',($critere_style['transform'] ?? ''),$m);
+			if (count(($m[0] ?? []))) {
+				for($i=0; $i<count(($m[0] ?? [])); $i++) {
+					$c = strtolower(($m[1][$i] ?? ''));
+					$v = trim(($m[2][$i] ?? ''));
+					$vv = preg_split('/[ ,]+/',($v ?? ''));
+					if ($c=='matrix' && count(($vv ?? []))==6) {
 					// mPDF 5.0.039
 						// Note angle of rotation is reversed (from SVG to PDF), so vv[1] and vv[2] are negated
 						$transformations .= sprintf(' %.3F %.3F %.3F %.3F %.3F %.3F cm ', $vv[0], -$vv[1], -$vv[2], $vv[3], $vv[4]*$this->kp, -$vv[5]*$this->kp);
@@ -916,38 +922,38 @@
 */
 
 					}
-					else if ($c=='translate' && count($vv)) {
+					else if ($c=='translate' && count(($vv ?? []))) {
 						$tm[4] = $vv[0];
-						if (count($vv)==2) { $t_y = -$vv[1]; }
+						if (count(($vv ?? []))==2) { $t_y = -$vv[1]; }
 						else { $t_y = 0; }
 						$tm[5] = $t_y;
 						$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $tm[4]*$this->kp, $tm[5]*$this->kp);
 					}
-					else if ($c=='scale' && count($vv)) {
-						if (count($vv)==2) { $s_y = $vv[1]; }
+					else if ($c=='scale' && count(($vv ?? []))) {
+						if (count(($vv ?? []))==2) { $s_y = $vv[1]; }
 						else { $s_y = $vv[0]; }
 						$tm[0] = $vv[0];
 						$tm[3] = $s_y;
 						$transformations .= sprintf(' %.3F 0 0 %.3F 0 0 cm ', $tm[0], $tm[3]);
 					}
-					else if ($c=='rotate' && count($vv)) {
+					else if ($c=='rotate' && count(($vv ?? []))) {
 						$tm[0] = cos(deg2rad(-$vv[0]));
 						$tm[1] = sin(deg2rad(-$vv[0]));
 						$tm[2] = -$tm[1];
 						$tm[3] = $tm[0];
-						if (count($vv)==3) {
+						if (count(($vv ?? []))==3) {
 							$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', $vv[1]*$this->kp, -$vv[2]*$this->kp);
 						}
 						$transformations .= sprintf(' %.3F %.3F %.3F %.3F 0 0 cm ', $tm[0], $tm[1], $tm[2], $tm[3]);
-						if (count($vv)==3) {
+						if (count(($vv ?? []))==3) {
 							$transformations .= sprintf(' 1 0 0 1 %.3F %.3F cm ', -$vv[1]*$this->kp, $vv[2]*$this->kp);
 						}
 					}
-					else if ($c=='skewx' && count($vv)) {
+					else if ($c=='skewx' && count(($vv ?? []))) {
 						$tm[2] = tan(deg2rad(-$vv[0]));
 						$transformations .= sprintf(' 1 0 %.3F 1 0 0 cm ', $tm[2]);
 					}
-					else if ($c=='skewy' && count($vv)) {
+					else if ($c=='skewy' && count(($vv ?? []))) {
 						$tm[1] = tan(deg2rad(-$vv[0]));
 						$transformations .= sprintf(' 1 %.3F 0 1 0 0 cm ', $tm[1]);
 					}
@@ -958,52 +964,52 @@
 		}
 
 		if (isset($critere_style['style'])){
-			if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/i',$critere_style['style'], $m)) {	// mPDF 5.7.2
-				$current_style['fill'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT);
-			}
-			else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']);
+			if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/i',($critere_style['style'] ?? ''), $m)) {	// mPDF 5.7.2
+				$current_style['fill'] = '#'.str_pad((dechex($m[1]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[2]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[3]) ?? ''), 2, "0", STR_PAD_LEFT);
+			}
+			else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 				if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill'] = $tmp; }
 			}
 
 			// mPDF 5.7.2
-			if ((preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m) ||
-				preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m)) && $m[1]!='inherit') {
+			if ((preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",($critere_style['style'] ?? ''), $m) ||
+				preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",($critere_style['style'] ?? ''), $m)) && $m[1]!='inherit') {
 				$current_style['fill-opacity'] = $m[1];
 				$current_style['stroke-opacity'] = $m[1];
 			}
 
-			$tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill-opacity'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['fill-rule'] = $tmp;}
 
-			if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) {
-				$current_style['stroke'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT);
-			}
-			else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',($critere_style['style'] ?? ''), $m)) {
+				$current_style['stroke'] = '#'.str_pad((dechex($m[1]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[2]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[3]) ?? ''), 2, "0", STR_PAD_LEFT);
+			}
+			else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 				if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke'] = $tmp; }
 			}
 			
-			$tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linecap'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;}
 			
-			$tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;}
 			
-			$tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-opacity'] = $tmp; }
 			
-			$tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-width'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp!='inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;}
 
 		}
@@ -1075,7 +1081,7 @@
 		if (substr_count($critere_style['fill'],'url')>0 && $element != 'line'){
 			//
 			// couleur degradé
-			$id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",$critere_style['fill']);
+			$id_gradient = preg_replace("/url\(#([\w_]*)\)/i","$1",($critere_style['fill'] ?? ''));
 			if ($id_gradient != $critere_style['fill']) {
 			   if (isset($this->svg_gradient[$id_gradient])) {
 				$fill_gradient = $this->svgGradient($this->svg_gradient[$id_gradient], $attribs, $element);
@@ -1089,11 +1095,11 @@
 
 		}
 		// Used as indirect setting for currentColor
-		else if (strtolower($critere_style['fill']) == 'currentcolor' && $element != 'line'){
+		else if (strtolower(($critere_style['fill'] ?? '')) == 'currentcolor' && $element != 'line'){
 			$col = $this->mpdf_ref->ConvertColor($critere_style['color']);
 			if ($col) {
-				if ($col{0}==5) {	$critere_style['fill-opacity'] = ord($col{4}/100); }	// RGBa
-				if ($col{0}==6) {	$critere_style['fill-opacity'] = ord($col{5}/100); }	// CMYKa
+				if ($col[0]==5) {	$critere_style['fill-opacity'] = ord(($col[4]/100 ?? '')); }	// RGBa
+				if ($col[0]==6) {	$critere_style['fill-opacity'] = ord(($col[5]/100 ?? '')); }	// CMYKa
 				$path_style .= $this->mpdf_ref->SetFColor($col, true).' ';
 				$style .= 'F';
 			}
@@ -1101,8 +1107,8 @@
 		else if ($critere_style['fill'] != 'none' && $element != 'line'){
 			$col = $this->mpdf_ref->ConvertColor($critere_style['fill']);
 			if ($col) {
-				if ($col{0}==5) {	$critere_style['fill-opacity'] = ord($col{4}/100); }	// RGBa
-				if ($col{0}==6) {	$critere_style['fill-opacity'] = ord($col{5}/100); }	// CMYKa
+				if ($col[0]==5) {	$critere_style['fill-opacity'] = ord(($col[4]/100 ?? '')); }	// RGBa
+				if ($col[0]==6) {	$critere_style['fill-opacity'] = ord(($col[5]/100 ?? '')); }	// CMYKa
 				$path_style .= $this->mpdf_ref->SetFColor($col, true).' ';
 				$style .= 'F';
 			}
@@ -1124,11 +1130,11 @@
 */
 		}
 		// Used as indirect setting for currentColor
-		else if (strtolower($critere_style['stroke']) == 'currentcolor'){
+		else if (strtolower(($critere_style['stroke'] ?? '')) == 'currentcolor'){
 			$col = $this->mpdf_ref->ConvertColor($critere_style['color']);
 			if ($col) {
-				if ($col{0}==5) {	$critere_style['stroke-opacity'] = ord($col{4}/100); }	// RGBa
-				if ($col{0}==6) {	$critere_style['stroke-opacity'] = ord($col{5}/100); }	// CMYKa
+				if ($col[0]==5) {	$critere_style['stroke-opacity'] = ord(($col[4]/100 ?? '')); }	// RGBa
+				if ($col[0]==6) {	$critere_style['stroke-opacity'] = ord(($col[5]/100 ?? '')); }	// CMYKa
 				$path_style .= $this->mpdf_ref->SetDColor($col, true).' ';
 				$style .= 'D';
 				$lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
@@ -1140,8 +1146,8 @@
 			if ($col) {
 				// mPDF 5.0.051
 				// mPDF 5.3.74
-				if ($col{0}==5) {	$critere_style['stroke-opacity'] = ord($col{4}/100); }	// RGBa
-				if ($col{0}==6) {	$critere_style['stroke-opacity'] = ord($col{5}/100); }	// CMYKa
+				if ($col[0]==5) {	$critere_style['stroke-opacity'] = ord(($col[4]/100 ?? '')); }	// RGBa
+				if ($col[0]==6) {	$critere_style['stroke-opacity'] = ord(($col[5]/100 ?? '')); }	// CMYKa
 				$path_style .= $this->mpdf_ref->SetDColor($col, true).' ';
 				$style .= 'D';
 				$lw = $this->ConvertSVGSizePixels($critere_style['stroke-width']);
@@ -1174,20 +1180,20 @@
 		if (isset($critere_style['stroke-miterlimit'])){
 		   if ($critere_style['stroke-miterlimit'] == 'none'){
 		   }
-		   else if (preg_match('/^[\d.]+$/',$critere_style['stroke-miterlimit'])) {
+		   else if (preg_match('/^[\d.]+$/',($critere_style['stroke-miterlimit'] ?? ''))) {
 			$path_style .= sprintf('%.2F M ',$critere_style['stroke-miterlimit']);
 		   }
 		}
 		if (isset($critere_style['stroke-dasharray'])){
 			$off = 0;
-			$d = preg_split('/[ ,]/',$critere_style['stroke-dasharray']);
-			if (count($d) == 1 && $d[0]==0) {
+			$d = preg_split('/[ ,]/',($critere_style['stroke-dasharray'] ?? ''));
+			if (count(($d ?? [])) == 1 && $d[0]==0) {
 				$path_style .= '[] 0 d '; 
 			}
 			else {
-			  if (count($d) % 2 == 1) { $d = array_merge($d, $d); }	// 5, 3, 1 => 5,3,1,5,3,1  OR 3 => 3,3
+			  if (count(($d ?? [])) % 2 == 1) { $d = array_merge($d, $d); }	// 5, 3, 1 => 5,3,1,5,3,1  OR 3 => 3,3
 			  $arr = '';
-			  for($i=0; $i<count($d); $i+=2) {
+			  for($i=0; $i<count(($d ?? [])); $i+=2) {
 				$arr .= sprintf('%.3F %.3F ', $d[$i]*$this->kp, $d[$i+1]*$this->kp);
 			  }
 			  if (isset($critere_style['stroke-dashoffset'])){ $off = $critere_style['stroke-dashoffset'] + 0; }
@@ -1256,18 +1262,18 @@
 
 		$start = array($this->xbase, -$this->ybase);
 
-		preg_match_all('/[\-^]?[\d.]+(e[\-]?[\d]+){0,1}/i', $arguments, $a, PREG_SET_ORDER);
+		preg_match_all('/[\-^]?[\d.]+(e[\-]?[\d]+){0,1}/i', ($arguments ?? ''), $a, PREG_SET_ORDER);
 
 		//	if the command is a capital letter, the coords go absolute, otherwise relative
-		if(strtolower($command) == $command) $relative = true;
+		if(strtolower(($command ?? '')) == $command) $relative = true;
 		else $relative = false;
 
 
-		$ile_argumentow = count($a);
+		$ile_argumentow = count(($a ?? []));
 
 		//	each command may have different needs for arguments [1 to 8]
 
-		switch(strtolower($command)){
+		switch(strtolower(($command ?? ''))){
 			case 'm': // move
 				for($i = 0; $i<$ile_argumentow; $i+=2){
 					$x = $a[$i][0]; 
@@ -1895,7 +1901,7 @@
 			$ybase = - $this->ConvertSVGSizePixels($arguments[1],'y');
 		}
 		$path_cmd = sprintf('%.3F %.3F m ', $xbase*$this->kp, $ybase*$this->kp);
-		for ($i = 2; $i<count($arguments);$i += 2) {
+		for ($i = 2; $i<count(($arguments ?? []));$i += 2) {
 			if ($ispolyline) {
 				$tmp_x = $arguments[$i] ;
 				$tmp_y = - $arguments[($i+1)] ;
@@ -1918,7 +1924,7 @@
 		$xbase = $arguments[0] ;
 		$ybase = - $arguments[1] ;
 		$path_cmd = sprintf('%.3F %.3F m ', $xbase*$this->kp, $ybase*$this->kp);
-		for ($i = 2; $i<count($arguments);$i += 2) {
+		for ($i = 2; $i<count(($arguments ?? []));$i += 2) {
 			$tmp_x = $arguments[$i] ;
 			$tmp_y = - $arguments[($i+1)] ;
 
@@ -1935,7 +1941,7 @@
 	//	write string to image
 	function svgText() {
 		// $tmp = count($this->txt_style)-1;
-		$current_style = $this->txt_style[count($this->txt_style)-1];	// mPDF 5.7.4
+		$current_style = $this->txt_style[count(($this->txt_style ?? []))-1];	// mPDF 5.7.4
 		$style = '';
 		$op = '';
 		$render = -1;
@@ -2010,13 +2016,13 @@
 				$y = $this->txt_data[1];	// mPDF 5.7.4
 				$txt = $this->txt_data[2];
 
-				$txt = preg_replace('/\f/','',$txt); 
-				$txt = preg_replace('/\r/','',$txt); 
-				$txt = preg_replace('/\n/',' ',$txt); 
-				$txt = preg_replace('/\t/',' ',$txt); 
-				$txt = preg_replace("/[ ]+/u",' ',$txt);
-
-				if ($this->textjuststarted) { $txt = ltrim($txt); }		// mPDF 5.7.4
+				$txt = preg_replace('/\f/','',($txt ?? '')); 
+				$txt = preg_replace('/\r/','',($txt ?? '')); 
+				$txt = preg_replace('/\n/',' ',($txt ?? '')); 
+				$txt = preg_replace('/\t/',' ',($txt ?? '')); 
+				$txt = preg_replace("/[ ]+/u",' ',($txt ?? ''));
+
+				if ($this->textjuststarted) { $txt = ltrim(($txt ?? '')); }		// mPDF 5.7.4
 				$this->textjuststarted = false;		// mPDF 5.7.4
 
 				$txt = $this->mpdf_ref->purify_utf8_text($txt);
@@ -2024,13 +2030,13 @@
 					$txt = $this->mpdf_ref->all_entities_to_utf8($txt);
 				}
 
-				$nb=mb_strlen($txt, 'UTF-8');
+				$nb=mb_strlen(($txt ?? ''), 'UTF-8');
 				$i=0;
 				$sw = 0;
 				$subpath_cmd = '';
 				while($i<$nb) {
 					//Get next character
-					$char = mb_substr($txt,$i,1,'UTF-8');
+					$char = mb_substr(($txt ?? ''),$i,1,'UTF-8');
 
 
 					if (isset($svg_font['glyphs'][$char])) {
@@ -2042,13 +2048,13 @@
 						$d = $svg_font['d'];
 						$horiz_adv_x = $svg_font['horiz-adv-x'];	// missing glyph width
 					}
-					preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $d, $commands, PREG_SET_ORDER);
+					preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', ($d ?? ''), $commands, PREG_SET_ORDER);
 					$subpath_cmd .= sprintf('q %.4F 0 0 %.4F mPDF-AXS(%.4F) %.4F cm ', $scale, -$scale, ($x + $sw*$scale)*$this->kp, -$y*$this->kp);
 
 					$this->subPathInit = true;
 					$this->pathBBox = array(999999,999999,-999999,-999999);
 					foreach($commands as $cmd){
-						if(count($cmd)==3 || (isset($cmd[2]) && $cmd[2]=='')){
+						if(count(($cmd ?? []))==3 || (isset($cmd[2]) && $cmd[2]=='')){
 							list($tmp, $command, $arguments) = $cmd;
 						}
 						else{
@@ -2136,13 +2142,13 @@
 			$y = $this->txt_data[1];	// mPDF 5.7.4
 			$txt = $this->txt_data[2];
 
-			$txt = preg_replace('/\f/','',$txt); 
-			$txt = preg_replace('/\r/','',$txt); 
-			$txt = preg_replace('/\n/',' ',$txt); 
-			$txt = preg_replace('/\t/',' ',$txt); 
-			$txt = preg_replace("/[ ]+/u",' ',$txt);
-
-			if ($this->textjuststarted) { $txt = ltrim($txt); }		// mPDF 5.7.4
+			$txt = preg_replace('/\f/','',($txt ?? '')); 
+			$txt = preg_replace('/\r/','',($txt ?? '')); 
+			$txt = preg_replace('/\n/',' ',($txt ?? '')); 
+			$txt = preg_replace('/\t/',' ',($txt ?? '')); 
+			$txt = preg_replace("/[ ]+/u",' ',($txt ?? ''));
+
+			if ($this->textjuststarted) { $txt = ltrim(($txt ?? '')); }		// mPDF 5.7.4
 			$this->textjuststarted = false;		// mPDF 5.7.4
 
 			$txt = $this->mpdf_ref->purify_utf8_text($txt);
@@ -2150,8 +2156,8 @@
 				$txt = $this->mpdf_ref->all_entities_to_utf8($txt);
 			}
 
-			if ($this->mpdf_ref->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mpdf_ref->mb_enc,'UTF-8'); }
-			if (preg_match("/([".$this->mpdf_ref->pregRTLchars."])/u", $txt)) { $this->mpdf_ref->biDirectional = true; }
+			if ($this->mpdf_ref->usingCoreFont) { $txt = mb_convert_encoding(($txt ?? ''),($this->mpdf_ref->mb_enc ?? ''),'UTF-8'); }
+			if (preg_match("/([".$this->mpdf_ref->pregRTLchars."])/u", ($txt ?? ''))) { $this->mpdf_ref->biDirectional = true; }
 
 			$textvar = 0;
 			$save_OTLtags = $this->mpdf_ref->OTLtags;
@@ -2198,7 +2204,7 @@
 		}
 		else { return ' '; }
 		// Reset font	// mPDF 5.7.4
-		$prev_style = $this->txt_style[count($this->txt_style)-1];
+		$prev_style = $this->txt_style[count(($this->txt_style ?? []))-1];
 		$style = '';
 		$style .= ($prev_style['font-weight'] == 'bold')?'B':'';
 		$style .= ($prev_style['font-style'] == 'italic')?'I':'';
@@ -2212,73 +2218,73 @@
 function svgDefineTxtStyle($critere_style)
 {
 		// get copy of current/default txt style, and modify it with supplied attributes
-		$tmp = count($this->txt_style)-1;
+		$tmp = count(($this->txt_style ?? []))-1;
 		$current_style = $this->txt_style[$tmp];
 		if (isset($critere_style['style'])){
-			if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) {
-				$current_style['fill'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT);
-			}
-			else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",$critere_style['style']);
+			if (preg_match('/fill:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',($critere_style['style'] ?? ''), $m)) {
+				$current_style['fill'] = '#'.str_pad((dechex($m[1]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[2]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[3]) ?? ''), 2, "0", STR_PAD_LEFT);
+			}
+			else { $tmp = preg_replace("/(.*)fill:\s*([a-z0-9#_()]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 				if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['fill'] = $tmp; }
 			}
 
 			// mPDF 6
-			if (preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m) ||
-				preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",$critere_style['style'], $m)) {
+			if (preg_match("/[^-]opacity:\s*([a-z0-9.]*|none)/i",($critere_style['style'] ?? ''), $m) ||
+				preg_match("/^opacity:\s*([a-z0-9.]*|none)/i",($critere_style['style'] ?? ''), $m)) {
 				$current_style['fill-opacity'] = $m[1];
 				$current_style['stroke-opacity'] = $m[1];
 			}
 
-			$tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)fill-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['fill-opacity'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)fill-rule:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp != $critere_style['style'] && $tmp!=$critere_style['style']){ $current_style['fill-rule'] = $tmp;}
 
-			if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',$critere_style['style'], $m)) {
-				$current_style['stroke'] = '#'.str_pad(dechex($m[1]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[2]), 2, "0", STR_PAD_LEFT).str_pad(dechex($m[3]), 2, "0", STR_PAD_LEFT);
-			}
-			else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			if (preg_match('/stroke:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/',($critere_style['style'] ?? ''), $m)) {
+				$current_style['stroke'] = '#'.str_pad((dechex($m[1]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[2]) ?? ''), 2, "0", STR_PAD_LEFT).str_pad((dechex($m[3]) ?? ''), 2, "0", STR_PAD_LEFT);
+			}
+			else { $tmp = preg_replace("/(.*)stroke:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 				if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke'] = $tmp; }
 			}
 			
-			$tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-linecap:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linecap'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-linejoin:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-linejoin'] = $tmp;}
 			
-			$tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-miterlimit:\s*([a-z0-9#]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-miterlimit'] = $tmp;}
 			
-			$tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-opacity:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-opacity'] = $tmp; }
 			
-			$tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-width:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-width'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-dasharray:\s*([a-z0-9., ]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dasharray'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)stroke-dashoffset:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $current_style['stroke-dashoffset'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.\"' ,\-]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)font-family:\s*([a-z0-9.\"' ,\-]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-family'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)font-size:\s*([a-z0-9.]*|none)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-size'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)font-weight:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)font-weight:\s*([a-z0-9.]*|normal)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-weight'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)font-style:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)font-style:\s*([a-z0-9.]*|normal)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-style'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)font-variant:\s*([a-z0-9.]*|normal)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)font-variant:\s*([a-z0-9.]*|normal)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['font-variant'] = $tmp;}
 
-			$tmp = preg_replace("/(.*)text-anchor:\s*(start|middle|end)(.*)/i","$2",$critere_style['style']);
+			$tmp = preg_replace("/(.*)text-anchor:\s*(start|middle|end)(.*)/i","$2",($critere_style['style'] ?? ''));
 			if ($tmp && $tmp != 'inherit' && $tmp!=$critere_style['style']){ $critere_style['text-anchor'] = $tmp;}
 
 		}
@@ -2286,14 +2292,14 @@
 
 			// [ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]?<'font-size'> [ / <'line-height'> ]? <'font-family'> ]
 
-			$tmp = preg_replace("/(.*)(italic|oblique)(.*)/i","$2",$critere_style['font']);
+			$tmp = preg_replace("/(.*)(italic|oblique)(.*)/i","$2",($critere_style['font'] ?? ''));
 			if ($tmp != $critere_style['font']){ 
 				if($tmp == 'oblique'){
 					$tmp = 'italic';
 				}
 				$current_style['font-style'] = $tmp;
 			}
-			$tmp = preg_replace("/(.*)(bold|bolder)(.*)/i","$2",$critere_style['font']);
+			$tmp = preg_replace("/(.*)(bold|bolder)(.*)/i","$2",($critere_style['font'] ?? ''));
 			if ($tmp != $critere_style['font']){ 
 				if($tmp == 'bolder'){
 					$tmp = 'bold';
@@ -2301,13 +2307,13 @@
 				$current_style['font-weight'] = $tmp;
 			}
 			
-			$tmp = preg_replace("/(.*)(small\-caps)(.*)/i","$2",$critere_style['font']);
+			$tmp = preg_replace("/(.*)(small\-caps)(.*)/i","$2",($critere_style['font'] ?? ''));
 			if ($tmp != $critere_style['font']){ 
 				$current_style['font-variant'] = $tmp;
 			}
 			
 			// select digits not followed by percent sign nor preceeded by forward slash
-			$tmp = preg_replace("/(.*)\b(\d+)[\b|\/](.*)/i","$2",$critere_style['font']);
+			$tmp = preg_replace("/(.*)\b(\d+)[\b|\/](.*)/i","$2",($critere_style['font'] ?? ''));
 			if ($tmp != $critere_style['font']){ 
 				$current_style['font-size'] = $this->ConvertSVGSizePts($tmp); 
 				$this->mpdf_ref->SetFont('','',$current_style['font-size'],false);
@@ -2339,7 +2345,7 @@
 		}
 		
 		if(isset($critere_style['font-style']) && $critere_style['font-style']!='inherit'){
-			if(strtolower($critere_style['font-style']) == 'oblique') 
+			if(strtolower(($critere_style['font-style'] ?? '')) == 'oblique') 
 			{
 				$critere_style['font-style'] = 'italic';
 			}
@@ -2347,7 +2353,7 @@
 		}
 		
 		if(isset($critere_style['font-weight']) && $critere_style['font-weight']!='inherit'){
-			if(strtolower($critere_style['font-weight']) == 'bolder')
+			if(strtolower(($critere_style['font-weight'] ?? '')) == 'bolder')
 			{
 				$critere_style['font-weight'] = 'bold';
 			}
@@ -2359,7 +2365,7 @@
 		}
 		
 		if(isset($critere_style['font-size']) && $critere_style['font-size']!='inherit'){
-			if (strpos($critere_style['font-size'], '%')!==false) {
+			if (strpos(($critere_style['font-size'] ?? ''), '%')!==false) {
 				$current_style['font-size-parent'] = $current_style['font-size'];
 			}
 			$current_style['font-size'] = $this->ConvertSVGSizePts($critere_style['font-size']);
@@ -2368,7 +2374,7 @@
 
 		if(isset($critere_style['font-family']) && $critere_style['font-family']!='inherit'){
 			$v = $critere_style['font-family'];
-			$aux_fontlist = explode(",",$v);
+			$aux_fontlist = explode(",",($v ?? ''));
 			$found = 0;
 
 			$svgfontstyle = 'R';
@@ -2377,10 +2383,10 @@
 			$svgfontstyle .= (isset($current_style['font-variant']) && $current_style['font-variant'] == 'small-caps')?'S':'';
 
 			foreach($aux_fontlist AS $f) {
-				$fonttype = trim($f);
-				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-				$fonttype = preg_replace('/ /','',$fonttype);
-				$v = strtolower(trim($fonttype));
+				$fonttype = trim(($f ?? ''));
+				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+				$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+				$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 				if (isset($this->mpdf_ref->fonttrans[$v]) && $this->mpdf_ref->fonttrans[$v]) { $v = $this->mpdf_ref->fonttrans[$v]; }
 				if ((!$this->mpdf_ref->usingCoreFont && in_array($v,$this->mpdf_ref->available_unifonts)) || 
 					($this->mpdf_ref->usingCoreFont && in_array($v,array('courier','times','helvetica','arial'))) || 
@@ -2392,10 +2398,10 @@
 			}
 			if (!$found) {
 			   foreach($aux_fontlist AS $f) {
-				$fonttype = trim($f);
-				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
-				$fonttype = preg_replace('/ /','',$fonttype);
-				$v = strtolower(trim($fonttype));
+				$fonttype = trim(($f ?? ''));
+				$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',($fonttype ?? ''));
+				$fonttype = preg_replace('/ /','',($fonttype ?? ''));
+				$v = strtolower((trim(($fonttype ?? '')) ?? ''));
 				if (isset($this->mpdf_ref->fonttrans[$v]) && $this->mpdf_ref->fonttrans[$v]) { $v = $this->mpdf_ref->fonttrans[$v]; }
 				if (in_array($v,$this->mpdf_ref->sans_fonts) || in_array($v,$this->mpdf_ref->serif_fonts) || in_array($v,$this->mpdf_ref->mono_fonts)  || isset($this->svg_font[$v][$svgfontstyle ])) { 	// mPDF 6
 					$current_style['font-family'] = $v; 
@@ -2447,12 +2453,12 @@
 		//$data = preg_replace('/<!DOCTYPE.*?  >/is', '', $data);
 		//$data = preg_replace('/<\?xml.*?  >/is', '', $data);
 
-		$data = preg_replace('/^.*?<svg([> ])/is', '<svg\\1', $data);	// mPDF 5.7.4
-
-		$data = preg_replace('/<!--.*?-->/is', '', $data);	// mPDF 5.7.4
+		$data = preg_replace('/^.*?<svg([> ])/is', '<svg\\1', ($data ?? ''));	// mPDF 5.7.4
+
+		$data = preg_replace('/<!--.*?-->/is', '', ($data ?? ''));	// mPDF 5.7.4
 
 		// Converts < to &lt; when not a tag
-		$data = preg_replace('/<([^!?\/a-zA-Z_:])/i','&lt;\\1',$data );	// mPDF 5.7.4
+		$data = preg_replace('/<([^!?\/a-zA-Z_:])/i','&lt;\\1',($data ?? '') );	// mPDF 5.7.4
 
 		if (_SVG_AUTOFONT) { $data = $this->markScriptToLang($data); }
 
@@ -2462,67 +2468,67 @@
 		$last_svg_fontdefw = '';	// mPDF 6
 		$last_svg_fontstyle = '';	// mPDF 6
 
-		if (preg_match('/<!ENTITY/si',$data)) {
+		if (preg_match('/<!ENTITY/si',($data ?? ''))) {
 			// Get User-defined entities
-			preg_match_all('/<!ENTITY\s+([a-z]+)\s+\"(.*?)\">/si',$data, $ent);
+			preg_match_all('/<!ENTITY\s+([a-z]+)\s+\"(.*?)\">/si',($data ?? ''), $ent);
 			// Replace entities
-			for ($i=0; $i<count($ent[0]); $i++) {
-				$data = preg_replace('/&'.preg_quote($ent[1][$i],'/').';/is', $ent[2][$i], $data);
-			}
-		}
-
-		if (preg_match('/xlink:href\s*=/si',$data)) {
+			for ($i=0; $i<count(($ent[0] ?? [])); $i++) {
+				$data = preg_replace('/&'.preg_quote(($ent[1][$i] ?? ''),'/').';/is', ($ent[2][$i] ?? ''), ($data ?? ''));
+			}
+		}
+
+		if (preg_match('/xlink:href\s*=/si',($data ?? ''))) {
 			// GRADIENTS
 			// Get links
-			preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href\s*=\s*["\']#(.*?)["\'](.*?)\/>/si',$data, $links);
-			if (count($links[0])) { $links[5] = array(); }
+			preg_match_all('/(<(linearGradient|radialgradient)[^>]*)xlink:href\s*=\s*["\']#(.*?)["\'](.*?)\/>/si',($data ?? ''), $links);
+			if (count(($links[0] ?? []))) { $links[5] = array(); }
 			// Delete links from data - keeping in $links
-			for ($i=0; $i<count($links[0]); $i++) {
+			for ($i=0; $i<count(($links[0] ?? [])); $i++) {
 				$links[5][$i] = 'tmpLink'.RAND(100000,9999999);
-				$data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', '<MYLINKS'.$links[5][$i].'>' , $data);
+				$data = preg_replace('/'.preg_quote(($links[0][$i] ?? ''),'/').'/is', '<MYLINKS'.$links[5][$i].'>' , ($data ?? ''));
 			}
 			// Get targets
-			preg_match_all('/<(linearGradient|radialgradient)([^>]*)id\s*=\s*["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',$data, $m);
+			preg_match_all('/<(linearGradient|radialgradient)([^>]*)id\s*=\s*["\'](.*?)["\'](.*?)>(.*?)<\/(linearGradient|radialgradient)>/si',($data ?? ''), $m);
 			$targets = array();
 			$stops = array();
 			// keeping in $targets
-			for ($i=0; $i<count($m[0]); $i++) {
+			for ($i=0; $i<count(($m[0] ?? [])); $i++) {
 				$stops[$m[3][$i]] = $m[5][$i];
 			}
 			// Add back links this time as targets (gradients)
-			for ($i=0; $i<count($links[0]); $i++) {
+			for ($i=0; $i<count(($links[0] ?? [])); $i++) {
 				$def = $links[1][$i] .' '.$links[4][$i].'>'. $stops[$links[3][$i]].'</'.$links[2][$i] .'>' ;
-				$data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', $def , $data);
+				$data = preg_replace('/<MYLINKS'.$links[5][$i].'>/is', ($def ?? '') , ($data ?? ''));
 			}
 
 			// mPDF 5.7.4
 			// <TREF>
-			preg_match_all('/<tref ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',$data, $links);
-			for ($i=0; $i<count($links[0]); $i++) {
+			preg_match_all('/<tref ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',($data ?? ''), $links);
+			for ($i=0; $i<count(($links[0] ?? [])); $i++) {
 
 				// Get the item to use from defs
 				$insert = '';
-				if (preg_match('/<text [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>(.*?)<\/text>/si',$data, $m)) {
+				if (preg_match('/<text [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>(.*?)<\/text>/si',($data ?? ''), $m)) {
 					$insert = $m[1]; 
 				}
 				if ($insert) {
-					$data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $insert, $data);
+					$data = preg_replace('/'.preg_quote(($links[0][$i] ?? ''),'/').'/is', ($insert ?? ''), ($data ?? ''));
 				}
 			}
 
 			// mPDF 5.7.2
 			// <USE>
-			preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',$data, $links);
-			for ($i=0; $i<count($links[0]); $i++) {
+			preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)\/>/si',($data ?? ''), $links);
+			for ($i=0; $i<count(($links[0] ?? [])); $i++) {
 
 				// Get the item to use from defs
 				$insert = '';
-				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) {
+				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',($data ?? ''), $m)) {
 					$insert = $m[0]; 
 				}
-				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',$data, $m)) {
-
-					if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) {
+				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',($data ?? ''), $m)) {
+
+					if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',($data ?? ''), $m)) {
 						$insert = $m[0]; 
 					}
 				}
@@ -2531,23 +2537,23 @@
 
 					$inners = $links[1][$i] . ' ' . $links[3][$i];
 					// Change x,y coords to translate()
-					if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; }
+					if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) { $y = $m[1]; }
 					else { $y = 0; }
-					if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; }
+					if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) { $x = $m[1]; }
 					else { $x = 0; }
 					if ($x || $y) {
-						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners);
-						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
-							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
+						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', ($inners ?? ''));
+						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) {
+							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', ($m[1] ?? ''), $mm)) {
 								$transform = $m[1];	// transform="...."
 								$x += $mm[1];
 								$y += $mm[2];
-								$transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform);
+								$transform = preg_replace('/'.preg_quote(($mm[0] ?? ''),'/').'/', '', ($transform ?? ''));
 								$transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"';
-								$inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners);
+								$inners = preg_replace('/'.preg_quote(($m[0] ?? ''),'/').'/is', ($transform ?? ''), ($inners ?? ''));
 							}
 							else {
-								$inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners);
+								$inners = preg_replace('/'.preg_quote(($m[0] ?? ''),'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', ($inners ?? ''));
 							}
 						}
 						else {
@@ -2556,19 +2562,19 @@
 					}
 				}
 				$replacement = '<g '.$inners.'>'.$insert.'</g>';
-				$data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data);
-			}
-			preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)>\s*<\/use>/si',$data, $links);
-			for ($i=0; $i<count($links[0]); $i++) {
+				$data = preg_replace('/'.preg_quote(($links[0][$i] ?? ''),'/').'/is', ($replacement ?? ''), ($data ?? ''));
+			}
+			preg_match_all('/<use ([^>]*)xlink:href\s*=\s*["\']#([^>]*?)["\']([^>]*)>\s*<\/use>/si',($data ?? ''), $links);
+			for ($i=0; $i<count(($links[0] ?? [])); $i++) {
 
 				// Get the item to use from defs
 				$insert = '';
-				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',$data, $m)) {
+				if (preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*\/>/si',($data ?? ''), $m)) {
 					$insert = $m[0]; 
 				}
-				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',$data, $m)) {
-
-					if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',$data, $m)) {
+				if (!$insert && preg_match('/<([a-zA-Z]*) [^>]*id\s*=\s*["\']'.$links[2][$i].'["\']/si',($data ?? ''), $m)) {
+
+					if (preg_match('/<'.$m[1].'[^>]*id\s*=\s*["\']'.$links[2][$i].'["\'][^>]*>.*?<\/'.$m[1].'>/si',($data ?? ''), $m)) {
 						$insert = $m[0]; 
 					}
 				}
@@ -2577,23 +2583,23 @@
 
 					$inners = $links[1][$i] . ' ' . $links[3][$i];
 					// Change x,y coords to translate()
-					if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $y = $m[1]; }
+					if (preg_match('/y\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) { $y = $m[1]; }
 					else { $y = 0; }
-					if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) { $x = $m[1]; }
+					if (preg_match('/x\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) { $x = $m[1]; }
 					else { $x = 0; }
 					if ($x || $y) {
-						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', $inners);
-						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', $inners, $m)) {
-							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', $m[1], $mm)) {
+						$inners = preg_replace('/(y|x)\s*=\s*["\']([^>]*?)["\']/', '', ($inners ?? ''));
+						if (preg_match('/transform\s*=\s*["\']([^>]*?)["\']/', ($inners ?? ''), $m)) {
+							if (preg_match('/translate\(\s*([0-9\.]+)\s*,\s*([0-9\.]+)\s*\)/', ($m[1] ?? ''), $mm)) {
 								$transform = $m[1];	// transform="...."
 								$x += $mm[1];
 								$y += $mm[2];
-								$transform = preg_replace('/'.preg_quote($mm[0],'/').'/', '', $transform);
+								$transform = preg_replace('/'.preg_quote(($mm[0] ?? ''),'/').'/', '', ($transform ?? ''));
 								$transform = 'transform="'.$transform.' translate('.$x.', '.$y.')"';
-								$inners = preg_replace('/'.preg_quote($m[0],'/').'/is', $transform, $inners);
+								$inners = preg_replace('/'.preg_quote(($m[0] ?? ''),'/').'/is', ($transform ?? ''), ($inners ?? ''));
 							}
 							else {
-								$inners = preg_replace('/'.preg_quote($m[0],'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', $inners);
+								$inners = preg_replace('/'.preg_quote(($m[0] ?? ''),'/').'/is', 'transform="'.$m[1].' translate('.$x.', '.$y.')"', ($inners ?? ''));
 							}
 						}
 						else {
@@ -2601,7 +2607,7 @@
 						}
 					}
 					$replacement = '<g '.$inners.'>'.$insert.'</g>';
-					$data = preg_replace('/'.preg_quote($links[0][$i],'/').'/is', $replacement, $data);
+					$data = preg_replace('/'.preg_quote(($links[0][$i] ?? ''),'/').'/is', ($replacement ?? ''), ($data ?? ''));
 
 
 				}
@@ -2609,9 +2615,9 @@
 		}
 
 		// Removes <pattern>
-		$data = preg_replace('/<pattern.*?<\/pattern>/is', '', $data);
+		$data = preg_replace('/<pattern.*?<\/pattern>/is', '', ($data ?? ''));
 		// Removes <marker>
-		$data = preg_replace('/<marker.*?<\/marker>/is', '', $data);
+		$data = preg_replace('/<marker.*?<\/marker>/is', '', ($data ?? ''));
 
 		$this->svg_info['data'] = $data;
 
@@ -2627,7 +2633,7 @@
 				global $svg_class, $last_gradid, $last_svg_fontid, $last_svg_fontdefw, $last_svg_fontstyle;	// mPDF 6
 
 				// mPDF 6
-				if (strtolower($name) == 'font'){
+				if (strtolower(($name ?? '')) == 'font'){
 					$last_svg_fontid = '';
 					if (isset($attribs['horiz-adv-x']) && $attribs['horiz-adv-x']) {
 						$last_svg_fontdefw = $attribs['horiz-adv-x'];
@@ -2635,7 +2641,7 @@
 					return;
 				}
 				// mPDF 6
-				else if (strtolower($name) == 'font-face'){
+				else if (strtolower(($name ?? '')) == 'font-face'){
 					$last_svg_fontstyle = 'R';
 					$last_svg_fontstyle .= (isset($attribs['font-weight']) && $attribs['font-weight'] == 'bold')?'B':'';
 					$last_svg_fontstyle .= (isset($attribs['font-style']) && $attribs['font-style'] == 'italic')?'I':'';
@@ -2647,7 +2653,7 @@
 							'd' => '',
 							'glyphs' => array()
 						);
-						$last_svg_fontid = strtolower($attribs['font-family']);
+						$last_svg_fontid = strtolower(($attribs['font-family'] ?? ''));
 						if ($last_svg_fontdefw) { $tmp_svg_font['horiz-adv-x'] = $last_svg_fontdefw; }
 						else { $tmp_svg_font['horiz-adv-x'] = 500; }
 						$svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle] = $tmp_svg_font;
@@ -2655,7 +2661,7 @@
 					return;
 				}
 				// mPDF 6
-				else if (strtolower($name) == 'missing-glyph'){
+				else if (strtolower(($name ?? '')) == 'missing-glyph'){
 					if ($last_svg_fontid && isset($attribs['horiz-adv-x'])) {
 						$svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['horiz-adv-x'] = (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : '');
 						$svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['d'] = (isset($attribs['d']) ? $attribs['d'] : '');
@@ -2663,7 +2669,7 @@
 					return;
 				}
 				// mPDF 6
-				else if (strtolower($name) == 'glyph'){
+				else if (strtolower(($name ?? '')) == 'glyph'){
 					if ($last_svg_fontid && isset($attribs['unicode'])) {
 						$svg_class->svg_font[$last_svg_fontid][$last_svg_fontstyle]['glyphs'][$attribs['unicode']] = array(
 							'horiz-adv-x' => (isset($attribs['horiz-adv-x']) ? $attribs['horiz-adv-x'] : $last_svg_fontdefw),
@@ -2673,7 +2679,7 @@
 					return;
 				}
 				// mPDF 5.7.2
-				else if (strtolower($name) == 'lineargradient'){
+				else if (strtolower(($name ?? '')) == 'lineargradient'){
 						$tmp_gradient = array(
 							'type' => 'linear',
 							'transform' => (isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : ''),
@@ -2689,7 +2695,7 @@
 						$svg_class->svgAddGradient($attribs['id'],$tmp_gradient);
 					return;
 				}
-				else if (strtolower($name) == 'radialgradient'){
+				else if (strtolower(($name ?? '')) == 'radialgradient'){
 						$tmp_gradient = array(
 							'type' => 'radial',
 							'transform' => (isset($attribs['gradientTransform']) ? $attribs['gradientTransform'] : ''),
@@ -2706,40 +2712,40 @@
 						$svg_class->svgAddGradient($attribs['id'],$tmp_gradient);
 					return;
 				}
-				else if (strtolower($name) == 'stop'){
-						if (!$last_gradid) break;
+				else if (strtolower(($name ?? '')) == 'stop'){
+						if (!$last_gradid) return;
 						$color = '#000000';
-						if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',$attribs['style'],$m)) {
-							$color = trim($m[1]);
+						if (isset($attribs['style']) AND preg_match('/stop-color:\s*([^;]*)/i',($attribs['style'] ?? ''),$m)) {
+							$color = trim(($m[1] ?? ''));
 						} else if (isset($attribs['stop-color']) && $attribs['stop-color']) {
 							$color = $attribs['stop-color'];
 						}
 						$col = $svg_class->mpdf_ref->ConvertColor($color);
 						if (!$col) { $col = $svg_class->mpdf_ref->ConvertColor('#000000'); }	// In case "transparent" or "inherit" returned
-						if ($col{0}==3 || $col{0}==5) {	// RGB
-							$color_final = sprintf('%.3F %.3F %.3F',ord($col{1})/255,ord($col{2})/255,ord($col{3})/255);
+						if ($col[0]==3 || $col[0]==5) {	// RGB
+							$color_final = sprintf('%.3F %.3F %.3F',ord(($col[1] ?? ''))/255,ord(($col[2] ?? ''))/255,ord(($col[3] ?? ''))/255);
 							$svg_class->svg_gradient[$last_gradid]['colorspace']='RGB';
 						}
-						else if ($col{0}==4 || $col{0}==6) {	// CMYK
-							$color_final = sprintf('%.3F %.3F %.3F %.3F',ord($col{1})/100,ord($col{2})/100,ord($col{3})/100,ord($col{4})/100);
+						else if ($col[0]==4 || $col[0]==6) {	// CMYK
+							$color_final = sprintf('%.3F %.3F %.3F %.3F',ord(($col[1] ?? ''))/100,ord(($col[2] ?? ''))/100,ord(($col[3] ?? ''))/100,ord(($col[4] ?? ''))/100);
 							$svg_class->svg_gradient[$last_gradid]['colorspace']='CMYK';
 						}
-						else if ($col{0}==1) {	// Grayscale
-							$color_final = sprintf('%.3F',ord($col{1})/255);
+						else if ($col[0]==1) {	// Grayscale
+							$color_final = sprintf('%.3F',ord(($col[1] ?? ''))/255);
 							$svg_class->svg_gradient[$last_gradid]['colorspace']='Gray';
 						}
 
 						$stop_opacity = 1;
-						if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',$attribs['style'],$m)) {
+						if (isset($attribs['style']) AND preg_match('/stop-opacity:\s*([0-9.]*)/i',($attribs['style'] ?? ''),$m)) {
 							$stop_opacity = $m[1];
 						} else if (isset($attribs['stop-opacity'])) {
 							$stop_opacity = $attribs['stop-opacity'];
 						}
-						else if ($col{0}==5) {	// RGBa
-							$stop_opacity = ord($col{4}/100);
-						}
-						else if ($col{0}==6) {	// CMYKa
-							$stop_opacity = ord($col{5}/100);
+						else if ($col[0]==5) {	// RGBa
+							$stop_opacity = ord(($col[4]/100 ?? ''));
+						}
+						else if ($col[0]==6) {	// CMYKa
+							$stop_opacity = ord(($col[5]/100 ?? ''));
 						}
 
 						$tmp_color = array(
@@ -2754,7 +2760,7 @@
 
 				$svg_class->xbase = 0;
 				$svg_class->ybase = 0;
-				switch (strtolower($name)){
+				switch (strtolower(($name ?? ''))){
 
 		 		// Don't output stuff inside <defs>
 				case 'defs':
@@ -2767,12 +2773,12 @@
 
 				case 'path':
 					$path = $attribs['d'];
-					preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $path, $commands, PREG_SET_ORDER);
+					preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', ($path ?? ''), $commands, PREG_SET_ORDER);
 					$path_cmd = '';
 					$svg_class->subPathInit = true;
 					$svg_class->pathBBox = array(999999,999999,-999999,-999999);
 					foreach($commands as $c){
-						if((isset($c) && count($c)==3) || (isset($c[2]) && $c[2]=='')){
+						if((isset($c) && count(($c ?? []))==3) || (isset($c[2]) && $c[2]=='')){
 							list($tmp, $command, $arguments) = $c;
 						}
 						else{
@@ -2851,9 +2857,9 @@
 
 				case 'polyline':
 					$path = $attribs['points'];
-					preg_match_all('/[0-9\-\.]*/',$path, $tmp, PREG_SET_ORDER);
+					preg_match_all('/[0-9\-\.]*/',($path ?? ''), $tmp, PREG_SET_ORDER);
 					$arguments = array();
-					for ($i=0;$i<count($tmp);$i++){
+					for ($i=0;$i<count(($tmp ?? []));$i++){
 						if ($tmp[$i][0] !=''){
 							array_push($arguments, $tmp[$i][0]);
 						}
@@ -2866,9 +2872,9 @@
 
 				case 'polygon':
 					$path = $attribs['points'];
-					preg_match_all('/([\-]*[0-9\.]+)/',$path, $tmp);
+					preg_match_all('/([\-]*[0-9\.]+)/',($path ?? ''), $tmp);
 					$arguments = array();
-					for ($i=0;$i<count($tmp[0]);$i++){
+					for ($i=0;$i<count(($tmp[0] ?? []));$i++){
 						if ($tmp[0][$i] !=''){
 							array_push($arguments, $tmp[0][$i]);
 						}
@@ -2918,12 +2924,12 @@
 
 						$styl = '';
 						if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) {
-							$classes = preg_split('/\s+/',trim($attribs['class']));
+							$classes = preg_split('/\s+/',(trim(($attribs['class'] ?? '')) ?? ''));
 							foreach($classes AS $class) {
-								if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)])) {
-									$c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)];
+								if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper(($class ?? ''))])) {
+									$c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper(($class ?? ''))];
 									foreach($c AS $prop=>$val) {
-										$styl .= strtolower($prop).':'.$val.';';
+										$styl .= strtolower(($prop ?? '')).':'.$val.';';
 									}
 								}
 							}
@@ -2961,7 +2967,7 @@
 						unset($critere_style['x'], $critere_style['y']);
 						$svg_class->svgDefineTxtStyle($critere_style);
 
-						$svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style)-1]['text-anchor'];	// mPDF 5.7.4
+						$svg_class->textanchor = $svg_class->txt_style[count(($svg_class->txt_style ?? []))-1]['text-anchor'];	// mPDF 5.7.4
 						$svg_class->textXorigin = $svg_class->txt_data[0];		// mPDF 5.7.4
 						$svg_class->textYorigin = $svg_class->txt_data[1];		// mPDF 5.7.4
 						$svg_class->textjuststarted = true;		// mPDF 5.7.4
@@ -2974,17 +2980,17 @@
 					// OUTPUT CHUNK(s) UP To NOW (svgText updates $svg_class->textlength)
 					$p_cmd = $svg_class->svgText();
 					$svg_class->textoutput .= $p_cmd;
-					$tmp = count($svg_class->svg_style)-1;
+					$tmp = count(($svg_class->svg_style ?? []))-1;
 					$current_style = $svg_class->svg_style[$tmp];
 
 					$styl = '';
 					if (_SVG_CLASSES && isset($attribs['class']) && $attribs['class']) {
-						$classes = preg_split('/\s+/',trim($attribs['class']));
+						$classes = preg_split('/\s+/',(trim(($attribs['class'] ?? '')) ?? ''));
 						foreach($classes AS $class) {
-							if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)])) {
-								$c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper($class)];
+							if (isset($svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper(($class ?? ''))])) {
+								$c = $svg_class->mpdf_ref->cssmgr->CSS['CLASS>>'.strtoupper(($class ?? ''))];
 								foreach($c AS $prop=>$val) {
-									$styl .= strtolower($prop).':'.$val.';';
+									$styl .= strtolower(($prop ?? '')).':'.$val.';';
 								}
 							}
 						}
@@ -3015,13 +3021,13 @@
 						if ($svg_class->textanchor == 'end') { $tx = -$svg_class->texttotallength; }
 						else if ($svg_class->textanchor == 'middle') { $tx = -$svg_class->texttotallength/2; }
 						else { $tx = 0; }
-						while(preg_match('/mPDF-AXS\((.*?)\)/',$svg_class->textoutput,$m)) {
+						while(preg_match('/mPDF-AXS\((.*?)\)/',($svg_class->textoutput ?? ''),$m)) {
 							if ($tx) { 
 								$txk = $m[1] + ($tx*$svg_class->kp);
-								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk) ,$svg_class->textoutput,1);
+								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', (sprintf('%.4F', $txk) ?? '') ,($svg_class->textoutput ?? ''),1);
 							}
 							else {
-								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',$svg_class->textoutput,1);
+								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',($svg_class->textoutput ?? ''),1);
 							}
 						}
 
@@ -3043,7 +3049,7 @@
 						unset($critere_style['x'], $critere_style['y']);
 						$svg_class->svgDefineTxtStyle($critere_style);
 
-						$svg_class->textanchor = $svg_class->txt_style[count($svg_class->txt_style)-1]['text-anchor'];
+						$svg_class->textanchor = $svg_class->txt_style[count(($svg_class->txt_style ?? []))-1]['text-anchor'];
 						$svg_class->textXorigin = $x;
 						$svg_class->textYorigin = $y;
 
@@ -3079,7 +3085,7 @@
 				//insertion des path et du style dans le flux de donné general.
 				if (isset($path_cmd) && $path_cmd) {
 					// mPDF 5.0
-					list($prestyle,$poststyle) = $svg_class->svgStyle($path_style, $attribs, strtolower($name));
+					list($prestyle,$poststyle) = $svg_class->svgStyle($path_style, $attribs, strtolower(($name ?? '')));
 					if (isset($path_style['transformations']) && $path_style['transformations']) {	// transformation on an element
 						$svg_class->svgWriteString(" q ".$path_style['transformations']. $prestyle . $path_cmd . $poststyle . " Q\n");
 					}
@@ -3121,7 +3127,7 @@
 							$svg_class->textoutput .= $p_cmd;
 						}
 
-						$tmp = count($svg_class->svg_style)-1;
+						$tmp = count(($svg_class->svg_style ?? []))-1;
 						$current_style = $svg_class->svg_style[$tmp];
 						if ($current_style['transformations']) {
 							// If in the middle of <text> element, add to textoutput, else WriteString
@@ -3148,10 +3154,10 @@
 						$last_gradid = '';
 						break;
 					case "text":
-						$svg_class->txt_data[2] = rtrim($svg_class->txt_data[2]);	// mPDF 5.7.4
+						$svg_class->txt_data[2] = rtrim(($svg_class->txt_data[2] ?? ''));	// mPDF 5.7.4
 						$path_cmd = $svg_class->svgText();
 						$svg_class->textoutput .= $path_cmd;	// mPDF 5.7.4
-						$tmp = count($svg_class->svg_style)-1;
+						$tmp = count(($svg_class->svg_style ?? []))-1;
 						$current_style = $svg_class->svg_style[$tmp];
 						if ($current_style['transformations']) {
 							$svg_class->textoutput .= " Q\n";	// mPDF 5.7.4
@@ -3164,13 +3170,13 @@
 						if ($svg_class->textanchor == 'end') { $tx = -$svg_class->texttotallength; }
 						else if ($svg_class->textanchor == 'middle') { $tx = -$svg_class->texttotallength/2; }
 						else { $tx = 0; }
-						while(preg_match('/mPDF-AXS\((.*?)\)/',$svg_class->textoutput,$m)) {
+						while(preg_match('/mPDF-AXS\((.*?)\)/',($svg_class->textoutput ?? ''),$m)) {
 							if ($tx) { 
 								$txk = $m[1] + ($tx*$svg_class->kp);
-								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', sprintf('%.4F', $txk) ,$svg_class->textoutput,1);
+								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/', (sprintf('%.4F', $txk) ?? '') ,($svg_class->textoutput ?? ''),1);
 							}
 							else {
-								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',$svg_class->textoutput,1);
+								$svg_class->textoutput = preg_replace('/mPDF-AXS\((.*?)\)/','\\1',($svg_class->textoutput ?? ''),1);
 							}
 						}
 
@@ -3185,7 +3191,7 @@
 					case "tspan":
 						$p_cmd = $svg_class->svgText();
 						$svg_class->textoutput .= $p_cmd;
-						$tmp = count($svg_class->svg_style)-1;
+						$tmp = count(($svg_class->svg_style ?? []))-1;
 						$current_style = $svg_class->svg_style[$tmp];
 						if ($current_style['transformations']) {
 							$svg_class->textoutput .= " Q\n";
@@ -3240,7 +3246,7 @@
 	}
 
 	$n = '';
-	$a=preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+	$a=preg_split('/<(.*?)>/ms',($html ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 	foreach($a as $i => $e) {
 	   if($i%2==0) {
 		$e = strcode2utf($e);
@@ -3280,7 +3286,7 @@
 		// Move common script from end of x to start of x+1
 		for($sch=0;$sch<$subchunk;$sch++) {
 			if ($scriptblocks[$sch] > 0 && $scriptblocks[$sch] != $this->mpdf_ref->baseScript && $scriptblocks[$sch+1] == $this->mpdf_ref->baseScript) {
-				$end = count($chardata[$sch])-1;
+				$end = count(($chardata[$sch] ?? []))-1;
 				while($chardata[$sch][$end]['script'] == 0 && $end > 1) {	// common script
 					$tmp = array_pop($chardata[$sch]);
 					array_unshift($chardata[$sch+1],$tmp);
@@ -3293,33 +3299,33 @@
 		for($sch=0;$sch<=$subchunk;$sch++) {
 		   if (isset($chardata[$sch])) { 
 			$s = '';
-			for ($j=0;$j<count($chardata[$sch]);$j++) {
+			for ($j=0;$j<count(($chardata[$sch] ?? []));$j++) {
 				$s.=code2utf($chardata[$sch][$j]['uni']);
 			}
 			// ZZZ99 Undo lesser_entity_decode as above - but only for <>&
- 			$s = str_replace("&","&amp;",$s);
- 			$s = str_replace("<","&lt;",$s);
- 			$s = str_replace(">","&gt;",$s);
-
-			if (substr($a[$i-1],0,5)!='<text' && substr($a[$i-1],0,5)!='<tspa') { continue; }	// <tspan> or <text> only
+ 			$s = str_replace("&","&amp;",($s ?? ''));
+ 			$s = str_replace("<","&lt;",($s ?? ''));
+ 			$s = str_replace(">","&gt;",($s ?? ''));
+
+			if (substr(($a[$i-1] ?? ''),0,5)!='<text' && substr(($a[$i-1] ?? ''),0,5)!='<tspa') { continue; }	// <tspan> or <text> only
 
 			$lang = '';
 			// Check Vietnamese if Latin script - even if Basescript
-			if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->mpdf_ref->autoVietnamese && preg_match("/([".$this->viet."])/u", $s)) {
+			if ($scriptblocks[$sch] == UCDN::SCRIPT_LATIN && $this->mpdf_ref->autoVietnamese && preg_match("/([".$this->viet."])/u", ($s ?? ''))) {
 				$lang="vi";
 			}
 			// Check Arabic for different languages if Arabic script - even if Basescript
 			else if ($scriptblocks[$sch] == UCDN::SCRIPT_ARABIC && $this->mpdf_ref->autoArabic) {
-				if (preg_match("/[".$this->sindhi ."]/u", $s) ) {
+				if (preg_match("/[".$this->sindhi ."]/u", ($s ?? '')) ) {
 					$lang="sd";
 				}
-				else if (preg_match("/[".$this->urdu ."]/u", $s) ) {
+				else if (preg_match("/[".$this->urdu ."]/u", ($s ?? '')) ) {
 					$lang="ur";
 				}
-				else if (preg_match("/[".$this->pashto ."]/u", $s) ) {
+				else if (preg_match("/[".$this->pashto ."]/u", ($s ?? '')) ) {
 					$lang="ps";
 				}
-				else if (preg_match("/[".$this->persian ."]/u", $s) ) {
+				else if (preg_match("/[".$this->persian ."]/u", ($s ?? '')) ) {
 					$lang="fa";
 				}
 				else if ($this->mpdf_ref->baseScript != UCDN::SCRIPT_ARABIC  && isset($this->script2lang[$scriptblocks[$sch]])) {
--- a/intranet/mpdf60/classes/bmp.php
+++ b/intranet/mpdf60/classes/bmp.php
@@ -4,7 +4,7 @@
 
 var $mpdf = null;
 
-function bmp(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 }
 
@@ -13,20 +13,20 @@
 	$info = array();
 		// Adapted from script by Valentin Schmidt
 		// http://staff.dasdeck.de/valentin/fpdf/fpdf_bmp/
-		$bfOffBits=$this->_fourbytes2int_le(substr($data,10,4));
-		$width=$this->_fourbytes2int_le(substr($data,18,4));
-		$height=$this->_fourbytes2int_le(substr($data,22,4));
+		$bfOffBits=$this->_fourbytes2int_le(substr(($data ?? ''),10,4));
+		$width=$this->_fourbytes2int_le(substr(($data ?? ''),18,4));
+		$height=$this->_fourbytes2int_le(substr(($data ?? ''),22,4));
 		$flip = ($height<0);
 		if ($flip) $height =-$height;
-		$biBitCount=$this->_twobytes2int_le(substr($data,28,2));
-		$biCompression=$this->_fourbytes2int_le(substr($data,30,4)); 
+		$biBitCount=$this->_twobytes2int_le(substr(($data ?? ''),28,2));
+		$biCompression=$this->_fourbytes2int_le(substr(($data ?? ''),30,4)); 
 		$info = array('w'=>$width, 'h'=>$height);
 		if ($biBitCount<16){
 			$info['cs'] = 'Indexed';
 			$info['bpc'] = $biBitCount;
-			$palStr = substr($data,54,($bfOffBits-54));
+			$palStr = substr(($data ?? ''),54,($bfOffBits-54));
 			$pal = '';
-			$cnt = strlen($palStr)/4;
+			$cnt = strlen(($palStr ?? ''))/4;
 			for ($i=0;$i<$cnt;$i++){
 				$n = 4*$i;
 				$pal .= $palStr[$n+2].$palStr[$n+1].$palStr[$n];
@@ -43,7 +43,7 @@
 			return array('error' => "BMP Image cannot be converted to suitable colour space - ".$file." - (Image replaced by 'no-image'.)"); 
 		}
 
-		$biXPelsPerMeter=$this->_fourbytes2int_le(substr($data,38,4));	// horizontal pixels per meter, usually set to zero
+		$biXPelsPerMeter=$this->_fourbytes2int_le(substr(($data ?? ''),38,4));	// horizontal pixels per meter, usually set to zero
 		//$biYPelsPerMeter=$this->_fourbytes2int_le(substr($data,42,4));	// vertical pixels per meter, usually set to zero
 		$biXPelsPerMeter=round($biXPelsPerMeter/1000 *25.4);
 		//$biYPelsPerMeter=round($biYPelsPerMeter/1000 *25.4);
@@ -51,13 +51,13 @@
 
 		switch ($biCompression){
 		  case 0:
-			$str = substr($data,$bfOffBits);
+			$str = substr(($data ?? ''),$bfOffBits);
 			break;
 		  case 1: # BI_RLE8
-			$str = $this->rle8_decode(substr($data,$bfOffBits), $width);
+			$str = $this->rle8_decode(substr(($data ?? ''),$bfOffBits), $width);
 			break;
 		  case 2: # BI_RLE4
-			$str = $this->rle4_decode(substr($data,$bfOffBits), $width);
+			$str = $this->rle4_decode(substr(($data ?? ''),$bfOffBits), $width);
 			break;
 		}
 		$bmpdata = '';
@@ -89,18 +89,18 @@
 				for ($y=0;$y<$height;$y++){
 					$y0 = $y*$w_row;
 					for ($x=0;$x<$width;$x++){
-						$n = (ord( $str[$y0 + 2*$x + 1])*256 +    ord( $str[$y0 + 2*$x]));
+						$n = (ord( ($str[$y0 + 2*$x + 1] ?? ''))*256 +    ord( ($str[$y0 + 2*$x] ?? '')));
 						$b = ($n & 31)<<3; $g = ($n & 992)>>2; $r = ($n & 31744)>>7128;
-						$bmpdata .= chr($r) . chr($g) . chr($b);
+						$bmpdata .= chr((int) ($r)) . chr((int) ($g)) . chr((int) ($b));
 					}
 				}
 			}else{
 				for ($y=$height-1;$y>=0;$y--){
 					$y0 = $y*$w_row;
 					for ($x=0;$x<$width;$x++){
-						$n = (ord( $str[$y0 + 2*$x + 1])*256 +    ord( $str[$y0 + 2*$x]));
+						$n = (ord( ($str[$y0 + 2*$x + 1] ?? ''))*256 +    ord( ($str[$y0 + 2*$x] ?? '')));
 						$b = ($n & 31)<<3; $g = ($n & 992)>>2; $r = ($n & 31744)>>7;
-						$bmpdata .= chr($r) . chr($g) . chr($b);
+						$bmpdata .= chr((int) ($r)) . chr((int) ($g)) . chr((int) ($b));
 					}
 				}
 			}
@@ -144,12 +144,12 @@
 
 function _fourbytes2int_le($s) {
 	//Read a 4-byte integer from string
-	return (ord($s[3])<<24) + (ord($s[2])<<16) + (ord($s[1])<<8) + ord($s[0]);
+	return (ord(($s[3] ?? ''))<<24) + (ord(($s[2] ?? ''))<<16) + (ord(($s[1] ?? ''))<<8) + ord(($s[0] ?? ''));
 }
 
 function _twobytes2int_le($s) {
 	//Read a 2-byte integer from string
-	return (ord(substr($s, 1, 1))<<8) + ord(substr($s, 0, 1));
+	return (ord((substr(($s ?? ''), 1, 1) ?? ''))<<8) + ord((substr(($s ?? ''), 0, 1) ?? ''));
 }
 
 
@@ -158,33 +158,33 @@
 function rle8_decode ($str, $width){
     $lineWidth = $width + (3 - ($width-1) % 4);
     $out = '';
-    $cnt = strlen($str);
+    $cnt = strlen(($str ?? ''));
     for ($i=0;$i<$cnt;$i++){
-        $o = ord($str[$i]);
+        $o = ord(($str[$i] ?? ''));
         switch ($o){
             case 0: # ESCAPE
                 $i++;
-                switch (ord($str[$i])){
+                switch (ord(($str[$i] ?? ''))){
                     case 0: # NEW LINE
-                         $padCnt = $lineWidth - strlen($out)%$lineWidth;
-                        if ($padCnt<$lineWidth) $out .= str_repeat(chr(0), $padCnt); # pad line
+                         $padCnt = $lineWidth - strlen(($out ?? ''))%$lineWidth;
+                        if ($padCnt<$lineWidth) $out .= str_repeat((chr(0) ?? ''), $padCnt); # pad line
                         break;
                     case 1: # END OF FILE
-                        $padCnt = $lineWidth - strlen($out)%$lineWidth;
-                        if ($padCnt<$lineWidth) $out .= str_repeat(chr(0), $padCnt); # pad line
+                        $padCnt = $lineWidth - strlen(($out ?? ''))%$lineWidth;
+                        if ($padCnt<$lineWidth) $out .= str_repeat((chr(0) ?? ''), $padCnt); # pad line
                          break 3;
                     case 2: # DELTA
                         $i += 2;
                         break;
                     default: # ABSOLUTE MODE
-                        $num = ord($str[$i]);
+                        $num = ord(($str[$i] ?? ''));
                         for ($j=0;$j<$num;$j++)
                             $out .= $str[++$i];
                         if ($num % 2) $i++;
              }
                 break;
             default:
-                $out .= str_repeat($str[++$i], $o);
+                $out .= str_repeat(($str[++$i] ?? ''), $o);
         }
     }
     return $out;
@@ -196,29 +196,29 @@
     $w = floor($width/2) + ($width % 2);
     $lineWidth = $w + (3 - ( ($width-1) / 2) % 4);    
     $pixels = array();
-    $cnt = strlen($str);
+    $cnt = strlen(($str ?? ''));
     for ($i=0;$i<$cnt;$i++){
-        $o = ord($str[$i]);
+        $o = ord(($str[$i] ?? ''));
         switch ($o){
             case 0: # ESCAPE
                 $i++;
-                switch (ord($str[$i])){
+                switch (ord(($str[$i] ?? ''))){
                     case 0: # NEW LINE                        
-                        while (count($pixels)%$lineWidth!=0)
+                        while (count(($pixels ?? []))%$lineWidth!=0)
                             $pixels[]=0;
                         break;
                     case 1: # END OF FILE
-                        while (count($pixels)%$lineWidth!=0)
+                        while (count(($pixels ?? []))%$lineWidth!=0)
                             $pixels[]=0;
                         break 3;
                     case 2: # DELTA
                         $i += 2;
                         break;
                     default: # ABSOLUTE MODE
-                        $num = ord($str[$i]);
+                        $num = ord(($str[$i] ?? ''));
                         for ($j=0;$j<$num;$j++){
                             if ($j%2==0){
-                                $c = ord($str[++$i]);
+                                $c = ord(($str[++$i] ?? ''));
                               $pixels[] = ($c & 240)>>4;
                              } else
                               $pixels[] = $c & 15;
@@ -227,17 +227,17 @@
              }
                 break;
             default:
-                $c = ord($str[++$i]);
+                $c = ord(($str[++$i] ?? ''));
                 for ($j=0;$j<$o;$j++)
                     $pixels[] = ($j%2==0 ? ($c & 240)>>4 : $c & 15);
         }
     }
     
     $out = '';
-    if (count($pixels)%2) $pixels[]=0;
-    $cnt = count($pixels)/2;
+    if (count(($pixels ?? []))%2) $pixels[]=0;
+    $cnt = count(($pixels ?? []))/2;
     for ($i=0;$i<$cnt;$i++)
-        $out .= chr(16*$pixels[2*$i] + $pixels[2*$i+1]);
+        $out .= chr((int) (16*$pixels[2*$i] + $pixels[2*$i+1]));
     return $out;
 } 
 
--- a/intranet/mpdf60/classes/ttfontsuni.php
+++ b/intranet/mpdf60/classes/ttfontsuni.php
@@ -43,12 +43,25 @@
 // mPDF 5.7.1
 if(!function_exists('unicode_hex')){ 
 	function unicode_hex($unicode_dec) {
-		return (sprintf("%05s", strtoupper(dechex($unicode_dec))));
+		return (sprintf("%05s", strtoupper((dechex($unicode_dec) ?? ''))));
 	}
 }
 
 
 class TTFontFile {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $version;
+    public $fontRevision;
+    public $restrictedUse;
+    public $GSUBFeatures;
+    public $GSUBLookups;
+    public $glyphIDtoUni;
+    public $glyphToChar;
+    public $GSLuCoverage;
+    public $LuCoverage;
+    public $codeToGlyph;
+    public $glyphdata;
+
 
 var $GPOSFeatures;	// mPDF 5.7.1
 var $GPOSLookups;		// mPDF 5.7.1
@@ -119,7 +132,7 @@
 var $haskernGPOS;
 var $hassmallcapsGSUB;
 
-	function TTFontFile() {
+	function __construct() {
 		$this->maxStrLenRead = 200000;	// Maximum size of glyf table to read in as string (otherwise reads each glyph from file)
 	}
 
@@ -208,7 +221,7 @@
             	$table = $this->get_chunk($t['offset'], $t['length']);
             	$checksum = $this->calcChecksum($table);
             	if ($t['tag'] == 'head') {
-				$up = unpack('n*', substr($table,8,4));
+				$up = unpack('n*', substr(($table ?? ''),8,4));
 				$adjustment[0] = $up[1];
 				$adjustment[1] = $up[2];
             		$checksum = $this->sub32($checksum, $adjustment);
@@ -234,13 +247,13 @@
 	}
 
 	function calcChecksum($data)  {
-		if (strlen($data) % 4) { $data .= str_repeat("\0",(4-(strlen($data) % 4))); }
-		$len = strlen($data);
+		if (strlen(($data ?? '')) % 4) { $data .= str_repeat("\0",(4-(strlen(($data ?? '')) % 4))); }
+		$len = strlen(($data ?? ''));
 		$hi=0x0000;
 		$lo=0x0000;
 		for($i=0;$i<$len;$i+=4) {
-			$hi += (ord($data[$i])<<8) + ord($data[$i+1]);
-			$lo += (ord($data[$i+2])<<8) + ord($data[$i+3]);
+			$hi += (ord(($data[$i] ?? ''))<<8) + ord(($data[$i+1] ?? ''));
+			$lo += (ord(($data[$i+2] ?? ''))<<8) + ord(($data[$i+3] ?? ''));
 			$hi += ($lo >> 16) & 0xFFFF;
 			$lo = $lo & 0xFFFF;
 		}
@@ -280,7 +293,7 @@
 	function read_short() {
 		$this->_pos += 2;
 		$s = fread($this->fh,2);
-		$a = (ord($s[0])<<8) + ord($s[1]);
+		$a = (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -288,7 +301,7 @@
 	}
 
 	function unpack_short($s) {
-		$a = (ord($s[0])<<8) + ord($s[1]);
+		$a = (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -298,27 +311,27 @@
 	function read_ushort() {
 		$this->_pos += 2;
 		$s = fread($this->fh,2);
-		return (ord($s[0])<<8) + ord($s[1]);
+		return (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 	}
 
 	function read_ulong() {
 		$this->_pos += 4;
 		$s = fread($this->fh,4);
 		// if large uInt32 as an integer, PHP converts it to -ve
-		return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); // 	16777216  = 1<<24
+		return (ord(($s[0] ?? ''))*16777216) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? '')); // 	16777216  = 1<<24
 	}
 
 	function get_ushort($pos) {
 		fseek($this->fh,$pos);
 		$s = fread($this->fh,2);
-		return (ord($s[0])<<8) + ord($s[1]);
+		return (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 	}
 
 	function get_ulong($pos) {
 		fseek($this->fh,$pos);
 		$s = fread($this->fh,4);
 		// iF large uInt32 as an integer, PHP converts it to -ve
-		return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); // 	16777216  = 1<<24
+		return (ord(($s[0] ?? ''))*16777216) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? '')); // 	16777216  = 1<<24
 	}
 
 	function pack_short($val) {
@@ -331,7 +344,7 @@
 	}
 
 	function splice($stream, $offset, $value) {
-		return substr($stream,0,$offset) . $value . substr($stream,$offset+strlen($value));
+		return substr(($stream ?? ''),0,$offset) . $value . substr(($stream ?? ''),$offset+strlen(($value ?? '')));
 	}
 
 	function _set_ushort($stream, $offset, $value) {
@@ -497,7 +510,7 @@
 			$string_data_offset = $name_offset + $this->read_ushort();
 			$names = array(1=>'',2=>'',3=>'',4=>'',6=>'');
 			$K = array_keys($names);
-			$nameCount = count($names);
+			$nameCount = count(($names ?? []));
 			for ($i=0;$i<$numRecords; $i++) {
 				$platformId = $this->read_ushort();
 				$encodingId = $this->read_ushort();
@@ -516,7 +529,7 @@
 					$N = '';
 					while ($length > 0) {
 						$char = $this->read_ushort();
-						$N .= (chr($char));
+						$N .= (chr((int) ($char)));
 						$length -= 1;
 					}
 					$this->_pos = $opos;
@@ -537,19 +550,19 @@
 			if ($names[6])
 				$psName = $names[6];
 			else if ($names[4])
-				$psName = preg_replace('/ /','-',$names[4]);
+				$psName = preg_replace('/ /','-',($names[4] ?? ''));
 			else if ($names[1])
-				$psName = preg_replace('/ /','-',$names[1]);
+				$psName = preg_replace('/ /','-',($names[1] ?? ''));
 			else
 				$psName = '';
 			if (!$psName)
 				die("Could not find PostScript font name: ".$this->filename);
 			// CHECK IF psName valid (PadaukBook contains illegal characters in Name ID 6 i.e. Postscript Name)
 			$psNameInvalid = false;
-			for ($i=0;$i<count($psName);$i++) {
+			for ($i=0;$i<count(($psName ?? []));$i++) {
 				$c = $psName[$i];
-				$oc = ord($c);
-				if ($oc>126 || strpos(' [](){}<>/%',$c)!==false) {
+				$oc = ord(($c ?? ''));
+				if ($oc>126 || strpos(' [](){}<>/%',($c ?? ''))!==false) {
 					//die("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));
 					$psNameInvalid = true;
 					break;
@@ -557,7 +570,7 @@
 			}
 
 			if ($psNameInvalid && $names[4])
-				$psName = preg_replace('/ /','-',$names[4]);
+				$psName = preg_replace('/ /','-',($names[4] ?? ''));
 
 
 			$this->name = $psName;
@@ -647,7 +660,7 @@
 			$this->_pos += 10;  //PANOSE = 10 byte length
 			$panose = fread($this->fh,10);
 			$this->panose = array();
-			for ($p=0;$p<strlen($panose);$p++) { $this->panose[] = ord($panose[$p]); }
+			for ($p=0;$p<strlen(($panose ?? ''));$p++) { $this->panose[] = ord(($panose[$p] ?? '')); }
 			//$this->skip(26);
 			// mPDF 6
 			$this->skip(20);
@@ -920,9 +933,9 @@
 					$char = $glyphToChar[$gid][0];
 
 					if ($char != 0 && $char != 65535) {
-						$this->glyphIDtoUni[$gid*3] = chr($char >> 16);
-						$this->glyphIDtoUni[$gid*3 + 1] = chr(($char >> 8) & 0xFF);
-						$this->glyphIDtoUni[$gid*3 + 2] = chr($char & 0xFF);
+						$this->glyphIDtoUni[$gid*3] = chr((int) ($char >> 16));
+						$this->glyphIDtoUni[$gid*3 + 1] = chr((int) (($char >> 8) & 0xFF));
+						$this->glyphIDtoUni[$gid*3 + 2] = chr((int) ($char & 0xFF));
 					}
 				}
 			}
@@ -1000,7 +1013,7 @@
 				$left = $this->read_ushort();
 				$right = $this->read_ushort();
 				$val = $this->read_short();
-				if (count($glyphToChar[$left])==1 && count($glyphToChar[$right])==1) {
+				if (count(($glyphToChar[$left] ?? []))==1 && count(($glyphToChar[$right] ?? []))==1) {
 				  if ($left != 32 && $right != 32) {
 					$this->kerninfo[$glyphToChar[$left][0]][$glyphToChar[$right][0]] = intval($val*$scale);
 				  }
@@ -1043,16 +1056,16 @@
 			}
 			else { $GlyphByClass = array(); }
 
-			if (isset($GlyphByClass[1]) && count($GlyphByClass[1])>0) { $this->GlyphClassBases = ' '.implode('| ',$GlyphByClass[1]); }
+			if (isset($GlyphByClass[1]) && count(($GlyphByClass[1] ?? []))>0) { $this->GlyphClassBases = ' '.implode('| ',$GlyphByClass[1]); }
 			else { $this->GlyphClassBases = ''; }
-			if (isset($GlyphByClass[2]) && count($GlyphByClass[2])>0) { $this->GlyphClassLigatures = ' '.implode('| ',$GlyphByClass[2]); }
+			if (isset($GlyphByClass[2]) && count(($GlyphByClass[2] ?? []))>0) { $this->GlyphClassLigatures = ' '.implode('| ',$GlyphByClass[2]); }
 			else { $this->GlyphClassLigatures = ''; }
-			if (isset($GlyphByClass[3]) && count($GlyphByClass[3])>0) { $this->GlyphClassMarks = ' '.implode('| ',$GlyphByClass[3]); }
+			if (isset($GlyphByClass[3]) && count(($GlyphByClass[3] ?? []))>0) { $this->GlyphClassMarks = ' '.implode('| ',$GlyphByClass[3]); }
 			else { $this->GlyphClassMarks = ''; }
-			if (isset($GlyphByClass[4]) && count($GlyphByClass[4])>0) { $this->GlyphClassComponents = ' '.implode('| ',$GlyphByClass[4]); }
+			if (isset($GlyphByClass[4]) && count(($GlyphByClass[4] ?? []))>0) { $this->GlyphClassComponents = ' '.implode('| ',$GlyphByClass[4]); }
 			else { $this->GlyphClassComponents = ''; }
 
-			if (isset($GlyphByClass[3]) && count($GlyphByClass[3])>0) { $Marks = $GlyphByClass[3]; } // to use for MarkAttachmentType 
+			if (isset($GlyphByClass[3]) && count(($GlyphByClass[3] ?? []))>0) { $Marks = $GlyphByClass[3]; } // to use for MarkAttachmentType 
 			else { $Marks = array(); }
 			
 
@@ -1095,7 +1108,7 @@
 				$MarkAttachmentTypes = $this->_getClassDefinitionTable();
 				foreach($MarkAttachmentTypes AS $class=>$glyphs) {
 
-					if (is_array($Marks) && count($Marks)) {
+					if (is_array($Marks) && count(($Marks ?? []))) {
 						$mat = array_diff($Marks, $MarkAttachmentTypes[$class]);
 						sort($mat, SORT_STRING);
 					}
@@ -1664,7 +1677,7 @@
 					if ($Lookup[$i]['Type'] == 1) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage(false);
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = unicode_hex($this->glyphToChar[$glyphs[$g]][0]);
@@ -1684,13 +1697,13 @@
 					else if ($Lookup[$i]['Type'] == 2) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage();
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = $glyphs[$g];
 							// Flag = Ignore
 							if ($this->_checkGSUBignore($Lookup[$i]['Flag'], $replace[0], $Lookup[$i]['MarkFilteringSet'])) { continue; }
-if (!isset($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID']) || count($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'])==0) { continue; }	// Illegal for GlyphCount to be 0; either error in font, or something has gone wrong - lets carry on for now!
+if (!isset($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID']) || count(($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'] ?? []))==0) { continue; }	// Illegal for GlyphCount to be 0; either error in font, or something has gone wrong - lets carry on for now!
 							foreach($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'] AS $sub) {
 								$substitute[] = unicode_hex($this->glyphToChar[$sub][0]);
 							}
@@ -1701,7 +1714,7 @@
 					else if ($Lookup[$i]['Type'] == 3) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage();
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = $glyphs[$g];
@@ -1978,14 +1991,14 @@
 					$rtl = array();
 					$rtlSUB = "array()";
 					$finals = '';
-					if (strpos('arab syrc hebr thaa nko  samr', $st)!==false) {	// all RTL scripts [any/all languages] ? Mandaic
+					if (strpos('arab syrc hebr thaa nko  samr', ($st ?? ''))!==false) {	// all RTL scripts [any/all languages] ? Mandaic
 //print_r($volt); exit;
 						foreach($volt AS $v) {
 							// isol fina fin2 fin3 medi med2 for Syriac
 							// ISOLATED FORM :: FINAL :: INITIAL :: MEDIAL :: MED2 :: FIN2 :: FIN3
-							if (strpos('isol fina init medi fin2 fin3 med2',$v['tag'])!==false) { 
+							if (strpos('isol fina init medi fin2 fin3 med2',($v['tag'] ?? ''))!==false) { 
 								$key = $v['match'];
-								$key = preg_replace('/[\(\)]*/','',$key);
+								$key = preg_replace('/[\(\)]*/','',($key ?? ''));
 								$sub = $v['replace'];
 								if ($v['tag'] == 'isol') $kk = 0;
 								else if ($v['tag'] == 'fina') $kk = 1;
@@ -1995,8 +2008,8 @@
 								else if ($v['tag'] == 'fin2') $kk = 5;
 								else if ($v['tag'] == 'fin3') $kk = 6;
 								$rtl[$key][$kk] = $sub;
-								if (isset($v['prel']) && count($v['prel'])) $rtl[$key]['prel'][$kk] = $v['prel'];
-								if (isset($v['postl']) && count($v['postl'])) $rtl[$key]['postl'][$kk] = $v['postl'];
+								if (isset($v['prel']) && count(($v['prel'] ?? []))) $rtl[$key]['prel'][$kk] = $v['prel'];
+								if (isset($v['postl']) && count(($v['postl'] ?? []))) $rtl[$key]['postl'][$kk] = $v['postl'];
 								if (isset($v['ignore']) && $v['ignore']) {
 									$rtl[$key]['ignore'][$kk] = $v['ignore'];
 								}
@@ -2006,9 +2019,9 @@
 							else { 
 								if (isset($v['context']) && $v['context']) {
 									foreach($v['rules'] AS $vs) {
-										for($i=0;$i<count($vs['match']);$i++) {
-											if (isset($vs['replace'][$i]) && preg_match('/^0[A-F0-9]{4}$/', $vs['match'][$i])) { 
-												if (preg_match('/^0[EF][A-F0-9]{3}$/', $vs['replace'][$i])) { 
+										for($i=0;$i<count(($vs['match'] ?? []));$i++) {
+											if (isset($vs['replace'][$i]) && preg_match('/^0[A-F0-9]{4}$/', ($vs['match'][$i] ?? ''))) { 
+												if (preg_match('/^0[EF][A-F0-9]{3}$/', ($vs['replace'][$i] ?? ''))) { 
 													$rtlpua[] = $vs['replace'][$i];
 												}
 											}
@@ -2016,11 +2029,11 @@
 									}
 								}
 								else {
-									preg_match_all('/\((0[A-F0-9]{4})\)/', $v['match'], $m);
-									for($i=0;$i<count($m[0]);$i++) { 
-										$sb = explode(' ',$v['replace']);
+									preg_match_all('/\((0[A-F0-9]{4})\)/', ($v['match'] ?? ''), $m);
+									for($i=0;$i<count(($m[0] ?? []));$i++) { 
+										$sb = explode(' ',($v['replace'] ?? ''));
 										foreach($sb AS $sbg) { 
-											if (preg_match('/(0[EF][A-F0-9]{3})/', $sbg, $mr)) { 
+											if (preg_match('/(0[EF][A-F0-9]{3})/', ($sbg ?? ''), $mr)) { 
 												$rtlpua[] = $mr[1]; 
 											}
 										}
@@ -2033,7 +2046,7 @@
 						// priority rules (see otl.php)
 						foreach($rtl AS $base=>$variants) {
 							if (isset($variants[1])) {	// i.e. final form
-								if (strpos('0FE8E 0FE94 0FEA2 0FEAA 0FEAE 0FEC2 0FEDA 0FEDE 0FB93 0FECA 0FED2 0FED6 0FEEE 0FEF0 0FEF2', $variants[1])===false) {	// not already included
+								if (strpos('0FE8E 0FE94 0FEA2 0FEAA 0FEAE 0FEC2 0FEDA 0FEDE 0FB93 0FECA 0FED2 0FED6 0FEEE 0FEF0 0FEF2', ($variants[1] ?? ''))===false) {	// not already included
 
 								// This version does not exclude RA (0631) FEAE; Ya (064A)  FEF2; Alef Maqsurah (0649) FEF0 which
 								// are selected in priority if connected to a medial Bah
@@ -2046,14 +2059,14 @@
 //print_r($rtlpua); exit;
 						ksort($rtl);
 						$a = var_export($rtl, true);
-						$a = preg_replace('/\\\\\\\\/',"\\",$a);
-						$a = preg_replace('/\'/','"',$a);
-						$a = preg_replace('/\r/','',$a);
-						$a = preg_replace('/> \n/','>',$a);
-						$a = preg_replace('/\n  \)/',')',$a);
-						$a= preg_replace('/\n    /',' ',$a);
-						$a = preg_replace('/\[IGNORE(\d+)\]/','".$ignore[\\1]."',$a);
-						$rtlSUB  = preg_replace('/[ ]+/',' ',$a);
+						$a = preg_replace('/\\\\\\\\/',"\\",($a ?? ''));
+						$a = preg_replace('/\'/','"',($a ?? ''));
+						$a = preg_replace('/\r/','',($a ?? ''));
+						$a = preg_replace('/> \n/','>',($a ?? ''));
+						$a = preg_replace('/\n  \)/',')',($a ?? ''));
+						$a= preg_replace('/\n    /',' ',($a ?? ''));
+						$a = preg_replace('/\[IGNORE(\d+)\]/','".$ignore[\\1]."',($a ?? ''));
+						$rtlSUB  = preg_replace('/[ ]+/',' ',($a ?? ''));
 
 					}
 					//=====================================================================================
@@ -2064,19 +2077,19 @@
 					$pref = array();
 					$blwf = array();
 					$pstf = array();
-					if (strpos('dev2 bng2 gur2 gjr2 ory2 tml2 tel2 knd2 mlm2 deva beng guru gujr orya taml telu knda mlym', $st)!==false) {	// all INDIC scripts [any/all languages]
-
-						if (strpos('deva beng guru gujr orya taml telu knda mlym', $st)!==false) { $is_old_spec = true; }
+					if (strpos('dev2 bng2 gur2 gjr2 ory2 tml2 tel2 knd2 mlm2 deva beng guru gujr orya taml telu knda mlym', ($st ?? ''))!==false) {	// all INDIC scripts [any/all languages]
+
+						if (strpos('deva beng guru gujr orya taml telu knda mlym', ($st ?? ''))!==false) { $is_old_spec = true; }
 						else  { $is_old_spec = false; }
 
 						// First get 'locl' substitutions (reversed!)
 						$loclsubs = array();
 						foreach($volt AS $v) {
-							if (strpos('locl',$v['tag'])!==false) { 
+							if (strpos('locl',($v['tag'] ?? ''))!==false) { 
 								$key = $v['match'];
-								$key = preg_replace('/[\(\)]*/','',$key);
+								$key = preg_replace('/[\(\)]*/','',($key ?? ''));
 								$sub = $v['replace'];
-								if ($key && strlen(trim($key))==5 && $sub) { $loclsubs[$sub] = $key; }
+								if ($key && strlen((trim(($key ?? '')) ?? ''))==5 && $sub) { $loclsubs[$sub] = $key; }
 							}
 						}
 //if (count($loclsubs)) { print_r($loclsubs); exit; }
@@ -2102,28 +2115,28 @@
 							// Currently set to cope with both
 							// See also classes/otl.php
 
-							if (strpos('rphf half pref blwf pstf',$v['tag'])!==false) { 
+							if (strpos('rphf half pref blwf pstf',($v['tag'] ?? ''))!==false) { 
 								if (isset($v['context']) && $v['context'] && $v['nBacktrack']==0 && $v['nLookahead']==0) {
 								  foreach($v['rules'] AS $vs) {
-									if (count($vs['match'])==2 && count($vs['replace'])==1) {
+									if (count(($vs['match'] ?? []))==2 && count(($vs['replace'] ?? []))==1) {
 										$sub = $vs['replace'][0];
 										// If Halant Cons   <pref>, <blwf> and <pstf> in New version only
-										if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',$vs['match'][0])!==false && strpos('pref blwf pstf',$v['tag'])!==false && !$is_old_spec ) {
+										if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',($vs['match'][0] ?? ''))!==false && strpos('pref blwf pstf',($v['tag'] ?? ''))!==false && !$is_old_spec ) {
 											$key = $vs['match'][1];
 											$tag = $v['tag'];
 											if (isset($loclsubs[$key])) {
-												$$tag[$loclsubs[$key]] = $sub;
+												${$tag}[$loclsubs[$key]] = $sub;
 											}
 											$tmp = &$$tag;
 											$tmp[hexdec($key)] = hexdec($sub);
 										}
 										// If Cons Halant    <rphf> and <half> always
 										// and <pref>, <blwf> and <pstf> in Old version 
-										else if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',$vs['match'][1])!==false && (strpos('rphf half',$v['tag'])!==false || (strpos('pref blwf pstf',$v['tag'])!==false && ($is_old_spec || _OTL_OLD_SPEC_COMPAT_2)))) {
+										else if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',($vs['match'][1] ?? ''))!==false && (strpos('rphf half',($v['tag'] ?? ''))!==false || (strpos('pref blwf pstf',($v['tag'] ?? ''))!==false && ($is_old_spec || _OTL_OLD_SPEC_COMPAT_2)))) {
 											$key = $vs['match'][0];
 											$tag = $v['tag'];
 											if (isset($loclsubs[$key])) {
-												$$tag[$loclsubs[$key]] = $sub;
+												${$tag}[$loclsubs[$key]] = $sub;
 											}
 											$tmp = &$$tag;
 											$tmp[hexdec($key)] = hexdec($sub);
@@ -2133,26 +2146,26 @@
 								}
 								else if (!isset($v['context'])) {
 									$key = $v['match'];
-									$key = preg_replace('/[\(\)]*/','',$key);
+									$key = preg_replace('/[\(\)]*/','',($key ?? ''));
 									$sub = $v['replace'];
-									if ($key && strlen(trim($key))==11 && $sub) {
+									if ($key && strlen((trim(($key ?? '')) ?? ''))==11 && $sub) {
 										// If Cons Halant    <rphf> and <half> always
 										// and <pref>, <blwf> and <pstf> in Old version 
 										// If Halant Cons   <pref>, <blwf> and <pstf> in New version only
-										if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',substr($key, 0, 5))!==false && strpos('pref blwf pstf',$v['tag'])!==false && !$is_old_spec ) {
-											$key = substr($key, 6, 5);
+										if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',(substr(($key ?? ''), 0, 5) ?? ''))!==false && strpos('pref blwf pstf',($v['tag'] ?? ''))!==false && !$is_old_spec ) {
+											$key = substr(($key ?? ''), 6, 5);
 											$tag = $v['tag'];
 											if (isset($loclsubs[$key])) {
-												$$tag[$loclsubs[$key]] = $sub;
+												${$tag}[$loclsubs[$key]] = $sub;
 											}
 											$tmp = &$$tag;
 											$tmp[hexdec($key)] = hexdec($sub);
 										}
-										else if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',substr($key, 6, 5))!==false && (strpos('rphf half',$v['tag'])!==false || (strpos('pref blwf pstf',$v['tag'])!==false && ($is_old_spec || _OTL_OLD_SPEC_COMPAT_2)))) {
-											$key = substr($key, 0, 5);
+										else if (strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',(substr(($key ?? ''), 6, 5) ?? ''))!==false && (strpos('rphf half',($v['tag'] ?? ''))!==false || (strpos('pref blwf pstf',($v['tag'] ?? ''))!==false && ($is_old_spec || _OTL_OLD_SPEC_COMPAT_2)))) {
+											$key = substr(($key ?? ''), 0, 5);
 											$tag = $v['tag'];
 											if (isset($loclsubs[$key])) {
-												$$tag[$loclsubs[$key]] = $sub;
+												${$tag}[$loclsubs[$key]] = $sub;
 											}
 											$tmp= &$$tag;
 											$tmp[hexdec($key)] = hexdec($sub);
@@ -2175,7 +2188,7 @@
 					//=====================================================================================
 					//=====================================================================================
 					//=====================================================================================
-					if (count($rtl) || count($rphf ) || count($half ) || count($pref ) || count($blwf ) || count($pstf ) || $finals) {
+					if (count(($rtl ?? [])) || count(($rphf ?? []) ) || count(($half ?? []) ) || count(($pref ?? []) ) || count(($blwf ?? []) ) || count(($pstf ?? []) ) || $finals) {
 						// SAVE LOOKUPS TO FILE fontname.GSUB.scripttag.langtag.php
 
 
@@ -2206,10 +2219,10 @@
 
 			// All RTL glyphs from font added to (or already in) PUA [reqd for magic_reverse]
 			$rtlPUAstr = "";
-			if (count($rtlpua)) {
+			if (count(($rtlpua ?? []))) {
 				$rtlpua = array_unique($rtlpua);
 				sort($rtlpua);
-				$n = count($rtlpua);
+				$n = count(($rtlpua ?? []));
 				for($i=0;$i<$n;$i++) { 
 					if (hexdec($rtlpua[$i])<hexdec('E000') || hexdec($rtlpua[$i])>hexdec('F8FF')) { 
 						unset($rtlpua[$i]); 
@@ -2278,7 +2291,7 @@
 
 					// LookupType 1: Single Substitution Subtable
 					if ($Lookup[$i]['Type'] == 1) {
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
 							// Ignore has already been applied earlier on
@@ -2289,7 +2302,7 @@
 					}
 					// LookupType 2: Multiple Substitution Subtable
 					else if ($Lookup[$i]['Type'] == 2) {
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = implode(" ", $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute']);
 							// Ignore has already been applied earlier on
@@ -2300,7 +2313,7 @@
 					}
 					// LookupType 3: Alternate Forms
 					else if ($Lookup[$i]['Type'] == 3) {
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
 							// Ignore has already been applied earlier on
@@ -2311,13 +2324,13 @@
 					}
 					// LookupType 4: Ligature Substitution Subtable
 					else if ($Lookup[$i]['Type'] == 4) {
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
 							// Ignore has already been applied earlier on
 							$ignore = $this->_getGSUBignoreString($Lookup[$i]['Flag'], $Lookup[$i]['MarkFilteringSet']);
 							$repl = $this->_makeGSUBinputMatch($inputGlyphs, $ignore);
-							$subs = $this->_makeGSUBinputReplacement(count($inputGlyphs), $substitute, $ignore, 0, count($inputGlyphs), 0);
+							$subs = $this->_makeGSUBinputReplacement(count(($inputGlyphs ?? [])), $substitute, $ignore, 0, count(($inputGlyphs ?? [])), 0);
 							$volt[] = array('match'=>$repl, 'replace'=>$subs, 'tag'=>$tag, 'key'=>$inputGlyphs[0], 'type' => 4, 'CompCount' => $Lookup[$i]['Subtable'][$c]['subs'][$s]['CompCount'], 'Lig' => $substitute);
 						}
 					}
@@ -2338,7 +2351,7 @@
 									}
 									$inputGlyphs[0] = $Lookup[$i]['Subtable'][$c]['SubRuleSet'][$s]['FirstGlyph'];
 									ksort($inputGlyphs);
-									$nInput = count($inputGlyphs);
+									$nInput = count(($inputGlyphs ?? []));
 
 									$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, array(), 0);
 									$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => '', 'match' => $contextInputMatch, 'nBacktrack' => 0, 'nInput' => $nInput, 'nLookahead' => 0, 'rules' => array(), );
@@ -2349,18 +2362,18 @@
 
 										// $Lookup[$lup] = secondary Lookup
 										for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-										   if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+										   if (count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 											foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 
 												$lookupGlyphs = $luss['Replace'];
-												$mLen = count($lookupGlyphs);
+												$mLen = count(($lookupGlyphs ?? []));
 
 												// Only apply if the (first) 'Replace' glyph from the 
 												// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 												// then apply the substitution
-												if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+												if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 												$REPL = implode(" ",$luss['substitute']);
-												if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+												if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 													$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 												}
 												else {
@@ -2372,7 +2385,7 @@
 									}
 
 
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 								}
 							}
@@ -2413,23 +2426,23 @@
 
 										// $Lookup[$lup] = secondary Lookup
 										for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-										   if (isset($Lookup[$lup]['Subtable'][$lus]['subs']) && count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+										   if (isset($Lookup[$lup]['Subtable'][$lus]['subs']) && count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 											foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 
 												$lookupGlyphs = $luss['Replace'];
-												$mLen = count($lookupGlyphs);
+												$mLen = count(($lookupGlyphs ?? []));
 
 												// Only apply if the (first) 'Replace' glyph from the 
 												// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 												// then apply the substitution
-												if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+												if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 
 												// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 												$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
 												$REPL = implode(" ",$luss['substitute']);
 												// Returns e.g. "REPL\${6}\${8}" or "\${1}\${2} \${3} REPL\${4}\${6}\${8} \${9}"
 
-												if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+												if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 													$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 												}
 												else {
@@ -2439,7 +2452,7 @@
 										   }
 										}
 									}
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 								}
 							}
@@ -2469,30 +2482,30 @@
 							// Returns e.g. ¦(ignore) (FD12|FD13)¦(ignore) (FEEB|FEEC)¦
 							$lookaheadMatch = $this->_makeGSUBlookaheadMatch($lookaheadGlyphs, $ignore);
 
-							$nBsubs = 2*count($backtrackGlyphs);
+							$nBsubs = 2*count(($backtrackGlyphs ?? []));
 							$nIsubs = (2*$nInput)-1;
 							$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, array(), 0);
-							$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count($backtrackGlyphs), 'nInput' => $nInput, 'nLookahead' => count($lookaheadGlyphs), 'rules' => array(), );
+							$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count(($backtrackGlyphs ?? [])), 'nInput' => $nInput, 'nLookahead' => count(($lookaheadGlyphs ?? [])), 'rules' => array(), );
 
 							for ($b=0;$b<$Lookup[$i]['Subtable'][$c]['SubstCount'];$b++) {
 								$lup = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['LookupListIndex'];
 								$seqIndex = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['SequenceIndex'];
 								for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-								   if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+								   if (count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 									foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 										$lookupGlyphs = $luss['Replace'];
-										$mLen = count($lookupGlyphs);
+										$mLen = count(($lookupGlyphs ?? []));
 
 										// Only apply if the (first) 'Replace' glyph from the 
 										// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 										// then apply the substitution
-										if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+										if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 
 										// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 										$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
 										$REPL = implode(" ",$luss['substitute']);
 
-										if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+										if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 											$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 										}
 										else {
@@ -2502,7 +2515,7 @@
 								   }
 								}
 							}
-							if (count($subRule['rules'])) $volt[] = $subRule;
+							if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 						}
 
 //print_r($Lookup[$i]);
@@ -2525,7 +2538,7 @@
 									}
 									$inputGlyphs[0] = $firstInputGlyph;
 									ksort($inputGlyphs);
-									$nInput = count($inputGlyphs);
+									$nInput = count(($inputGlyphs ?? []));
 
 									if ($rule['BacktrackGlyphCount']) { $backtrackGlyphs = $rule['BacktrackGlyphs']; }
 									else { $backtrackGlyphs = array(); }
@@ -2536,11 +2549,11 @@
 
 									$lookaheadMatch = $this->_makeGSUBlookaheadMatch($lookaheadGlyphs, $ignore);
 
-									$nBsubs = 2*count($backtrackGlyphs);
+									$nBsubs = 2*count(($backtrackGlyphs ?? []));
 									$nIsubs = (2*$nInput)-1;
 
 									$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, array(), 0);
-									$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count($backtrackGlyphs), 'nInput' => $nInput, 'nLookahead' => count($lookaheadGlyphs), 'rules' => array(), );
+									$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count(($backtrackGlyphs ?? [])), 'nInput' => $nInput, 'nLookahead' => count(($lookaheadGlyphs ?? [])), 'rules' => array(), );
 
 
 									for ($b=0;$b<$rule['SubstCount'];$b++) {
@@ -2549,23 +2562,23 @@
 
 										// $Lookup[$lup] = secondary Lookup
 										for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-										   if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+										   if (count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 											foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 
 												$lookupGlyphs = $luss['Replace'];
-												$mLen = count($lookupGlyphs);
+												$mLen = count(($lookupGlyphs ?? []));
 
 												// Only apply if the (first) 'Replace' glyph from the 
 												// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 												// then apply the substitution
-												if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+												if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 
 												// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 												$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
 
 												$REPL = implode(" ",$luss['substitute']);
 
-												if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+												if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 													$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 												}
 												else {
@@ -2577,7 +2590,7 @@
 									}
 
 
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 
 
@@ -2651,11 +2664,11 @@
 									// Returns e.g. ¦(ignore) (FD12|FD13)¦(ignore) (FEEB|FEEC)¦
 									$lookaheadMatch = $this->_makeGSUBlookaheadMatch($lookaheadGlyphs, $ignore);
 
-									$nBsubs = 2*count($backtrackGlyphs);
+									$nBsubs = 2*count(($backtrackGlyphs ?? []));
 									$nIsubs = (2*$nInput)-1;
 
 									$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, array(), 0);
-									$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count($backtrackGlyphs), 'nInput' => $nInput, 'nLookahead' => count($lookaheadGlyphs), 'rules' => array(), );
+									$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count(($backtrackGlyphs ?? [])), 'nInput' => $nInput, 'nLookahead' => count(($lookaheadGlyphs ?? [])), 'rules' => array(), );
 
 									for ($b=0;$b<$rule['SubstCount'];$b++) {
 										$lup = $rule['LookupListIndex'][$b];
@@ -2663,23 +2676,23 @@
 
 										// $Lookup[$lup] = secondary Lookup
 										for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-										   if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+										   if (count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 											foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 
 												$lookupGlyphs = $luss['Replace'];
-												$mLen = count($lookupGlyphs);
+												$mLen = count(($lookupGlyphs ?? []));
 
 												// Only apply if the (first) 'Replace' glyph from the 
 												// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 												// then apply the substitution
-												if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+												if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 
 												// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 												$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
 												$REPL = implode(" ",$luss['substitute']);
 												// Returns e.g. "REPL\${6}\${8}" or "\${1}\${2} \${3} REPL\${4}\${6}\${8} \${9}"
 
-												if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+												if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 													$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 												}
 												else {
@@ -2689,7 +2702,7 @@
 										   }
 										}
 									}
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 								}
 							}
@@ -2720,30 +2733,30 @@
 							// Returns e.g. ¦(ignore) (FD12|FD13)¦(ignore) (FEEB|FEEC)¦
 							$lookaheadMatch = $this->_makeGSUBlookaheadMatch($lookaheadGlyphs, $ignore);
 
-							$nBsubs = 2*count($backtrackGlyphs);
+							$nBsubs = 2*count(($backtrackGlyphs ?? []));
 							$nIsubs = (2*$nInput)-1;
 							$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, array(), 0);
-							$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count($backtrackGlyphs), 'nInput' => $nInput, 'nLookahead' => count($lookaheadGlyphs), 'rules' => array(), );
+							$subRule = array('context' => 1, 'tag' => $tag, 'matchback' => $backtrackMatch, 'match' => ($contextInputMatch . $lookaheadMatch), 'nBacktrack' => count(($backtrackGlyphs ?? [])), 'nInput' => $nInput, 'nLookahead' => count(($lookaheadGlyphs ?? [])), 'rules' => array(), );
 
 							for ($b=0;$b<$Lookup[$i]['Subtable'][$c]['SubstCount'];$b++) {
 								$lup = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['LookupListIndex'];
 								$seqIndex = $Lookup[$i]['Subtable'][$c]['SubstLookupRecord'][$b]['SequenceIndex'];
 								for($lus=0;$lus<$Lookup[$lup]['SubtableCount'];$lus++) {
-								   if (count($Lookup[$lup]['Subtable'][$lus]['subs'])) {
+								   if (count(($Lookup[$lup]['Subtable'][$lus]['subs'] ?? []))) {
 									foreach($Lookup[$lup]['Subtable'][$lus]['subs'] AS $luss) {
 										$lookupGlyphs = $luss['Replace'];
-										$mLen = count($lookupGlyphs);
+										$mLen = count(($lookupGlyphs ?? []));
 
 										// Only apply if the (first) 'Replace' glyph from the 
 										// Lookup list is in the [inputGlyphs] at ['SequenceIndex']
 										// then apply the substitution
-										if (strpos($inputGlyphs[$seqIndex],$lookupGlyphs[0])===false) { continue; }
+										if (strpos(($inputGlyphs[$seqIndex] ?? ''),($lookupGlyphs[0] ?? ''))===false) { continue; }
 
 										// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 										$contextInputMatch = $this->_makeGSUBcontextInputMatch($inputGlyphs, $ignore, $lookupGlyphs, $seqIndex);
 										$REPL = implode(" ",$luss['substitute']);
 
-										if (strpos("isol fina fin2 fin3 medi med2 init ",$tag)!==false && $scripttag=='arab') {
+										if (strpos("isol fina fin2 fin3 medi med2 init ",($tag ?? ''))!==false && $scripttag=='arab') {
 											$volt[] = array('match'=>$lookupGlyphs[0], 'replace'=>$REPL, 'tag'=>$tag, 'prel'=>$backtrackGlyphs, 'postl'=>$lookaheadGlyphs, 'ignore'=>$ignore);
 										}
 										else {
@@ -2753,7 +2766,7 @@
 								   }
 								}
 							}
-							if (count($subRule['rules'])) $volt[] = $subRule;
+							if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 						}
 					}
 				}
@@ -2767,17 +2780,17 @@
 	function _checkGSUBignore($flag, $glyph, $MarkFilteringSet) {
 		$ignore = false;
 		// Flag & 0x0008 = Ignore Marks - (unless already done with MarkAttachmentType)
-		if ((($flag & 0x0008) == 0x0008 && ($flag & 0xFF00) == 0) && strpos($this->GlyphClassMarks,$glyph)) { $ignore = true; }
-		if ((($flag & 0x0004) == 0x0004) && strpos($this->GlyphClassLigatures,$glyph)) { $ignore = true; }
-		if ((($flag & 0x0002) == 0x0002) && strpos($this->GlyphClassBases,$glyph)) { $ignore = true; }
+		if ((($flag & 0x0008) == 0x0008 && ($flag & 0xFF00) == 0) && strpos(($this->GlyphClassMarks ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if ((($flag & 0x0004) == 0x0004) && strpos(($this->GlyphClassLigatures ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if ((($flag & 0x0002) == 0x0002) && strpos(($this->GlyphClassBases ?? ''),($glyph ?? ''))) { $ignore = true; }
 		// Flag & 0xFF?? = MarkAttachmentType
 		if ($flag & 0xFF00) {
 			// "a lookup must ignore any mark glyphs that are not in the specified mark attachment class"
 			// $this->MarkAttachmentType is already adjusted for this i.e. contains all Marks except those in the MarkAttachmentClassDef table
-			if (strpos($this->MarkAttachmentType[($flag >> 8)],$glyph)) { $ignore = true; }
+			if (strpos(($this->MarkAttachmentType[($flag >> 8)] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		}
 		// Flag & 0x0010 = UseMarkFilteringSet
-		if (($flag & 0x0010) && strpos($this->MarkGlyphSets[$MarkFilteringSet],$glyph)) { $ignore = true; }
+		if (($flag & 0x0010) && strpos(($this->MarkGlyphSets[$MarkFilteringSet] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		return $ignore;
 	}
 
@@ -2891,8 +2904,8 @@
 		// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 		// $inputGlyphs = array of glyphs(glyphstrings) making up Input sequence in Context
 		// $lookupGlyphs = array of glyphs (single Glyphs) making up Lookup Input sequence
-		$mLen = count($lookupGlyphs);		// nGlyphs in the secondary Lookup match 
-		$nInput = count($inputGlyphs);	// nGlyphs in the Primary Input sequence
+		$mLen = count(($lookupGlyphs ?? []));		// nGlyphs in the secondary Lookup match 
+		$nInput = count(($inputGlyphs ?? []));	// nGlyphs in the Primary Input sequence
 		$str = "";
 		for($i=0;$i<$nInput;$i++) {
 			if ($i>0) { $str .= $ignore." "; }
@@ -2908,7 +2921,7 @@
 		// $inputGlyphs = array of glyphs(glyphstrings) making up Input sequence in Context
 		// $lookupGlyphs = array of glyphs making up Lookup Input sequence - if applicable
 		$str = "";
-		for($i=1;$i<=count($inputGlyphs);$i++) {
+		for($i=1;$i<=count(($inputGlyphs ?? []));$i++) {
 			if ($i>1) { $str .= $ignore." "; }
 			$str .= "(".$inputGlyphs[($i-1)].")";
 		}
@@ -2922,7 +2935,7 @@
 		// 3  2  1  0
 		// each item being e.g. E0AD|E0AF|F1FD
 		$str = "";
-		for($i=(count($backtrackGlyphs)-1);$i>=0;$i--) {
+		for($i=(count(($backtrackGlyphs ?? []))-1);$i>=0;$i--) {
 			$str .= "(".$backtrackGlyphs[$i].")".$ignore." ";
 		}
 		return $str;
@@ -2935,7 +2948,7 @@
 		// 0  1  2  3
 		// each item being e.g. E0AD|E0AF|F1FD
 		$str = "";
-		for($i=0;$i<count($lookaheadGlyphs);$i++) {
+		for($i=0;$i<count(($lookaheadGlyphs ?? []));$i++) {
 			$str .= $ignore." (".$lookaheadGlyphs[$i].")";
 		}
 		return $str;
@@ -3424,7 +3437,7 @@
 			$this->getGlyphs($originalGlyphIdx, $start, $glyphSet, $subsetglyphs);
 		}
 
-		$numGlyphs = $numberOfHMetrics = count($subsetglyphs );
+		$numGlyphs = $numberOfHMetrics = count(($subsetglyphs ?? []) );
 
 		///////////////////////////////////
 		// name - table copied from the original
@@ -3448,7 +3461,7 @@
 		///////////////////////////////////
 		if (isset($this->tables['post'])) {
 			$opost = $this->get_table('post');
-			$post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
+			$post = "\x00\x03\x00\x00" . substr(($opost ?? ''),4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
 			$this->add('post', $post);
 		}
 
@@ -3482,7 +3495,7 @@
 		// CMap table
 		///////////////////////////////////
 		// cmap - Character to glyph mapping 
-		$segCount = count($range) + 1;	// + 1 Last segment has missing character 0xFFFF
+		$segCount = count(($range ?? [])) + 1;	// + 1 Last segment has missing character 0xFFFF
 		$searchRange = 1;
 		$entrySelector = 0;
 		while ($searchRange * 2 <= $segCount ) {
@@ -3507,7 +3520,7 @@
 
 		// endCode(s)
 		foreach($range AS $start=>$subrange) {
-			$endCode = $start + (count($subrange)-1);
+			$endCode = $start + (count(($subrange ?? []))-1);
 			$cmap[] = $endCode;	// endCode(s)
 		}
 		$cmap[] =	0xFFFF;	// endCode of last Segment
@@ -3521,7 +3534,7 @@
 		// idDelta(s) 
 		foreach($range AS $start=>$subrange) {
 			$idDelta = -($start-$subrange[0]);
-			$n += count($subrange);
+			$n += count(($subrange ?? []));
 			$cmap[] = $idDelta;	// idDelta(s)
 		}
 		$cmap[] =	1;	// idDelta of last Segment
@@ -3579,7 +3592,7 @@
 			$glyphPos = $this->glyphPos[$originalGlyphIdx];
 			$glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
 			if ($glyfLength < $this->maxStrLenRead) {
-				$data = substr($glyphData,$glyphPos,$glyphLen);
+				$data = substr(($glyphData ?? ''),$glyphPos,$glyphLen);
 			}
 			else {
 				if ($glyphLen > 0) $data = $this->get_chunk($glyfOffset+$glyphPos,$glyphLen);
@@ -3588,22 +3601,22 @@
 
 			if ($glyphLen > 0) {
 			  if (_RECALC_PROFILE) {
-				$xMin = $this->unpack_short(substr($data,2,2));
-				$yMin = $this->unpack_short(substr($data,4,2));
-				$xMax = $this->unpack_short(substr($data,6,2));
-				$yMax = $this->unpack_short(substr($data,8,2));
+				$xMin = $this->unpack_short(substr(($data ?? ''),2,2));
+				$yMin = $this->unpack_short(substr(($data ?? ''),4,2));
+				$xMax = $this->unpack_short(substr(($data ?? ''),6,2));
+				$yMax = $this->unpack_short(substr(($data ?? ''),8,2));
 				$xMinT = min($xMinT,$xMin);
 				$yMinT = min($yMinT,$yMin);
 				$xMaxT = max($xMaxT,$xMax);
 				$yMaxT = max($yMaxT,$yMax);
-				$aw = $this->unpack_short(substr($hm,0,2)); 
-				$lsb = $this->unpack_short(substr($hm,2,2));
+				$aw = $this->unpack_short(substr(($hm ?? ''),0,2)); 
+				$lsb = $this->unpack_short(substr(($hm ?? ''),2,2));
 				$advanceWidthMax = max($advanceWidthMax,$aw);
 				$minLeftSideBearing = min($minLeftSideBearing,$lsb);
 				$minRightSideBearing = min($minRightSideBearing,($aw - $lsb - ($xMax - $xMin)));
 				$xMaxExtent = max($xMaxExtent,($lsb + ($xMax - $xMin)));
 			   }
-				$up = unpack("n", substr($data,0,2));
+				$up = unpack("n", substr(($data ?? ''),0,2));
 			}
 			if ($glyphLen > 2 && ($up[1] & (1 << 15)) ) {	// If number of contours <= -1 i.e. composiste glyph
 				$pos_in_glyph = 10;
@@ -3611,9 +3624,9 @@
 				$nComponentElements = 0;
 				while ($flags & GF_MORE) {
 					$nComponentElements += 1;	// number of glyphs referenced at top level
-					$up = unpack("n", substr($data,$pos_in_glyph,2));
+					$up = unpack("n", substr(($data ?? ''),$pos_in_glyph,2));
 					$flags = $up[1];
-					$up = unpack("n", substr($data,$pos_in_glyph+2,2));
+					$up = unpack("n", substr(($data ?? ''),$pos_in_glyph+2,2));
 					$glyphIdx = $up[1];
 					$this->glyphdata[$originalGlyphIdx]['compGlyphs'][] = $glyphIdx;
 					$data = $this->_set_ushort($data, $pos_in_glyph + 2, $glyphSet[$glyphIdx]);
@@ -3634,7 +3647,7 @@
 
 				// Count number of points in simple glyph
 				$pos_in_glyph = 10 + ($nContours  * 2) - 2;	// Last endContourPoint
-				$up = unpack("n", substr($data,$pos_in_glyph,2));
+				$up = unpack("n", substr(($data ?? ''),$pos_in_glyph,2));
 				$points = $up[1]+1;
 				$this->glyphdata[$originalGlyphIdx]['nPoints'] = $points;
 				$maxPoints = max($maxPoints, $points);
@@ -3695,7 +3708,7 @@
 			$head = $this->_set_short($head, 38, $yMinT);	// for all glyph bounding boxes
 			$head = $this->_set_short($head, 40, $xMaxT);	// for all glyph bounding boxes
 			$head = $this->_set_short($head, 42, $yMaxT);	// for all glyph bounding boxes
-			$head[17] = chr($head[17] & ~(1 << 4)); 	// Unset Bit 4 (as hdmx/LTSH tables not included)
+			$head[17] = chr((int) ($head[17] & ~(1 << 4))); 	// Unset Bit 4 (as hdmx/LTSH tables not included)
 		}
 		$this->add('head', $head);
 
@@ -3950,7 +3963,7 @@
 			}
 			else { $originalGlyphIdx = 0; }
 			if (!isset($glyphSet[$originalGlyphIdx])) {
-				$glyphSet[$originalGlyphIdx] = count($glyphMap);
+				$glyphSet[$originalGlyphIdx] = count(($glyphMap ?? []));
 				$glyphMap[] = $originalGlyphIdx;
 			}
 			$codeToGlyph[$code] = $glyphSet[$originalGlyphIdx];
@@ -3959,7 +3972,7 @@
 		list($start,$dummy) = $this->get_table_pos('glyf');
 
 		$n = 0;
-		while ($n < count($glyphMap)) {
+		while ($n < count(($glyphMap ?? []))) {
 			$originalGlyphIdx = $glyphMap[$n];
 			$glyphPos = $this->glyphPos[$originalGlyphIdx];
 			$glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
@@ -3974,7 +3987,7 @@
 					$flags = $this->read_ushort();
 					$glyphIdx = $this->read_ushort();
 					if (!isset($glyphSet[$glyphIdx])) {
-						$glyphSet[$glyphIdx] = count($glyphMap);
+						$glyphSet[$glyphIdx] = count(($glyphMap ?? []));
 						$glyphMap[] = $glyphIdx;
 					}
 					if ($flags & GF_WORDS)
@@ -3991,7 +4004,7 @@
 			}
 		}
 
-		$numGlyphs = $n = count($glyphMap);
+		$numGlyphs = $n = count(($glyphMap ?? []));
 		$numberOfHMetrics = $n;
 
 		///////////////////////////////////
@@ -4039,7 +4052,7 @@
 			$os2 = $this->_set_ushort($os2, 84, 0x0000);	// ulCodePageRange = Bit #32- Symbol **** 84 = Bits 32-47
 	
 			$os2 = $this->_set_ushort($os2, 64, 0x01);		// FirstCharIndex
-			$os2 = $this->_set_ushort($os2, 66, count($subset));		// LastCharIndex
+			$os2 = $this->_set_ushort($os2, 66, count(($subset ?? [])));		// LastCharIndex
 			// Set PANOSE first bit to 5 for Symbol
 			$os2 = $this->splice($os2, 32, chr(5).chr(0).chr(1).chr(0).chr(1).chr(0).chr(0).chr(0).chr(0).chr(0));
 			$this->add('OS/2', $os2 );
@@ -4059,7 +4072,7 @@
 		///////////////////////////////////
 		if (isset($this->tables['post'])) { 
 			$opost = $this->get_table('post');
-			$post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
+			$post = "\x00\x03\x00\x00" . substr(($opost ?? ''),4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
 		}
 		$this->add('post', $post);
 
@@ -4103,7 +4116,7 @@
 			$prevglidx = $glidx;
 		}
 		// cmap - Character to glyph mapping 
-		$segCount = count($range) + 1;	// + 1 Last segment has missing character 0xFFFF
+		$segCount = count(($range ?? [])) + 1;	// + 1 Last segment has missing character 0xFFFF
 		$searchRange = 1;
 		$entrySelector = 0;
 		while ($searchRange * 2 <= $segCount ) {
@@ -4122,7 +4135,7 @@
 
 		// endCode(s)
 		foreach($range AS $start=>$subrange) {
-			$endCode = $start + (count($subrange)-1);
+			$endCode = $start + (count(($subrange ?? []))-1);
 			$cmap[] = $endCode;	// endCode(s)
 		}
 		$cmap[] =	0xFFFF;	// endCode of last Segment
@@ -4136,7 +4149,7 @@
 		// idDelta(s) 
 		foreach($range AS $start=>$subrange) {
 			$idDelta = -($start-$subrange[0]);
-			$n += count($subrange);
+			$n += count(($subrange ?? []));
 			$cmap[] = $idDelta;	// idDelta(s)
 		}
 		$cmap[] =	1;	// idDelta of last Segment
@@ -4158,7 +4171,7 @@
 		///////////////////////////////////
 		// cmap - Character to glyph mapping
 		///////////////////////////////////
-		$entryCount = count($subset);
+		$entryCount = count(($subset ?? []));
 		$length = 10 + $entryCount * 2;
 
 		$off = 20 + $length;
@@ -4208,20 +4221,20 @@
 			$glyphPos = $this->glyphPos[$originalGlyphIdx];
 			$glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
 			if ($glyfLength < $this->maxStrLenRead) {
-				$data = substr($glyphData,$glyphPos,$glyphLen);
+				$data = substr(($glyphData ?? ''),$glyphPos,$glyphLen);
 			}
 			else {
 				if ($glyphLen > 0) $data = $this->get_chunk($glyfOffset+$glyphPos,$glyphLen);
 				else $data = '';
 			}
-			if ($glyphLen > 0) $up = unpack("n", substr($data,0,2));
+			if ($glyphLen > 0) $up = unpack("n", substr(($data ?? ''),0,2));
 			if ($glyphLen > 2 && ($up[1] & (1 << 15)) ) {
 				$pos_in_glyph = 10;
 				$flags = GF_MORE;
 				while ($flags & GF_MORE) {
-					$up = unpack("n", substr($data,$pos_in_glyph,2));
+					$up = unpack("n", substr(($data ?? ''),$pos_in_glyph,2));
 					$flags = $up[1];
-					$up = unpack("n", substr($data,$pos_in_glyph+2,2));
+					$up = unpack("n", substr(($data ?? ''),$pos_in_glyph+2,2));
 					$glyphIdx = $up[1];
 					$data = $this->_set_ushort($data, $pos_in_glyph + 2, $glyphSet[$glyphIdx]);
 					$pos_in_glyph += 4;
@@ -4278,7 +4291,7 @@
 	function getGlyphData($originalGlyphIdx, &$maxdepth, &$depth, &$points, &$contours) {
 		$depth++;
 		$maxdepth = max($maxdepth, $depth);
-		if (count($this->glyphdata[$originalGlyphIdx]['compGlyphs'])) {
+		if (count(($this->glyphdata[$originalGlyphIdx]['compGlyphs'] ?? []))) {
 			foreach($this->glyphdata[$originalGlyphIdx]['compGlyphs'] AS $glyphIdx) {
 				$this->getGlyphData($glyphIdx, $maxdepth, $depth, $points, $contours);
 			}
@@ -4308,7 +4321,7 @@
 				$flags = $this->read_ushort();
 				$glyphIdx = $this->read_ushort();
 				if (!isset($glyphSet[$glyphIdx])) {
-					$glyphSet[$glyphIdx] = count($subsetglyphs);	// old glyphID to new glyphID
+					$glyphSet[$glyphIdx] = count(($subsetglyphs ?? []));	// old glyphID to new glyphID
 					$subsetglyphs[$glyphIdx] = true;
 				}
 				$savepos = ftell($this->fh);
@@ -4362,8 +4375,8 @@
  						$w = intval(round($scale*$aw));
 						if ($w == 0) { $w = 65535; }
 						if ($char < 196608) {
-							$this->charWidths[$char*2] = chr($w >> 8);
-							$this->charWidths[$char*2 + 1] = chr($w & 0xFF);
+							$this->charWidths[$char*2] = chr((int) ($w >> 8));
+							$this->charWidths[$char*2 + 1] = chr((int) ($w & 0xFF));
 							$nCharWidths++;
 
 						}
@@ -4383,8 +4396,8 @@
 				foreach($glyphToChar[$glyph] AS $char) {
 					if ($char != 0 && $char != 65535) {
 						if ($char < 196608) { 
-							$this->charWidths[$char*2] = chr($w >> 8);
-							$this->charWidths[$char*2 + 1] = chr($w & 0xFF);
+							$this->charWidths[$char*2] = chr((int) ($w >> 8));
+							$this->charWidths[$char*2 + 1] = chr((int) ($w & 0xFF));
 							$nCharWidths++;
 						}
 					}
@@ -4393,8 +4406,8 @@
 		}
 		// NB 65535 is a set width of 0
 		// First bytes define number of chars in font
-		$this->charWidths[0] = chr($nCharWidths >> 8);
-		$this->charWidths[1] = chr($nCharWidths & 0xFF);
+		$this->charWidths[0] = chr((int) ($nCharWidths >> 8));
+		$this->charWidths[1] = chr((int) ($nCharWidths & 0xFF));
 	}
 
 
@@ -4487,7 +4500,7 @@
 		// Put the TTF file together
 	function endTTFile(&$stm) {
 		$stm = '';
-		$numTables = count($this->otables);
+		$numTables = count(($this->otables ?? []));
 		$searchRange = 1;
 		$entrySelector = 0;
 		while ($searchRange * 2 <= $numTables) {
@@ -4514,15 +4527,15 @@
 			$stm .= $tag;
 			$checksum = $this->calcChecksum($data);
 			$stm .= pack("nn", $checksum[0],$checksum[1]);
-			$stm .= pack("NN", $offset, strlen($data));
-			$paddedLength = (strlen($data)+3)&~3;
+			$stm .= pack("NN", $offset, strlen(($data ?? '')));
+			$paddedLength = (strlen(($data ?? ''))+3)&~3;
 			$offset = $offset + $paddedLength;
 		}
 
 		// Table data
 		foreach ($tables AS $tag=>$data) {
 			$data .= "\0\0\0";
-			$stm .= substr($data,0,(strlen($data)&~3));
+			$stm .= substr(($data ?? ''),0,(strlen(($data ?? ''))&~3));
 		}
 
 		$checksum = $this->calcChecksum($stm);
@@ -4656,7 +4669,7 @@
 			// CMap table
 			///////////////////////////////////
 			// cmap - Character to glyph mapping 
-			$segCount = count($range) + 1;	// + 1 Last segment has missing character 0xFFFF
+			$segCount = count(($range ?? [])) + 1;	// + 1 Last segment has missing character 0xFFFF
 			$searchRange = 1;
 			$entrySelector = 0;
 			while ($searchRange * 2 <= $segCount ) {
@@ -4681,7 +4694,7 @@
 
 			// endCode(s)
 			foreach($range AS $start=>$subrange) {
-				$endCode = $start + (count($subrange)-1);
+				$endCode = $start + (count(($subrange ?? []))-1);
 				$cmap[] = $endCode;	// endCode(s)
 			}
 			$cmap[] =	0xFFFF;	// endCode of last Segment
--- a/intranet/mpdf60/classes/gif.php
+++ b/intranet/mpdf60/classes/gif.php
@@ -26,7 +26,7 @@
 	///////////////////////////////////////////////////////////////////////////
 
 	// CONSTRUCTOR
-	function CGIFLZW()
+	function __construct()
 	{
 		$this->MAX_LZW_BITS = 12;
 		unSet($this->Next);
@@ -44,7 +44,7 @@
 
 	function deCompress($data, &$datLen)
 	{
-		$stLen  = strlen($data);
+		$stLen  = strlen(($data ?? ''));
 		$datLen = 0;
 		$ret    = "";
 		$dp = 0; 	// data pointer
@@ -53,7 +53,7 @@
 		$this->LZWCommandInit($data, $dp);
 
 		while(($iIndex = $this->LZWCommand($data, $dp)) >= 0) {
-			$ret .= chr($iIndex);
+			$ret .= chr((int) ($iIndex));
 		}
 
 		$datLen = $dp;
@@ -68,7 +68,7 @@
 	///////////////////////////////////////////////////////////////////////////
 	function LZWCommandInit(&$data, &$dp)
 	{
-			$this->SetCodeSize = ord($data[0]);
+			$this->SetCodeSize = ord(($data[0] ?? ''));
 			$dp += 1;
 
 			$this->CodeSize    = $this->SetCodeSize + 1;
@@ -202,12 +202,12 @@
 			$this->Buf[0] = $this->Buf[$this->LastByte - 2];
 			$this->Buf[1] = $this->Buf[$this->LastByte - 1];
 
-			$Count = ord($data[$dp]);
+			$Count = ord(($data[$dp] ?? ''));
 			$dp += 1;
 
 			if($Count) {
 				for($i = 0; $i < $Count; $i++) {
-					$this->Buf[2 + $i] = ord($data[$dp+$i]);
+					$this->Buf[2 + $i] = ord(($data[$dp+$i] ?? ''));
 				}
 				$dp += $Count;
 			}
@@ -240,7 +240,7 @@
 	///////////////////////////////////////////////////////////////////////////
 
 	// CONSTRUCTOR
-	function CGIFCOLORTABLE()
+	function __construct()
 	{
 		unSet($this->m_nColors);
 		unSet($this->m_arColors);
@@ -254,12 +254,12 @@
 		$this->m_arColors = array();
 
 		for($i = 0; $i < $num; $i++) {
-			$rgb = substr($lpData, $i * 3, 3);
-			if(strlen($rgb) < 3) {
+			$rgb = substr(($lpData ?? ''), $i * 3, 3);
+			if(strlen(($rgb ?? '')) < 3) {
 				return false;
 			}
 
-			$this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]);
+			$this->m_arColors[] = (ord(($rgb[2] ?? '')) << 16) + (ord(($rgb[1] ?? '')) << 8) + ord(($rgb[0] ?? ''));
 			$this->m_nColors++;
 		}
 
@@ -274,9 +274,9 @@
 
 		for($i = 0; $i < $this->m_nColors; $i++) {
 			$ret .=
-				chr(($this->m_arColors[$i] & 0x000000FF))       . // R
-				chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
-				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16);  // B
+				chr(((int) ($this->m_arColors[$i] & 0x000000FF)))       . // R
+				chr((int) (($this->m_arColors[$i] & 0x0000FF00) >>  8)) . // G
+				chr((int) (($this->m_arColors[$i] & 0x00FF0000) >> 16));  // B
 		}
 
 		return $ret;
@@ -327,7 +327,7 @@
 	///////////////////////////////////////////////////////////////////////////
 
 	// CONSTRUCTOR
-	function CGIFFILEHEADER()
+	function __construct()
 	{
 		unSet($this->m_lpVer);
 		unSet($this->m_nWidth);
@@ -347,29 +347,29 @@
 	{
 		$hdrLen = 0;
 
-		$this->m_lpVer = substr($lpData, 0, 6);
+		$this->m_lpVer = substr(($lpData ?? ''), 0, 6);
 		if(($this->m_lpVer <> "GIF87a") && ($this->m_lpVer <> "GIF89a")) {
 			return false;
 		}
 
-		$this->m_nWidth  = $this->w2i(substr($lpData, 6, 2));
-		$this->m_nHeight = $this->w2i(substr($lpData, 8, 2));
+		$this->m_nWidth  = $this->w2i(substr(($lpData ?? ''), 6, 2));
+		$this->m_nHeight = $this->w2i(substr(($lpData ?? ''), 8, 2));
 		if(!$this->m_nWidth || !$this->m_nHeight) {
 			return false;
 		}
 
-		$b = ord(substr($lpData, 10, 1));
+		$b = ord((substr(($lpData ?? ''), 10, 1) ?? ''));
 		$this->m_bGlobalClr  = ($b & 0x80) ? true : false;
 		$this->m_nColorRes   = ($b & 0x70) >> 4;
 		$this->m_bSorted     = ($b & 0x08) ? true : false;
 		$this->m_nTableSize  = 2 << ($b & 0x07);
-		$this->m_nBgColor    = ord(substr($lpData, 11, 1));
-		$this->m_nPixelRatio = ord(substr($lpData, 12, 1));
+		$this->m_nBgColor    = ord((substr(($lpData ?? ''), 11, 1) ?? ''));
+		$this->m_nPixelRatio = ord((substr(($lpData ?? ''), 12, 1) ?? ''));
 		$hdrLen = 13;
 
 		if($this->m_bGlobalClr) {
 			$this->m_colorTable = new CGIFCOLORTABLE();
-			if(!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
+			if(!$this->m_colorTable->load(substr(($lpData ?? ''), $hdrLen), $this->m_nTableSize)) {
 				return false;
 			}
 			$hdrLen += 3 * $this->m_nTableSize;
@@ -382,7 +382,7 @@
 
 	function w2i($str)
 	{
-		return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
+		return ord((substr(($str ?? ''), 0, 1) ?? '')) + (ord((substr(($str ?? ''), 1, 1) ?? '')) << 8);
 	}
 }
 
@@ -403,7 +403,7 @@
 	///////////////////////////////////////////////////////////////////////////
 
 	// CONSTRUCTOR
-	function CGIFIMAGEHEADER()
+	function __construct()
 	{
 		unSet($this->m_nLeft);
 		unSet($this->m_nTop);
@@ -422,16 +422,16 @@
 	{
 		$hdrLen = 0;
 
-		$this->m_nLeft   = $this->w2i(substr($lpData, 0, 2));
-		$this->m_nTop    = $this->w2i(substr($lpData, 2, 2));
-		$this->m_nWidth  = $this->w2i(substr($lpData, 4, 2));
-		$this->m_nHeight = $this->w2i(substr($lpData, 6, 2));
+		$this->m_nLeft   = $this->w2i(substr(($lpData ?? ''), 0, 2));
+		$this->m_nTop    = $this->w2i(substr(($lpData ?? ''), 2, 2));
+		$this->m_nWidth  = $this->w2i(substr(($lpData ?? ''), 4, 2));
+		$this->m_nHeight = $this->w2i(substr(($lpData ?? ''), 6, 2));
 
 		if(!$this->m_nWidth || !$this->m_nHeight) {
 			return false;
 		}
 
-		$b = ord($lpData{8});
+		$b = ord(($lpData[8] ?? ''));
 		$this->m_bLocalClr  = ($b & 0x80) ? true : false;
 		$this->m_bInterlace = ($b & 0x40) ? true : false;
 		$this->m_bSorted    = ($b & 0x20) ? true : false;
@@ -440,7 +440,7 @@
 
 		if($this->m_bLocalClr) {
 			$this->m_colorTable = new CGIFCOLORTABLE();
-			if(!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
+			if(!$this->m_colorTable->load(substr(($lpData ?? ''), $hdrLen), $this->m_nTableSize)) {
 				return false;
 			}
 			$hdrLen += 3 * $this->m_nTableSize;
@@ -453,7 +453,7 @@
 
 	function w2i($str)
 	{
-		return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
+		return ord((substr(($str ?? ''), 0, 1) ?? '')) + (ord((substr(($str ?? ''), 1, 1) ?? '')) << 8);
 	}
 }
 
@@ -473,7 +473,7 @@
 
 	///////////////////////////////////////////////////////////////////////////
 
-	function CGIFIMAGE()
+	function __construct()
 	{
 		unSet($this->m_disp);
 		unSet($this->m_bUser);
@@ -493,8 +493,8 @@
 		$datLen = 0;
 
 		while(true) {
-			$b = ord($data[0]);
-			$data = substr($data, 1);
+			$b = ord(($data[0] ?? ''));
+			$data = substr(($data ?? ''), 1);
 			$datLen++;
 
 			switch($b) {
@@ -512,7 +512,7 @@
 				if(!$this->m_gih->load($data, $len)) {
 					return false;
 				}
-				$data = substr($data, $len);
+				$data = substr(($data ?? ''), $len);
 				$datLen += $len;
 
 				// ALLOC BUFFER
@@ -522,7 +522,7 @@
 					return false;
 				}
 
-				$data = substr($data, $len);
+				$data = substr(($data ?? ''), $len);
 				$datLen += $len;
 
 				if($this->m_gih->m_bInterlace) {
@@ -545,22 +545,22 @@
 	{
 		$extLen = 0;
 
-		$b = ord($data[0]);
-		$data = substr($data, 1);
+		$b = ord(($data[0] ?? ''));
+		$data = substr(($data ?? ''), 1);
 		$extLen++;
 
 		switch($b) {
 		case 0xF9: // Graphic Control
-			$b = ord($data[1]);
+			$b = ord(($data[1] ?? ''));
 			$this->m_disp   = ($b & 0x1C) >> 2;
 			$this->m_bUser  = ($b & 0x02) ? true : false;
 			$this->m_bTrans = ($b & 0x01) ? true : false;
-			$this->m_nDelay = $this->w2i(substr($data, 2, 2));
-			$this->m_nTrans = ord($data[4]);
+			$this->m_nDelay = $this->w2i(substr(($data ?? ''), 2, 2));
+			$this->m_nTrans = ord(($data[4] ?? ''));
 			break;
 
 		case 0xFE: // Comment
-			$this->m_lpComm = substr($data, 1, ord($data[0]));
+			$this->m_lpComm = substr(($data ?? ''), 1, ord(($data[0] ?? '')));
 			break;
 
 		case 0x01: // Plain text
@@ -571,14 +571,14 @@
 		}
 
 		// SKIP DEFAULT AS DEFS MAY CHANGE
-		$b = ord($data[0]);
-		$data = substr($data, 1);
+		$b = ord(($data[0] ?? ''));
+		$data = substr(($data ?? ''), 1);
 		$extLen++;
 		while($b > 0) {
-			$data = substr($data, $b);
+			$data = substr(($data ?? ''), $b);
 			$extLen += $b;
-			$b    = ord($data[0]);
-			$data = substr($data, 1);
+			$b    = ord(($data[0] ?? ''));
+			$data = substr(($data ?? ''), 1);
 			$extLen++;
 		}
 		return true;
@@ -588,7 +588,7 @@
 
 	function w2i($str)
 	{
-		return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
+		return ord((substr(($str ?? ''), 0, 1) ?? '')) + (ord((substr(($str ?? ''), 1, 1) ?? '')) << 8);
 	}
 
 	///////////////////////////////////////////////////////////////////////////
@@ -621,13 +621,13 @@
 			}
 
 			for(; $y < $this->m_gih->m_nHeight; $y += $s) {
-				$lne = substr($this->m_data, 0, $this->m_gih->m_nWidth);
-				$this->m_data = substr($this->m_data, $this->m_gih->m_nWidth);
+				$lne = substr(($this->m_data ?? ''), 0, $this->m_gih->m_nWidth);
+				$this->m_data = substr(($this->m_data ?? ''), $this->m_gih->m_nWidth);
 
 				$data =
-					substr($data, 0, $y * $this->m_gih->m_nWidth) .
+					substr(($data ?? ''), 0, $y * $this->m_gih->m_nWidth) .
 					$lne .
-					substr($data, ($y + 1) * $this->m_gih->m_nWidth);
+					substr(($data ?? ''), ($y + 1) * $this->m_gih->m_nWidth);
 			}
 		}
 
@@ -647,7 +647,7 @@
 	///////////////////////////////////////////////////////////////////////////
 
 	// CONSTRUCTOR
-	function CGIF()
+	function __construct()
 	{
 		$this->m_gfh     = new CGIFFILEHEADER();
 		$this->m_img     = new CGIFIMAGE();
@@ -678,14 +678,14 @@
 			return false;
 		}
 
-		$this->m_lpData = substr($this->m_lpData, $len);
+		$this->m_lpData = substr(($this->m_lpData ?? ''), $len);
 
 		do {
 			$imgLen = 0;
 			if(!$this->m_img->load($this->m_lpData, $imgLen)) {
 				return false;
 			}
-			$this->m_lpData = substr($this->m_lpData, $imgLen);
+			$this->m_lpData = substr(($this->m_lpData ?? ''), $imgLen);
 		}
 		while($iIndex-- > 0);
 
--- a/intranet/mpdf60/classes/myanmar.php
+++ b/intranet/mpdf60/classes/myanmar.php
@@ -214,21 +214,21 @@
 	$syllable_serial = 1;
 	$broken_syllables = false;
 
-	while($ptr < strlen($s)) {
+	while($ptr < strlen(($s ?? ''))) {
 		$match = '';
 		$syllable_length = 1;
 		$syllable_type = self::NON_MYANMAR_CLUSTER ;
 		// CONSONANT_SYLLABLE Consonant syllable
 		// From OT spec:
-		if (preg_match('/^(RaH)?([C|R]|V|d|D)[s]?(H([C|R|V])[s]?)*(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		if (preg_match('/^(RaH)?([C|R]|V|d|D)[s]?(H([C|R|V])[s]?)*(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::CONSONANT_SYLLABLE ;
 		}
 
 		// BROKEN_CLUSTER syllable
-		else if (preg_match('/^(RaH)?s?(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', substr($s,$ptr), $ma)) {
-			if (strlen($ma[0])) {	// May match blank
-				$syllable_length = strlen($ma[0]);
+		else if (preg_match('/^(RaH)?s?(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			if (strlen(($ma[0] ?? ''))) {	// May match blank
+				$syllable_length = strlen(($ma[0] ?? ''));
 				$syllable_type = self::BROKEN_CLUSTER ;
 				$broken_syllables = true;
 			}
@@ -244,7 +244,7 @@
 
 public static function reordering(&$info, $GSUBdata, $broken_syllables, $dottedcircle) {
 	if ($broken_syllables && $dottedcircle) { self::insert_dotted_circles ($info, $dottedcircle); }
-	$count = count($info);
+	$count = count(($info ?? []));
 	if (!$count) return;
 	$last = 0;
 	$last_syllable = $info[0]['syllable'];
@@ -261,7 +261,7 @@
 public static function insert_dotted_circles(&$info, $dottedcircle) {
 	$idx = 0;
 	$last_syllable = 0;
-	while ($idx < count($info)) {
+	while ($idx < count(($info ?? []))) {
 		$syllable = $info[$idx]['syllable'];
 		$syllable_type = ($syllable & 0x0F);
 		if ($last_syllable != $syllable && $syllable_type == self::BROKEN_CLUSTER) {
--- a/intranet/mpdf60/classes/otl_dump.php
+++ b/intranet/mpdf60/classes/otl_dump.php
@@ -25,10 +25,22 @@
 // mPDF 5.7.1
 if(!function_exists('unicode_hex')){ 
 	function unicode_hex($unicode_dec) {
-		return (sprintf("%05s", strtoupper(dechex($unicode_dec))));
+		return (sprintf("%05s", strtoupper((dechex($unicode_dec) ?? ''))));
 	}
 }
 class OTLdump {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $mpdf;
+    public $mode;
+    public $version;
+    public $fontRevision;
+    public $restrictedUse;
+    public $GSUBFeatures;
+    public $GSUBLookups;
+    public $glyphIDtoUni;
+    public $glyphToChar;
+    public $GSLuCoverage;
+
 
 var $GPOSFeatures;	// mPDF 5.7.1
 var $GPOSLookups;		// mPDF 5.7.1
@@ -85,13 +97,13 @@
 var $maxUniChar;
 var $kerninfo;
 
-	function OTLdump(&$mpdf) {
+	function __construct(&$mpdf) {
 		$this->mpdf = $mpdf;
 		$this->maxStrLenRead = 200000;	// Maximum size of glyf table to read in as string (otherwise reads each glyph from file)
 	}
 
 
-	function getMetrics($file, $fontkey, $TTCfontID=0, $debug=false, $BMPonly=false, $kerninfo=false, $useOTL=0, $mode) {	// mPDF 5.7.1
+	function getMetrics($file, $fontkey, $TTCfontID, $debug, $BMPonly, $kerninfo, $useOTL, $mode) {	// mPDF 5.7.1
 		$this->mode = $mode;
 		$this->useOTL = $useOTL;	// mPDF 5.7.1
 		$this->fontkey = $fontkey;	// mPDF 5.7.1
@@ -157,7 +169,7 @@
             	$table = $this->get_chunk($t['offset'], $t['length']);
             	$checksum = $this->calcChecksum($table);
             	if ($t['tag'] == 'head') {
-				$up = unpack('n*', substr($table,8,4));
+				$up = unpack('n*', substr(($table ?? ''),8,4));
 				$adjustment[0] = $up[1];
 				$adjustment[1] = $up[2];
             		$checksum = $this->sub32($checksum, $adjustment);
@@ -183,13 +195,13 @@
 	}
 
 	function calcChecksum($data)  {
-		if (strlen($data) % 4) { $data .= str_repeat("\0",(4-(strlen($data) % 4))); }
-		$len = strlen($data);
+		if (strlen(($data ?? '')) % 4) { $data .= str_repeat("\0",(4-(strlen(($data ?? '')) % 4))); }
+		$len = strlen(($data ?? ''));
 		$hi=0x0000;
 		$lo=0x0000;
 		for($i=0;$i<$len;$i+=4) {
-			$hi += (ord($data[$i])<<8) + ord($data[$i+1]);
-			$lo += (ord($data[$i+2])<<8) + ord($data[$i+3]);
+			$hi += (ord(($data[$i] ?? ''))<<8) + ord(($data[$i+1] ?? ''));
+			$lo += (ord(($data[$i+2] ?? ''))<<8) + ord(($data[$i+3] ?? ''));
 			$hi += ($lo >> 16) & 0xFFFF;
 			$lo = $lo & 0xFFFF;
 		}
@@ -227,7 +239,7 @@
 	function read_short() {
 		$this->_pos += 2;
 		$s = fread($this->fh,2);
-		$a = (ord($s[0])<<8) + ord($s[1]);
+		$a = (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -235,7 +247,7 @@
 	}
 
 	function unpack_short($s) {
-		$a = (ord($s[0])<<8) + ord($s[1]);
+		$a = (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -245,27 +257,27 @@
 	function read_ushort() {
 		$this->_pos += 2;
 		$s = fread($this->fh,2);
-		return (ord($s[0])<<8) + ord($s[1]);
+		return (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 	}
 
 	function read_ulong() {
 		$this->_pos += 4;
 		$s = fread($this->fh,4);
 		// if large uInt32 as an integer, PHP converts it to -ve
-		return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); // 	16777216  = 1<<24
+		return (ord(($s[0] ?? ''))*16777216) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? '')); // 	16777216  = 1<<24
 	}
 
 	function get_ushort($pos) {
 		fseek($this->fh,$pos);
 		$s = fread($this->fh,2);
-		return (ord($s[0])<<8) + ord($s[1]);
+		return (ord(($s[0] ?? ''))<<8) + ord(($s[1] ?? ''));
 	}
 
 	function get_ulong($pos) {
 		fseek($this->fh,$pos);
 		$s = fread($this->fh,4);
 		// iF large uInt32 as an integer, PHP converts it to -ve
-		return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); // 	16777216  = 1<<24
+		return (ord(($s[0] ?? ''))*16777216) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? '')); // 	16777216  = 1<<24
 	}
 
 	function pack_short($val) {
@@ -278,7 +290,7 @@
 	}
 
 	function splice($stream, $offset, $value) {
-		return substr($stream,0,$offset) . $value . substr($stream,$offset+strlen($value));
+		return substr(($stream ?? ''),0,$offset) . $value . substr(($stream ?? ''),$offset+strlen(($value ?? '')));
 	}
 
 	function _set_ushort($stream, $offset, $value) {
@@ -338,7 +350,7 @@
 			$string_data_offset = $name_offset + $this->read_ushort();
 			$names = array(1=>'',2=>'',3=>'',4=>'',6=>'');
 			$K = array_keys($names);
-			$nameCount = count($names);
+			$nameCount = count(($names ?? []));
 			for ($i=0;$i<$numRecords; $i++) {
 				$platformId = $this->read_ushort();
 				$encodingId = $this->read_ushort();
@@ -357,7 +369,7 @@
 					$N = '';
 					while ($length > 0) {
 						$char = $this->read_ushort();
-						$N .= (chr($char));
+						$N .= (chr((int) ($char)));
 						$length -= 1;
 					}
 					$this->_pos = $opos;
@@ -378,19 +390,19 @@
 			if ($names[6])
 				$psName = $names[6];
 			else if ($names[4])
-				$psName = preg_replace('/ /','-',$names[4]);
+				$psName = preg_replace('/ /','-',($names[4] ?? ''));
 			else if ($names[1])
-				$psName = preg_replace('/ /','-',$names[1]);
+				$psName = preg_replace('/ /','-',($names[1] ?? ''));
 			else
 				$psName = '';
 			if (!$psName)
 				die("Could not find PostScript font name: ".$this->filename);
 			if ($debug) {
-			   for ($i=0;$i<count($psName);$i++) {
+			   for ($i=0;$i<count(($psName ?? []));$i++) {
 				$c = $psName[$i];
-				$oc = ord($c);
-				if ($oc>126 || strpos(' [](){}<>/%',$c)!==false)
-					die("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));
+				$oc = ord(($c ?? ''));
+				if ($oc>126 || strpos(' [](){}<>/%',($c ?? ''))!==false)
+					die("psName=".$psName." contains invalid character ".$c." ie U+".ord((c ?? '')));
 			   }
 			}
 			$this->name = $psName;
@@ -470,7 +482,7 @@
 			$this->_pos += 10;  //PANOSE = 10 byte length
 			$panose = fread($this->fh,10);
 			$this->panose = array();
-			for ($p=0;$p<strlen($panose);$p++) { $this->panose[] = ord($panose[$p]); }
+			for ($p=0;$p<strlen(($panose ?? ''));$p++) { $this->panose[] = ord(($panose[$p] ?? '')); }
 			$this->skip(26);
 			$sTypoAscender = $this->read_short();
 			$sTypoDescender = $this->read_short();
@@ -687,9 +699,9 @@
 				if (isset($glyphToChar[$gid][0])) {
 					$char = $glyphToChar[$gid][0];
 					if ($char != 0 && $char != 65535) {
-						$this->glyphIDtoUni[$gid*3] = chr($char >> 16);
-						$this->glyphIDtoUni[$gid*3 + 1] = chr(($char >> 8) & 0xFF);
-						$this->glyphIDtoUni[$gid*3 + 2] = chr($char & 0xFF);
+						$this->glyphIDtoUni[$gid*3] = chr((int) ($char >> 16));
+						$this->glyphIDtoUni[$gid*3 + 1] = chr((int) (($char >> 8) & 0xFF));
+						$this->glyphIDtoUni[$gid*3 + 2] = chr((int) ($char & 0xFF));
 					}
 				}
 			}
@@ -722,7 +734,7 @@
 					$left = $this->read_ushort();
 					$right = $this->read_ushort();
 					$val = $this->read_short();
-					if (count($glyphToChar[$left])==1 && count($glyphToChar[$right])==1) {
+					if (count(($glyphToChar[$left] ?? []))==1 && count(($glyphToChar[$right] ?? []))==1) {
 					  if ($left != 32 && $right != 32) {
 						$this->kerninfo[$glyphToChar[$left][0]][$glyphToChar[$right][0]] = intval($val*$scale);
 					  }
@@ -768,7 +780,7 @@
 				$this->mpdf->WriteHTML('<h2>Glyph classes</h2>'); 
 			}
 
-			if (isset($GlyphByClass[1]) && count($GlyphByClass[1])>0) { 
+			if (isset($GlyphByClass[1]) && count(($GlyphByClass[1] ?? []))>0) { 
 				$this->GlyphClassBases = $this->formatClassArr($GlyphByClass[1]); 
 				if ($this->mode == 'summary') {
 					$this->mpdf->WriteHTML('<h3>Glyph class 1</h3>'); 
@@ -783,7 +795,7 @@
 				}
 			}
 			else { $this->GlyphClassBases = ''; }
-			if (isset($GlyphByClass[2]) && count($GlyphByClass[2])>0) {
+			if (isset($GlyphByClass[2]) && count(($GlyphByClass[2] ?? []))>0) {
 				$this->GlyphClassLigatures = $this->formatClassArr($GlyphByClass[2]); 
 				if ($this->mode == 'summary') {
 					$this->mpdf->WriteHTML('<h3>Glyph class 2</h3>'); 
@@ -798,7 +810,7 @@
 				}
 			}
 			else { $this->GlyphClassLigatures = ''; }
-			if (isset($GlyphByClass[3]) && count($GlyphByClass[3])>0) {
+			if (isset($GlyphByClass[3]) && count(($GlyphByClass[3] ?? []))>0) {
 				$this->GlyphClassMarks = $this->formatClassArr($GlyphByClass[3]); 
 				if ($this->mode == 'summary') {
 					$this->mpdf->WriteHTML('<h3>Glyph class 3</h3>'); 
@@ -813,7 +825,7 @@
 				}
 			}
 			else { $this->GlyphClassMarks = ''; }
-			if (isset($GlyphByClass[4]) && count($GlyphByClass[4])>0) {
+			if (isset($GlyphByClass[4]) && count(($GlyphByClass[4] ?? []))>0) {
 				$this->GlyphClassComponents = $this->formatClassArr($GlyphByClass[4]); 
 				if ($this->mode == 'summary') {
 					$this->mpdf->WriteHTML('<h3>Glyph class 4</h3>'); 
@@ -871,7 +883,7 @@
 				$MarkAttachmentTypes = $this->_getClassDefinitionTable();
 				foreach($MarkAttachmentTypes AS $class=>$glyphs) {
 
-					if (is_array($Marks) && count($Marks)) {
+					if (is_array($Marks) && count(($Marks ?? []))) {
 						$mat = array_diff($Marks, $MarkAttachmentTypes[$class]);
 						sort($mat, SORT_STRING);
 					}
@@ -1076,7 +1088,7 @@
 				$this->mpdf->WriteHTML('<h3>GSUB Scripts &amp; Languages</h3>'); 
 				$this->mpdf->WriteHTML('<div class="glyphs">'); 
 				$html = '';
-				if (count($gsub)) {
+				if (count(($gsub ?? []))) {
 					foreach ($gsub AS $st=>$g) {
 						$html .= '<h5>'.$st.'</h5>'; 
 						foreach ($g AS $l=>$t) {
@@ -1448,7 +1460,7 @@
 					if ($Lookup[$i]['Type'] == 1) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage(false);
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = unicode_hex($this->glyphToChar[$glyphs[$g]][0]);
@@ -1468,13 +1480,13 @@
 					else if ($Lookup[$i]['Type'] == 2) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage();
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = $glyphs[$g];
 							// Flag = Ignore
 							if ($this->_checkGSUBignore($Lookup[$i]['Flag'], $replace[0], $Lookup[$i]['MarkFilteringSet'])) { continue; }
-if (!isset($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID']) || count($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'])==0) { continue; }	// Illegal for GlyphCount to be 0; either error in font, or something has gone wrong - lets carry on for now!
+if (!isset($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID']) || count(($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'] ?? []))==0) { continue; }	// Illegal for GlyphCount to be 0; either error in font, or something has gone wrong - lets carry on for now!
 							foreach($Lookup[$i]['Subtable'][$c]['Sequences'][$g]['SubstituteGlyphID'] AS $sub) {
 								$substitute[] = unicode_hex($this->glyphToChar[$sub][0]);
 							}
@@ -1485,7 +1497,7 @@
 					else if ($Lookup[$i]['Type'] == 3) {
 						$this->seek($Lookup[$i]['Subtable'][$c]['CoverageTableOffset']);
 						$glyphs = $this->_getCoverage();
-						for ($g=0;$g<count($glyphs);$g++) {
+						for ($g=0;$g<count(($glyphs ?? []));$g++) {
 							$replace = array();
 							$substitute = array();
 							$replace[] = $glyphs[$g];
@@ -1798,10 +1810,10 @@
 					// LookupType 1: Single Substitution Subtable
 					if ($Lookup[$i]['Type'] == 1) {
 						$html .= '<div class="lookuptype">LookupType 1: Single Substitution Subtable</div>'; 
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
-							if ($level==2 && strpos($coverage, $inputGlyphs[0])===false) { continue; }
+							if ($level==2 && strpos(($coverage ?? ''), ($inputGlyphs[0] ?? ''))===false) { continue; }
 							$html .= '<div class="substitution">';
 							$html .= '<span class="unicode">'.$this->formatUni($inputGlyphs[0]).'&nbsp;</span> ';
 							if ($level==2 && $exB) { $html .= $exB; }
@@ -1818,10 +1830,10 @@
 					// LookupType 2: Multiple Substitution Subtable
 					else if ($Lookup[$i]['Type'] == 2) {
 						$html .= '<div class="lookuptype">LookupType 2: Multiple Substitution Subtable</div>'; 
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'];
-							if ($level==2 && strpos($coverage, $inputGlyphs[0])===false) { continue; }
+							if ($level==2 && strpos(($coverage ?? ''), ($inputGlyphs[0] ?? ''))===false) { continue; }
 							$html .= '<div class="substitution">';
 							$html .= '<span class="unicode">'.$this->formatUni($inputGlyphs[0]).'&nbsp;</span> ';
 							if ($level==2 && $exB) { $html .= $exB; }
@@ -1838,10 +1850,10 @@
 					// LookupType 3: Alternate Forms
 					else if ($Lookup[$i]['Type'] == 3) {
 						$html .= '<div class="lookuptype">LookupType 3: Alternate Forms</div>'; 
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
-							if ($level==2 && strpos($coverage, $inputGlyphs[0])===false) { continue; }
+							if ($level==2 && strpos(($coverage ?? ''), ($inputGlyphs[0] ?? ''))===false) { continue; }
 							$html .= '<div class="substitution">';
 							$html .= '<span class="unicode">'.$this->formatUni($inputGlyphs[0]).'&nbsp;</span> ';
 							if ($level==2 && $exB) { $html .= $exB; }
@@ -1852,8 +1864,8 @@
 							$html .= '<span class="changed">&nbsp;'.$this->formatEntity($substitute).'</span>';
 							if ($level==2 && $exL) { $html .= $exL; }
 							$html .= '&nbsp; <span class="unicode">'.$this->formatUni($substitute).'</span> ';
-							if (count($Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'])>1) {
-								for ($alt=1;$alt<count($Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute']);$alt++) {
+							if (count(($Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'] ?? []))>1) {
+								for ($alt=1;$alt<count(($Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'] ?? []));$alt++) {
 									$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][$alt];
 									$html .= '&nbsp; | &nbsp; ALT #'.$alt.' &nbsp; ';
 									$html .= '<span class="changed">&nbsp;'.$this->formatEntity($substitute).'</span>';
@@ -1866,10 +1878,10 @@
 					// LookupType 4: Ligature Substitution Subtable
 					else if ($Lookup[$i]['Type'] == 4) {
 						$html .= '<div class="lookuptype">LookupType 4: Ligature Substitution Subtable</div>'; 
-						for ($s=0;$s<count($Lookup[$i]['Subtable'][$c]['subs']);$s++) {
+						for ($s=0;$s<count(($Lookup[$i]['Subtable'][$c]['subs'] ?? []));$s++) {
 							$inputGlyphs = $Lookup[$i]['Subtable'][$c]['subs'][$s]['Replace'];
 							$substitute = $Lookup[$i]['Subtable'][$c]['subs'][$s]['substitute'][0];
-							if ($level==2 && strpos($coverage, $inputGlyphs[0])===false) { continue; }
+							if ($level==2 && strpos(($coverage ?? ''), ($inputGlyphs[0] ?? ''))===false) { continue; }
 							$html .= '<div class="substitution">';
 							$html .= '<span class="unicode">'.$this->formatUniArr($inputGlyphs).'&nbsp;</span> ';
 							if ($level==2 && $exB) { $html .= $exB; }
@@ -1903,12 +1915,12 @@
 									}
 									$inputGlyphs[0] = $Lookup[$i]['Subtable'][$c]['SubRuleSet'][$s]['FirstGlyph'];
 									ksort($inputGlyphs);
-									$nInput = count($inputGlyphs);
+									$nInput = count(($inputGlyphs ?? []));
 
 
 									$exampleI = array();
 									$html .= '<div class="context">CONTEXT: ';
-									for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 										$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;'.$this->formatEntityStr($inputGlyphs[$ff]).'&nbsp;</span></div>';
 										$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 									}
@@ -1929,9 +1941,9 @@
 											}
 											$exB .= '</span>';
 										}
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												$exL .=  $this->formatEntity($inputGlyphs[$ip]).'&#x200d;';
 											}
 											$exL .= '</span>';
@@ -1948,7 +1960,7 @@
 									}
 
 
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 								}
 							}
@@ -1979,7 +1991,7 @@
 
 									$exampleI = array();
 									$html .= '<div class="context">CONTEXT: ';
-									for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 
 										if (!$inputGlyphs[$ff]) { 
 
@@ -2015,9 +2027,9 @@
 											$exB .= '</span>';
 										}
 
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												if (!$inputGlyphs[$ip]) { 
 													$exL .=  '[*]';
 												}
@@ -2038,7 +2050,7 @@
 										// to level 2 and only apply if first Replace glyph is in this list
 										$html .= $this->_getGSUBarray($Lookup, $lul2, $scripttag, 2, $inputGlyphs[$seqIndex], $exB, $exL);
 									}
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 								}
 							}
@@ -2056,7 +2068,7 @@
 
 							$exampleI = array();
 							$html .= '<div class="context">CONTEXT: ';
-							for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+							for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 								$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;'.$this->formatEntityStr($inputGlyphs[$ff]).'&nbsp;</span></div>';
 								$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 							}
@@ -2077,9 +2089,9 @@
 											$exB .= '</span>';
 										}
 
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												$exL .=  $exampleI[$ip].'&#x200d;';
 											}
 											$exL .= '</span>';
@@ -2095,7 +2107,7 @@
 										// to level 2 and only apply if first Replace glyph is in this list
 										$html .= $this->_getGSUBarray($Lookup, $lul2, $scripttag, 2, $inputGlyphs[$seqIndex], $exB, $exL);
 							}
-							if (count($subRule['rules'])) $volt[] = $subRule;
+							if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 						}
 
 //print_r($Lookup[$i]);
@@ -2121,7 +2133,7 @@
 									}
 									$inputGlyphs[0] = $firstInputGlyph;
 									ksort($inputGlyphs);
-									$nInput = count($inputGlyphs);
+									$nInput = count(($inputGlyphs ?? []));
 
 									if ($rule['BacktrackGlyphCount']) { $backtrackGlyphs = $rule['BacktrackGlyphs']; }
 									else { $backtrackGlyphs = array(); }
@@ -2134,15 +2146,15 @@
 									$exampleI = array();
 									$exampleL = array();
 									$html .= '<div class="context">CONTEXT: ';
-									for ($ff=count($backtrackGlyphs)-1;$ff>=0;$ff--) {
+									for ($ff=count(($backtrackGlyphs ?? []))-1;$ff>=0;$ff--) {
 										$html .= '<div>Backtrack #'.$ff.': <span class="unicode">'.$this->formatUniStr($backtrackGlyphs[$ff]).'</span></div>';
 										$exampleB[] = $this->formatEntityFirst($backtrackGlyphs[$ff]);
 									}
-									for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 										$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;'.$this->formatEntityStr($inputGlyphs[$ff]).'&nbsp;</span></div>';
 										$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 									}
-									for ($ff=0;$ff<count($lookaheadGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($lookaheadGlyphs ?? []));$ff++) {
 										$html .= '<div>Lookahead #'.$ff.': <span class="unicode">'.$this->formatUniStr($lookaheadGlyphs[$ff]).'</span></div>';
 										$exampleL[] = $this->formatEntityFirst($lookaheadGlyphs[$ff]);
 									}
@@ -2156,7 +2168,7 @@
 										// GENERATE exampleB[n] exampleI[<seqIndex] .... exampleI[>seqIndex] exampleL[n]
 										$exB = '';
 										$exL = '';
-										if (count($exampleB)) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
+										if (count(($exampleB ?? []))) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
 
 										if ($seqIndex>0) {
 											$exB .= '<span class="inputother">';
@@ -2166,15 +2178,15 @@
 											$exB .= '</span>';
 										}
 
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												$exL .=  $this->formatEntity($inputGlyphs[$ip]).'&#x200d;';
 											}
 											$exL .= '</span>';
 										}
 
-										if (count($exampleL)) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
+										if (count(($exampleL ?? []))) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
 
 										$html .= '<div class="sequenceIndex">Substitution Position: '.$seqIndex.'</div>'; 
 
@@ -2188,7 +2200,7 @@
 									}
 
 
-									if (count($subRule['rules'])) $volt[] = $subRule;
+									if (count(($subRule['rules'] ?? []))) $volt[] = $subRule;
 
 
 
@@ -2249,7 +2261,7 @@
 									$exampleI = array();
 									$exampleL = array();
 									$html .= '<div class="context">CONTEXT: ';
-									for ($ff=count($backtrackGlyphs)-1;$ff>=0;$ff--) {
+									for ($ff=count(($backtrackGlyphs ?? []))-1;$ff>=0;$ff--) {
 										if (!$backtrackGlyphs[$ff]) { 
 											$html .= '<div>Backtrack #'.$ff.': <span class="unchanged">&nbsp;[NOT '.$this->formatEntityStr($class0excl).']&nbsp;</span></div>';
 											$exampleB[] = '[NOT '.$this->formatEntityFirst($class0excl).']';
@@ -2260,7 +2272,7 @@
 											$exampleB[] = $this->formatEntityFirst($backtrackGlyphs[$ff]);
 										}
 									}
-									for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 										if (!$inputGlyphs[$ff]) { 
 											$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;[NOT '.$this->formatEntityStr($class0excl).']&nbsp;</span></div>';
 											$exampleI[] = '[NOT '.$this->formatEntityFirst($class0excl).']';
@@ -2270,7 +2282,7 @@
 											$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 										}
 									}
-									for ($ff=0;$ff<count($lookaheadGlyphs);$ff++) {
+									for ($ff=0;$ff<count(($lookaheadGlyphs ?? []));$ff++) {
 										if (!$lookaheadGlyphs[$ff]) { 
 											$html .= '<div>Lookahead #'.$ff.': <span class="unchanged">&nbsp;[NOT '.$this->formatEntityStr($class0excl).']&nbsp;</span></div>';
 											$exampleL[] = '[NOT '.$this->formatEntityFirst($class0excl).']';
@@ -2291,7 +2303,7 @@
 										// GENERATE exampleB[n] exampleI[<seqIndex] .... exampleI[>seqIndex] exampleL[n]
 										$exB = '';
 										$exL = '';
-										if (count($exampleB)) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
+										if (count(($exampleB ?? []))) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
 
 										if ($seqIndex>0) {
 											$exB .= '<span class="inputother">';
@@ -2306,9 +2318,9 @@
 											$exB .= '</span>';
 										}
 
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												if (!$inputGlyphs[$ip]) { 
 													$exL .=  '[*]';
 												}
@@ -2319,7 +2331,7 @@
 											$exL .= '</span>';
 										}
 
-										if (count($exampleL)) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
+										if (count(($exampleL ?? []))) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
 
 										$html .= '<div class="sequenceIndex">Substitution Position: '.$seqIndex.'</div>'; 
 
@@ -2363,15 +2375,15 @@
 							$exampleI = array();
 							$exampleL = array();
 							$html .= '<div class="context">CONTEXT: ';
-							for ($ff=count($backtrackGlyphs)-1;$ff>=0;$ff--) {
+							for ($ff=count(($backtrackGlyphs ?? []))-1;$ff>=0;$ff--) {
 								$html .= '<div>Backtrack #'.$ff.': <span class="unicode">'.$this->formatUniStr($backtrackGlyphs[$ff]).'</span></div>';
 								$exampleB[] = $this->formatEntityFirst($backtrackGlyphs[$ff]);
 							}
-							for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+							for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 								$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;'.$this->formatEntityStr($inputGlyphs[$ff]).'&nbsp;</span></div>';
 								$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 							}
-							for ($ff=0;$ff<count($lookaheadGlyphs);$ff++) {
+							for ($ff=0;$ff<count(($lookaheadGlyphs ?? []));$ff++) {
 								$html .= '<div>Lookahead #'.$ff.': <span class="unicode">'.$this->formatUniStr($lookaheadGlyphs[$ff]).'</span></div>';
 								$exampleL[] = $this->formatEntityFirst($lookaheadGlyphs[$ff]);
 							}
@@ -2386,7 +2398,7 @@
 										// GENERATE exampleB[n] exampleI[<seqIndex] .... exampleI[>seqIndex] exampleL[n]
 										$exB = '';
 										$exL = '';
-										if (count($exampleB)) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
+										if (count(($exampleB ?? []))) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
 
 										if ($seqIndex>0) {
 											$exB .= '<span class="inputother">';
@@ -2396,15 +2408,15 @@
 											$exB .= '</span>';
 										}
 
-										if (count($inputGlyphs)>($seqIndex+1)) {
+										if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 											$exL .= '<span class="inputother">';
-											for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+											for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 												$exL .=  $exampleI[$ip].'&#x200d;';
 											}
 											$exL .= '</span>';
 										}
 
-										if (count($exampleL)) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
+										if (count(($exampleL ?? []))) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
 
 										$html .= '<div class="sequenceIndex">Substitution Position: '.$seqIndex.'</div>'; 
 
@@ -2432,13 +2444,13 @@
 	function _checkGSUBignore($flag, $glyph, $MarkFilteringSet) {
 		$ignore = false;
 		// Flag & 0x0008 = Ignore Marks
-		if ((($flag & 0x0008) == 0x0008) && strpos($this->GlyphClassMarks,$glyph)) { $ignore = true; }
-		if ((($flag & 0x0004) == 0x0004) && strpos($this->GlyphClassLigatures,$glyph)) { $ignore = true; }
-		if ((($flag & 0x0002) == 0x0002) && strpos($this->GlyphClassBases,$glyph)) { $ignore = true; }
+		if ((($flag & 0x0008) == 0x0008) && strpos(($this->GlyphClassMarks ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if ((($flag & 0x0004) == 0x0004) && strpos(($this->GlyphClassLigatures ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if ((($flag & 0x0002) == 0x0002) && strpos(($this->GlyphClassBases ?? ''),($glyph ?? ''))) { $ignore = true; }
 		// Flag & 0xFF?? = MarkAttachmentType
-		if (($flag & 0xFF00) && strpos($this->MarkAttachmentType[($flag >> 8)],$glyph)) { $ignore = true; }
+		if (($flag & 0xFF00) && strpos(($this->MarkAttachmentType[($flag >> 8)] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		// Flag & 0x0010 = UseMarkFilteringSet
-		if (($flag & 0x0010) && strpos($this->MarkGlyphSets[$MarkFilteringSet],$glyph)) { $ignore = true; }
+		if (($flag & 0x0010) && strpos(($this->MarkGlyphSets[$MarkFilteringSet] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		return $ignore;
 	}
 
@@ -2540,8 +2552,8 @@
 		// Returns e.g. ¦(0612)¦(ignore) (0613)¦(ignore) (0614)¦
 		// $inputGlyphs = array of glyphs(glyphstrings) making up Input sequence in Context
 		// $lookupGlyphs = array of glyphs (single Glyphs) making up Lookup Input sequence
-		$mLen = count($lookupGlyphs);		// nGlyphs in the secondary Lookup match 
-		$nInput = count($inputGlyphs);	// nGlyphs in the Primary Input sequence
+		$mLen = count(($lookupGlyphs ?? []));		// nGlyphs in the secondary Lookup match 
+		$nInput = count(($inputGlyphs ?? []));	// nGlyphs in the Primary Input sequence
 		$str = "";
 		for($i=0;$i<$nInput;$i++) {
 			if ($i>0) { $str .= $ignore." "; }
@@ -2557,7 +2569,7 @@
 		// $inputGlyphs = array of glyphs(glyphstrings) making up Input sequence in Context
 		// $lookupGlyphs = array of glyphs making up Lookup Input sequence - if applicable
 		$str = "";
-		for($i=1;$i<=count($inputGlyphs);$i++) {
+		for($i=1;$i<=count(($inputGlyphs ?? []));$i++) {
 			if ($i>1) { $str .= $ignore." "; }
 			$str .= "".$inputGlyphs[($i-1)]."";
 		}
@@ -2571,7 +2583,7 @@
 		// 3  2  1  0
 		// each item being e.g. E0AD|E0AF|F1FD
 		$str = "";
-		for($i=(count($backtrackGlyphs)-1);$i>=0;$i--) {
+		for($i=(count(($backtrackGlyphs ?? []))-1);$i>=0;$i--) {
 			$str .= "".$backtrackGlyphs[$i]." ".$ignore." ";
 		}
 		return $str;
@@ -2584,7 +2596,7 @@
 		// 0  1  2  3
 		// each item being e.g. E0AD|E0AF|F1FD
 		$str = "";
-		for($i=0;$i<count($lookaheadGlyphs);$i++) {
+		for($i=0;$i<count(($lookaheadGlyphs ?? []));$i++) {
 			$str .= $ignore." ".$lookaheadGlyphs[$i]."";
 		}
 		return $str;
@@ -2818,7 +2830,7 @@
 			if ($this->mode == 'summary') {
 				$this->mpdf->WriteHTML('<h3>GPOS Scripts &amp; Languages</h3>'); 
 				$html = '';
-				if (count($gpos)) {
+				if (count(($gpos ?? []))) {
 					foreach ($gpos AS $st=>$g) {
 						$html .= '<h5>'.$st.'</h5>'; 
 						foreach ($g AS $l=>$t) {
@@ -2889,7 +2901,7 @@
 
 			$lul = array();	// array of LookupListIndexes
 			$tags = array();	// corresponding array of feature tags e.g. 'ccmp'
-			if (count($langsys)) {
+			if (count(($langsys ?? []))) {
 				foreach($langsys AS $tag=>$ft) {
 					foreach($ft AS $ll) { 
 						$lul[$ll] = $tag; 
@@ -2955,8 +2967,8 @@
 
 							$this->seek($Coverage);
 							$glyphs = $this->_getCoverage();	// Array of Hex Glyphs
-							for($g=0;$g<count($glyphs);$g++) {
-								if ($level==2 && strpos($lcoverage, $glyphs[$g])===false) { continue; }
+							for($g=0;$g<count(($glyphs ?? []));$g++) {
+								if ($level==2 && strpos(($lcoverage ?? ''), ($glyphs[$g] ?? ''))===false) { continue; }
 
 								$html .= '<div class="substitution">';
 								$html .= '<span class="unicode">'.$this->formatUni($glyphs[$g]).'&nbsp;</span> ';
@@ -2991,8 +3003,8 @@
 							$this->seek($Coverage);
 							$glyphs = $this->_getCoverage();	// Array of Hex Glyphs
 
-							for($g=0;$g<count($glyphs);$g++) {
-								if ($level==2 && strpos($lcoverage, $glyphs[$g])===false) { continue; }
+							for($g=0;$g<count(($glyphs ?? []));$g++) {
+								if ($level==2 && strpos(($lcoverage ?? ''), ($glyphs[$g] ?? ''))===false) { continue; }
 								$Value = $Values[$g];
 
 								$html .= '<div class="substitution">';
@@ -3036,7 +3048,7 @@
 							$this->seek($Coverage);
 							$glyphs = $this->_getCoverage();	// Array of Hex Glyphs
 							for($p=0;$p<$PairSetCount;$p++) {
-								if ($level==2 && strpos($lcoverage, $glyphs[$p])===false) { continue; }
+								if ($level==2 && strpos(($lcoverage ?? ''), ($glyphs[$p] ?? ''))===false) { continue; }
 								$this->seek($PairSetOffset[$p]);
 								// First Glyph = $glyphs[$p]
 
@@ -3131,15 +3143,15 @@
 											}
 
 
-											for($c1=0;$c1<count($Class1[$i]);$c1++) {
+											for($c1=0;$c1<count(($Class1[$i] ?? []));$c1++) {
 
 												$FirstGlyph = $Class1[$i][$c1];
-												if ($level==2 && strpos($lcoverage, $FirstGlyph)===false) { 
+												if ($level==2 && strpos(($lcoverage ?? ''), ($FirstGlyph ?? ''))===false) { 
 													continue; 
 												}
 
 
-												for($c2=0;$c2<count($Class2[$j]);$c2++) {
+												for($c2=0;$c2<count(($Class2[$j] ?? []));$c2++) {
 													$SecondGlyph = $Class2[$j][$c2];
 
 
@@ -3241,8 +3253,8 @@
 
 						$firstMark = '';
 						$html .= '<div class="glyphs">Marks: ';
-						for($i=0;$i<count($MarkGlyphs);$i++) {
-							if ($level==2 && strpos($lcoverage, $MarkGlyphs[$i])===false) { continue; }
+						for($i=0;$i<count(($MarkGlyphs ?? []));$i++) {
+							if ($level==2 && strpos(($lcoverage ?? ''), ($MarkGlyphs[$i] ?? ''))===false) { continue; }
 							else { 
 								if (!$firstMark) { $firstMark = $MarkGlyphs[$i]; }
 							}
@@ -3252,14 +3264,14 @@
 						if (!$firstMark) { return; }
 
 						$html .= '<div class="glyphs">Bases: ';
-						for($j=0;$j<count($BaseGlyphs);$j++) {
+						for($j=0;$j<count(($BaseGlyphs ?? []));$j++) {
 							$html .= ' '.$this->formatEntity($BaseGlyphs[$j]).' ';
 						}
 						$html .= '</div>';
 
 						// Example
 						$html .= '<div class="glyphs" style="font-feature-settings:\''.$tag.'\' 1;">Example(s): ';
-						for ($j=0;$j<min(count($BaseGlyphs),20);$j++) {
+						for ($j=0;$j<min(count(($BaseGlyphs ?? [])),20);$j++) {
 							$html .= ' '.$this->formatEntity($BaseGlyphs[$j]).$this->formatEntity($firstMark,true).' &nbsp; ';
 						}
 						$html .= '</div>';
@@ -3286,8 +3298,8 @@
 						$firstMark = '';
 						$html .= '<div class="glyphs">Marks: <span class="unchanged">';
 						$MarkRecord = array();
-						for ($i=0;$i<count($MarkGlyphs);$i++) {
-							if ($level==2 && strpos($lcoverage, $MarkGlyphs[$i])===false) { continue; }
+						for ($i=0;$i<count(($MarkGlyphs ?? []));$i++) {
+							if ($level==2 && strpos(($lcoverage ?? ''), ($MarkGlyphs[$i] ?? ''))===false) { continue; }
 							else { 
 								if (!$firstMark) { $firstMark = $MarkGlyphs[$i]; }
 							}
@@ -3303,7 +3315,7 @@
 						$LigatureCount = $this->read_ushort();
 						$LigatureAttach = array();
 						$html .= '<div class="glyphs">Ligatures: <span class="unchanged">';
-						for ($j=0;$j<count($LigatureGlyphs);$j++) {
+						for ($j=0;$j<count(($LigatureGlyphs ?? []));$j++) {
 							// Get the relevant LigatureRecord
 							$LigatureAttach[$j] = $LigatureArray + $this->read_ushort();
 							$html .= ' '.$this->formatEntity($LigatureGlyphs[$j]).' ';
@@ -3355,8 +3367,8 @@
 
 						$firstMark = '';
 						$html .= '<div class="glyphs">Marks: <span class="unchanged">';
-						for($i=0;$i<count($Mark1Glyphs);$i++) {
-							if ($level==2 && strpos($lcoverage, $Mark1Glyphs[$i])===false) { continue; }
+						for($i=0;$i<count(($Mark1Glyphs ?? []));$i++) {
+							if ($level==2 && strpos(($lcoverage ?? ''), ($Mark1Glyphs[$i] ?? ''))===false) { continue; }
 							else { 
 								if (!$firstMark) { $firstMark = $Mark1Glyphs[$i]; }
 							}
@@ -3367,14 +3379,14 @@
 						if ($firstMark) { 
 
 							$html .= '<div class="glyphs">Bases: <span class="unchanged">';
-							for($j=0;$j<count($Mark2Glyphs);$j++) {
+							for($j=0;$j<count(($Mark2Glyphs ?? []));$j++) {
 								$html .= ' '.$this->formatEntity($Mark2Glyphs[$j]).' ';
 							}
 							$html .= '</span></div>';
 
 							// Example
 							$html .= '<div class="glyphs" style="font-feature-settings:\''.$tag.'\' 1;">Example(s): <span class="changed">';
-							for ($j=0;$j<min(count($Mark2Glyphs),20);$j++) {
+							for ($j=0;$j<min(count(($Mark2Glyphs ?? [])),20);$j++) {
 								$html .= ' '.$this->formatEntity($Mark2Glyphs[$j]).$this->formatEntity($firstMark,true).' &nbsp; ';
 							}
 							$html .= '</span></div>';
@@ -3476,15 +3488,15 @@
 							$exampleI = array();
 							$exampleL = array();
 							$html .= '<div class="context">CONTEXT: ';
-							for ($ff=count($backtrackGlyphs)-1;$ff>=0;$ff--) {
+							for ($ff=count(($backtrackGlyphs ?? []))-1;$ff>=0;$ff--) {
 								$html .= '<div>Backtrack #'.$ff.': <span class="unicode">'.$this->formatUniStr($backtrackGlyphs[$ff]).'</span></div>';
 								$exampleB[] = $this->formatEntityFirst($backtrackGlyphs[$ff]);
 							}
-							for ($ff=0;$ff<count($inputGlyphs);$ff++) {
+							for ($ff=0;$ff<count(($inputGlyphs ?? []));$ff++) {
 								$html .= '<div>Input #'.$ff.': <span class="unchanged">&nbsp;'.$this->formatEntityStr($inputGlyphs[$ff]).'&nbsp;</span></div>';
 								$exampleI[] = $this->formatEntityFirst($inputGlyphs[$ff]);
 							}
-							for ($ff=0;$ff<count($lookaheadGlyphs);$ff++) {
+							for ($ff=0;$ff<count(($lookaheadGlyphs ?? []));$ff++) {
 								$html .= '<div>Lookahead #'.$ff.': <span class="unicode">'.$this->formatUniStr($lookaheadGlyphs[$ff]).'</span></div>';
 								$exampleL[] = $this->formatEntityFirst($lookaheadGlyphs[$ff]);
 							}
@@ -3498,7 +3510,7 @@
 								// GENERATE exampleB[n] exampleI[<seqIndex] .... exampleI[>seqIndex] exampleL[n]
 								$exB = '';
 								$exL = '';
-								if (count($exampleB)) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
+								if (count(($exampleB ?? []))) { $exB .= '<span class="backtrack">'.implode('&#x200d;',$exampleB).'</span>'; }
 
 								if ($seqIndex>0) {
 									$exB .= '<span class="inputother">';
@@ -3508,15 +3520,15 @@
 									$exB .= '</span>';
 								}
 
-								if (count($inputGlyphs)>($seqIndex+1)) {
+								if (count(($inputGlyphs ?? []))>($seqIndex+1)) {
 									$exL .= '<span class="inputother">';
-									for($ip=$seqIndex+1;$ip<count($inputGlyphs);$ip++) {
+									for($ip=$seqIndex+1;$ip<count(($inputGlyphs ?? []));$ip++) {
 										$exL .=  '&#x200d;'.$exampleI[$ip];
 									}
 									$exL .= '</span>';
 								}
 
-								if (count($exampleL)) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
+								if (count(($exampleL ?? []))) { $exL .= '<span class="lookahead">'.implode('&#x200d;',$exampleL).'</span>'; }
 
 								$html .= '<div class="sequenceIndex">Substitution Position: '.$seqIndex.'</div>'; 
 
@@ -3599,7 +3611,7 @@
 	function getGlyphData($originalGlyphIdx, &$maxdepth, &$depth, &$points, &$contours) {
 		$depth++;
 		$maxdepth = max($maxdepth, $depth);
-		if (count($this->glyphdata[$originalGlyphIdx]['compGlyphs'])) {
+		if (count(($this->glyphdata[$originalGlyphIdx]['compGlyphs'] ?? []))) {
 			foreach($this->glyphdata[$originalGlyphIdx]['compGlyphs'] AS $glyphIdx) {
 				$this->getGlyphData($glyphIdx, $maxdepth, $depth, $points, $contours);
 			}
@@ -3629,7 +3641,7 @@
 				$flags = $this->read_ushort();
 				$glyphIdx = $this->read_ushort();
 				if (!isset($glyphSet[$glyphIdx])) {
-					$glyphSet[$glyphIdx] = count($subsetglyphs);	// old glyphID to new glyphID
+					$glyphSet[$glyphIdx] = count(($subsetglyphs ?? []));	// old glyphID to new glyphID
 					$subsetglyphs[$glyphIdx] = true;
 				}
 				$savepos = ftell($this->fh);
@@ -3685,8 +3697,8 @@
  						$w = intval(round($scale*$aw));
 						if ($w == 0) { $w = 65535; }
 						if ($char < 196608) {
-							$this->charWidths[$char*2] = chr($w >> 8);
-							$this->charWidths[$char*2 + 1] = chr($w & 0xFF);
+							$this->charWidths[$char*2] = chr((int) ($w >> 8));
+							$this->charWidths[$char*2 + 1] = chr((int) ($w & 0xFF));
 							$nCharWidths++;
 						}
 					}
@@ -3704,8 +3716,8 @@
 				foreach($glyphToChar[$glyph] AS $char) {
 					if ($char != 0 && $char != 65535) {
 						if ($char < 196608) { 
-							$this->charWidths[$char*2] = chr($w >> 8);
-							$this->charWidths[$char*2 + 1] = chr($w & 0xFF);
+							$this->charWidths[$char*2] = chr((int) ($w >> 8));
+							$this->charWidths[$char*2 + 1] = chr((int) ($w & 0xFF));
 							$nCharWidths++;
 						}
 					}
@@ -3714,8 +3726,8 @@
 		}
 		// NB 65535 is a set width of 0
 		// First bytes define number of chars in font
-		$this->charWidths[0] = chr($nCharWidths >> 8);
-		$this->charWidths[1] = chr($nCharWidths & 0xFF);
+		$this->charWidths[0] = chr((int) ($nCharWidths >> 8));
+		$this->charWidths[1] = chr((int) ($nCharWidths & 0xFF));
 	}
 
 
@@ -3805,17 +3817,17 @@
 	}
 
 function formatUni($char) {
-	$x = preg_replace('/^[0]*/','',$char);
-	$x = str_pad($x, 4, '0', STR_PAD_LEFT);
+	$x = preg_replace('/^[0]*/','',($char ?? ''));
+	$x = str_pad(($x ?? ''), 4, '0', STR_PAD_LEFT);
 	$d = hexdec($x);
 	if (($d>57343 && $d<63744) || ($d>122879 && $d<126977)) { $id = 'M'; }	// E000 - F8FF, 1E000-1F000
 	else { $id = 'U'; }
 	return $id .'+'.$x;
 }
 function formatEntity($char, $allowjoining=false) {
-	$char = preg_replace('/^[0]/','',$char);
+	$char = preg_replace('/^[0]/','',($char ?? ''));
 	$x = '&#x'.$char.';';
-	if (strpos($this->GlyphClassMarks, $char)!==false) { 
+	if (strpos(($this->GlyphClassMarks ?? ''), ($char ?? ''))!==false) { 
 		if (!$allowjoining) { 
 			$x = '&#x25cc;'.$x; 
 		}
@@ -3825,20 +3837,20 @@
 function formatUniArr($arr) {
 	$s = array();
 	foreach($arr AS $c) {
-		$x = preg_replace('/^[0]*/','',$c);
+		$x = preg_replace('/^[0]*/','',($c ?? ''));
 		$d = hexdec($x);
 		if (($d>57343 && $d<63744) || ($d>122879 && $d<126977)) { $id = 'M'; }	// E000 - F8FF, 1E000-1F000
 		else { $id = 'U'; }
-		$s[] = $id .'+'.str_pad($x, 4, '0', STR_PAD_LEFT);
+		$s[] = $id .'+'.str_pad(($x ?? ''), 4, '0', STR_PAD_LEFT);
 	}
 	return implode(', ',$s);
 }
 function formatEntityArr($arr) {
 	$s = array();
 	foreach($arr AS $c) {
-		$c = preg_replace('/^[0]/','',$c);
+		$c = preg_replace('/^[0]/','',($c ?? ''));
 		$x = '&#x'.$c.';';
-		if (strpos($this->GlyphClassMarks, $c)!==false) { 
+		if (strpos(($this->GlyphClassMarks ?? ''), ($c ?? ''))!==false) { 
 			$x = '&#x25cc;'.$x; 
 		}
 		$s[] = $x;
@@ -3848,33 +3860,33 @@
 function formatClassArr($arr) {
 	$s = array();
 	foreach($arr AS $c) {
-		$x = preg_replace('/^[0]*/','',$c);
+		$x = preg_replace('/^[0]*/','',($c ?? ''));
 		$d = hexdec($x);
 		if (($d>57343 && $d<63744) || ($d>122879 && $d<126977)) { $id = 'M'; }	// E000 - F8FF, 1E000-1F000
 		else { $id = 'U'; }
-		$s[] = $id .'+'.str_pad($x, 4, '0', STR_PAD_LEFT);
+		$s[] = $id .'+'.str_pad(($x ?? ''), 4, '0', STR_PAD_LEFT);
 	}
 	return implode(', ',$s);
 }
 function formatUniStr($str) {
 	$s = array();
-	$arr = explode('|',$str);
+	$arr = explode('|',($str ?? ''));
 	foreach($arr AS $c) {
-		$x = preg_replace('/^[0]*/','',$c);
+		$x = preg_replace('/^[0]*/','',($c ?? ''));
 		$d = hexdec($x);
 		if (($d>57343 && $d<63744) || ($d>122879 && $d<126977)) { $id = 'M'; }	// E000 - F8FF, 1E000-1F000
 		else { $id = 'U'; }
-		$s[] = $id .'+'.str_pad($x, 4, '0', STR_PAD_LEFT);
+		$s[] = $id .'+'.str_pad(($x ?? ''), 4, '0', STR_PAD_LEFT);
 	}
 	return implode(', ',$s);
 }
 function formatEntityStr($str) {
 	$s = array();
-	$arr = explode('|',$str);
+	$arr = explode('|',($str ?? ''));
 	foreach($arr AS $c) {
-		$c = preg_replace('/^[0]/','',$c);
+		$c = preg_replace('/^[0]/','',($c ?? ''));
 		$x = '&#x'.$c.';';
-		if (strpos($this->GlyphClassMarks, $c)!==false) { 
+		if (strpos(($this->GlyphClassMarks ?? ''), ($c ?? ''))!==false) { 
 			$x = '&#x25cc;'.$x; 
 		}
 		$s[] = $x;
@@ -3882,10 +3894,10 @@
 	return implode(' ',$s);	// ZWNJ? &#x200d;
 }
 function formatEntityFirst($str) {
-	$arr = explode('|',$str);
-	$char = preg_replace('/^[0]/','',$arr[0]);
+	$arr = explode('|',($str ?? ''));
+	$char = preg_replace('/^[0]/','',($arr[0] ?? ''));
 	$x = '&#x'.$char.';';
-	if (strpos($this->GlyphClassMarks, $char)!==false) { 
+	if (strpos(($this->GlyphClassMarks ?? ''), ($char ?? ''))!==false) { 
 		$x = '&#x25cc;'.$x; 
 	}
 	return $x;
--- a/intranet/mpdf60/classes/mpdfform.php
+++ b/intranet/mpdf60/classes/mpdfform.php
@@ -49,7 +49,7 @@
 // FORMS
 var $textarea_lineheight;
 
-function mpdfform(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 
 	// ACTIVE FORMS
@@ -148,11 +148,11 @@
 				$this->mpdf->y += $this->form_element_spacing['input']['outer']['v'] /$k;
 				// Chop texto to max length $w-inner-padding
 				while ($this->mpdf->GetStringWidth($texto) > $w-($this->form_element_spacing['input']['inner']['h']*2)) {
-					$texto = mb_substr($texto,0,mb_strlen($texto,$this->mpdf->mb_enc)-1,$this->mpdf->mb_enc);
+					$texto = mb_substr(($texto ?? ''),0,mb_strlen(($texto ?? ''),$this->mpdf->mb_enc)-1,$this->mpdf->mb_enc);
 				}
 
 				// DIRECTIONALITY
-				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; }	// *RTL*
+				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", ($texto ?? ''))) { $this->mpdf->biDirectional = true; }	// *RTL*
 
 				// Use OTL OpenType Table Layout - GSUB & GPOS
 				if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
@@ -269,14 +269,14 @@
 				else { $js = ''; }	// mPDF 5.3.37
 				$data = array('VAL' => array(), 'OPT' => array(), 'SEL' => array(), );
 				if (isset($objattr['items'])) {
-					for($i=0; $i<count($objattr['items']); $i++) {
+					for($i=0; $i<count(($objattr['items'] ?? [])); $i++) {
 						$item = $objattr['items'][$i];
 						$data['VAL'][] = (isset($item['exportValue']) ? $item['exportValue'] : '');
 						$data['OPT'][] = (isset($item['content']) ? $item['content'] : '');
 						if (isset($item['selected']) && $item['selected']) { $data['SEL'][] = $i; }
 					}
 				}
-				if (count($data['SEL'])==0 && $this->formSelectDefaultOption) {$data['SEL'][] = 0; }
+				if (count(($data['SEL'] ?? []))==0 && $this->formSelectDefaultOption) {$data['SEL'][] = 0; }
 				if (isset($objattr['color'])) {
 					$this->mpdf->SetTColor($objattr['color']);
 				}
@@ -302,7 +302,7 @@
 				$this->mpdf->y += $this->form_element_spacing['select']['outer']['v'] /$k ;
 
 				// DIRECTIONALITY
-				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; }	// *RTL*
+				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", ($texto ?? ''))) { $this->mpdf->biDirectional = true; }	// *RTL*
 
 				$this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $objattr['OTLdata']);
 
@@ -397,7 +397,7 @@
 				$this->mpdf->y += $this->form_element_spacing['button']['inner']['v'] /$k ;
 
 				// DIRECTIONALITY
-				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; }	// *RTL*
+				if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", ($texto ?? ''))) { $this->mpdf->biDirectional = true; }	// *RTL*
 
 				// Use OTL OpenType Table Layout - GSUB & GPOS
 				if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
@@ -644,7 +644,7 @@
 
 
 function SetFormButtonJS( $name, $js ) {
-	$js = str_replace("\t",' ', trim($js) );
+	$js = str_replace("\t",' ', (trim(($js ?? '')) ?? '') );
 	if ( isset($name) && isset($js) ) {
 		$this->array_form_button_js[$this->mpdf->_escape($name)] = array(
 				'js' => $js
@@ -653,7 +653,7 @@
 }
 
 function SetFormChoiceJS( $name, $js ) {
-	$js = str_replace("\t",' ', trim($js) );
+	$js = str_replace("\t",' ', (trim(($js ?? '')) ?? '') );
 	if ( isset($name) && isset($js) ) {
 		$this->array_form_choice_js[$this->mpdf->_escape($name)] = array(
 				'js' => $js
@@ -662,8 +662,8 @@
 }
 
 function SetFormTextJS( $name, $js) {
-   for ($i=0; $i<count($js); $i++) {
-	$j = str_replace("\t",' ', trim($js[$i][1]) );
+   for ($i=0; $i<count(($js ?? [])); $i++) {
+	$j = str_replace("\t",' ', (trim(($js[$i][1] ?? '')) ?? '') );
 	$format = $js[$i][0];
 	if ($name) {
 		$this->array_form_text_js[$this->mpdf->_escape($name)][$format] = array('js' => $j);
@@ -682,7 +682,7 @@
 		chr(0202) => chr(0221), chr(0232) => chr(0235), chr(0230) => chr(0037), chr(0231) => chr(0222),
 		chr(0216) => chr(0231), chr(0240) => chr(0040)
 	); // mPDF 5.3.46
-	return strtr($txt, $Win1252ToPDFDocEncoding );
+	return strtr(($txt ?? ''), ($Win1252ToPDFDocEncoding ?? '') );
 }
 
 
@@ -693,7 +693,7 @@
 	else if( $align == 'R' ) { $align = '2'; }
 	else { $align = '0'; }
 	if ($maxlen < 1) { $maxlen = false; }
-	if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) {
+	if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', ($name ?? ''))) {
 			$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); 
 	}
 	if ($this->mpdf->onlyCoreFonts) { 
@@ -740,7 +740,7 @@
 				'fontcolor'	=> $this->mpdf->TextColor,
 			)
 	);
-	if (is_array($js) && count($js)>0) { $this->SetFormTextJS( $name, $js); }	// mPDF 5.3.25
+	if (is_array($js) && count(($js ?? []))>0) { $this->SetFormTextJS( $name, $js); }	// mPDF 5.3.25
 	if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; }
 	else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; }
 	else { 
@@ -764,17 +764,17 @@
 		$this->formn++;
 		if( $this->mpdf->blk[$this->mpdf->blklvl]['direction'] == 'rtl' ) { $align = '2'; }
 		else { $align = '0'; }
-		if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { 
+		if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', ($name ?? ''))) { 
 			$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); 
 		}
 		if ($this->mpdf->onlyCoreFonts) { 
-			for($i=0;$i<count($array['VAL']);$i++) {
+			for($i=0;$i<count(($array['VAL'] ?? []));$i++) {
 				$array['VAL'][$i] = $this->Win1252ToPDFDocEncoding($array['VAL'][$i]); 
 				$array['OPT'][$i] = $this->Win1252ToPDFDocEncoding($array['OPT'][$i]); 
 			}
 		}
 		else { 
-			for($i=0;$i<count($array['VAL']);$i++) {
+			for($i=0;$i<count(($array['VAL'] ?? []));$i++) {
 				if (isset($this->mpdf->CurrentFont['subset'])) {
 					$this->mpdf->UTF8StringToArray($array['VAL'][$i], true);	// Add characters to font subset
 					$this->mpdf->UTF8StringToArray($array['OPT'][$i], true);	// Add characters to font subset
@@ -858,7 +858,7 @@
 	}
 
 
-	function SetFormSubmit( $w, $h, $name, $value = 'Submit', $url, $title = '', $typ = 'html', $method = 'POST', $flags = array(), $background_col=false, $border_col=false, $noprint=false) {
+	function SetFormSubmit( $w, $h, $name, $value, $url, $title = '', $typ = 'html', $method = 'POST', $flags = array(), $background_col=false, $border_col=false, $noprint=false) {
 		if (!$name) { $name = 'Submit'; }
 		$this->SetFormButton( $w, $h, $name, $value, 'submit', $title, $flags, false, false, $background_col, $border_col, $noprint);
 		$this->forms[$this->formn]['URL'] = $url;
@@ -896,7 +896,7 @@
 
 	function SetFormButton( $bb, $hh, $name, $value, $type, $title = '', $flags = array(), $checked=false, $disabled=false, $background_col=false, $border_col=false, $noprint=false ) {
 		$this->formn++;
-		if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) {
+		if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', ($name ?? ''))) {
 			$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); 
 		}
 		if (!$this->mpdf->onlyCoreFonts) {
@@ -910,7 +910,7 @@
 		   }
 		   else if ($type == 'radio') { 
 			$uvalue = $this->mpdf->UTF8ToUTF16BE($value, true); 
-			$value = mb_convert_encoding($value, 'Windows-1252', 'UTF-8'); 
+			$value = mb_convert_encoding(($value ?? ''), 'Windows-1252', 'UTF-8'); 
 		   }
 		   else { 
 			$value = $this->mpdf->UTF8ToUTF16BE($value, true); 
@@ -920,11 +920,11 @@
 		else { 
 			$title = $this->Win1252ToPDFDocEncoding($title); 
 			$value = $this->Win1252ToPDFDocEncoding($value); 				//// ??? not needed
-			$uvalue = mb_convert_encoding($value, 'UTF-8', 'Windows-1252'); 
+			$uvalue = mb_convert_encoding(($value ?? ''), 'UTF-8', 'Windows-1252'); 
 			$uvalue = $this->mpdf->UTF8ToUTF16BE($uvalue, true); 
 		}
 		if ($type == 'radio' || $type == 'checkbox') {
-			if (!preg_match('/^[a-zA-Z0-9_:\-\.]+$/', $value)) {
+			if (!preg_match('/^[a-zA-Z0-9_:\-\.]+$/', ($value ?? ''))) {
 				$this->mpdf->Error("Field '".$name."' must have a value, which can only contain letters, numbers, colon(:), undersore(_), hyphen(-) or period(.)"); 
 			}
 		}
@@ -1088,10 +1088,10 @@
 	$this->mpdf->_out('/Type /XObject');
 	$this->mpdf->_out('/Subtype /Image');
 	$this->mpdf->_out('/BBox [0 0 1 1]');
-	$this->mpdf->_out('/Length '.strlen($info['data']));
+	$this->mpdf->_out('/Length '.strlen(($info['data'] ?? '')));
 	$this->mpdf->_out('/BitsPerComponent '.$info['bpc']);
 	if ($info['cs']=='Indexed') {
-		$this->mpdf->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->mpdf->n+1).' 0 R]');
+		$this->mpdf->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen(($info['pal'] ?? ''))/3-1).' '.($this->mpdf->n+1).' 0 R]');
 	}
 	else {
 		$this->mpdf->_out('/ColorSpace /'.$info['cs']);
@@ -1113,7 +1113,7 @@
 		$filter=($this->mpdf->compress) ? '/Filter /FlateDecode ' : '';
 		$this->mpdf->_newobj();
 		$pal=($this->mpdf->compress) ? gzcompress($info['pal']) : $info['pal'];
-		$this->mpdf->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
+		$this->mpdf->_out('<<'.$filter.'/Length '.strlen(($pal ?? '')).'>>');
 		$this->mpdf->_putstream($pal);
 		$this->mpdf->_out('endobj');
 	}
@@ -1322,13 +1322,13 @@
 
 		$this->mpdf->_newobj();
 		$p=($this->mpdf->compress) ? gzcompress($r_on) : $r_on;
-		$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
+		$this->mpdf->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).' /Resources 2 0 R>>');
 		$this->mpdf->_putstream($p);
 		$this->mpdf->_out('endobj');
 
 		$this->mpdf->_newobj();
 		$p=($this->mpdf->compress) ? gzcompress($r_off) : $r_off;
-		$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
+		$this->mpdf->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).' /Resources 2 0 R>>');
 		$this->mpdf->_putstream($p);
 		$this->mpdf->_out('endobj');
 	}
@@ -1351,7 +1351,7 @@
 		}
 		$this->mpdf->_newobj();
 		$p=($this->mpdf->compress) ? gzcompress($cb_on) : $cb_on;
-		$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
+		$this->mpdf->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).' /Resources 2 0 R>>');
 		$this->mpdf->_putstream($p);
 		$this->mpdf->_out('endobj');
 
@@ -1359,7 +1359,7 @@
 		if (!$this->formUseZapD) {
 			$this->mpdf->_newobj();
 			$p=($this->mpdf->compress) ? gzcompress($cb_off) : $cb_off;
-			$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
+			$this->mpdf->_out('<<'.$filter.'/Length '.strlen(($p ?? '')).' /Resources 2 0 R>>');
 			$this->mpdf->_putstream($p);
 			$this->mpdf->_out('endobj');
 		}
@@ -1400,7 +1400,7 @@
 	$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
 
 	$opt = '';
-	for( $i = 0; $i < count($form['OPT']['VAL']) ; $i++ ) {
+	for( $i = 0; $i < count(($form['OPT']['VAL'] ?? [])) ; $i++ ) {
 		$opt .= '[ '.$this->mpdf->_textstring($form['OPT']['VAL'][$i]).' '.$this->mpdf->_textstring($form['OPT']['OPT'][$i]).' ] ';
 	}
 	$this->mpdf->_out('/Opt [ '.$opt.']');
@@ -1414,7 +1414,7 @@
       	$selectIndex .= ' '.$selectVal.' ';
 	}
 	if ( $selectItem ) {
-		if (count($form['OPT']['SEL']) < 2) {
+		if (count(($form['OPT']['SEL'] ?? [])) < 2) {
 	      	$this->mpdf->_out('/V '.$selectItem.' ');
 	      	$this->mpdf->_out('/DV '.$selectItem.' ');
 		}
@@ -1425,7 +1425,7 @@
 	      $this->mpdf->_out('/I ['.$selectIndex.'] ');
 	}
     
-	if ( is_array($form['FF']) && count($form['FF'])>0 ) {
+	if ( is_array($form['FF']) && count(($form['FF'] ?? []))>0 ) {
 		$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' ');
 	}
 	// Javascript
@@ -1465,7 +1465,7 @@
 	$this->mpdf->_out('/H /N ');
 	$this->mpdf->_out('/R 0 ');
 
-	if ( is_array($form['FF']) && count($form['FF'])>0 ) {
+	if ( is_array($form['FF']) && count(($form['FF'] ?? []))>0 ) {
 		$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' ');
 	}
 	if ( isset($form['maxlen']) && $form['maxlen']>0 ) {
--- a/intranet/mpdf60/classes/indic.php
+++ b/intranet/mpdf60/classes/indic.php
@@ -186,24 +186,24 @@
 	$syllable_serial = 1;
 	$broken_syllables = false;
 
-	while($ptr < strlen($s)) {
+	while($ptr < strlen(($s ?? ''))) {
 		$match = '';
 		$syllable_length = 1;
 		$syllable_type = self::NON_INDIC_CLUSTER ;
 		// CONSONANT_SYLLABLE Consonant syllable
 		// From OT spec:
-		if (preg_match('/^([CR]m*[N]?(H[ZJ]?|[ZJ]H))*[CR]m*[N]?[A]?(H[ZJ]?|[M]*[N]?[H]?)?[S]?[v]{0,2}/', substr($s,$ptr), $ma)) {
+		if (preg_match('/^([CR]m*[N]?(H[ZJ]?|[ZJ]H))*[CR]m*[N]?[A]?(H[ZJ]?|[M]*[N]?[H]?)?[S]?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
 		// From HarfBuzz:
 		//if (preg_match('/^r?([CR]J?(Z?[N]{0,2})?[ZJ]?H(J[N]?)?){0,4}[CR]J?(Z?[N]{0,2})?A?((([ZJ]?H(J[N]?)?)|HZ)|(HJ)?([ZJ]{0,3}M[N]?(H|JHJR)?){0,4})?(S[Z]?)?[v]{0,2}/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::CONSONANT_SYLLABLE ;
 		}
 		// VOWEL_SYLLABLE Vowel-based syllable
 		// From OT spec:
-		else if (preg_match('/^(RH|r)?V[N]?([ZJ]?H[CR]m*|J[CR]m*)?([M]*[N]?[H]?)?[S]?[v]{0,2}/', substr($s,$ptr), $ma)) {
+		else if (preg_match('/^(RH|r)?V[N]?([ZJ]?H[CR]m*|J[CR]m*)?([M]*[N]?[H]?)?[S]?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
 		// From HarfBuzz:
 		//else if (preg_match('/^(RH|r)?V(Z?[N]{0,2})?(J|([ZJ]?H(J[N]?)?[CR]J?(Z?[N]{0,2})?){0,4}((([ZJ]?H(J[N]?)?)|HZ)|(HJ)?([ZJ]{0,3}M[N]?(H|JHJR)?){0,4})?(S[Z]?)?[v]{0,2})/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::VOWEL_SYLLABLE ;
 		}
 
@@ -215,19 +215,19 @@
 				$o[$ptr - 1]['general_category'] > UCDN::UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK
 				)
 
-			&& (preg_match('/^(RH|r)?[sD][N]?([ZJ]?H[CR]m*)?([M]*[N]?[H]?)?[S]?[v]{0,2}/', substr($s,$ptr), $ma))) {
+			&& (preg_match('/^(RH|r)?[sD][N]?([ZJ]?H[CR]m*)?([M]*[N]?[H]?)?[S]?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma))) {
 			// From HarfBuzz:
 			// && (preg_match('/^(RH|r)?[sD](Z?[N]{0,2})?(([ZJ]?H(J[N]?)?)[CR]J?(Z?[N]{0,2})?){0,4}((([ZJ]?H(J[N]?)?)|HZ)|(HJ)?([ZJ]{0,3}M[N]?(H|JHJR)?){0,4})?(S[Z]?)?[v]{0,2}/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::STANDALONE_CLUSTER ;
 		}
 
 		// BROKEN_CLUSTER syllable
-		else if (preg_match('/^(RH|r)?[N]?([ZJ]?H[CR])?([M]*[N]?[H]?)?[S]?[v]{0,2}/', substr($s,$ptr), $ma)) {
+		else if (preg_match('/^(RH|r)?[N]?([ZJ]?H[CR])?([M]*[N]?[H]?)?[S]?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
 		// From HarfBuzz:
 		//else if (preg_match('/^(RH|r)?(Z?[N]{0,2})?(([ZJ]?H(J[N]?)?)[CR]J?(Z?[N]{0,2})?){0,4}((([ZJ]?H(J[N]?)?)|HZ)|(HJ)?([ZJ]{0,3}M[N]?(H|JHJR)?){0,4})(S[Z]?)?[v]{0,2}/', substr($s,$ptr), $ma)) {
-			if (strlen($ma[0])) {	// May match blank
-				$syllable_length = strlen($ma[0]);
+			if (strlen(($ma[0] ?? ''))) {	// May match blank
+				$syllable_length = strlen(($ma[0] ?? ''));
 				$syllable_type = self::BROKEN_CLUSTER ;
 				$broken_syllables = true;
 			}
@@ -246,20 +246,20 @@
 	$syllable_serial = 1;
 	$broken_syllables = false;
 
-	while($ptr < strlen($s)) {
+	while($ptr < strlen(($s ?? ''))) {
 		$match = '';
 		$syllable_length = 1;
 		$syllable_type = self::NON_INDIC_CLUSTER ;
 		// CONSONANT_SYLLABLE Consonant syllable
 		// From OT spec:
-		if (preg_match('/^([CR]HJ|[CR]JH){0,8}[CR][HM]{0,3}[S]{0,1}/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		if (preg_match('/^([CR]HJ|[CR]JH){0,8}[CR][HM]{0,3}[S]{0,1}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::CONSONANT_SYLLABLE ;
 		}
 		// VOWEL_SYLLABLE Vowel-based syllable
 		// From OT spec:
-		else if (preg_match('/^V[S]{0,1}/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		else if (preg_match('/^V[S]{0,1}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::VOWEL_SYLLABLE ;
 		}
 
@@ -275,26 +275,26 @@
 	$syllable_serial = 1;
 	$broken_syllables = false;
 
-	while($ptr < strlen($s)) {
+	while($ptr < strlen(($s ?? ''))) {
 		$match = '';
 		$syllable_length = 1;
 		$syllable_type = self::NON_INDIC_CLUSTER ;
 		// CONSONANT_SYLLABLE Consonant syllable
-		if (preg_match('/^r?([CR]J?((Z?F)?[N]{0,2})?[ZJ]?G(JN?)?){0,4}[CR]J?((Z?F)?[N]{0,2})?A?((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})?(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2}/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		if (preg_match('/^r?([CR]J?((Z?F)?[N]{0,2})?[ZJ]?G(JN?)?){0,4}[CR]J?((Z?F)?[N]{0,2})?A?((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})?(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::CONSONANT_SYLLABLE ;
 		}
 		// VOWEL_SYLLABLE Vowel-based syllable
-		else if (preg_match('/^(RH|r)?V((Z?F)?[N]{0,2})?(J|([ZJ]?G(JN?)?[CR]J?((Z?F)?[N]{0,2})?){0,4}((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})?(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2})/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		else if (preg_match('/^(RH|r)?V((Z?F)?[N]{0,2})?(J|([ZJ]?G(JN?)?[CR]J?((Z?F)?[N]{0,2})?){0,4}((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})?(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2})/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::VOWEL_SYLLABLE ;
 		}
 
 
 		// BROKEN_CLUSTER syllable
-		else if (preg_match('/^(RH|r)?((Z?F)?[N]{0,2})?(([ZJ]?G(JN?)?)[CR]J?((Z?F)?[N]{0,2})?){0,4}((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2}/', substr($s,$ptr), $ma)) {
-			if (strlen($ma[0])) {	// May match blank
-				$syllable_length = strlen($ma[0]);
+		else if (preg_match('/^(RH|r)?((Z?F)?[N]{0,2})?(([ZJ]?G(JN?)?)[CR]J?((Z?F)?[N]{0,2})?){0,4}((([ZJ]?G(JN?)?)|GZ)|(GJ)?([ZJ]{0,3}MN?(H|JHJR)?){0,4})(G([CR]J?((Z?F)?[N]{0,2})?|V))?(SZ?)?[v]{0,2}/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			if (strlen(($ma[0] ?? ''))) {	// May match blank
+				$syllable_length = strlen(($ma[0] ?? ''));
 				$syllable_type = self::BROKEN_CLUSTER ;
 				$broken_syllables = true;
 			}
@@ -313,7 +313,7 @@
 
 	if ($broken_syllables && $dottedcircle) { self::insert_dotted_circles ($info, $dottedcircle); }
 
-	$count = count($info);
+	$count = count(($info ?? []));
 	if (!$count) return;
 	$last = 0;
 	$last_syllable = $info[0]['syllable'];
@@ -328,7 +328,7 @@
 }
 
 public static function update_consonant_positions(&$info, $GSUBdata) {
-	$count = count($info);
+	$count = count(($info ?? []));
 	for ($i = 0; $i < $count; $i++) {
 		if ($info[$i]['indic_position'] == self::POS_BASE_C) {
 			$c = $info[$i]['uni'];
@@ -343,7 +343,7 @@
 public static function insert_dotted_circles(&$info, $dottedcircle) {
 	$idx = 0;
 	$last_syllable = 0;
-	while ($idx < count($info)) {
+	while ($idx < count(($info ?? []))) {
 		$syllable = $info[$idx]['syllable'];
 		$syllable_type = ($syllable & 0x0F);
 		if ($last_syllable != $syllable && $syllable_type == self::BROKEN_CLUSTER) {
@@ -352,7 +352,7 @@
 			$dottedcircle[0]['syllable'] = $info[$idx]['syllable'];
 
 			/* Insert dottedcircle after possible Repha. */
-			while ($idx < count($info) && $last_syllable == $info[$idx]['syllable'] && $info[$idx]['indic_category'] == self::OT_Repha)
+			while ($idx < count(($info ?? [])) && $last_syllable == $info[$idx]['syllable'] && $info[$idx]['indic_category'] == self::OT_Repha)
 				$idx++;
 			array_splice($info, $idx, 0, $dottedcircle);
 		}
@@ -415,7 +415,7 @@
 		/* -> If the syllable starts with Ra + Halant (in a script that has Reph)
 		*	and has more than one consonant, Ra is excluded from candidates for
 		*	base consonants. */
-		if (count($GSUBdata['rphf']) /* ?? $indic_plan->mask_array[RPHF] */ && $start + 3 <= $end &&
+		if (count(($GSUBdata['rphf'] ?? [])) /* ?? $indic_plan->mask_array[RPHF] */ && $start + 3 <= $end &&
 			(
 			($indic_config[4] == self::REPH_MODE_IMPLICIT && !self::is_joiner($info[$start + 2])) ||
 			($indic_config[4] == self::REPH_MODE_EXPLICIT && $info[$start + 2]['indic_category'] == self::OT_ZWJ)
@@ -791,7 +791,7 @@
 	}
 
 	if ($scriptblock != UCDN::SCRIPT_KHMER) { 
-		if (count($GSUBdata['pref']) && $base + 2 < $end) {
+		if (count(($GSUBdata['pref'] ?? [])) && $base + 2 < $end) {
 			/* Find a Halant,Ra sequence and mark it for pre-base processing. */
 			for ($i = $base + 1; $i + 1 < $end; $i++) {
 				// If old_spec find Ra-Halant...
@@ -835,7 +835,7 @@
 }
 
 public static function final_reordering (&$info, $GSUBdata, $indic_config, $scriptblock, $is_old_spec) {
-	$count = count($info);
+	$count = count(($info ?? []));
 	if (!$count) return;
 	$last = 0;
 	$last_syllable = $info[0]['syllable'];
@@ -1067,7 +1067,7 @@
 	*/
 
 
-	if (count($GSUBdata['pref']) && $base + 1 < $end) { /* Otherwise there can't be any pre-base reordering Ra. */
+	if (count(($GSUBdata['pref'] ?? [])) && $base + 1 < $end) { /* Otherwise there can't be any pre-base reordering Ra. */
 		for ($i = $base + 1; $i < $end; $i++) {
 			if ($info[$i]['mask'] & self::FLAG(self::PREF)) {
 				/*	1. Only reorder a glyph produced by substitution during application
--- a/intranet/mpdf60/classes/otl.php
+++ b/intranet/mpdf60/classes/otl.php
@@ -10,6 +10,18 @@
 
 
 class otl {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $current_fh;
+    public $GDEFdata;
+    public $GSUB_length;
+    public $schOTLdata;
+    public $GSLuCoverage;
+    public $GSUBLookups;
+    public $arabGlyphs;
+    public $Entry;
+    public $Exit;
+    public $GPOSLookups;
+
 
 var $mpdf;
 var $arabLeftJoining;
@@ -43,7 +55,7 @@
 
 var $debugOTL = false;
 
-function otl(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 
 	$this->arabic_initialise();
@@ -61,7 +73,7 @@
 
 function applyOTL($str, $useOTL) {
 	$this->OTLdata = array();
-	if (trim($str)=='') { return $str; }
+	if (trim(($str ?? ''))=='') { return $str; }
 	if (!$useOTL) { return $str; }
 
 	// 1. Load GDEF data
@@ -134,7 +146,7 @@
 
 		$charasstr = $this->unicode_hex($char); 
 
-		if (strpos($this->GlyphClassMarks, $charasstr)!==false) { $OTLdata[$subchunk][$charctr]['group'] =  'M'; }
+		if (strpos(($this->GlyphClassMarks ?? ''), ($charasstr ?? ''))!==false) { $OTLdata[$subchunk][$charctr]['group'] =  'M'; }
 		else if ($char == 32 || $char == 12288) { $OTLdata[$subchunk][$charctr]['group'] =  'S'; }	// 12288 = 0x3000 = CJK space
 		else { $OTLdata[$subchunk][$charctr]['group'] =  'C'; }
 
@@ -173,10 +185,10 @@
 	$is_old_spec = false;
 
 	$ScriptLang = $this->mpdf->CurrentFont['GSUBScriptLang'];
-	if (count($ScriptLang)) { 
+	if (count(($ScriptLang ?? []))) { 
 		list($GSUBscriptTag,$is_old_spec) = $this->_getOTLscriptTag($ScriptLang, $scripttag, $scriptblock, $this->shaper, $useOTL, 'GSUB');
-		if ($this->mpdf->fontLanguageOverride && strpos($ScriptLang[$GSUBscriptTag], $this->mpdf->fontLanguageOverride)!==false) {
-			$GSUBlangsys = str_pad($this->mpdf->fontLanguageOverride,4);
+		if ($this->mpdf->fontLanguageOverride && strpos(($ScriptLang[$GSUBscriptTag] ?? ''), ($this->mpdf->fontLanguageOverride ?? ''))!==false) {
+			$GSUBlangsys = str_pad(($this->mpdf->fontLanguageOverride ?? ''),4);
 		}
 		else if ($GSUBscriptTag && isset($ScriptLang[$GSUBscriptTag]) && $ScriptLang[$GSUBscriptTag]!='') { 
 			$GSUBlangsys = $this->_getOTLLangTag($this->mpdf->currentLang, $ScriptLang[$GSUBscriptTag]);
@@ -185,17 +197,17 @@
 	$ScriptLang = $this->mpdf->CurrentFont['GPOSScriptLang'];
 
 	// NB If after GSUB, the same script/lang exist for GPOS, just use these...
-	if ($GSUBscriptTag && $GSUBlangsys && isset($ScriptLang[$GSUBscriptTag]) && strpos($ScriptLang[$GSUBscriptTag], $GSUBlangsys)!==false) {
+	if ($GSUBscriptTag && $GSUBlangsys && isset($ScriptLang[$GSUBscriptTag]) && strpos(($ScriptLang[$GSUBscriptTag] ?? ''), ($GSUBlangsys ?? ''))!==false) {
 		$GPOSlangsys = $GSUBlangsys;
 		$GPOSscriptTag = $GSUBscriptTag;
 	}
 
 	// else repeat for GPOS
 	// [Font XBRiyaz has GSUB tables for latn, but not GPOS for latn]
-	else if (count($ScriptLang)) {
+	else if (count(($ScriptLang ?? []))) {
 		list($GPOSscriptTag,$dummy) = $this->_getOTLscriptTag($ScriptLang, $scripttag, $scriptblock, $this->shaper, $useOTL, 'GPOS');
-		if ($GPOSscriptTag && $this->mpdf->fontLanguageOverride && strpos($ScriptLang[$GPOSscriptTag], $this->mpdf->fontLanguageOverride)!==false) {
-			$GPOSlangsys = str_pad($this->mpdf->fontLanguageOverride,4);
+		if ($GPOSscriptTag && $this->mpdf->fontLanguageOverride && strpos(($ScriptLang[$GPOSscriptTag] ?? ''), ($this->mpdf->fontLanguageOverride ?? ''))!==false) {
+			$GPOSlangsys = str_pad(($this->mpdf->fontLanguageOverride ?? ''),4);
 		}
 		else if ($GPOSscriptTag && isset($ScriptLang[$GPOSscriptTag]) && $ScriptLang[$GPOSscriptTag]!='') { 
 			$GPOSlangsys = $this->_getOTLLangTag($this->mpdf->currentLang, $ScriptLang[$GPOSscriptTag]);
@@ -212,7 +224,7 @@
 
 	if (!$GSUBscriptTag && !$GSUBlangsys && !$GPOSscriptTag && !$GPOSlangsys) {
 		// Remove ZWJ and ZWNJ
-		for ($i=0;$i<count($this->OTLdata);$i++) {
+		for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			if ($this->OTLdata[$i]['uni']==8204 || $this->OTLdata[$i]['uni']==8205) {
 				array_splice($this->OTLdata, $i, 1);
 			}
@@ -327,7 +339,7 @@
 
 		$this->arabGlyphs = $this->GSUBdata[$this->GSUBfont]['rtlSUB'];
 
-		$gcms = explode("| ",$this->GlyphClassMarks);
+		$gcms = explode("| ",($this->GlyphClassMarks ?? ''));
 		$gcm = array();
 		foreach($gcms AS $g) { $gcm[hexdec($g)] = 1; }
 		$this->arabTransparentJoin = $this->arabTransparent + $gcm;
@@ -337,7 +349,7 @@
 		// c. Set Kashida points (after joining occurred - medi, fina, init) but before other substitutions
 		//-----------------------------------------------------------------------------------
 		//if ($scriptblock == UCDN::SCRIPT_ARABIC ) {
-		for ($i=0;$i<count($this->OTLdata);$i++) {
+		for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			// Put the kashida marker on the character BEFORE which is inserted the kashida
 			// Kashida marker is inverse of priority i.e. Priority 1 => 7, Priority 7 => 1.
 
@@ -354,7 +366,7 @@
 			// Position: After the character
 			else if ($this->OTLdata[$i]['uni']==0xFEB3 || $this->OTLdata[$i]['uni']==0xFEB4 || $this->OTLdata[$i]['uni']==0xFEBB || $this->OTLdata[$i]['uni']==0xFEBC) {
 				$checkpos = $i+1;
-				while (isset($this->OTLdata[$checkpos]) && strpos($this->GlyphClassMarks, $this->OTLdata[$checkpos]['hex'])!==false) {
+				while (isset($this->OTLdata[$checkpos]) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 					$checkpos++; 
 				}
 				if (isset($this->OTLdata[$checkpos])) {
@@ -388,7 +400,7 @@
 				|| $this->OTLdata[$i]['uni']==0xFBFD || $this->OTLdata[$i]['uni']==0xFBFF
 				) {
 				$checkpos = $i-1;
-				while (isset($this->OTLdata[$checkpos]) && strpos($this->GlyphClassMarks, $this->OTLdata[$checkpos]['hex'])!==false) {
+				while (isset($this->OTLdata[$checkpos]) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 					$checkpos--; 
 				}
 				if (isset($this->OTLdata[$checkpos]) && $this->OTLdata[$checkpos]['uni']==0xFE92) {
@@ -415,10 +427,10 @@
 			*/
 
 			if (!isset($this->OTLdata[$i]['GPOSinfo']['kashida'])) {
-				if (strpos($this->GSUBdata[$this->GSUBfont]['finals'], $this->OTLdata[$i]['hex'])!==false) {	// ANY OTHER FINAL FORM
+				if (strpos(($this->GSUBdata[$this->GSUBfont]['finals'] ?? ''), ($this->OTLdata[$i]['hex'] ?? ''))!==false) {	// ANY OTHER FINAL FORM
 					$this->OTLdata[$i]['GPOSinfo']['kashida'] = 2;
 				}
-				else if (strpos('0FEAE 0FEF0 0FEF2',$this->OTLdata[$i]['hex'])!==false) {	// not already included in 5 above
+				else if (strpos('0FEAE 0FEF0 0FEF2',($this->OTLdata[$i]['hex'] ?? ''))!==false) {	// not already included in 5 above
 					$this->OTLdata[$i]['GPOSinfo']['kashida'] = 1;
 				}
 			}
@@ -435,7 +447,7 @@
 			$usetags = $this->_applyTagSettings($tags, $GSUBFeatures, $omittags, false) ;
 		}
 
-		$ts = explode(' ',$usetags);
+		$ts = explode(' ',($usetags ?? ''));
 		foreach($ts AS $ut) {	//  - Apply one at a time in Feature order
 			$this->_applyGSUBrules($ut, $GSUBscriptTag, $GSUBlangsys);
 		}
@@ -443,7 +455,7 @@
 		// e. NOT IN SPEC
 		// If space precedes a mark -> substitute a &nbsp; before the Mark, to prevent line breaking Test: 
 		//-----------------------------------------------------------------------------------
-		for($ptr=1; $ptr<count($this->OTLdata); $ptr++) {
+		for($ptr=1; $ptr<count(($this->OTLdata ?? [])); $ptr++) {
 			if ($this->OTLdata[$ptr]['general_category'] == UCDN::UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK && $this->OTLdata[$ptr-1]['uni'] == 32) {
 				$this->OTLdata[$ptr-1]['uni'] =  0xa0;
 				$this->OTLdata[$ptr-1]['hex'] =  '000A0';
@@ -459,24 +471,24 @@
 		// a. First decompose/compose split mattras
 		// (normalize) ??????? Nukta/Halant order etc ??????????????????????????????????????????????????????????????????????????
 		//-----------------------------------------------------------------------------------
-		for($ptr=0; $ptr<count($this->OTLdata); $ptr++) {
+		for($ptr=0; $ptr<count(($this->OTLdata ?? [])); $ptr++) {
 			$char = $this->OTLdata[$ptr]['uni'];
 			$sub = INDIC::decompose_indic($char);
 			if ($sub) {
 				$newinfo = array();
-				for($i=0;$i<count($sub);$i++) {
+				for($i=0;$i<count(($sub ?? []));$i++) {
 					$newinfo[$i] = array();
 					$ucd_record = UCDN::get_ucd_record($sub[$i]);
 					$newinfo[$i]['general_category'] = $ucd_record[0];
 					$newinfo[$i]['bidi_type'] = $ucd_record[2];
 					$charasstr = $this->unicode_hex($sub[$i]); 
-					if (strpos($this->GlyphClassMarks, $charasstr)!==false) { $newinfo[$i]['group'] =  'M'; }
+					if (strpos(($this->GlyphClassMarks ?? ''), ($charasstr ?? ''))!==false) { $newinfo[$i]['group'] =  'M'; }
 					else { $newinfo[$i]['group'] =  'C'; }
 					$newinfo[$i]['uni'] =  $sub[$i];
 					$newinfo[$i]['hex'] =  $charasstr;
 				}
 				array_splice($this->OTLdata, $ptr, 1, $newinfo);
-				$ptr += count($sub)-1;
+				$ptr += count(($sub ?? []))-1;
 			}
 			/* Only Composition-exclusion exceptions that we want to recompose. */
 			if ($this->shaper == 'I') {
@@ -774,7 +786,7 @@
 		 * Lao versions are the same as Thai + 0x80.
 		 */
 		if ($this->shaper == 'T' || $this->shaper == 'L') {
-			for($ptr=0; $ptr<count($this->OTLdata); $ptr++) {
+			for($ptr=0; $ptr<count(($this->OTLdata ?? [])); $ptr++) {
 				$char = $this->OTLdata[$ptr]['uni'];
     				if (($char & ~0x0080) == 0x0E33) {	// if SARA_AM (U+0E33 or U+0EB3)
 
@@ -787,7 +799,7 @@
 					$newinfo[0]['general_category'] = $ucd_record[0];
 					$newinfo[0]['bidi_type'] = $ucd_record[2];
 					$charasstr = $this->unicode_hex($sub[0]); 
-					if (strpos($this->GlyphClassMarks, $charasstr)!==false) { $newinfo[0]['group'] =  'M'; }
+					if (strpos(($this->GlyphClassMarks ?? ''), ($charasstr ?? ''))!==false) { $newinfo[0]['group'] =  'M'; }
 					else { $newinfo[0]['group'] =  'C'; }
 					$newinfo[0]['uni'] =  $sub[0];
 					$newinfo[0]['hex'] =  $charasstr;
@@ -812,7 +824,7 @@
 					$newinfo[0]['general_category'] = $ucd_record[0];
 					$newinfo[0]['bidi_type'] = $ucd_record[2];
 					$charasstr = $this->unicode_hex($sub[1]); 
-					if (strpos($this->GlyphClassMarks, $charasstr)!==false) { $newinfo[0]['group'] =  'M'; }
+					if (strpos(($this->GlyphClassMarks ?? ''), ($charasstr ?? ''))!==false) { $newinfo[0]['group'] =  'M'; }
 					else { $newinfo[0]['group'] =  'C'; }
 					$newinfo[0]['uni'] =  $sub[1];
 					$newinfo[0]['hex'] =  $charasstr;
@@ -835,7 +847,7 @@
 			// From MS OTL spec the following are Digit modifiers (Md): 0F18–0F19, 0F3E–0F3F
 			// Digits: 0F20–0F33
 			// On testing only 0x0F3F (pre-based mark) seems to need re-ordering
-			for($ptr=0; $ptr<count($this->OTLdata)-1; $ptr++) {
+			for($ptr=0; $ptr<count(($this->OTLdata ?? []))-1; $ptr++) {
     				if (INDIC::in_range($this->OTLdata[$ptr]['uni'], 0x0F20, 0x0F33) && $this->OTLdata[$ptr+1]['uni'] == 0x0F3F ) {
 					$tmp = $this->OTLdata[$ptr+1];
 					$this->OTLdata[$ptr+1] = $this->OTLdata[$ptr];
@@ -892,7 +904,7 @@
 			$useGSUBtags = $this->_applyTagSettings($tags, $GSUBFeatures, $omittags, false) ;
 		}
 		// APPLY GSUB rules (as long as not Latin + SmallCaps - but not OTL smcp)
-		if (!(($this->mpdf->textvar & FC_SMALLCAPS) && $scriptblock == UCDN::SCRIPT_LATIN && strpos($useGSUBtags, 'smcp')===false)) {
+		if (!(($this->mpdf->textvar & FC_SMALLCAPS) && $scriptblock == UCDN::SCRIPT_LATIN && strpos(($useGSUBtags ?? ''), 'smcp')===false)) {
 			$this->_applyGSUBrules($useGSUBtags, $GSUBscriptTag, $GSUBlangsys);
 		}
 	}
@@ -912,7 +924,7 @@
 			'bidi_type' => UCDN::BIDI_CLASS_BN, 
 			'group' => 'S', 'uni' => 0x200B, 'hex' => '0200B');
 		// Then insert U+200B at (after) all word end boundaries
-		for ($i=count($this->OTLdata)-1;$i>0;$i--) {
+		for ($i=count(($this->OTLdata ?? []))-1;$i>0;$i--) {
 			// Make sure after GSUB that wordend has not been moved - check next char is not in the same syllable
 			if (isset($this->OTLdata[$i]['wordend']) && $this->OTLdata[$i]['wordend'] &&
 					isset($this->OTLdata[$i+1]['uni']) && (!isset($this->OTLdata[$i+1]['syllable']) || !isset($this->OTLdata[$i+1]['syllable']) || $this->OTLdata[$i+1]['syllable']!=$this->OTLdata[$i]['syllable'])) { 
@@ -931,7 +943,7 @@
 	//=======================================================
 	if ($this->shaper == 'I' || $this->shaper == 'S' || $this->shaper == 'A' || $this->shaper == 'K' || $this->shaper == 'M') {
 		// Remove ZWJ and ZWNJ
-		for ($i=0;$i<count($this->OTLdata);$i++) {
+		for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			if ($this->OTLdata[$i]['uni']==8204 || $this->OTLdata[$i]['uni']==8205) {
 				array_splice($this->OTLdata, $i, 1);
 				$this->_updateLigatureMarks($i, -1);
@@ -990,7 +1002,7 @@
 	//==============================
 	$LookupList = array();
 	foreach($GPOSFeatures AS $tag=>$arr) {
-		if (strpos($usetags, $tag)!==false) {
+		if (strpos(($usetags ?? ''), ($tag ?? ''))!==false) {
 			foreach($arr AS $lu) { $LookupList[$lu] = $tag; }
 		}
 	}
@@ -1001,20 +1013,20 @@
 	//==============================
 
 	// APPLY THE GPOS RULES (as long as not Latin + SmallCaps - but not OTL smcp)
-	if (!(($this->mpdf->textvar & FC_SMALLCAPS) && $scriptblock == UCDN::SCRIPT_LATIN && strpos($useGSUBtags, 'smcp')===false)) {
+	if (!(($this->mpdf->textvar & FC_SMALLCAPS) && $scriptblock == UCDN::SCRIPT_LATIN && strpos(($useGSUBtags ?? ''), 'smcp')===false)) {
 		$this->_applyGPOSrules($LookupList, $is_old_spec);
 		// (sets: $this->OTLdata[n]['GPOSinfo'] XPlacement YPlacement XAdvance Entry Exit )
 	}
 
 	// 10. Process cursive text
 	//==============================
-	if (count($this->Entry) || count($this->Exit)) {
+	if (count(($this->Entry ?? [])) || count(($this->Exit ?? []))) {
 		// RTL
 		$incurs = false;
-		for ($i=(count($this->OTLdata)-1);$i>=0;$i--) {
+		for ($i=(count(($this->OTLdata ?? []))-1);$i>=0;$i--) {
 			if (isset($this->Entry[$i]) && isset($this->Entry[$i]['Y']) && $this->Entry[$i]['dir']=='RTL') {
 				$nextbase = $i-1;	// Set as next base ignoring marks (next base reading RTL in logical oder
-				while(isset($this->OTLdata[$nextbase]['hex']) && strpos($this->GlyphClassMarks, $this->OTLdata[$nextbase]['hex'])!==false) { $nextbase--; }
+				while(isset($this->OTLdata[$nextbase]['hex']) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$nextbase]['hex'] ?? ''))!==false) { $nextbase--; }
 				if (isset($this->Exit[$nextbase]) && isset($this->Exit[$nextbase]['Y']) ) {
 					$diff = $this->Entry[$i]['Y'] - $this->Exit[$nextbase]['Y'];
 					if ($incurs===false) { $incurs = $diff; }
@@ -1033,15 +1045,15 @@
 				}
 				else { $incurs = false; }
 			}
-			else if (strpos($this->GlyphClassMarks, $this->OTLdata[$i]['hex'])!==false) { continue; } // ignore Marks
+			else if (strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$i]['hex'] ?? ''))!==false) { continue; } // ignore Marks
 			else { $incurs = false; }
 		}
 		// LTR
 		$incurs = false;
-		for ($i=0;$i<count($this->OTLdata);$i++) {
+		for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			if (isset($this->Exit[$i]) && isset($this->Exit[$i]['Y']) && $this->Exit[$i]['dir']=='LTR') {
 				$nextbase = $i+1;	// Set as next base ignoring marks
-				while(strpos($this->GlyphClassMarks, $this->OTLdata[$nextbase]['hex'])!==false) { $nextbase++; }
+				while(strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$nextbase]['hex'] ?? ''))!==false) { $nextbase++; }
 				if (isset($this->Entry[$nextbase]) && isset($this->Entry[$nextbase]['Y']) ) {
 
 					$diff = $this->Exit[$i]['Y'] - $this->Entry[$nextbase]['Y'];
@@ -1061,7 +1073,7 @@
 				}
 				else { $incurs = false; }
 			}
-			else if (strpos($this->GlyphClassMarks, $this->OTLdata[$i]['hex'])!==false) { continue; } // ignore Marks
+			else if (strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$i]['hex'] ?? ''))!==false) { continue; } // ignore Marks
 			else { $incurs = false; }
 		}
 	}
@@ -1088,7 +1100,7 @@
 	$ectr = 0;
 
 	for($sch=0;$sch<=$subchunk;$sch++) {
-		for ($i=0;$i<count($this->schOTLdata[$sch]);$i++) {
+		for ($i=0;$i<count(($this->schOTLdata[$sch] ?? []));$i++) {
 			if (isset($this->schOTLdata[$sch][$i]['GPOSinfo'])) {
 				$newGPOSinfo[$ectr] = $this->schOTLdata[$sch][$i]['GPOSinfo'];
 			}
@@ -1127,45 +1139,45 @@
 
 		// Font features to enable - set by font-variant-xx
 		if (isset($this->mpdf->OTLtags['Plus'])) $fp = $this->mpdf->OTLtags['Plus'];
-		preg_match_all('/([a-zA-Z0-9]{4})/',$fp,$m);
-		for($i=0;$i<count($m[0]);$i++) {
+		preg_match_all('/([a-zA-Z0-9]{4})/',($fp ?? ''),$m);
+		for($i=0;$i<count(($m[0] ?? []));$i++) {
 			$t = $m[1][$i];
 			// Is it a valid tag?
-			if(isset($Features[$t]) && strpos($omittags,$t)===false && (!$onlytags || strpos($tags,$t)!==false )) {
+			if(isset($Features[$t]) && strpos(($omittags ?? ''),($t ?? ''))===false && (!$onlytags || strpos(($tags ?? ''),($t ?? ''))!==false )) {
 				$usetags .= ' '.$t;
 			}
 		}
 
 		// Font features to disable - set by font-variant-xx
 		if (isset($this->mpdf->OTLtags['Minus'])) $fm = $this->mpdf->OTLtags['Minus'];
-		preg_match_all('/([a-zA-Z0-9]{4})/',$fm,$m);
-		for($i=0;$i<count($m[0]);$i++) {
+		preg_match_all('/([a-zA-Z0-9]{4})/',($fm ?? ''),$m);
+		for($i=0;$i<count(($m[0] ?? []));$i++) {
 			$t = $m[1][$i];
 			// Is it a valid tag?
-			if(isset($Features[$t]) && strpos($omittags,$t)===false && (!$onlytags || strpos($tags,$t)!==false )) {
-				$usetags = str_replace($t,'',$usetags);
+			if(isset($Features[$t]) && strpos(($omittags ?? ''),($t ?? ''))===false && (!$onlytags || strpos(($tags ?? ''),($t ?? ''))!==false )) {
+				$usetags = str_replace(($t ?? ''),'',($usetags ?? ''));
 			}
 		}
 
 		// Font features to enable - set by font-feature-settings
 		if (isset($this->mpdf->OTLtags['FFPlus'])) $ffp = $this->mpdf->OTLtags['FFPlus'];	// Font Features - may include integer: salt4
-		preg_match_all('/([a-zA-Z0-9]{4})([\d+]*)/',$ffp,$m);
-		for($i=0;$i<count($m[0]);$i++) {
+		preg_match_all('/([a-zA-Z0-9]{4})([\d+]*)/',($ffp ?? ''),$m);
+		for($i=0;$i<count(($m[0] ?? []));$i++) {
 			$t = $m[1][$i];
 			// Is it a valid tag?
-			if(isset($Features[$t]) && strpos($omittags,$t)===false && (!$onlytags || strpos($tags,$t)!==false )) {
+			if(isset($Features[$t]) && strpos(($omittags ?? ''),($t ?? ''))===false && (!$onlytags || strpos(($tags ?? ''),($t ?? ''))!==false )) {
 				$usetags .= ' '.$m[0][$i];		//  - may include integer: salt4
 			}
 		}
 
 		// Font features to disable - set by font-feature-settings
 		if (isset($this->mpdf->OTLtags['FFMinus'])) $ffm = $this->mpdf->OTLtags['FFMinus'];
-		preg_match_all('/([a-zA-Z0-9]{4})/',$ffm,$m);
-		for($i=0;$i<count($m[0]);$i++) {
+		preg_match_all('/([a-zA-Z0-9]{4})/',($ffm ?? ''),$m);
+		for($i=0;$i<count(($m[0] ?? []));$i++) {
 			$t = $m[1][$i];
 			// Is it a valid tag?
-			if(isset($Features[$t]) && strpos($omittags,$t)===false && (!$onlytags || strpos($tags,$t)!==false )) {
-				$usetags = str_replace($t,'',$usetags);
+			if(isset($Features[$t]) && strpos(($omittags ?? ''),($t ?? ''))===false && (!$onlytags || strpos(($tags ?? ''),($t ?? ''))!==false )) {
+				$usetags = str_replace(($t ?? ''),'',($usetags ?? ''));
 			}
 		}
 		return $usetags; 
@@ -1180,7 +1192,7 @@
 	$GSUBFeatures = $this->mpdf->CurrentFont['GSUBFeatures'][$scriptTag][$langsys];
 	$LookupList = array();
 	foreach($GSUBFeatures AS $tag=>$arr) {
-		if (strpos($usetags, $tag)!==false) {
+		if (strpos(($usetags ?? ''), ($tag ?? ''))!==false) {
 			foreach($arr AS $lu) { $LookupList[$lu] = $tag; }
 		}
 	}
@@ -1191,12 +1203,12 @@
 		$Flag = $this->GSUBLookups[$lu]['Flag'];
 		$MarkFilteringSet = $this->GSUBLookups[$lu]['MarkFilteringSet'];
 		$tagInt = 1;
-		if (preg_match('/'.$tag.'([0-9]{1,2})/', $usetags, $m)) {
+		if (preg_match('/'.$tag.'([0-9]{1,2})/', ($usetags ?? ''), $m)) {
 			$tagInt = $m[1];
 		}
 		$ptr = 0;
 		// Test each glyph sequentially
-		while($ptr < (count($this->OTLdata))) {	// whilst there is another glyph ..0064
+		while($ptr < (count(($this->OTLdata ?? [])))) {	// whilst there is another glyph ..0064
 			$currGlyph = $this->OTLdata[$ptr]['hex'];
 			$currGID = $this->OTLdata[$ptr]['uni'];
 			$shift = 1;
@@ -1221,11 +1233,11 @@
 
 	$GSUBFeatures = $this->mpdf->CurrentFont['GSUBFeatures'][$scriptTag][$langsys];
 
-	$tags = explode(' ',$usetags);
+	$tags = explode(' ',($usetags ?? ''));
 	foreach($tags AS $usetag) {
 		$LookupList = array();
 		foreach($GSUBFeatures AS $tag=>$arr) {
-			if (strpos($usetags, $tag)!==false) {
+			if (strpos(($usetags ?? ''), ($tag ?? ''))!==false) {
 				foreach($arr AS $lu) { $LookupList[$lu] = $tag; }
 			}
 		}
@@ -1233,7 +1245,7 @@
 
 		$ptr = 0;
 		// Test each glyph sequentially
-		while($ptr < (count($this->OTLdata))) {	// whilst there is another glyph ..0064
+		while($ptr < (count(($this->OTLdata ?? [])))) {	// whilst there is another glyph ..0064
 			$currGlyph = $this->OTLdata[$ptr]['hex'];
 			$currGID = $this->OTLdata[$ptr]['uni'];
 			$shift = 1;
@@ -1243,7 +1255,7 @@
 				$Flag = $this->GSUBLookups[$lu]['Flag'];
 				$MarkFilteringSet = $this->GSUBLookups[$lu]['MarkFilteringSet'];
 				$tagInt = 1;
-				if (preg_match('/'.$tag.'([0-9]{1,2})/', $usetags, $m)) {
+				if (preg_match('/'.$tag.'([0-9]{1,2})/', ($usetags ?? ''), $m)) {
 					$tagInt = $m[1];
 				}
 
@@ -1272,7 +1284,7 @@
 
 	// ALL should be applied one syllable at a time	
 	// Implemented in functions checkContextMatch and checkContextMatchMultiple by failing to match if outside scope of current 'syllable'
-	$tags = explode(' ',$usetags);
+	$tags = explode(' ',($usetags ?? ''));
 	foreach($tags AS $usetag) {
 
 		$LookupList = array();
@@ -1289,13 +1301,13 @@
 			$Flag = $this->GSUBLookups[$lu]['Flag'];
 			$MarkFilteringSet = $this->GSUBLookups[$lu]['MarkFilteringSet'];
 			$tagInt = 1;
-			if (preg_match('/'.$tag.'([0-9]{1,2})/', $usetags, $m)) {
+			if (preg_match('/'.$tag.'([0-9]{1,2})/', ($usetags ?? ''), $m)) {
 				$tagInt = $m[1];
 			}
 
 			$ptr = 0;
 			// Test each glyph sequentially
-			while($ptr < (count($this->OTLdata))) {	// whilst there is another glyph ..0064
+			while($ptr < (count(($this->OTLdata ?? [])))) {	// whilst there is another glyph ..0064
 				$currGlyph = $this->OTLdata[$ptr]['hex'];
 				$currGID = $this->OTLdata[$ptr]['uni'];
 				$shift = 1;
@@ -1325,7 +1337,7 @@
 
 	// ALL should be applied one syllable at a time	
 	// Implemented in functions checkContextMatch and checkContextMatchMultiple by failing to match if outside scope of current 'syllable'
-	$tags = explode(' ',$usetags);
+	$tags = explode(' ',($usetags ?? ''));
 	foreach($tags AS $usetag) {
 
 		$LookupList = array();
@@ -1342,20 +1354,20 @@
 			$Flag = $this->GSUBLookups[$lu]['Flag'];
 			$MarkFilteringSet = $this->GSUBLookups[$lu]['MarkFilteringSet'];
 			$tagInt = 1;
-			if (preg_match('/'.$tag.'([0-9]{1,2})/', $usetags, $m)) {
+			if (preg_match('/'.$tag.'([0-9]{1,2})/', ($usetags ?? ''), $m)) {
 				$tagInt = $m[1];
 			}
 
 			$ptr = 0;
 			// Test each glyph sequentially
-			while($ptr < (count($this->OTLdata))) {	// whilst there is another glyph ..0064
+			while($ptr < (count(($this->OTLdata ?? [])))) {	// whilst there is another glyph ..0064
 				$currGlyph = $this->OTLdata[$ptr]['hex'];
 				$currGID = $this->OTLdata[$ptr]['uni'];
 				$shift = 1;
 				foreach($this->GSUBLookups[$lu]['Subtables'] AS $c=>$subtable_offset) {
 					// NB Coverage only looks at glyphs for position 1 (esp. 7.3 and 8.3)
 					if (isset($this->GSLuCoverage[$lu][$c][$currGID])) {
-						if (strpos('rphf pref blwf half pstf cfar init' , $usetag)!==false) { // only apply when mask indicates
+						if (strpos('rphf pref blwf half pstf cfar init' , ($usetag ?? ''))!==false) { // only apply when mask indicates
 							$mask = 0;
 							switch ($usetag) {
 								case 'rphf': $mask = (1<<(INDIC::RPHF)); break;
@@ -1380,9 +1392,9 @@
 					// incorrectly just moved old spec tables to new spec. Uniscribe seems to cope with this
 					// See also ttffontsuni.php
 					// First check if current glyph is a Halant/Virama
-					else if (_OTL_OLD_SPEC_COMPAT_1 && $Type==4 && !$is_old_spec && strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',$currGlyph)!== false) {
+					else if (_OTL_OLD_SPEC_COMPAT_1 && $Type==4 && !$is_old_spec && strpos('0094D 009CD 00A4D 00ACD 00B4D 00BCD 00C4D 00CCD 00D4D',($currGlyph ?? ''))!== false) {
 						 // only apply when 'pref blwf pstf' tags, and when mask indicates
-						if (strpos('pref blwf pstf' , $usetag)!==false) {
+						if (strpos('pref blwf pstf' , ($usetag ?? ''))!==false) {
 							$mask = 0;
 							switch ($usetag) {
 								case 'pref': $mask = (1<<(INDIC::PREF)); break;
@@ -1476,7 +1488,7 @@
 	return 0;
 }
 
-function _applyGSUBsubtable($lookupID, $subtable, $ptr, $currGlyph, $currGID, $subtable_offset, $Type, $Flag, $MarkFilteringSet, $LuCoverage, $level=0, $currentTag, $is_old_spec, $tagInt) {
+function _applyGSUBsubtable($lookupID, $subtable, $ptr, $currGlyph, $currGID, $subtable_offset, $Type, $Flag, $MarkFilteringSet, $LuCoverage, $level, $currentTag, $is_old_spec, $tagInt) {
 	$ignore = $this->_getGCOMignoreString($Flag, $MarkFilteringSet);
 
 	// Lets start
@@ -1614,7 +1626,7 @@
 
 				$spos++;
 				//while $this->OTLdata[$spos]['uni'] is an "ignore" =>  spos++
-				while (isset($this->OTLdata[$spos]) && strpos($ignore, $this->OTLdata[$spos]['hex'])!==false) { $spos++; }
+				while (isset($this->OTLdata[$spos]) && strpos(($ignore ?? ''), ($this->OTLdata[$spos]['hex'] ?? ''))!==false) { $spos++; }
 
 				if (isset($this->OTLdata[$spos]) && $this->OTLdata[$spos]['uni'] == $checkGlyph) {
 					$GlyphPos[] = $spos;
@@ -1771,7 +1783,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$class0excl = array();
-						for ($gc=1;$gc<=count($InputClasses);$gc++) {
+						for ($gc=1;$gc<=count(($InputClasses ?? []));$gc++) {
 							if (is_array($InputClasses[$gc])) $class0excl = $class0excl + $InputClasses[$gc];
 						}
 
@@ -1990,7 +2002,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$class0excl = array();
-						for ($gc=1;$gc<=count($InputClasses);$gc++) {
+						for ($gc=1;$gc<=count(($InputClasses ?? []));$gc++) {
 							if (isset($InputClasses[$gc])) $class0excl = $class0excl + $InputClasses[$gc];
 						}
 
@@ -2005,7 +2017,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$bclass0excl = array();
-						for ($gc=1;$gc<=count($BacktrackClasses);$gc++) {
+						for ($gc=1;$gc<=count(($BacktrackClasses ?? []));$gc++) {
 							if (isset($BacktrackClasses[$gc])) $bclass0excl = $bclass0excl + $BacktrackClasses[$gc];
 						}
 
@@ -2021,7 +2033,7 @@
 
  						// Class 0 contains all the glyphs NOT in the other classes
 						$lclass0excl = array();
-						for ($gc=1;$gc<=count($LookaheadClasses);$gc++) {
+						for ($gc=1;$gc<=count(($LookaheadClasses ?? []));$gc++) {
 							if (isset($LookaheadClasses[$gc])) $lclass0excl = $lclass0excl + $LookaheadClasses[$gc];
 						}
 
@@ -2153,14 +2165,14 @@
 		// Any position lpos or mpos > $pos + count($substitute)
 		//	$this->assocMarks = array(); 	// assocMarks[$pos mpos] => array(compID, ligPos)
 		//	$this->assocLigs = array();	// Ligatures[$pos lpos] => nc
-		for ($p=count($this->OTLdata)-1;$p>=($pos+$n);$p--) {
+		for ($p=count(($this->OTLdata ?? []))-1;$p>=($pos+$n);$p--) {
 			if (isset($this->assocLigs[$p])) {
 				$tmp = $this->assocLigs[$p];
 				unset($this->assocLigs[$p]); 
 				$this->assocLigs[($p + $n)] = $tmp;
 			}
 		}
-		for ($p=count($this->OTLdata)-1;$p>=0;$p--) {
+		for ($p=count(($this->OTLdata ?? []))-1;$p>=0;$p--) {
 			if (isset($this->assocMarks[$p])) {
 				if ($this->assocMarks[$p]['ligPos'] >=($pos+$n)) { $this->assocMarks[$p]['ligPos'] += $n; }
 				if ($p>=($pos+$n)) {
@@ -2175,14 +2187,14 @@
 	else if ($n<1) { // glyphs removed
 		$nrem = -$n;
 		// Update position of pre-existing Ligatures and associated Marks
-		for ($p=($pos+1);$p<count($this->OTLdata);$p++) {
+		for ($p=($pos+1);$p<count(($this->OTLdata ?? []));$p++) {
 			if (isset($this->assocLigs[$p])) {
 				$tmp = $this->assocLigs[$p];
 				unset($this->assocLigs[$p]); 
 				$this->assocLigs[($p - $nrem)] = $tmp;
 			}
 		}
-		for ($p=0;$p<count($this->OTLdata);$p++) {
+		for ($p=0;$p<count(($this->OTLdata ?? []));$p++) {
 			if (isset($this->assocMarks[$p])) {
 				if ($this->assocMarks[$p]['ligPos'] >=($pos)) { $this->assocMarks[$p]['ligPos'] -= $nrem; }
 				if ($p>$pos) {
@@ -2206,7 +2218,7 @@
 	}
 	// LookupType 2: Multiple Substitution Subtable : 1 to n
 	else if ($Type == 2) {
-		for($i=0;$i<count($substitute);$i++) {
+		for($i=0;$i<count(($substitute ?? []));$i++) {
 			$uni = $substitute[$i];
 			$newOTLdata[$i] = array();
 			$newOTLdata[$i]['uni'] = $uni;
@@ -2219,7 +2231,7 @@
 				$bt = $this->OTLdata[$pos]['bidi_type']; 
 		//	}
 
-			if (strpos($this->GlyphClassMarks, $newOTLdata[$i]['hex'] )!==false) { $gp = 'M'; }
+			if (strpos(($this->GlyphClassMarks ?? ''), ($newOTLdata[$i]['hex'] ?? '') )!==false) { $gp = 'M'; }
 			else if ($uni == 32) { $gp = 'S'; }
 			else { $gp = 'C'; }
 
@@ -2244,15 +2256,15 @@
 
 		}
 		if ($this->shaper=='K' || $this->shaper=='T' || $this->shaper=='L') {
-			if ($this->OTLdata[$pos]['wordend']) { $newOTLdata[count($substitute)-1]['wordend'] = true; }
+			if ($this->OTLdata[$pos]['wordend']) { $newOTLdata[count(($substitute ?? []))-1]['wordend'] = true; }
 		}
 
 		array_splice($this->OTLdata, $pos, 1, $newOTLdata);	// Replace 1 with n
 		// Update position of Ligatures and associated Marks
 		// count($substitute)-1  is the number of glyphs added
-		$nadd = count($substitute)-1;
+		$nadd = count(($substitute ?? []))-1;
 		$this->_updateLigatureMarks($pos, $nadd);
-		return count($substitute);
+		return count(($substitute ?? []));
 	}
 	// LookupType 4: Ligature Substitution Subtable : n to 1
 	else if ($Type == 4) {
@@ -2264,13 +2276,13 @@
 		$contains_nonmarks = false;
 		if (isset($this->OTLdata[$pos]['syllable'])) { $current_syllable = $this->OTLdata[$pos]['syllable']; }
 		else { $current_syllable = 0; }
-		for($i=0;$i<count($GlyphPos);$i++) {
+		for($i=0;$i<count(($GlyphPos ?? []));$i++) {
 			// If subsequent components are not Marks as well - don't ligate
 			$unistr = $this->OTLdata[$GlyphPos[$i]]['hex'];
 			if ($this->restrictToSyllable && isset($this->OTLdata[$GlyphPos[$i]]['syllable']) && $this->OTLdata[$GlyphPos[$i]]['syllable'] != $current_syllable) {
 				return 0;
 			}
-			if (strpos($this->GlyphClassMarks, $unistr )!==false) { $contains_marks = true; }
+			if (strpos(($this->GlyphClassMarks ?? ''), ($unistr ?? '') )!==false) { $contains_marks = true; }
 			else  { $contains_nonmarks = true; }
 		}
 		if ($contains_marks && !$contains_nonmarks) {
@@ -2280,7 +2292,7 @@
 				$firstMarkAssoc = $this->assocMarks[$pos]; 
 			}
 			// If all components of the ligature are marks, we call this a mark ligature.
-			for($i=1;$i<count($GlyphPos);$i++) {
+			for($i=1;$i<count(($GlyphPos ?? []));$i++) {
 
 				// If subsequent components are not Marks as well - don't ligate
 		//		$unistr = $this->OTLdata[$GlyphPos[$i]]['hex'];
@@ -2320,7 +2332,7 @@
    */
 			// So if is_array($firstMarkAssoc) - the new (Mark) ligature should keep this association
 
-			$lastPos = $GlyphPos[(count($GlyphPos)-1)];
+			$lastPos = $GlyphPos[(count(($GlyphPos ?? []))-1)];
 		}
 		else {
 /*
@@ -2353,7 +2365,7 @@
    */
 
 			$currComp = 0;
-			for($i=0;$i<count($GlyphPos);$i++) {
+			for($i=0;$i<count(($GlyphPos ?? []));$i++) {
 				if ($i>0 && isset($this->assocLigs[$GlyphPos[$i]])) {	// One of the other components is already a ligature
 					$nc = $this->assocLigs[$GlyphPos[$i]];
 				}
@@ -2361,7 +2373,7 @@
 			 	// While next char to right is a mark (but not the next matched glyph)
 				// ?? + also include a Mark Ligature here
 				$ic = 1;
-				while((($i==count($GlyphPos)-1) || (isset($GlyphPos[$i+1]) && ($GlyphPos[$i]+$ic) < $GlyphPos[$i+1])) && isset($this->OTLdata[($GlyphPos[$i]+$ic)]) && strpos($this->GlyphClassMarks, $this->OTLdata[($GlyphPos[$i]+$ic)]['hex'])!== false) {
+				while((($i==count(($GlyphPos ?? []))-1) || (isset($GlyphPos[$i+1]) && ($GlyphPos[$i]+$ic) < $GlyphPos[$i+1])) && isset($this->OTLdata[($GlyphPos[$i]+$ic)]) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[($GlyphPos[$i]+$ic)]['hex'] ?? ''))!== false) {
 					$newComp = $currComp;
 					if (isset($this->assocMarks[$GlyphPos[$i]+$ic])) {	// One of the inbetween Marks is already associated with a Lig
 						// OK as long as it is associated with the current Lig
@@ -2373,7 +2385,7 @@
 				}
 				$currComp += $nc;
 			}
-			$lastPos = $GlyphPos[(count($GlyphPos)-1)]+$ic-1;
+			$lastPos = $GlyphPos[(count(($GlyphPos ?? []))-1)]+$ic-1;
 			$this->assocLigs[$pos] = $currComp ;	// Number of components in new Ligature
 		}
 
@@ -2386,7 +2398,7 @@
 			$bt = $this->OTLdata[$pos]['bidi_type']; 
 	//	}
 
-		if (strpos($this->GlyphClassMarks, $this->unicode_hex($substitute))!==false) { $gp = 'M'; }
+		if (strpos(($this->GlyphClassMarks ?? ''), ($this->unicode_hex($substitute) ?? ''))!==false) { $gp = 'M'; }
 		else if ($substitute == 32) { $gp = 'S'; }
 		else { $gp = 'C'; }
 
@@ -2400,8 +2412,8 @@
 		// If previous/first component of ligature is a medial form, then keep this as a kashida point
 		// TEST (Arabic Typesetting) &#x64a;&#x64e;&#x646;&#x62a;&#x64f;&#x645;
 		$ka = 0;
-		if (isset($this->OTLdata[$GlyphPos[(count($GlyphPos)-1)]]['GPOSinfo']['kashida'])) {
-			$ka = $this->OTLdata[$GlyphPos[(count($GlyphPos)-1)]]['GPOSinfo']['kashida']; 
+		if (isset($this->OTLdata[$GlyphPos[(count(($GlyphPos ?? []))-1)]]['GPOSinfo']['kashida'])) {
+			$ka = $this->OTLdata[$GlyphPos[(count(($GlyphPos ?? []))-1)]]['GPOSinfo']['kashida']; 
 		}
 		if ($ka==1 && isset($this->OTLdata[$pos]['form']) && $this->OTLdata[$pos]['form']==3) { $newOTLdata[0]['GPOSinfo']['kashida'] = $ka; }
 
@@ -2427,7 +2439,7 @@
 		// GlyphPos contains array of arr_pos to set null - not necessarily contiguous
 
 		// +- Remove any assocMarks or assocLigs from the main components (the ones that are deleted)
-		for($i=count($GlyphPos)-1;$i>0;$i--) {
+		for($i=count(($GlyphPos ?? []))-1;$i>0;$i--) {
 			$gpos = $GlyphPos[$i];
 			array_splice($this->OTLdata, $gpos, 1);
 			unset($this->assocLigs[$gpos]);
@@ -2439,9 +2451,9 @@
 		// Update position of pre-existing Ligatures and associated Marks
 		// Start after first GlyphPos
 		// count($GlyphPos)-1  is the number of glyphs removed from string
-		for($p=($GlyphPos[0]+1);$p<(count($this->OTLdata)+count($GlyphPos)-1) ;$p++ ) {
+		for($p=($GlyphPos[0]+1);$p<(count(($this->OTLdata ?? []))+count(($GlyphPos ?? []))-1) ;$p++ ) {
 			$nrem = 0;	// Number of Glyphs removed at this point in the string
-			for($i=0;$i<count($GlyphPos);$i++) {
+			for($i=0;$i<count(($GlyphPos ?? []));$i++) {
 				if ($i>0 && $p > $GlyphPos[$i]) { $nrem++; }
 			}
 			if (isset($this->assocLigs[$p])) {
@@ -2598,14 +2610,14 @@
 
 function arabic_shaper($usetags, $scriptTag) {
 		$chars = array();
-		for($i=0;$i<count($this->OTLdata);$i++) {
+		for($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			$chars[] = $this->OTLdata[$i]['hex'];
 		}
 		$crntChar = null;
 		$prevChar = null;
 		$nextChar = null;
 		$output = array();
-		$max = count($chars);
+		$max = count(($chars ?? []));
 		for ($i = $max - 1; $i >= 0; $i--) {
 			$crntChar = $chars[$i];
 			if ($i > 0){ $prevChar = hexdec($chars[$i - 1]); }
@@ -2646,7 +2658,7 @@
 			$nextChar = $crntChar;
 		}
 		$ra = array_reverse($output);
-		for($i=0;$i<count($this->OTLdata);$i++) {
+		for($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			$this->OTLdata[$i]['uni'] = hexdec($ra[$i][0]);
 			$this->OTLdata[$i]['hex'] = $ra[$i][0];
 			$this->OTLdata[$i]['form'] = $ra[$i][1];	// Actaul form substituted 0=ISOLATED FORM :: 1=FINAL :: 2=INITIAL :: 3=MEDIAL
@@ -2657,7 +2669,7 @@
 function get_arab_glyphs($char, $type, &$chars, $i, $scriptTag, $usetags) {
 
 	// Optional Feature settings	// doesn't control Syriac at present
-	if (($type===0 && strpos($usetags, 'isol')===false) || ($type===1 && strpos($usetags, 'fina')===false) || ($type===2 && strpos($usetags, 'init')===false) || ($type===3 && strpos($usetags, 'medi')===false)) {
+	if (($type===0 && strpos(($usetags ?? ''), 'isol')===false) || ($type===1 && strpos(($usetags ?? ''), 'fina')===false) || ($type===2 && strpos(($usetags ?? ''), 'init')===false) || ($type===3 && strpos(($usetags ?? ''), 'medi')===false)) {
 		return array($char,0);
 	}
 
@@ -2672,11 +2684,11 @@
 		// not in $this->arabLeftJoining i.e. not a char which can join to the next one
 		if (isset($chars[$n]) && isset($this->arabLeftJoining[hexdec($chars[$n])])) {
 			// if in the middle of Syriac words
-			if (isset($chars[$i+1]) && preg_match('/[\x{0700}-\x{0745}]/u',code2utf(hexdec($chars[$n]))) && preg_match('/[\x{0700}-\x{0745}]/u',code2utf(hexdec($chars[$i+1]))) && isset($this->arabGlyphs[$char][4])) { $retk = 4; }
+			if (isset($chars[$i+1]) && preg_match('/[\x{0700}-\x{0745}]/u',(code2utf(hexdec($chars[$n])) ?? '')) && preg_match('/[\x{0700}-\x{0745}]/u',(code2utf(hexdec($chars[$i+1])) ?? '')) && isset($this->arabGlyphs[$char][4])) { $retk = 4; }
 			// if at the end of Syriac words
-			else if(!isset($chars[$i+1]) || !preg_match('/[\x{0700}-\x{0745}]/u',code2utf(hexdec($chars[$i+1])))) {
+			else if(!isset($chars[$i+1]) || !preg_match('/[\x{0700}-\x{0745}]/u',(code2utf(hexdec($chars[$i+1])) ?? ''))) {
 				// if preceding base character IS (00715|00716|0072A)
-				if (strpos('0715|0716|072A',$chars[$n])!==false && isset($this->arabGlyphs[$char][6])) { $retk = 6; }
+				if (strpos('0715|0716|072A',($chars[$n] ?? ''))!==false && isset($this->arabGlyphs[$char][6])) { $retk = 6; }
 
 				// else if preceding base character is NOT (00715|00716|0072A) 
 				else if (isset($this->arabGlyphs[$char][5])) { $retk = 5; }
@@ -2704,12 +2716,12 @@
 			$ig = 1;
 			foreach($this->arabGlyphs[$char]['prel'][$retk] AS $k=>$v) {	// $k starts 0, 1...
 				if (!isset($chars[$i-$ig-$k])) { $match = false; }
-				else if (strpos($v,$chars[$i-$ig-$k])===false) { 
-					while (strpos($this->arabGlyphs[$char]['ignore'][$retk],$chars[$i-$ig-$k])!==false) { 	// ignore
+				else if (strpos(($v ?? ''),($chars[$i-$ig-$k] ?? ''))===false) { 
+					while (strpos(($this->arabGlyphs[$char]['ignore'][$retk] ?? ''),($chars[$i-$ig-$k] ?? ''))!==false) { 	// ignore
 						$ig++;
 					}
 					if (!isset($chars[$i-$ig-$k])) { $match = false; }
-					else if (strpos($v,$chars[$i-$ig-$k])===false) { $match = false; }
+					else if (strpos(($v ?? ''),($chars[$i-$ig-$k] ?? ''))===false) { $match = false; }
 				}
 			}
 		}
@@ -2717,12 +2729,12 @@
 			$ig = 1;
 			foreach($this->arabGlyphs[$char]['postl'][$retk] AS $k=>$v) {	// $k starts 0, 1...
 				if (!isset($chars[$i+$ig+$k])) { $match = false; }
-				else if (strpos($v,$chars[$i+$ig+$k])===false) { 
-					while (strpos($this->arabGlyphs[$char]['ignore'][$retk],$chars[$i+$ig+$k])!==false) { 	// ignore
+				else if (strpos(($v ?? ''),($chars[$i+$ig+$k] ?? ''))===false) { 
+					while (strpos(($this->arabGlyphs[$char]['ignore'][$retk] ?? ''),($chars[$i+$ig+$k] ?? ''))!==false) { 	// ignore
 						$ig++;
 					}
 					if (!isset($chars[$i+$ig+$k])) { $match = false; }
-					else if (strpos($v,$chars[$i+$ig+$k])===false) { $match = false; }
+					else if (strpos(($v ?? ''),($chars[$i+$ig+$k] ?? ''))===false) { $match = false; }
 				}
 			}
 		}
@@ -2746,7 +2758,7 @@
 ////////////////////////////////////////////////////////////////
 // Sets $this->OTLdata[$i]['wordend']=true at possible end of word boundaries
 function TibetanlineBreaking() {
-	for ($ptr=0; $ptr<count($this->OTLdata);$ptr++) {
+	for ($ptr=0; $ptr<count(($this->OTLdata ?? []));$ptr++) {
 		// Break opportunities at U+0F0B Tsheg or U=0F0D
 		if (isset($this->OTLdata[$ptr]['uni']) && ($this->OTLdata[$ptr]['uni']==0x0F0B || $this->OTLdata[$ptr]['uni']==0x0F0D)) {
 			if (isset($this->OTLdata[$ptr+1]['uni']) && ($this->OTLdata[$ptr+1]['uni']==0x0F0D || $this->OTLdata[$ptr+1]['uni']==0xF0E)) { continue; }
@@ -2778,15 +2790,15 @@
 
 	$rollover = array();
 	$ptr = 0;
-	while ($ptr<count($this->OTLdata)-3) {
-		if (count($rollover)) {
+	while ($ptr<count(($this->OTLdata ?? []))-3) {
+		if (count(($rollover ?? []))) {
 			$matches = $rollover;
 			$rollover = array();
 		}
 		else {
 			$matches = $this->checkwordmatch($dict, $ptr);
 		}
-		if (count($matches)==1) {
+		if (count(($matches ?? []))==1) {
 			$matchpos = $matches[0];
 			// Check for repeaters - if so $matchpos++
 			if (isset($this->OTLdata[$matchpos+1]['uni']) && ($this->OTLdata[$matchpos+1]['uni']==0x0E2F || $this->OTLdata[$matchpos+1]['uni']==0x0E46 || $this->OTLdata[$matchpos+1]['uni']==0x0EC6)) { $matchpos++; }
@@ -2801,11 +2813,11 @@
 		}
 		else {	// Multiple matches
 			$secondmatch = false;
-			for ($m=count($matches)-1;$m>=0;$m--) {
+			for ($m=count(($matches ?? []))-1;$m>=0;$m--) {
 			//for ($m=0;$m<count($matches);$m++) {
 				$firstmatch = $matches[$m];
 				$matches2 = $this->checkwordmatch($dict, $firstmatch+1);
-				if (count($matches2)) {
+				if (count(($matches2 ?? []))) {
 					// Set end of word marker in OTLdata at matchpos
 					$this->OTLdata[$firstmatch]['wordend'] = true;
 					$ptr = $firstmatch + 1;
@@ -2816,8 +2828,8 @@
 			}
 			if (!$secondmatch) {
 				// Set end of word marker in OTLdata at end of longest first match
-				$this->OTLdata[$matches[count($matches)-1]]['wordend'] = true;
-				$ptr = $matches[count($matches)-1] + 1;
+				$this->OTLdata[$matches[count(($matches ?? []))-1]]['wordend'] = true;
+				$ptr = $matches[count(($matches ?? []))-1] + 1;
 				// Move past any ASCII characters 
 				while (isset($this->OTLdata[$ptr]['uni']) && ($this->OTLdata[$ptr]['uni'] >> 8) == 0) { $ptr++; }
 			}
@@ -2850,12 +2862,12 @@
 	$ok = true;
 	$matches = array();
 	while ($ok) {
-		$x = ord($dict{$dictptr});
+		$x = ord(($dict[$dictptr] ?? ''));
 		$c = $this->OTLdata[$ptr]['uni'] & 0xFF;
 		if ($x==_DICT_INTERMEDIATE_MATCH) {
 //echo "DICT_INTERMEDIATE_MATCH: ".dechex($c).'<br />';
 			// Do not match if next character in text is a Mark
-			if (isset($this->OTLdata[$ptr]['uni']) && strpos($this->GlyphClassMarks, $this->OTLdata[$ptr]['hex'])===false) { 
+			if (isset($this->OTLdata[$ptr]['uni']) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$ptr]['hex'] ?? ''))===false) { 
 				$matches[] = $ptr - 1;
 			}
 			$dictptr++;
@@ -2863,7 +2875,7 @@
 		else if ($x==_DICT_FINAL_MATCH) {
 //echo "DICT_FINAL_MATCH: ".dechex($c).'<br />';
 			// Do not match if next character in text is a Mark
-			if (isset($this->OTLdata[$ptr]['uni']) && strpos($this->GlyphClassMarks, $this->OTLdata[$ptr]['hex'])===false) { 
+			if (isset($this->OTLdata[$ptr]['uni']) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$ptr]['hex'] ?? ''))===false) { 
 				$matches[] = $ptr - 1;
 			}
 			return $matches;
@@ -2871,14 +2883,14 @@
 		else if ($x==_DICT_NODE_TYPE_LINEAR) {
 //echo "DICT_NODE_TYPE_LINEAR: ".dechex($c).'<br />';
 			$dictptr++;
-			$m = ord($dict{$dictptr});
+			$m = ord(($dict[$dictptr] ?? ''));
 			if ($c == $m) {
 				$ptr++;
-				if ($ptr > count($this->OTLdata)-1) {
-					$next = ord($dict{$dictptr+1});
+				if ($ptr > count(($this->OTLdata ?? []))-1) {
+					$next = ord(($dict[$dictptr+1] ?? ''));
 					if ($next==_DICT_INTERMEDIATE_MATCH || $next==_DICT_FINAL_MATCH) {
 						// Do not match if next character in text is a Mark
-						if (isset($this->OTLdata[$ptr]['uni']) && strpos($this->GlyphClassMarks, $this->OTLdata[$ptr]['hex'])===false) { 
+						if (isset($this->OTLdata[$ptr]['uni']) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$ptr]['hex'] ?? ''))===false) { 
 							$matches[] = $ptr - 1;
 						}
 					}
@@ -2895,14 +2907,14 @@
 		else if ($x==_DICT_NODE_TYPE_SPLIT) {
 //echo "DICT_NODE_TYPE_SPLIT ON ".dechex($d).": ".dechex($c).'<br />';
 			$dictptr++;
-			$d = ord($dict{$dictptr});
+			$d = ord(($dict[$dictptr] ?? ''));
 			if ($c < $d) {
 				$dictptr += 5;
 			}
 			else {
 				$dictptr++;
 				// Unsigned long 32-bit offset
-				$offset = (ord($dict{$dictptr})*16777216) + (ord($dict{$dictptr+1})<<16) + (ord($dict{$dictptr+2})<<8) + ord($dict{$dictptr+3});
+				$offset = (ord(($dict[$dictptr] ?? ''))*16777216) + (ord(($dict[$dictptr+1] ?? ''))<<16) + (ord(($dict[$dictptr+2] ?? ''))<<8) + ord(($dict[$dictptr+3] ?? ''));
 				$dictptr = $offset;
 			}
 		}
@@ -2932,7 +2944,7 @@
 			$MarkFilteringSet = $this->GPOSLookups[$lu]['MarkFilteringSet'];
 		$ptr = 0;
 		// Test each glyph sequentially
-		while($ptr < (count($this->OTLdata))) {	// whilst there is another glyph ..0064
+		while($ptr < (count(($this->OTLdata ?? [])))) {	// whilst there is another glyph ..0064
 			$currGlyph = $this->OTLdata[$ptr]['hex'];
 			$currGID = $this->OTLdata[$ptr]['uni'];
 			$shift = 1;
@@ -2969,7 +2981,7 @@
 
 	// If current glyph is a mark with a defined width, any XAdvance is considered to REPLACE the character Advance Width
 	// Test case <div style="font-family:myanmartext">&#x1004;&#x103a;&#x1039;&#x1000;&#x1039;&#x1000;&#x103b;&#x103c;&#x103d;&#x1031;&#x102d;</div>
-	if (strpos($this->GlyphClassMarks, $this->OTLdata[$basepos]['hex'])!==false) { 
+	if (strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$basepos]['hex'] ?? ''))!==false) { 
 		$cw = round($this->mpdf->_getCharWidth($this->mpdf->CurrentFont['cw'], $this->OTLdata[$basepos]['uni']) * $this->mpdf->CurrentFont['unitsPerEm'] / 1000);	// convert back to font design units
 	}
 	else { 
@@ -3012,16 +3024,16 @@
 	// NB Not all fonts have all marks specified in GlyphClassMarks
 
 	// If the current glyph is not a base (but a mark) then ignore this, and apply to the current position
-	if (strpos($this->GlyphClassMarks, $this->OTLdata[$pos]['hex'])!==false) { return $pos; }
-
-	while(isset($this->OTLdata[$pos+1]['hex']) && strpos($this->GlyphClassMarks, $this->OTLdata[$pos+1]['hex'])!==false) { $pos++; }
+	if (strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$pos]['hex'] ?? ''))!==false) { return $pos; }
+
+	while(isset($this->OTLdata[$pos+1]['hex']) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$pos+1]['hex'] ?? ''))!==false) { $pos++; }
 	return $pos ;
 }
 
 
 
 
-function _applyGPOSsubtable($lookupID, $subtable, $ptr, $currGlyph, $currGID, $subtable_offset, $Type, $Flag, $MarkFilteringSet, $LuCoverage, $tag, $level=0, $is_old_spec) {
+function _applyGPOSsubtable($lookupID, $subtable, $ptr, $currGlyph, $currGID, $subtable_offset, $Type, $Flag, $MarkFilteringSet, $LuCoverage, $tag, $level, $is_old_spec) {
 	if (($Flag  & 0x0001) == 1) { $dir = 'RTL'; }	// only used for Type 3
 	else { $dir = 'LTR'; }
 	$ignore = $this->_getGCOMignoreString($Flag, $MarkFilteringSet);
@@ -3088,7 +3100,7 @@
 
 						$checkpos = $ptr;
 						$checkpos++;
-						while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) {
+						while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 							 $checkpos++; 
 						}
 						if (isset($this->OTLdata[$checkpos]) && $this->OTLdata[$checkpos]['uni']==$SecondGlyph) {
@@ -3138,7 +3150,7 @@
 			$FirstGlyph = $this->OTLdata[$ptr]['uni'];
 			$checkpos = $ptr;
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) {
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 				$checkpos++; 
 			}
 			if (isset($this->OTLdata[$checkpos])) { $matchedpos = $checkpos; }
@@ -3146,12 +3158,12 @@
 
 			$SecondGlyph = $this->OTLdata[$matchedpos]['uni'];
 			for($i=0;$i<$Class1Count;$i++) {
-				if (isset($Class1[$i]) && count($Class1[$i])) {
+				if (isset($Class1[$i]) && count(($Class1[$i] ?? []))) {
 					$FirstClassPos = array_search($FirstGlyph, $Class1[$i]);
 					if ($FirstClassPos === false) { continue; }
 					else {
 						for($j=0;$j<$Class2Count;$j++) {
-							if (isset($Class2[$j]) && count($Class2[$j])) {
+							if (isset($Class2[$j]) && count(($Class2[$j] ?? []))) {
 
 									$SecondClassPos = array_search($SecondGlyph, $Class2[$j]);
 									if ($SecondClassPos === false) { continue; }
@@ -3245,15 +3257,15 @@
 		// This Fix blocks the GPOS rule if the "mark" is not actually classified as a mark in the GlyphClasses of GDEF
 		// but only in Indic old-spec.
 		// Test cases: &#xca8;&#xccd;&#xca8;&#xcc1; and &#xc95;&#xccd;&#xcb0;&#xccc;
-		if ($this->shaper=='I' && $is_old_spec && strpos($this->GlyphClassMarks, $this->OTLdata[$ptr]['hex'])===false) { return; }
+		if ($this->shaper=='I' && $is_old_spec && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$ptr]['hex'] ?? ''))===false) { return; }
 
 
 		// "To identify the base glyph that combines with a mark, the text-processing client must look backward in the glyph string from the mark to the preceding base glyph."
-		while (isset($this->OTLdata[$checkpos]) && strpos($this->GlyphClassMarks, $this->OTLdata[$checkpos]['hex'])!==false) {
+		while (isset($this->OTLdata[$checkpos]) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$checkpos--; 
 		}
 
-		if (isset($this->OTLdata[$checkpos]) && strpos($BaseGlyphs, $this->OTLdata[$checkpos]['hex'])!==false) {
+		if (isset($this->OTLdata[$checkpos]) && strpos(($BaseGlyphs ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$matchedpos = $checkpos;
 		}
 		else { $matchedpos = false; }
@@ -3268,7 +3280,7 @@
 			// Get the relevant BaseRecord
 			$this->seek($BaseArray);
 			$BaseCount = $this->read_ushort();
-			$BasePos = strpos($BaseGlyphs, $this->OTLdata[$matchedpos]['hex'])/6;
+			$BasePos = strpos(($BaseGlyphs ?? ''), ($this->OTLdata[$matchedpos]['hex'] ?? ''))/6;
 
 			// Move to the BaseRecord we want
 			$nSkip = (2 * $BasePos * $ClassCount );
@@ -3325,11 +3337,11 @@
 		$checkpos--;
 
 		// "To position a combining mark using a MarkToLigature attachment subtable, the text-processing client must work backward from the mark to the preceding ligature glyph."
-		while (isset($this->OTLdata[$checkpos]) && strpos($this->GlyphClassMarks, $this->OTLdata[$checkpos]['hex'])!==false) {
+		while (isset($this->OTLdata[$checkpos]) && strpos(($this->GlyphClassMarks ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$checkpos--; 
 		}
 
-		if (isset($this->OTLdata[$checkpos]) && strpos($LigatureGlyphs, $this->OTLdata[$checkpos]['hex'])!==false) {
+		if (isset($this->OTLdata[$checkpos]) && strpos(($LigatureGlyphs ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$matchedpos = $checkpos;
 		}
 		else { $matchedpos = false; }
@@ -3345,7 +3357,7 @@
 			// Get the relevant LigatureRecord
 			$this->seek($LigatureArray);
 			$LigatureCount = $this->read_ushort();
-			$LigaturePos = strpos($LigatureGlyphs, $this->OTLdata[$matchedpos]['hex'])/6;
+			$LigaturePos = strpos(($LigatureGlyphs ?? ''), ($this->OTLdata[$matchedpos]['hex'] ?? ''))/6;
 
 			// Move to the LigatureAttach table Record we want
 			$nSkip = (2 * $LigaturePos);
@@ -3415,10 +3427,10 @@
 		$Mark2Glyphs = implode('|',$this->_getCoverage());
 		$checkpos = $ptr;
 		$checkpos--;
-		while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) {
+		while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$checkpos--; 
 		}
-		if (isset($this->OTLdata[$checkpos]) && strpos($Mark2Glyphs, $this->OTLdata[$checkpos]['hex'])!==false) {
+		if (isset($this->OTLdata[$checkpos]) && strpos(($Mark2Glyphs ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 			$matchedpos = $checkpos;
 		}
 		else { $matchedpos = false; }
@@ -3433,7 +3445,7 @@
 			// Get the relevant Mark2Record
 			$this->seek($Mark2Array);
 			$Mark2Count = $this->read_ushort();
-			$Mark2Pos = strpos($Mark2Glyphs, $this->OTLdata[$matchedpos]['hex'])/6;
+			$Mark2Pos = strpos(($Mark2Glyphs ?? ''), ($this->OTLdata[$matchedpos]['hex'] ?? ''))/6;
 
 			// Move to the Mark2Record we want
 			$nSkip = (2 * $Mark2Pos * $ClassCount );
@@ -3564,7 +3576,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$class0excl = array();
-						for ($gc=1;$gc<=count($InputClasses);$gc++) {
+						for ($gc=1;$gc<=count(($InputClasses ?? []));$gc++) {
 							if (is_array($InputClasses[$gc])) $class0excl = $class0excl + $InputClasses[$gc];
 						}
 
@@ -3698,7 +3710,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$class0excl = array();
-						for ($gc=1;$gc<=count($InputClasses);$gc++) {
+						for ($gc=1;$gc<=count(($InputClasses ?? []));$gc++) {
 							if (isset($InputClasses[$gc]) && is_array($InputClasses[$gc])) $class0excl = $class0excl + $InputClasses[$gc];
 						}
 
@@ -3714,7 +3726,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$bclass0excl = array();
-						for ($gc=1;$gc<=count($BacktrackClasses);$gc++) {
+						for ($gc=1;$gc<=count(($BacktrackClasses ?? []));$gc++) {
 							if (isset($BacktrackClasses[$gc]) && is_array($BacktrackClasses[$gc])) $bclass0excl = $bclass0excl + $BacktrackClasses[$gc];
 						}
 
@@ -3730,7 +3742,7 @@
 
 						// Class 0 contains all the glyphs NOT in the other classes
 						$lclass0excl = array();
-						for ($gc=1;$gc<=count($LookaheadClasses);$gc++) {
+						for ($gc=1;$gc<=count(($LookaheadClasses ?? []));$gc++) {
 							if (isset($LookaheadClasses[$gc]) && is_array($LookaheadClasses[$gc])) $lclass0excl = $lclass0excl + $LookaheadClasses[$gc];
 						}
 
@@ -3864,9 +3876,9 @@
 
 		// BACKTRACK
 		$checkpos = $ptr;
-		for ($i=0;$i<count($Backtrack);$i++) {
+		for ($i=0;$i<count(($Backtrack ?? []));$i++) {
 			$checkpos--;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos--; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos--; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -3879,9 +3891,9 @@
 		// INPUT
 		$matched = array(0=>$ptr);
 		$checkpos = $ptr;
-		for ($i=1;$i<count($Input);$i++) {
+		for ($i=1;$i<count(($Input ?? []));$i++) {
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -3893,9 +3905,9 @@
 		}
 		
 		// LOOKAHEAD
-		for ($i=0;$i<count($Lookahead);$i++) {
+		for ($i=0;$i<count(($Lookahead ?? []));$i++) {
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -3920,18 +3932,18 @@
 
 		// BACKTRACK
 		$checkpos = $ptr;
-		for ($i=0;$i<count($Backtrack);$i++) {
+		for ($i=0;$i<count(($Backtrack ?? []));$i++) {
 			$checkpos--;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos--; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos--; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
 			}
 			// If Class 0 specified, matches anything NOT in $bclass0excl 
-			else if (!$Backtrack[$i] && isset($this->OTLdata[$checkpos]) && strpos($bclass0excl,$this->OTLdata[$checkpos]['hex'])!==false) {
+			else if (!$Backtrack[$i] && isset($this->OTLdata[$checkpos]) && strpos(($bclass0excl ?? ''),($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 				return false;
 			}
-			else if (!isset($this->OTLdata[$checkpos]) || strpos($Backtrack[$i], $this->OTLdata[$checkpos]['hex'])===false) {
+			else if (!isset($this->OTLdata[$checkpos]) || strpos(($Backtrack[$i] ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))===false) {
 				return false;
 			}
 		}
@@ -3939,36 +3951,36 @@
 		// INPUT
 		$matched = array(0=>$ptr);
 		$checkpos = $ptr;
-		for ($i=1;$i<count($Input);$i++) {	// Start at 1 - already matched the first InputGlyph
+		for ($i=1;$i<count(($Input ?? []));$i++) {	// Start at 1 - already matched the first InputGlyph
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
 			}
 			// If Input Class 0 specified, matches anything NOT in $class0excl 
-			else if (!$Input[$i] && isset($this->OTLdata[$checkpos]) && strpos($class0excl,$this->OTLdata[$checkpos]['hex'])===false) {
+			else if (!$Input[$i] && isset($this->OTLdata[$checkpos]) && strpos(($class0excl ?? ''),($this->OTLdata[$checkpos]['hex'] ?? ''))===false) {
 					$matched[] = $checkpos;
 			}
-			else if (isset($this->OTLdata[$checkpos]) && strpos($Input[$i],$this->OTLdata[$checkpos]['hex'])!==false) {
+			else if (isset($this->OTLdata[$checkpos]) && strpos(($Input[$i] ?? ''),($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 					$matched[] = $checkpos;
 			}
 			else { return false; }
 		}
 		
 		// LOOKAHEAD
-		for ($i=0;$i<count($Lookahead);$i++) {
+		for ($i=0;$i<count(($Lookahead ?? []));$i++) {
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
 			}
 			// If Class 0 specified, matches anything NOT in $lclass0excl 
-			else if (!$Lookahead[$i] && isset($this->OTLdata[$checkpos]) && strpos($lclass0excl,$this->OTLdata[$checkpos]['hex'])!==false) {
+			else if (!$Lookahead[$i] && isset($this->OTLdata[$checkpos]) && strpos(($lclass0excl ?? ''),($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) {
 				return false;
 			}
-			else if (!isset($this->OTLdata[$checkpos]) || strpos($Lookahead[$i],$this->OTLdata[$checkpos]['hex'])===false) {
+			else if (!isset($this->OTLdata[$checkpos]) || strpos(($Lookahead[$i] ?? ''),($this->OTLdata[$checkpos]['hex'] ?? ''))===false) {
 				return false;
 			}
 		}
@@ -3986,9 +3998,9 @@
 
 		// BACKTRACK
 		$checkpos = $ptr;
-		for ($i=0;$i<count($Backtrack);$i++) {
+		for ($i=0;$i<count(($Backtrack ?? []));$i++) {
 			$checkpos--;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos--; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos--; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -4005,9 +4017,9 @@
 		// INPUT
 		$matched = array(0=>$ptr);
 		$checkpos = $ptr;
-		for ($i=1;$i<count($Input);$i++) {	// Start at 1 - already matched the first InputGlyph
+		for ($i=1;$i<count(($Input ?? []));$i++) {	// Start at 1 - already matched the first InputGlyph
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -4023,9 +4035,9 @@
 		}
 		
 		// LOOKAHEAD
-		for ($i=0;$i<count($Lookahead);$i++) {
+		for ($i=0;$i<count(($Lookahead ?? []));$i++) {
 			$checkpos++;
-			while (isset($this->OTLdata[$checkpos]) && strpos($ignore, $this->OTLdata[$checkpos]['hex'])!==false) { $checkpos++; }
+			while (isset($this->OTLdata[$checkpos]) && strpos(($ignore ?? ''), ($this->OTLdata[$checkpos]['hex'] ?? ''))!==false) { $checkpos++; }
 			// If outside scope of current syllable - return no match
 			if ($this->restrictToSyllable && isset($this->OTLdata[$checkpos]['syllable']) && $this->OTLdata[$checkpos]['syllable'] != $current_syllable) {
 				return false;
@@ -4182,17 +4194,17 @@
 	function _checkGCOMignore($flag, $glyph, $MarkFilteringSet) {
 		$ignore = false;
 		// Flag & 0x0008 = Ignore Marks - (unless already done with MarkAttachmentType)
-		if (($flag & 0x0008 && ($flag & 0xFF00) == 0) && strpos($this->GlyphClassMarks,$glyph)) { $ignore = true; }
-		if (($flag & 0x0004) && strpos($this->GlyphClassLigatures,$glyph)) { $ignore = true; }
-		if (($flag & 0x0002) && strpos($this->GlyphClassBases,$glyph)) { $ignore = true; }
+		if (($flag & 0x0008 && ($flag & 0xFF00) == 0) && strpos(($this->GlyphClassMarks ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if (($flag & 0x0004) && strpos(($this->GlyphClassLigatures ?? ''),($glyph ?? ''))) { $ignore = true; }
+		if (($flag & 0x0002) && strpos(($this->GlyphClassBases ?? ''),($glyph ?? ''))) { $ignore = true; }
 		// Flag & 0xFF?? = MarkAttachmentType
 		if ($flag & 0xFF00) {
 			// "a lookup must ignore any mark glyphs that are not in the specified mark attachment class"
 			// $this->MarkAttachmentType is already adjusted for this i.e. contains all Marks except those in the MarkAttachmentClassDef table
-			if (strpos($this->MarkAttachmentType[($flag >> 8)],$glyph)) { $ignore = true; }
+			if (strpos(($this->MarkAttachmentType[($flag >> 8)] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		}
 		// Flag & 0x0010 = UseMarkFilteringSet
-		if (($flag & 0x0010) && strpos($this->MarkGlyphSets[$MarkFilteringSet],$glyph)) { $ignore = true; }
+		if (($flag & 0x0010) && strpos(($this->MarkGlyphSets[$MarkFilteringSet] ?? ''),($glyph ?? ''))) { $ignore = true; }
 		return $ignore;
 	}
 
@@ -4235,11 +4247,11 @@
 ON 	Other Neutrals 		All other characters, including OBJECT REPLACEMENT CHARACTER
 */
 
-function _bidiSort($ta, $str='', $dir, &$chunkOTLdata, $useGPOS) {
+function _bidiSort($ta, $str, $dir, &$chunkOTLdata, $useGPOS) {
 
 	$pel = 0;	// paragraph embedding level
 	$maxlevel = 0;
-	$numchars = count($chunkOTLdata['char_data']);
+	$numchars = count(($chunkOTLdata['char_data'] ?? []));
 
 	// Set the initial paragraph embedding level
 	if ($dir == 'rtl') { $pel = 1; } 
@@ -4305,8 +4317,8 @@
 		}
 		else if ($chunkOTLdata['char_data'][$i]['uni'] == 8236) {	// PDF
 			// X7. With each PDF, determine the matching embedding or override code. If there was a valid matching code, restore (pop) the last remembered (pushed) embedding level and directional override.
-			if (count($remember)) {
-				$last = count($remember ) - 1;
+			if (count(($remember ?? []))) {
+				$last = count(($remember ?? []) ) - 1;
 				if (($remember[$last]['num'] == 8235) || ($remember[$last]['num'] == 8234) || ($remember[$last]['num'] == 8238) || 
 					($remember[$last]['num'] == 8237)) {
 					$match = array_pop($remember);
@@ -4332,11 +4344,11 @@
 			// stores string characters and other information
 			if (isset($chunkOTLdata['GPOSinfo'][$i])) { $gpos = $chunkOTLdata['GPOSinfo'][$i]; }
 			else $gpos = '';
-			$chardata[] = array('char' => $chunkOTLdata['char_data'][$i]['uni'], 'level' => $cel, 'type' => $chardir, 'group' => $chunkOTLdata['group']{$i}, 'GPOSinfo' => $gpos);
-		}
-	}
-
-	$numchars = count($chardata);
+			$chardata[] = array('char' => $chunkOTLdata['char_data'][$i]['uni'], 'level' => $cel, 'type' => $chardir, 'group' => $chunkOTLdata['group'][$i], 'GPOSinfo' => $gpos);
+		}
+	}
+
+	$numchars = count(($chardata ?? []));
 
 	// X8. All explicit directional embeddings and overrides are completely terminated at the end of each paragraph.
 	// Paragraph separators are not included in the embedding.
@@ -4641,11 +4653,11 @@
 
 	// Process each character iteratively, applying rules X2 through X9. Only embedding levels from 0 to 61 are valid in this phase.
 	// In the resolution of levels in rules I1 and I2, the maximum embedding level of 62 can be reached.
-	$numchunks = count($para);
+	$numchunks = count(($para ?? []));
 	for ($nc=0;$nc<$numchunks;$nc++) {
 		$chunkOTLdata =& $para[$nc][18];
 
-		$numchars = count($chunkOTLdata['char_data']);
+		$numchars = count(($chunkOTLdata['char_data'] ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
 		  if ($chunkOTLdata['char_data'][$i]['uni'] == 8235) {	// RLE
 			// X2. With each RLE, compute the least greater odd embedding level.
@@ -4697,8 +4709,8 @@
 		  }
 		  else if ($chunkOTLdata['char_data'][$i]['uni'] == 8236) {	// PDF
 			// X7. With each PDF, determine the matching embedding or override code. If there was a valid matching code, restore (pop) the last remembered (pushed) embedding level and directional override.
-			if (count($remember)) {
-				$last = count($remember ) - 1;
+			if (count(($remember ?? []))) {
+				$last = count(($remember ?? []) ) - 1;
 				if (($remember[$last]['num'] == 8235) || ($remember[$last]['num'] == 8234) || ($remember[$last]['num'] == 8238) || 
 					($remember[$last]['num'] == 8237)) {
 					$match = array_pop($remember);
@@ -4725,9 +4737,9 @@
 				$lvl = 0;
 				$nc2 = $nc;
 				$i2 = $i;
-				while (!($nc2==($numchunks-1) && $i2==((count($para[$nc2][18]['char_data']))-1))) { 	// while not at end of last chunk
+				while (!($nc2==($numchunks-1) && $i2==((count(($para[$nc2][18]['char_data'] ?? [])))-1))) { 	// while not at end of last chunk
 					$i2++;
-					if ($i2 >= count($para[$nc2][18]['char_data'])) { 
+					if ($i2 >= count(($para[$nc2][18]['char_data'] ?? []))) { 
 						$nc2++;
 						$i2 = 0;
 					}
@@ -4774,8 +4786,8 @@
 		  else if ($chunkOTLdata['char_data'][$i]['uni'] == 8297) {	// PDI
 			// X6a. With each PDI, perform the following steps:
 			//	Pop the last entry from the directional status stack and decrement the isolate count by one.
-			while (count($remember)) {
-				$last = count($remember ) - 1;
+			while (count(($remember ?? []))) {
+				$last = count(($remember ?? []) ) - 1;
 				if (($remember[$last]['num'] == 8294) || ($remember[$last]['num'] == 8295) || ($remember[$last]['num'] == 8296)) {
 					$match = array_pop($remember);
 					$cel = $match['cel'];
@@ -4827,18 +4839,18 @@
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x80\xac");
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x80\xad");
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x80\xae");
-			preg_replace("/\x{202a}-\x{202e}/u", '', $para[$nc][0]);
+			preg_replace("/\x{202a}-\x{202e}/u", '', ($para[$nc][0] ?? ''));
 		}
 	}
 
 	// Remove any blank chunks made by removing directional codes
-	$numchunks = count($para);
+	$numchunks = count(($para ?? []));
 	for ($nc=($numchunks-1);$nc>=0;$nc--) {
-		if (count($para[$nc][18]['char_data'])==0) { array_splice($para, $nc, 1); }
+		if (count(($para[$nc][18]['char_data'] ?? []))==0) { array_splice($para, $nc, 1); }
 	}
 	if ($dir != 'rtl' && !$strongrtl && !$controlchars) { return; }
 
-	$numchunks = count($para);
+	$numchunks = count(($para ?? []));
 
 	// X10. Determine the start-of-sequence (sor) and end-of-sequence (eor) types, either L or R, for each isolating run sequence. These depend on the higher of the two levels on either side of the sequence boundary:
 	// For sor, compare the level of the first character in the sequence with the level of the character preceding it in the paragraph or if there is none, with the paragraph embedding level.
@@ -4851,15 +4863,15 @@
 		$firstchar = true;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				$right = $postlevel;
 				$nc2 = $nc;
 				$i2 = $i;
-				while (!($nc2==($numchunks-1) && $i2==((count($para[$nc2][18]['char_data']))-1))) { 	// while not at end of last chunk
+				while (!($nc2==($numchunks-1) && $i2==((count(($para[$nc2][18]['char_data'] ?? [])))-1))) { 	// while not at end of last chunk
 					$i2++;
-					if ($i2 >= count($para[$nc2][18]['char_data'])) { 
+					if ($i2 >= count(($para[$nc2][18]['char_data'] ?? []))) { 
 						$nc2++;
 						$i2 = 0;
 					}
@@ -4890,7 +4902,7 @@
 		$prevtype = 0;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				if ($chardata[$i]['type'] == UCDN::BIDI_CLASS_NSM) {
@@ -4911,7 +4923,7 @@
 		$laststrongtype = -1;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				if (isset($chardata[$i]['sor'])) { $laststrongtype = $chardata[$i]['sor']; }
@@ -4929,7 +4941,7 @@
 	// W3. Change all ALs to R.
 	for ($nc=0;$nc<$numchunks;$nc++) {
 		$chardata =& $para[$nc][18]['char_data'];
-		$numchars = count($chardata);
+		$numchars = count(($chardata ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
  			if (isset($chardata[$i]['type']) && $chardata[$i]['type'] == UCDN::BIDI_CLASS_AL) { $chardata[$i]['type'] = UCDN::BIDI_CLASS_R; }
 		}
@@ -4942,7 +4954,7 @@
 		$nexttype = -1;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 
@@ -4950,9 +4962,9 @@
 				$nexttype = -1; 
 				$nc2 = $nc;
 				$i2 = $i;
-				while (!($nc2==($numchunks-1) && $i2==((count($para[$nc2][18]['char_data']))-1))) { 	// while not at end of last chunk
+				while (!($nc2==($numchunks-1) && $i2==((count(($para[$nc2][18]['char_data'] ?? [])))-1))) { 	// while not at end of last chunk
 					$i2++;
-					if ($i2 >= count($para[$nc2][18]['char_data'])) { 
+					if ($i2 >= count(($para[$nc2][18]['char_data'] ?? []))) { 
 						$nc2++;
 						$i2 = 0;
 					}
@@ -4982,7 +4994,7 @@
 		$nexttype = -1;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				if (isset($chardata[$i]['sor'])) { $prevtype = $chardata[$i]['sor']; }
@@ -4995,9 +5007,9 @@
 						$nexttype = -1;
 						$nc2 = $nc;
 						$i2 = $i;
-						while (!($nc2==($numchunks-1) && $i2==((count($para[$nc2][18]['char_data']))-1))) { // while not at end of last chunk
+						while (!($nc2==($numchunks-1) && $i2==((count(($para[$nc2][18]['char_data'] ?? [])))-1))) { // while not at end of last chunk
 							$i2++;
-							if ($i2 >= count($para[$nc2][18]['char_data'])) { 
+							if ($i2 >= count(($para[$nc2][18]['char_data'] ?? []))) { 
 								$nc2++;
 								$i2 = 0;
 							}
@@ -5020,7 +5032,7 @@
 	// W6. Otherwise, separators and terminators change to Other Neutral.
 	for ($nc=0;$nc<$numchunks;$nc++) {
 		$chardata =& $para[$nc][18]['char_data'];
-		$numchars = count($chardata);
+		$numchars = count(($chardata ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
 			if (isset($chardata[$i]['type']) && (($chardata[$i]['type'] == UCDN::BIDI_CLASS_ET) || ($chardata[$i]['type'] == UCDN::BIDI_CLASS_ES) || ($chardata[$i]['type'] == UCDN::BIDI_CLASS_CS))) {
 				$chardata[$i]['type'] = UCDN::BIDI_CLASS_ON;
@@ -5033,7 +5045,7 @@
 		$laststrongtype = -1;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				if (isset($chardata[$i]['sor'])) { $laststrongtype = $chardata[$i]['sor']; }
@@ -5052,7 +5064,7 @@
 		$laststrongtype = -1;
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$chardata =& $para[$nc][18]['char_data'];
-			$numchars = count($chardata);
+			$numchars = count(($chardata ?? []));
 			for ($i=0; $i < $numchars; ++$i) {
 				if (!isset($chardata[$i]['diid']) || $chardata[$i]['diid']!=$ir) { continue; }	// Ignore characters in a different isolate run
 				if (isset($chardata[$i]['sor'])) { $laststrongtype = $chardata[$i]['sor']; }
@@ -5076,9 +5088,9 @@
 						$nexttype = -1;
 						$nc2 = $nc;
 						$i2 = $i;
-						while (!($nc2==($numchunks-1) && $i2==((count($para[$nc2][18]['char_data']))-1))) { // while not at end of last chunk
+						while (!($nc2==($numchunks-1) && $i2==((count(($para[$nc2][18]['char_data'] ?? [])))-1))) { // while not at end of last chunk
 							$i2++;
-							if ($i2 >= count($para[$nc2][18]['char_data'])) { 
+							if ($i2 >= count(($para[$nc2][18]['char_data'] ?? []))) { 
 								$nc2++;
 								$i2 = 0;
 							}
@@ -5114,7 +5126,7 @@
 	// N2. Any remaining neutrals take the embedding direction
 	for ($nc=0;$nc<$numchunks;$nc++) {
 		$chardata =& $para[$nc][18]['char_data'];
-		$numchars = count($chardata);
+		$numchars = count(($chardata ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
 			if (isset($chardata[$i]['type']) && ($chardata[$i]['type'] == UCDN::BIDI_CLASS_ON || $chardata[$i]['type'] == UCDN::BIDI_CLASS_WS)) {
 				$chardata[$i]['orig_type'] = $chardata[$i]['type'];	// Need to store the original 'WS' for reference in L1 below
@@ -5127,7 +5139,7 @@
 	// I2. For all characters with an odd (right-to-left) embedding direction, those of type L, EN or AN go up one level.
 	for ($nc=0;$nc<$numchunks;$nc++) {
 		$chardata =& $para[$nc][18]['char_data'];
-		$numchars = count($chardata);
+		$numchars = count(($chardata ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
 			if (isset($chardata[$i]['level'])) { 
 				$odd = $chardata[$i]['level'] % 2;
@@ -5145,18 +5157,18 @@
 	}
 
 	// Remove Isolate formatters
-	$numchunks = count($para);
+	$numchunks = count(($para ?? []));
 	if ($controlchars) {
 		for ($nc=0;$nc<$numchunks;$nc++) {
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x81\xa6");
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x81\xa7");
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x81\xa8");
 			$this->removeChar($para[$nc][0], $para[$nc][18], "\xe2\x81\xa9");
-			preg_replace("/\x{2066}-\x{2069}/u", '', $para[$nc][0]);
+			preg_replace("/\x{2066}-\x{2069}/u", '', ($para[$nc][0] ?? ''));
 		}
 		// Remove any blank chunks made by removing directional codes
 		for ($nc=($numchunks-1);$nc>=0;$nc--) {
-			if (count($para[$nc][18]['char_data'])==0) { array_splice($para, $nc, 1); }
+			if (count(($para[$nc][18]['char_data'] ?? []))==0) { array_splice($para, $nc, 1); }
 		}
 	}
 
@@ -5171,10 +5183,10 @@
 	$bidiData = array();
 
 	// First combine into one array (and get the highest level in use)
-	$numchunks = count($content);
+	$numchunks = count(($content ?? []));
 	$maxlevel = 0;
 	for ($nc=0;$nc<$numchunks;$nc++) {
-		$numchars = count($cOTLdata[$nc]['char_data']);
+		$numchars = count(($cOTLdata[$nc]['char_data'] ?? []));
 		for ($i=0; $i < $numchars; ++$i) {
 
 			$carac = array();
@@ -5183,7 +5195,7 @@
 			if (isset($cOTLdata[$nc]['char_data'][$i]['type'])) $carac['type'] = $cOTLdata[$nc]['char_data'][$i]['type'];
 			if (isset($cOTLdata[$nc]['char_data'][$i]['level'])) $carac['level'] = $cOTLdata[$nc]['char_data'][$i]['level'];
 			if (isset($cOTLdata[$nc]['char_data'][$i]['orig_type'])) { $carac['orig_type'] = $cOTLdata[$nc]['char_data'][$i]['orig_type']; }
-			$carac['group'] = $cOTLdata[$nc]['group']{$i};
+			$carac['group'] = $cOTLdata[$nc]['group'][$i];
 			$carac['chunkid'] = $chunkorder[$nc];	// gives font id and/or object ID
 
 			$maxlevel = max((isset($carac['level']) ? $carac['level'] : 0),$maxlevel);
@@ -5192,7 +5204,7 @@
 	}
 	if ($maxlevel==0) { return; }
 
-	$numchars = count($bidiData);
+	$numchars = count(($bidiData ?? []));
 
 	// L1. On each line, reset the embedding level of the following characters to the paragraph embedding level:
 	//	1. Segment separators (Tab) 'S',
@@ -5291,8 +5303,8 @@
 function splitOTLdata(&$cOTLdata, $OTLcutoffpos, $OTLrestartpos='') {
 	if (!$OTLrestartpos) { $OTLrestartpos = $OTLcutoffpos; }
 	$newOTLdata = array('GPOSinfo' => array(), 'char_data' => array());
-	$newOTLdata['group'] = substr($cOTLdata['group'],$OTLrestartpos);
-	$cOTLdata['group'] = substr($cOTLdata['group'],0,$OTLcutoffpos);
+	$newOTLdata['group'] = substr(($cOTLdata['group'] ?? ''),$OTLrestartpos);
+	$cOTLdata['group'] = substr(($cOTLdata['group'] ?? ''),0,$OTLcutoffpos);
 
 	if (isset($cOTLdata['GPOSinfo']) && $cOTLdata['GPOSinfo']) {
 		foreach($cOTLdata['GPOSinfo'] AS $k => $val) {
@@ -5319,7 +5331,7 @@
 
 function sliceOTLdata($OTLdata, $pos, $len) {
 	$newOTLdata = array('GPOSinfo' => array(), 'char_data' => array());
-	$newOTLdata['group'] = substr($OTLdata['group'],$pos,$len);
+	$newOTLdata['group'] = substr(($OTLdata['group'] ?? ''),$pos,$len);
 
 	if ($OTLdata['GPOSinfo']) {
 		foreach($OTLdata['GPOSinfo'] AS $k => $val) {
@@ -5339,10 +5351,10 @@
 
 // Remove one or more occurrences of $char (single character) from $txt and adjust OTLdata
 function removeChar(&$txt, &$cOTLdata, $char) {
-	while(mb_strpos($txt, $char, 0, $this->mpdf->mb_enc )!== false) {
-		$pos = mb_strpos($txt, $char, 0, $this->mpdf->mb_enc );
+	while(mb_strpos(($txt ?? ''), ($char ?? ''), 0, $this->mpdf->mb_enc )!== false) {
+		$pos = mb_strpos(($txt ?? ''), ($char ?? ''), 0, $this->mpdf->mb_enc );
 		$newGPOSinfo = array();
-		$cOTLdata['group'] = substr_replace($cOTLdata['group'], '', $pos, 1);
+		$cOTLdata['group'] = substr_replace(($cOTLdata['group'] ?? ''), '', $pos, 1);
 		if ($cOTLdata['GPOSinfo']) {
 			foreach($cOTLdata['GPOSinfo'] AS $k => $val) {
 				if ($k > $pos) {
@@ -5356,25 +5368,25 @@
 		}
 		if (isset($cOTLdata['char_data'])) { array_splice($cOTLdata['char_data'], $pos, 1); }
 
-		$txt = preg_replace("/".$char."/",'',$txt, 1);
+		$txt = preg_replace("/".$char."/",'',($txt ?? ''), 1);
 	}
 }
 
 // Remove one or more occurrences of $char (single character) from $txt and adjust OTLdata
 function replaceSpace(&$txt, &$cOTLdata) {
 	$char = chr(194).chr(160);	// NBSP
-	while(mb_strpos($txt, $char, 0, $this->mpdf->mb_enc )!== false) {
-		$pos = mb_strpos($txt, $char, 0, $this->mpdf->mb_enc );
+	while(mb_strpos(($txt ?? ''), ($char ?? ''), 0, $this->mpdf->mb_enc )!== false) {
+		$pos = mb_strpos(($txt ?? ''), ($char ?? ''), 0, $this->mpdf->mb_enc );
 		if ($cOTLdata['char_data'][$pos]['uni'] == 160) {
 			$cOTLdata['char_data'][$pos]['uni'] = 32;
 		}
-		$txt = preg_replace("/".$char."/",' ',$txt, 1);
+		$txt = preg_replace("/".$char."/",' ',($txt ?? ''), 1);
 	}
 }
 
 function trimOTLdata(&$cOTLdata, $Left=true, $Right=true) {
 
-	$len = count($cOTLdata['char_data']);
+	$len = count(($cOTLdata['char_data'] ?? []));
 	$nLeft = 0;
 	$nRight = 0;
 	for($i=0;$i<$len;$i++) {
@@ -5388,7 +5400,7 @@
 
 	// Trim Right
 	if ($Right && $nRight) {
-		$cOTLdata['group'] = substr($cOTLdata['group'],0,strlen($cOTLdata['group'])-$nRight);
+		$cOTLdata['group'] = substr(($cOTLdata['group'] ?? ''),0,strlen(($cOTLdata['group'] ?? ''))-$nRight);
 		if ($cOTLdata['GPOSinfo']) {
 			foreach($cOTLdata['GPOSinfo'] AS $k => $val) {
 				if ($k >= $len-$nRight) {
@@ -5404,7 +5416,7 @@
 	}
 	// Trim Left
 	if ($Left && $nLeft) {
-		$cOTLdata['group'] = substr($cOTLdata['group'],$nLeft);
+		$cOTLdata['group'] = substr(($cOTLdata['group'] ?? ''),$nLeft);
 		if ($cOTLdata['GPOSinfo']) {
 			$newPOSinfo = array();
 			foreach($cOTLdata['GPOSinfo'] AS $k => $val) {
@@ -5431,11 +5443,11 @@
 
 
 	function glyphToChar($gid) {
-		return (ord($this->glyphIDtoUni[$gid*3]) << 16) + (ord($this->glyphIDtoUni[$gid*3+1]) << 8) + ord($this->glyphIDtoUni[$gid*3+2]);
+		return (ord(($this->glyphIDtoUni[$gid*3] ?? '')) << 16) + (ord(($this->glyphIDtoUni[$gid*3+1] ?? '')) << 8) + ord(($this->glyphIDtoUni[$gid*3+2] ?? ''));
 	}
 
 	function unicode_hex($unicode_dec) {
-		return (str_pad(strtoupper(dechex($unicode_dec)),5,'0',STR_PAD_LEFT));
+		return (str_pad((strtoupper((dechex($unicode_dec) ?? '')) ?? ''),5,'0',STR_PAD_LEFT));
 	}
 
 	function seek($pos) {
@@ -5446,7 +5458,7 @@
 		$this->_pos += $delta;
 	}
 	function read_short() {
-		$a = (ord($this->ttfOTLdata[$this->_pos])<<8) + ord($this->ttfOTLdata[$this->_pos+1]);
+		$a = (ord(($this->ttfOTLdata[$this->_pos] ?? ''))<<8) + ord(($this->ttfOTLdata[$this->_pos+1] ?? ''));
 		if ($a & (1 << 15) ) { 
 			$a = ($a - (1 << 16)); 
 		}
@@ -5455,7 +5467,7 @@
 	}
 
 	function read_ushort() {
-		$a = (ord($this->ttfOTLdata[$this->_pos])<<8) + ord($this->ttfOTLdata[$this->_pos+1]);
+		$a = (ord(($this->ttfOTLdata[$this->_pos] ?? ''))<<8) + ord(($this->ttfOTLdata[$this->_pos+1] ?? ''));
 		$this->_pos += 2;
 		return $a;
 	}
@@ -5657,23 +5669,23 @@
 	// http://www.microsoft.com/typography/otspec/languagetags.htm
 	// IETF tag = e.g. en-US, und-Arab, sr-Cyrl cf. config_lang2fonts.php
 	if ($available=='') { return ''; }
-	$tags = preg_split('/-/',$ietf);
+	$tags = preg_split('/-/',($ietf ?? ''));
 	$lang = '';
 	$country = '';
 	$script = '';
-	$lang = strtolower($tags[0]);
+	$lang = strtolower(($tags[0] ?? ''));
 	if (isset($tags[1]) && $tags[1]) { 
-		if (strlen($tags[1]) == 2) { $country = strtolower($tags[1]); }
-	}
-	if (isset($tags[2]) && $tags[2]) { $country = strtolower($tags[2]); }
+		if (strlen(($tags[1] ?? '')) == 2) { $country = strtolower(($tags[1] ?? '')); }
+	}
+	if (isset($tags[2]) && $tags[2]) { $country = strtolower(($tags[2] ?? '')); }
 
 	if ($lang!='' && isset(UCDN::$ot_languages[$lang])) { $langsys = UCDN::$ot_languages[$lang]; }
 	else if ($lang!='' && $country !='' && isset(UCDN::$ot_languages[$lang.''.$country])) { 
 		$langsys = UCDN::$ot_languages[$lang.''.$country]; 
 	}
 	else { $langsys = "DFLT"; }
-	if (strpos($available, $langsys)===false) { 
-		if (strpos($available, "DFLT")!==false) { return "DFLT"; }
+	if (strpos(($available ?? ''), ($langsys ?? ''))===false) { 
+		if (strpos(($available ?? ''), "DFLT")!==false) { return "DFLT"; }
 		else return ''; 
 	}
 	return $langsys;
@@ -5685,22 +5697,22 @@
 	echo '<div style="font-family:monospace">';
 	echo 'Glyph position: '.$ptr.' Current Glyph: '.$currGlyph.'<br />';
 
-	for ($i=0;$i<count($this->OTLdata);$i++) {
+	for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 		if ($i==$ptr) { echo '<b>'; }
 		echo $this->OTLdata[$i]['hex'] . ' ';
 		if ($i==$ptr) { echo '</b>'; }
 	}
 	echo '<br />';
 
-	for ($i=0;$i<count($this->OTLdata);$i++) {
+	for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 		if ($i==$ptr) { echo '<b>'; }
-		echo str_pad($this->OTLdata[$i]['uni'],5) . ' ';
+		echo str_pad(($this->OTLdata[$i]['uni'] ?? ''),5) . ' ';
 		if ($i==$ptr) { echo '</b>'; }
 	}
 	echo '<br />';
 
 	if ($GPOSSUB == 'GPOS') {
-		for ($i=0;$i<count($this->OTLdata);$i++) {
+		for ($i=0;$i<count(($this->OTLdata ?? []));$i++) {
 			if (!empty($this->OTLdata[$i]['GPOSinfo'])) {
 				echo $this->OTLdata[$i]['hex'] . ' &#x'.$this->OTLdata[$i]['hex'].'; ';
 				print_r($this->OTLdata[$i]['GPOSinfo']);
--- a/intranet/mpdf60/classes/sea.php
+++ b/intranet/mpdf60/classes/sea.php
@@ -134,19 +134,19 @@
 	$ptr = 0;
 	$syllable_serial = 1;
 	$broken_syllables = false;
-	while($ptr < strlen($s)) {
+	while($ptr < strlen(($s ?? ''))) {
 		$match = '';
 		$syllable_length = 1;
 		$syllable_type = self::NON_SEA_CLUSTER ;
 
 		// CONSONANT_SYLLABLE Consonant syllable
-		if (preg_match('/^(C|V|G)(p|a|b|t|HC|M|R|T|A)*/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		if (preg_match('/^(C|V|G)(p|a|b|t|HC|M|R|T|A)*/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::CONSONANT_SYLLABLE ;
 		}
 		// BROKEN_CLUSTER syllable
-		else if (preg_match('/^(p|a|b|t|HC|M|R|T|A)+/', substr($s,$ptr), $ma)) {
-			$syllable_length = strlen($ma[0]);
+		else if (preg_match('/^(p|a|b|t|HC|M|R|T|A)+/', (substr(($s ?? ''),$ptr) ?? ''), $ma)) {
+			$syllable_length = strlen(($ma[0] ?? ''));
 			$syllable_type = self::BROKEN_CLUSTER ;
 			$broken_syllables = true;
 		}
@@ -162,7 +162,7 @@
 
 	if ($broken_syllables && $dottedcircle) { self::insert_dotted_circles ($info, $dottedcircle); }
 
-	$count = count($info);
+	$count = count(($info ?? []));
 	if (!$count) return;
 	$last = 0;
 	$last_syllable = $info[0]['syllable'];
@@ -179,7 +179,7 @@
 public static function insert_dotted_circles(&$info, $dottedcircle) {
 	$idx = 0;
 	$last_syllable = 0;
-	while ($idx < count($info)) {
+	while ($idx < count(($info ?? []))) {
 		$syllable = $info[$idx]['syllable'];
 		$syllable_type = ($syllable & 0x0F);
 		if ($last_syllable != $syllable && $syllable_type == self::BROKEN_CLUSTER) {
@@ -234,7 +234,7 @@
 }
 
 public static function final_reordering (&$info, $GSUBdata, $scriptblock) {
-	$count = count($info);
+	$count = count(($info ?? []));
 	if (!$count) return;
 	$last = 0;
 	$last_syllable = $info[0]['syllable'];
--- a/intranet/mpdf60/classes/wmf.php
+++ b/intranet/mpdf60/classes/wmf.php
@@ -5,7 +5,7 @@
 var $mpdf = null;
 var $gdiObjectArray;
 
-function wmf(&$mpdf) {
+function __construct(&$mpdf) {
 	$this->mpdf = $mpdf;
 }
 
@@ -18,7 +18,7 @@
 		if ($a['test']!=1)
 		return array(0, 'Error parsing WMF image - Big-endian architecture not supported'); 
 		// check for Aldus placeable metafile header
-		$key = unpack('Lmagic', substr($data, 0, 4));
+		$key = unpack('Lmagic', substr(($data ?? ''), 0, 4));
 		$p = 18;  // WMF header 
 		if ($key['magic'] == (int)0x9AC6CDD7) { $p +=22; } // Aldus header
 		// define some state variables
@@ -29,14 +29,14 @@
 		$nullBrush = false;
 		$endRecord = false;
 		$wmfdata = '';
-		while ($p < strlen($data) && !$endRecord) {
-			$recordInfo = unpack('Lsize/Sfunc', substr($data, $p, 6));	$p += 6;
+		while ($p < strlen(($data ?? '')) && !$endRecord) {
+			$recordInfo = unpack('Lsize/Sfunc', substr(($data ?? ''), $p, 6));	$p += 6;
 			// size of record given in WORDs (= 2 bytes)
 			$size = $recordInfo['size'];
 			// func is number of GDI function
 			$func = $recordInfo['func'];
 			if ($size > 3) {
-				$parms = substr($data, $p, 2*($size-3));	$p += 2*($size-3);
+				$parms = substr(($data ?? ''), $p, 2*($size-3));	$p += 2*($size-3);
 			}
 			switch ($func) {
 				case 0x020b:  // SetWindowOrg
@@ -126,9 +126,9 @@
 							}
 							if (!empty($dashArray)) {
 								$s = '[';
-								for ($i=0; $i<count($dashArray);$i++) {
+								for ($i=0; $i<count(($dashArray ?? []));$i++) {
 									$s .= $dashArray[$i] * $k;
-									if ($i != count($dashArray)-1) { $s .= ' '; }
+									if ($i != count(($dashArray ?? []))-1) { $s .= ' '; }
 								}
 								$s .= '] 0 d';
 								$wmfdata .= $s."\n";
--- a/intranet/mpdf60/utils/font_coverage.php
+++ b/intranet/mpdf60/utils/font_coverage.php
@@ -35,8 +35,8 @@
 
 
 
-$mqr=ini_get("magic_quotes_runtime");
-if ($mqr) { set_magic_quotes_runtime(0); }
+$mqr='0';
+if ($mqr) { false; }
 if (!class_exists('TTFontFile_Analysis', false)) { include(_MPDF_PATH .'classes/ttfontsuni_analysis.php'); }
 
 //==============================================================
--- a/intranet/mpdf60/utils/font_names.php
+++ b/intranet/mpdf60/utils/font_names.php
@@ -31,8 +31,8 @@
 }
 else { $ttfdir = _MPDF_TTFONTPATH; }
 
-$mqr=ini_get("magic_quotes_runtime");
-if ($mqr) { set_magic_quotes_runtime(0); }
+$mqr='0';
+if ($mqr) { false; }
 if (!class_exists('TTFontFile_Analysis', false)) { include(_MPDF_PATH .'classes/ttfontsuni_analysis.php'); }
 $ttf = new TTFontFile_Analysis();
 
--- a/intranet/mpdf60/utils/image_details.php
+++ b/intranet/mpdf60/utils/image_details.php
@@ -15,13 +15,13 @@
  		if ($orig_srcpath && $fileIsLocal && $check = @fopen($orig_srcpath,"rb")) {
 			fclose($check); 
 			$file=$orig_srcpath;
-			$data = file_get_contents($file);
+			$data = file_get_contents(($file ?? ''));
 			$type = _imageTypeFromString($data);
 			echo 'File accessed using fopen on $orig_srcpath' . '<br />';
 		}
 		if (!$data && $check = @fopen($file,"rb")) {
 			fclose($check); 
-			$data = file_get_contents($file);
+			$data = file_get_contents(($file ?? ''));
 			$type = _imageTypeFromString($data);
 			echo 'File accessed using fopen on $file' . '<br />';
 		}
@@ -40,7 +40,7 @@
 
 	if (!$data) { echo 'Could not access image file' . '<br />'; exit; }
 
-	echo 'Image type determined: ' .strtoupper($type) . '<br />';
+	echo 'Image type determined: ' .strtoupper(($type ?? '')) . '<br />';
 
 	// JPEG
 	if ($type == 'jpeg' || $type == 'jpg') {
@@ -54,12 +54,12 @@
 		echo 'BPC (bits per channel): ' . $a[3]. '<br />';
 		echo 'Channels: ' . $channels. '<br />';
 
-		$j = strpos($data,'JFIF');
+		$j = strpos(($data ?? ''),'JFIF');
 		if ($j) { 
 			//Read resolution
-			$unitSp=ord(substr($data,($j+7),1));
+			$unitSp=ord((substr(($data ?? ''),($j+7),1) ?? ''));
 			if ($unitSp > 0) {
-				$ppUx=_twobytes2int(substr($data,($j+8),2));	// horizontal pixels per meter, usually set to zero
+				$ppUx=_twobytes2int(substr(($data ?? ''),($j+8),2));	// horizontal pixels per meter, usually set to zero
 				if ($unitSp == 2) {	// = dots per cm (if == 1 set as dpi)
 					$ppUx=round($ppUx/10 *25.4);
 				}
@@ -72,25 +72,25 @@
 			// mPDF 6 ICC profile
 			$offset = 0;
 			$icc = array();
-			while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
+			while (($pos = strpos(($data ?? ''), "ICC_PROFILE\0", $offset)) !== false) {
 				// get ICC sequence length
-				$length = _twobytes2int(substr($data, ($pos - 2),2)) - 16;
-				$sn = max(1, ord($data[($pos + 12)]));
-				$nom = max(1, ord($data[($pos + 13)]));
-				$icc[($sn - 1)] = substr($data, ($pos + 14), $length);
+				$length = _twobytes2int(substr(($data ?? ''), ($pos - 2),2)) - 16;
+				$sn = max(1, ord(($data[($pos + 12)] ?? '')));
+				$nom = max(1, ord(($data[($pos + 13)] ?? '')));
+				$icc[($sn - 1)] = substr(($data ?? ''), ($pos + 14), $length);
 				$offset = ($pos + 14 + $length);
 			}
 			// order and compact ICC segments
-			if (count($icc) > 0) {
+			if (count(($icc ?? [])) > 0) {
 				echo 'ICC profile present' . '<br />';
 				ksort($icc);
 				$icc = implode('', $icc);
-				if (substr($icc, 36, 4) != 'acsp') {
+				if (substr(($icc ?? ''), 36, 4) != 'acsp') {
 					// invalid ICC profile
 					echo 'ICC profile INVALID (no acsp flag)' . '<br />';
 				}
-				$input = substr($icc, 16, 4); 
-				$output = substr($icc, 20, 4);
+				$input = substr(($icc ?? ''), 16, 4); 
+				$output = substr(($icc ?? ''), 20, 4);
 				echo 'ICC profile Input: ' . $input. '<br />';
 				echo 'ICC profile Output: ' . $output. '<br />';
 				// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
@@ -102,17 +102,17 @@
 	// PNG
 	else if ($type == 'png') {
 		//Check signature
-		if(substr($data,0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
+		if(substr(($data ?? ''),0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
 			echo 'Error parsing PNG identifier<br />';  exit;
 		}
 		//Read header chunk
-		if(substr($data,12,4)!='IHDR') { 
+		if(substr(($data ?? ''),12,4)!='IHDR') { 
 			echo 'Incorrect PNG file (no IHDR block found)<br />'; exit; 
 		}
 
-		$w=_fourbytes2int(substr($data,16,4));
-		$h=_fourbytes2int(substr($data,20,4));
-		$bpc=ord(substr($data,24,1));
+		$w=_fourbytes2int(substr(($data ?? ''),16,4));
+		$h=_fourbytes2int(substr(($data ?? ''),20,4));
+		$bpc=ord((substr(($data ?? ''),24,1) ?? ''));
 		$errpng = false;
 		$pngalpha = false;
 		$channels = 0;
@@ -121,7 +121,7 @@
 		echo 'Height: ' .$h . '<br />';
 		echo 'BPC (bits per channel): ' .$bpc . '<br />';
 
-		$ct=ord(substr($data,25,1));
+		$ct=ord((substr(($data ?? ''),25,1) ?? ''));
 		if($ct==0) { $colspace='DeviceGray'; $channels = 1; }
 		elseif($ct==2) { $colspace='DeviceRGB'; $channels = 3; }
 		elseif($ct==3) { $colspace='Indexed'; $channels = 1; }
@@ -132,20 +132,20 @@
 		echo 'Channels: ' . $channels. '<br />';
 		if ($pngalpha) echo 'Alpha channel detected'. '<br />';
 
-		if ($ct < 4 && strpos($data,'tRNS')!==false) {	echo 'Transparency detected'. '<br />'; $errpng = 'transparency'; $pngalpha = true;}
-
-		if ($ct == 3 && strpos($data,'iCCP')!==false) {	echo 'Indexed plus ICC'. '<br />'; $errpng = 'indexed plus ICC'; }
-
-		if(ord(substr($data,26,1))!=0) { echo 'compression method not set to zero<br />'; $errpng = 'compression method'; }	// only 0 should be specified
-		if(ord(substr($data,27,1))!=0) { echo 'filter method not set to zero<br />'; $errpng = 'filter method'; }		// only 0 should be specified
-		if(ord(substr($data,28,1))!=0) { echo 'interlaced file not set to zero<br />'; $errpng = 'interlaced file'; }
-
-		$j = strpos($data,'pHYs');
+		if ($ct < 4 && strpos(($data ?? ''),'tRNS')!==false) {	echo 'Transparency detected'. '<br />'; $errpng = 'transparency'; $pngalpha = true;}
+
+		if ($ct == 3 && strpos(($data ?? ''),'iCCP')!==false) {	echo 'Indexed plus ICC'. '<br />'; $errpng = 'indexed plus ICC'; }
+
+		if(ord((substr(($data ?? ''),26,1) ?? ''))!=0) { echo 'compression method not set to zero<br />'; $errpng = 'compression method'; }	// only 0 should be specified
+		if(ord((substr(($data ?? ''),27,1) ?? ''))!=0) { echo 'filter method not set to zero<br />'; $errpng = 'filter method'; }		// only 0 should be specified
+		if(ord((substr(($data ?? ''),28,1) ?? ''))!=0) { echo 'interlaced file not set to zero<br />'; $errpng = 'interlaced file'; }
+
+		$j = strpos(($data ?? ''),'pHYs');
 		if ($j) { 
 			//Read resolution
-			$unitSp=ord(substr($data,($j+12),1));
+			$unitSp=ord((substr(($data ?? ''),($j+12),1) ?? ''));
 			if ($unitSp == 1) {
-				$ppUx=_fourbytes2int(substr($data,($j+4),4));	// horizontal pixels per meter, usually set to zero
+				$ppUx=_fourbytes2int(substr(($data ?? ''),($j+4),4));	// horizontal pixels per meter, usually set to zero
 				$ppUx=round($ppUx/1000 *25.4);
 			}
 			echo 'Resolution ppUx: ' . $ppUx. '<br />';
@@ -154,9 +154,9 @@
 		// mPDF 6 Gamma correction
 		$gamma_correction = 0; 
 		$gAMA = 0;
-		$j = strpos($data,'gAMA');
-		if ($j && strpos($data,'sRGB')===false) {	// sRGB colorspace - overrides gAMA
-			$gAMA=_fourbytes2int(substr($data,($j+4),4));	// Gamma value times 100000
+		$j = strpos(($data ?? ''),'gAMA');
+		if ($j && strpos(($data ?? ''),'sRGB')===false) {	// sRGB colorspace - overrides gAMA
+			$gAMA=_fourbytes2int(substr(($data ?? ''),($j+4),4));	// Gamma value times 100000
 			$gAMA /= 100000;
 
 		}
@@ -169,8 +169,8 @@
 		if ($gamma_correction) { echo 'Gamma correction detected'. '<br />';  }
 
 		// NOT supported at present
-		if (strpos($data,'sRGB')!==false)	echo 'sRGB colorspace - NOT supported at present'. '<br />';
-		if (strpos($data,'cHRM')!==false)	echo 'Chromaticity and Whitepoint - NOT supported at present'. '<br />';
+		if (strpos(($data ?? ''),'sRGB')!==false)	echo 'sRGB colorspace - NOT supported at present'. '<br />';
+		if (strpos(($data ?? ''),'cHRM')!==false)	echo 'Chromaticity and Whitepoint - NOT supported at present'. '<br />';
 
 		if (($errpng || $pngalpha || $gamma_correction)) {
 			if (function_exists('gd_info')) { $gd = gd_info(); }
@@ -197,22 +197,22 @@
 
 				// ICC profile
 				$icc = false;
-				$p = strpos($data,'iCCP');
+				$p = strpos(($data ?? ''),'iCCP');
 				if ($p && $colspace=="Indexed") { 
 					$p += 4;
-					$n=_fourbytes2int(substr($data,($p-8),4));
-					$nullsep = strpos(substr($data,$p,80), chr(0));
-					$icc = substr($data, ($p+$nullsep+2), ($n-($nullsep+2)) );
+					$n=_fourbytes2int(substr(($data ?? ''),($p-8),4));
+					$nullsep = strpos((substr(($data ?? ''),$p,80) ?? ''), (chr(0) ?? ''));
+					$icc = substr(($data ?? ''), ($p+$nullsep+2), ($n-($nullsep+2)) );
 					// Test if file is gzcompressed
-					if (ord(substr($str, 0, 1)) == 0x1f && ord(substr($str, 1, 1)) == 0x8b) {
+					if (ord((substr(($str ?? ''), 0, 1) ?? '')) == 0x1f && ord((substr(($str ?? ''), 1, 1) ?? '')) == 0x8b) {
 						$icc = @gzuncompress($icc);	// Ignored if fails
 					}
 					if ($icc) {
 						echo 'ICC profile present' . '<br />';
-						if (substr($icc, 36, 4) != 'acsp') { echo 'ICC profile INVALID (no acsp flag)' . '<br />'; $icc = false; }	// invalid ICC profile
+						if (substr(($icc ?? ''), 36, 4) != 'acsp') { echo 'ICC profile INVALID (no acsp flag)' . '<br />'; $icc = false; }	// invalid ICC profile
 						else {
-							$input = substr($icc, 16, 4); 
-							$output = substr($icc, 20, 4);
+							$input = substr(($icc ?? ''), 16, 4); 
+							$output = substr(($icc ?? ''), 20, 4);
 							echo 'ICC profile Input: ' . $input. '<br />';
 							echo 'ICC profile Output: ' . $output. '<br />';
 							// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
@@ -242,17 +242,17 @@
 
 
 			//Check signature
-			if(substr($data,0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
+			if(substr(($data ?? ''),0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
 				echo 'Error parsing PNG identifier<br />';  exit;
 			}
 			//Read header chunk
-			if(substr($data,12,4)!='IHDR') { 
+			if(substr(($data ?? ''),12,4)!='IHDR') { 
 				echo 'Incorrect PNG file (no IHDR block found)<br />'; exit; 
 			}
 
-			$w=_fourbytes2int(substr($data,16,4));
-			$h=_fourbytes2int(substr($data,20,4));
-			$bpc=ord(substr($data,24,1));
+			$w=_fourbytes2int(substr(($data ?? ''),16,4));
+			$h=_fourbytes2int(substr(($data ?? ''),20,4));
+			$bpc=ord((substr(($data ?? ''),24,1) ?? ''));
 			$errpng = false;
 			$pngalpha = false;
 			$channels = 0;
@@ -261,7 +261,7 @@
 			echo 'Height: ' .$h . '<br />';
 			echo 'BPC (bits per channel): ' .$bpc . '<br />';
 
-			$ct=ord(substr($data,25,1));
+			$ct=ord((substr(($data ?? ''),25,1) ?? ''));
 			if($ct==0) { $colspace='DeviceGray'; $channels = 1; }
 			elseif($ct==2) { $colspace='DeviceRGB'; $channels = 3; }
 			elseif($ct==3) { $colspace='Indexed'; $channels = 1; }
@@ -272,20 +272,20 @@
 			echo 'Channels: ' . $channels. '<br />';
 			if ($pngalpha) echo 'Alpha channel detected'. '<br />';
 
-			if ($ct < 4 && strpos($data,'tRNS')!==false) {	echo 'Transparency detected'. '<br />'; $errpng = 'transparency'; $pngalpha = true;}
-
-			if ($ct == 3 && strpos($data,'iCCP')!==false) {	echo 'Indexed plus ICC'. '<br />'; $errpng = 'indexed plus ICC'; }
-
-			if(ord(substr($data,26,1))!=0) { echo 'compression method not set to zero<br />'; $errpng = 'compression method'; }	// only 0 should be specified
-			if(ord(substr($data,27,1))!=0) { echo 'filter method not set to zero<br />'; $errpng = 'filter method'; }		// only 0 should be specified
-			if(ord(substr($data,28,1))!=0) { echo 'interlaced file not set to zero<br />'; $errpng = 'interlaced file'; }
-
-			$j = strpos($data,'pHYs');
+			if ($ct < 4 && strpos(($data ?? ''),'tRNS')!==false) {	echo 'Transparency detected'. '<br />'; $errpng = 'transparency'; $pngalpha = true;}
+
+			if ($ct == 3 && strpos(($data ?? ''),'iCCP')!==false) {	echo 'Indexed plus ICC'. '<br />'; $errpng = 'indexed plus ICC'; }
+
+			if(ord((substr(($data ?? ''),26,1) ?? ''))!=0) { echo 'compression method not set to zero<br />'; $errpng = 'compression method'; }	// only 0 should be specified
+			if(ord((substr(($data ?? ''),27,1) ?? ''))!=0) { echo 'filter method not set to zero<br />'; $errpng = 'filter method'; }		// only 0 should be specified
+			if(ord((substr(($data ?? ''),28,1) ?? ''))!=0) { echo 'interlaced file not set to zero<br />'; $errpng = 'interlaced file'; }
+
+			$j = strpos(($data ?? ''),'pHYs');
 			if ($j) { 
 				//Read resolution
-				$unitSp=ord(substr($data,($j+12),1));
+				$unitSp=ord((substr(($data ?? ''),($j+12),1) ?? ''));
 				if ($unitSp == 1) {
-					$ppUx=_fourbytes2int(substr($data,($j+4),4));	// horizontal pixels per meter, usually set to zero
+					$ppUx=_fourbytes2int(substr(($data ?? ''),($j+4),4));	// horizontal pixels per meter, usually set to zero
 					$ppUx=round($ppUx/1000 *25.4);
 				}
 				echo 'Resolution ppUx: ' . $ppUx. '<br />';
@@ -294,9 +294,9 @@
 			//Gamma correction
 			$gamma_correction = 0; 
 			$gAMA = 0;
-			$j = strpos($data,'gAMA');
-			if ($j && strpos($data,'sRGB')===false) {	// sRGB colorspace - overrides gAMA
-				$gAMA=_fourbytes2int(substr($data,($j+4),4));	// Gamma value times 100000
+			$j = strpos(($data ?? ''),'gAMA');
+			if ($j && strpos(($data ?? ''),'sRGB')===false) {	// sRGB colorspace - overrides gAMA
+				$gAMA=_fourbytes2int(substr(($data ?? ''),($j+4),4));	// Gamma value times 100000
 				$gAMA /= 100000;
 
 			}
@@ -309,8 +309,8 @@
 			if ($gamma_correction) { echo 'Gamma correction detected'. '<br />';  }
 
 			// NOT supported at present
-			if (strpos($data,'sRGB')!==false)	echo 'sRGB colorspace - NOT supported at present'. '<br />';
-			if (strpos($data,'cHRM')!==false)	echo 'Chromaticity and Whitepoint - NOT supported at present'. '<br />';
+			if (strpos(($data ?? ''),'sRGB')!==false)	echo 'sRGB colorspace - NOT supported at present'. '<br />';
+			if (strpos(($data ?? ''),'cHRM')!==false)	echo 'Chromaticity and Whitepoint - NOT supported at present'. '<br />';
 
 		}
 
@@ -322,41 +322,41 @@
 			$icc = false;
 			$p = 33;
 			do {
-				$n=_fourbytes2int(substr($data,$p,4));	$p += 4;
-				$type=substr($data,$p,4);	$p += 4;
+				$n=_fourbytes2int(substr(($data ?? ''),$p,4));	$p += 4;
+				$type=substr(($data ?? ''),$p,4);	$p += 4;
 				if ($type=='PLTE') {
 					//Read palette
-					$pal=substr($data,$p,$n);	$p += $n;
+					$pal=substr(($data ?? ''),$p,$n);	$p += $n;
 					$p += 4;
 				}
 				else if($type=='tRNS') {
 					//Read transparency info
-					$t=substr($data,$p,$n);	$p += $n;
-					if ($ct==0) $trns=array(ord(substr($t,1,1)));
-					else if ($ct==2) $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
+					$t=substr(($data ?? ''),$p,$n);	$p += $n;
+					if ($ct==0) $trns=array(ord((substr(($t ?? ''),1,1) ?? '')));
+					else if ($ct==2) $trns=array(ord((substr(($t ?? ''),1,1) ?? '')),ord((substr(($t ?? ''),3,1) ?? '')),ord((substr(($t ?? ''),5,1) ?? '')));
 					else {
-						$pos=strpos($t,chr(0));
+						$pos=strpos(($t ?? ''),(chr(0) ?? ''));
 						if(is_int($pos)) $trns=array($pos);
 					}
 					$p += 4;
 				}
 				else if ($type=='IDAT') {
-					$pngdata.=substr($data,$p,$n);	$p += $n;
+					$pngdata.=substr(($data ?? ''),$p,$n);	$p += $n;
 					$p += 4;
 				}
 				else if ($type=='iCCP') {
-					$nullsep = strpos(substr($data,$p,80), chr(0));
-					$icc = substr($data, ($p+$nullsep+2), ($n-($nullsep+2)) );
+					$nullsep = strpos((substr(($data ?? ''),$p,80) ?? ''), (chr(0) ?? ''));
+					$icc = substr(($data ?? ''), ($p+$nullsep+2), ($n-($nullsep+2)) );
 					// Test if file is gzcompressed
-					if (ord(substr($str, 0, 1)) == 0x1f && ord(substr($str, 1, 1)) == 0x8b) {
+					if (ord((substr(($str ?? ''), 0, 1) ?? '')) == 0x1f && ord((substr(($str ?? ''), 1, 1) ?? '')) == 0x8b) {
 						$icc = @gzuncompress($icc);	// Ignored if fails
 					}
 					if ($icc) {
 					echo 'ICC profile present' . '<br />';
-						if (substr($icc, 36, 4) != 'acsp') { echo 'ICC profile INVALID (no acsp flag)' . '<br />'; $icc = false; }	// invalid ICC profile
+						if (substr(($icc ?? ''), 36, 4) != 'acsp') { echo 'ICC profile INVALID (no acsp flag)' . '<br />'; $icc = false; }	// invalid ICC profile
 						else {
-							$input = substr($icc, 16, 4); 
-							$output = substr($icc, 20, 4);
+							$input = substr(($icc ?? ''), 16, 4); 
+							$output = substr(($icc ?? ''), 20, 4);
 							echo 'ICC profile Input: ' . $input. '<br />';
 							echo 'ICC profile Output: ' . $output. '<br />';
 							// Ignore Color profiles for conversion to other colorspaces e.g. CMYK/Lab
@@ -369,7 +369,7 @@
 
 
 				else if($type=='IEND') { break; }
-				else if (preg_match('/[a-zA-Z]{4}/',$type)) { $p += $n+4; }
+				else if (preg_match('/[a-zA-Z]{4}/',($type ?? ''))) { $p += $n+4; }
 				else { echo 'Error parsing PNG image data<br />'; }
 			}
 			while($n);
@@ -410,33 +410,33 @@
 
 function _fourbytes2int($s) {
 	//Read a 4-byte integer from string
-	return (ord($s[0])<<24) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]);
+	return (ord(($s[0] ?? ''))<<24) + (ord(($s[1] ?? ''))<<16) + (ord(($s[2] ?? ''))<<8) + ord(($s[3] ?? ''));
 }
 
 function _twobytes2int($s) {	// equivalent to _get_ushort
 	//Read a 2-byte integer from string
-	return (ord(substr($s, 0, 1))<<8) + ord(substr($s, 1, 1));
+	return (ord((substr(($s ?? ''), 0, 1) ?? ''))<<8) + ord((substr(($s ?? ''), 1, 1) ?? ''));
 }
 
 function _jpgHeaderFromString(&$data) {
 	$p = 4;
-	$p += _twobytes2int(substr($data, $p, 2));	// Length of initial marker block
-	$marker = substr($data, $p, 2);
-	while($marker != chr(255).chr(192) && $marker != chr(255).chr(194) && $p<strlen($data)) {
+	$p += _twobytes2int(substr(($data ?? ''), $p, 2));	// Length of initial marker block
+	$marker = substr(($data ?? ''), $p, 2);
+	while($marker != chr(255).chr(192) && $marker != chr(255).chr(194) && $p<strlen(($data ?? ''))) {
 		// Start of frame marker (FFC0) or (FFC2) mPDF 4.4.004
-		$p += (_twobytes2int(substr($data, $p+2, 2))) + 2;	// Length of marker block
-		$marker = substr($data, $p, 2);
+		$p += (_twobytes2int(substr(($data ?? ''), $p+2, 2))) + 2;	// Length of marker block
+		$marker = substr(($data ?? ''), $p, 2);
 	}
 	if ($marker != chr(255).chr(192) && $marker != chr(255).chr(194)) { return false; }
-	return substr($data, $p+2, 10);
+	return substr(($data ?? ''), $p+2, 10);
 }
 
 function _jpgDataFromHeader($hdr) {
-	$bpc = ord(substr($hdr, 2, 1));
+	$bpc = ord((substr(($hdr ?? ''), 2, 1) ?? ''));
 	if (!$bpc) { $bpc = 8; }
-	$h = _twobytes2int(substr($hdr, 3, 2));
-	$w = _twobytes2int(substr($hdr, 5, 2));
-	$channels = ord(substr($hdr, 7, 1));
+	$h = _twobytes2int(substr(($hdr ?? ''), 3, 2));
+	$w = _twobytes2int(substr(($hdr ?? ''), 5, 2));
+	$channels = ord((substr(($hdr ?? ''), 7, 1) ?? ''));
 	if ($channels==3) { $colspace='DeviceRGB'; }
 	elseif($channels==4) { $colspace='DeviceCMYK'; }
 	else { $colspace='DeviceGray'; }
@@ -495,25 +495,25 @@
 
 function _imageTypeFromString(&$data) {
 	$type = '';
-	if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif' || substr($data, 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8
+	if (substr(($data ?? ''), 6, 4)== 'JFIF' || substr(($data ?? ''), 6, 4)== 'Exif' || substr(($data ?? ''), 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8
 		$type = 'jpeg'; 
 	}
-	else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") { 
+	else if (substr(($data ?? ''), 0, 6)== "GIF87a" || substr(($data ?? ''), 0, 6)== "GIF89a") { 
 		$type = 'gif';
 	}
-	else if (substr($data, 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
+	else if (substr(($data ?? ''), 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
 		$type = 'png';
 	}
 /*-- IMAGES-WMF --*/
-	else if (substr($data, 0, 4)== chr(215).chr(205).chr(198).chr(154)) { 
+	else if (substr(($data ?? ''), 0, 4)== chr(215).chr(205).chr(198).chr(154)) { 
 		$type = 'wmf';
 	}
 /*-- END IMAGES-WMF --*/
-	else if (preg_match('/<svg.*<\/svg>/is',$data)) { 
+	else if (preg_match('/<svg.*<\/svg>/is',($data ?? ''))) { 
 		$type = 'svg';
 	}
 	// BMP images
-	else if (substr($data, 0, 2)== "BM") { 
+	else if (substr(($data ?? ''), 0, 2)== "BM") { 
 		$type = 'bmp';
 	}
 	return $type;
--- a/intranet/mpdf60/utils/font_dump.php
+++ b/intranet/mpdf60/utils/font_dump.php
@@ -47,7 +47,7 @@
 
 // This generates a .mtx.php file if not already generated
 $mpdf->WriteHTML('<style>td { border: 0.1mm solid #555555; } body { font-weight: normal; }</style>');
-$mpdf->WriteHTML('<h3 style="font-family:'.$font.'">'.strtoupper($font).'</h3>');	// Separate Paragraphs  defined by font
+$mpdf->WriteHTML('<h3 style="font-family:'.$font.'">'.strtoupper(($font ?? '')).'</h3>');	// Separate Paragraphs  defined by font
 $html = '';
 //==============================================================
 //==============================================================
@@ -57,10 +57,10 @@
 $unichars = array();
 
 foreach($unifile AS $line) {
-	if ($smp && preg_match('/^(1[0-9A-Za-z]{4});/',$line,$m)) { 
+	if ($smp && preg_match('/^(1[0-9A-Za-z]{4});/',($line ?? ''),$m)) { 
 	  $unichars[hexdec($m[1])] = hexdec($m[1]);
 	}
-	else if (preg_match('/^([0-9A-Za-z]{4});/',$line,$m)) { 
+	else if (preg_match('/^([0-9A-Za-z]{4});/',($line ?? ''),$m)) { 
 	  $unichars[hexdec($m[1])] = hexdec($m[1]);
 	}
 }
@@ -102,8 +102,8 @@
 	  $lastrange  = $range ;
     // create HTML content
     $html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
-    $html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-weight:bold">'.strtoupper($font).'</td></tr>';
-    $html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart .'-U+'.$rangeend.')</td></tr>';
+    $html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-weight:bold">'.strtoupper(($font ?? '')).'</td></tr>';
+    $html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper(($range ?? '')).' (U+'.$rangestart .'-U+'.$rangeend.')</td></tr>';
     $html .= '<tr><td></td>';
 
     $html .= '<td></td>';
@@ -155,7 +155,7 @@
 				$html .= '</tr></table><br />';
 				$mpdf->WriteHTML($html); $html = '';
 				$html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
-    				$html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
+    				$html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper(($range ?? '')).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
 				$html .= '<tr><td></td>';
     				$html .= '<td></td>';
 				for ($k = 0; $k < 16; $k++) {
@@ -184,7 +184,7 @@
 			$html .= '</tr></table><br />';
 			$mpdf->WriteHTML($html); $html = '';
 			$html .= '<table cellpadding="2" cellspacing="0" style="font-family:'.$font.';text-align:center; border-collapse: collapse; ">';
-    			$html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper($range).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
+    			$html .= '<tr><td colspan="18" style="font-family:dejavusanscondensed;font-size:8pt;font-weight:bold">'.strtoupper(($range ?? '')).' (U+'.$rangestart.'-U+'.$rangeend.')</td></tr>';
 			$html .= '<tr><td></td>';
     			$html .= '<td></td>';
 			for ($k = 0; $k < 16; $k++) {
@@ -214,7 +214,7 @@
 //==============================================================
 function _getCharWidth(&$cw, $u, $isdef=true) {
 	if ($u==0) { $w = false; }
-	else { $w = (ord($cw[$u*2]) << 8) + ord($cw[$u*2+1]); }
+	else { $w = (ord(($cw[$u*2] ?? '')) << 8) + ord(($cw[$u*2+1] ?? '')); }
 	if ($w == 65535) { return 0; }
 	else if ($w) { return $w; }
 	else if ($isdef) { return false; }
--- a/intranet/mpdf60/utils/font_collections.php
+++ b/intranet/mpdf60/utils/font_collections.php
@@ -32,8 +32,8 @@
 
 
 
-$mqr=ini_get("magic_quotes_runtime");
-if ($mqr) { set_magic_quotes_runtime(0); }
+$mqr='0';
+if ($mqr) { false; }
 if (!class_exists('TTFontFile_Analysis', false)) { include(_MPDF_PATH .'classes/ttfontsuni_analysis.php'); }
 $ttf = new TTFontFile_Analysis();
 
--- a/intranet/mpdf60/mpdfi/pdf_parser.php
+++ b/intranet/mpdf60/mpdfi/pdf_parser.php
@@ -42,6 +42,9 @@
 
 
 class pdf_parser {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $actual_obj;
+
 	
 	/**
      * Filename
@@ -82,7 +85,7 @@
      *
      * @param string $filename  Source-Filename
      */
-	function pdf_parser($filename) {
+	function __construct($filename) {
         $this->filename = $filename;
 	  // mPDF 4.0
 	  $this->success = true;
@@ -181,10 +184,10 @@
        	fseek ($this->f, -min(filesize($this->filename),1500), SEEK_END);
         $data = fread($this->f, 1500);
         
-        $pos = strlen($data) - strpos(strrev($data), strrev('startxref')); 
-        $data = substr($data, $pos);
+        $pos = strlen(($data ?? '')) - strpos((strrev($data) ?? ''), (strrev('startxref') ?? '')); 
+        $data = substr(($data ?? ''), $pos);
         
-        if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
+        if (!preg_match('/\s*(\d+).*$/s', ($data ?? ''), $matches)) {
 	 	// mPDF 4.0
            	$this->success = false;
             $this->errormsg = sprintf("Unable to find pointer to xref table");
@@ -205,19 +208,19 @@
     function pdf_read_xref(&$result, $offset, $start = null, $end = null) {
         if (is_null ($start) || is_null ($end)) {
 		fseek($this->f, $o_pos = $offset);
-            $data = trim(fgets($this->f,1024));
-
-            if (strlen($data) == 0) 
-                $data = trim(fgets($this->f,1024));
+            $data = trim((fgets($this->f,1024) ?? ''));
+
+            if (strlen(($data ?? '')) == 0) 
+                $data = trim((fgets($this->f,1024) ?? ''));
 
             if ($data !== 'xref') {
             	fseek($this->f, $o_pos);
-            	$data = trim(_fgets($this->f, true));
+            	$data = trim((_fgets($this->f, true) ?? ''));
             	if ($data !== 'xref') {
-            	    if (preg_match('/(.*xref)(.*)/m', $data, $m)) { // xref 0 128 - in one line
-                        fseek($this->f, $o_pos+strlen($m[1]));            	        
-            	    } elseif (preg_match('/(x|r|e|f)+/', $data, $m)) { // correct invalid xref-pointer
-            	        $tmpOffset = $offset-4+strlen($m[0]);
+            	    if (preg_match('/(.*xref)(.*)/m', ($data ?? ''), $m)) { // xref 0 128 - in one line
+                        fseek($this->f, $o_pos+strlen(($m[1] ?? '')));            	        
+            	    } elseif (preg_match('/(x|r|e|f)+/', ($data ?? ''), $m)) { // correct invalid xref-pointer
+            	        $tmpOffset = $offset-4+strlen(($m[0] ?? ''));
             	        $this->pdf_read_xref($result, $tmpOffset, $start, $end);
             	        return;
                     } else {
@@ -230,14 +233,14 @@
     		}
 
     		$o_pos = ftell($this->f);
-    	    $data = explode(' ', trim(fgets($this->f,1024)));
-			if (count($data) != 2) {
+    	    $data = explode(' ', (trim((fgets($this->f,1024) ?? '')) ?? ''));
+			if (count(($data ?? [])) != 2) {
     	        fseek($this->f, $o_pos);
-    	        $data = explode(' ', trim(_fgets($this->f, true)));
+    	        $data = explode(' ', (trim((_fgets($this->f, true) ?? '')) ?? ''));
 			
-            	if (count($data) != 2) {
-            	    if (count($data) > 2) { // no lineending
-            	        $n_pos = $o_pos+strlen($data[0])+strlen($data[1])+2;
+            	if (count(($data ?? [])) != 2) {
+            	    if (count(($data ?? [])) > 2) { // no lineending
+            	        $n_pos = $o_pos+strlen(($data[0] ?? ''))+strlen(($data[1] ?? ''))+2;
             	        fseek($this->f, $n_pos);
             	    } else {
 	 			// mPDF 4.0
@@ -260,9 +263,9 @@
     	}
 
     	for (; $start < $end; $start++) {
-    		$data = ltrim(fread($this->f, 20)); // Spezifications says: 20 bytes including newlines
-    		$offset = substr($data, 0, 10);
-    		$generation = substr($data, 11, 5);
+    		$data = ltrim((fread($this->f, 20) ?? '')); // Spezifications says: 20 bytes including newlines
+    		$offset = substr(($data ?? ''), 0, 10);
+    		$generation = substr(($data ?? ''), 11, 5);
 
     	    if (!isset ($result['xref'][$start][(int) $generation])) {
     	    	$result['xref'][$start][(int) $generation] = (int) $offset;
@@ -271,12 +274,12 @@
 
     	$o_pos = ftell($this->f);
         $data = fgets($this->f,1024);
-		if (strlen(trim($data)) == 0) 
+		if (strlen((trim(($data ?? '')) ?? '')) == 0) 
 		    $data = fgets($this->f, 1024);
 
-        if (preg_match("/trailer/",$data)) {
-            if (preg_match("/(.*trailer[ \n\r]*)/",$data,$m)) {
-            	fseek($this->f, $o_pos+strlen($m[1]));
+        if (preg_match("/trailer/",($data ?? ''))) {
+            if (preg_match("/(.*trailer[ \n\r]*)/",($data ?? ''),$m)) {
+            	fseek($this->f, $o_pos+strlen(($m[1] ?? '')));
     		}
 
 			// mPDF 5.0 Removed pass by reference =&
@@ -290,13 +293,13 @@
     	        $result['trailer'] = $trailer;
             }
     	} else {
-    	    $data = explode(' ', trim($data));
+    	    $data = explode(' ', (trim(($data ?? '')) ?? ''));
             
-    		if (count($data) != 2) {
+    		if (count(($data ?? [])) != 2) {
             	fseek($this->f, $o_pos);
-        		$data = explode(' ', trim (_fgets ($this->f, true)));
-
-        		if (count($data) != 2) {
+        		$data = explode(' ', (trim ((_fgets ($this->f, true) ?? '')) ?? ''));
+
+        		if (count(($data ?? [])) != 2) {
 	 			// mPDF 4.0
            			$this->success = false;
             		$this->errormsg = sprintf("Unexpected data in xref table");
@@ -334,7 +337,7 @@
 
     			while(1) {
 
-                    $match = strpos ($c->buffer, '>', $pos);
+                    $match = strpos (($c->buffer ?? ''), '>', $pos);
 				
     				// If you can't find it, try
     				// reading more data from the stream
@@ -347,7 +350,7 @@
                     	}
     				}
 
-    				$result = substr ($c->buffer, $c->offset, $match - $c->offset);
+    				$result = substr (($c->buffer ?? ''), $c->offset, $match - $c->offset);
     				$c->offset = $match+1;
     				
     				return array (PDF_TYPE_HEX, $result);
@@ -405,7 +408,7 @@
                     // Start by finding the next closed
     				// parenthesis
 
-    				$match = strpos ($c->buffer, ')', $pos);
+    				$match = strpos (($c->buffer ?? ''), ')', $pos);
 
     				// If you can't find it, try
     				// reading more data from the stream
@@ -421,9 +424,9 @@
     				// Make sure that there is no backslash
     				// before the parenthesis. If there is,
     				// move on. Otherwise, return the string.
-                    $esc = preg_match('/([\\\\]+)$/', $tmpresult = substr($c->buffer, $c->offset, $match - $c->offset), $m);
+                    $esc = preg_match('/([\\\\]+)$/', (($tmpresult = substr(($c->buffer ?? ''), $c->offset, $match - $c->offset) ?? '' ?? '')), $m);
                     
-                    if ($esc === 0 || strlen($m[1]) % 2 == 0) {
+                    if ($esc === 0 || strlen(($m[1] ?? '')) % 2 == 0) {
     				    $result = $tmpresult;
                         $c->offset = $match + 1;
                         return array (PDF_TYPE_STRING, $result);
@@ -437,7 +440,7 @@
                 }
 
             case "stream":
-            	$o_pos = ftell($c->file)-strlen($c->buffer);
+            	$o_pos = ftell($c->file)-strlen(($c->buffer ?? ''));
 		        $o_offset = $c->offset;
 		        
 		        $c->reset($startpos = $o_pos + $o_offset);
@@ -564,7 +567,7 @@
     			// we encounter an end-of-object marker
     			while(1) {
                     $value = $this->pdf_read_value($c);
-					if ($value === false || count($result) > 4) {
+					if ($value === false || count(($result ?? [])) > 4) {
 						// in this case the parser coudn't find an endobj so we break here
 						break;
     				}
@@ -603,7 +606,7 @@
     	// on the stack, pop it out and
     	// return it.
 
-    	if (count($c->stack)) {
+    	if (count(($c->stack ?? []))) {
     		return array_pop($c->stack);
     	}
 
@@ -677,7 +680,7 @@
     				}
     			}
 
-    			$result = substr($c->buffer, $c->offset - 1, $pos + 1);
+    			$result = substr(($c->buffer ?? ''), $c->offset - 1, $pos + 1);
 
     			$c->offset += $pos;
     			return $result;
--- a/intranet/mpdf60/mpdfi/fpdi_pdf_parser.php
+++ b/intranet/mpdf60/mpdfi/fpdi_pdf_parser.php
@@ -60,11 +60,11 @@
      * @param string $filename  Source-Filename
      * @param object $fpdi      Object of type fpdi
      */
-    function fpdi_pdf_parser($filename,&$fpdi) {
+    function __construct($filename,&$fpdi) {
         $this->fpdi =& $fpdi;
 	  $this->filename = $filename;
 
-        parent::pdf_parser($filename);
+        parent::__construct($filename);
         if ($this->success == false) { return false; }
 
         // resolve Pages-Dictonary
@@ -76,7 +76,7 @@
         if ($this->success == false) { return false; }
 
         // count pages;
-        $this->page_count = count($this->pages);
+        $this->page_count = count(($this->pages ?? []));
     }
     
     
@@ -216,7 +216,7 @@
             switch ($_filter[1]) {
                 case "/FlateDecode":
 			if (function_exists('gzuncompress')) {
-                        $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';                        
+                        $stream = (strlen(($stream ?? '')) > 0) ? @gzuncompress($stream) : '';                        
 			} else {
                         $this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
 			}
--- a/intranet/mpdf60/mpdfi/pdf_context.php
+++ b/intranet/mpdf60/mpdfi/pdf_context.php
@@ -28,7 +28,7 @@
 
 	// Constructor
 
-	function pdf_context($f) {
+	function __construct($f) {
 		$this->file = $f;
 		$this->reset();
 	}
@@ -44,7 +44,7 @@
 
 		$this->buffer = $l > 0 ? fread($this->file, $l) : '';
 		$this->offset = 0;
-		$this->length = strlen($this->buffer);
+		$this->length = strlen(($this->buffer ?? ''));
 		$this->stack = array();
 	}
 
@@ -69,7 +69,7 @@
 			return false;
 		} else {
 			$this->buffer .= fread($this->file, $l);
-			$this->length = strlen($this->buffer);
+			$this->length = strlen(($this->buffer ?? ''));
 			return true;
 		}
 	}
--- a/intranet/mpdf60/mpdfi/filters/FilterLZW.php
+++ b/intranet/mpdf60/mpdfi/filters/FilterLZW.php
@@ -48,7 +48,7 @@
         $this->initsTable();
 
         $this->data = $data;
-        $this->dataLength = strlen($data);
+        $this->dataLength = strlen(($data ?? ''));
 
         // Initialize pointers
         $this->bytePointer = 0;
@@ -104,7 +104,7 @@
         $this->sTable = array();
 
         for ($i = 0; $i < 256; $i++)
-            $this->sTable[$i] = chr($i);
+            $this->sTable[$i] = chr((int) ($i));
 
         $this->tIdx = 258;
         $this->bitsToGet = 9;
@@ -134,11 +134,11 @@
             return 257;
         }
 
-        $this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
+        $this->nextData = ($this->nextData << 8) | (ord(($this->data[$this->bytePointer++] ?? '')) & 0xff);
         $this->nextBits += 8;
 
         if ($this->nextBits < $this->bitsToGet) {
-            $this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
+            $this->nextData = ($this->nextData << 8) | (ord(($this->data[$this->bytePointer++] ?? '')) & 0xff);
             $this->nextBits += 8;
         }
 
--- a/intranet/mpdf60/mpdfi/filters/FilterASCII85.php
+++ b/intranet/mpdf60/mpdfi/filters/FilterASCII85.php
@@ -37,15 +37,15 @@
         $state = 0;
         $chn = null;
         
-        $l = strlen($in);
+        $l = strlen(($in ?? ''));
         
         for ($k = 0; $k < $l; ++$k) {
-            $ch = ord($in[$k]) & 0xff;
+            $ch = ord(($in[$k] ?? '')) & 0xff;
             
             if ($ch == ORD_tilde) {
                 break;
             }
-            if (preg_match('/^\s$/',chr($ch))) {
+            if (preg_match('/^\s$/',(chr((int) ($ch)) ?? ''))) {
                 continue;
             }
             if ($ch == ORD_z && $state == 0) {
@@ -63,10 +63,10 @@
                 $r = 0;
                 for ($j = 0; $j < 5; ++$j)
                     $r = $r * 85 + $chn[$j];
-                $out .= chr($r >> 24);
-                $out .= chr($r >> 16);
-                $out .= chr($r >> 8);
-                $out .= chr($r);
+                $out .= chr((int) ($r >> 24));
+                $out .= chr((int) ($r >> 16));
+                $out .= chr((int) ($r >> 8));
+                $out .= chr((int) ($r));
             }
         }
         $r = 0;
@@ -75,18 +75,18 @@
             $this->error('Illegal length in ASCII85Decode.');
         if ($state == 2) {
             $r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
-            $out .= chr($r >> 24);
+            $out .= chr((int) ($r >> 24));
         }
         else if ($state == 3) {
             $r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85  + ($chn[2]+1) * 85 * 85;
-            $out .= chr($r >> 24);
-            $out .= chr($r >> 16);
+            $out .= chr((int) ($r >> 24));
+            $out .= chr((int) ($r >> 16));
         }
         else if ($state == 4) {
             $r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85  + $chn[2] * 85 * 85  + ($chn[3]+1) * 85 ;
-            $out .= chr($r >> 24);
-            $out .= chr($r >> 16);
-            $out .= chr($r >> 8);
+            $out .= chr((int) ($r >> 24));
+            $out .= chr((int) ($r >> 16));
+            $out .= chr((int) ($r >> 8));
         }
 
         return $out;
--- a/intranet/mpdf60/examples/index.php
+++ b/intranet/mpdf60/examples/index.php
@@ -6,9 +6,9 @@
 
 $files = array();
 foreach($ff AS $f) {
-	if (preg_match('/example[0]{0,1}(\d+)_(.*?)\.php/',$f,$m)) {
+	if (preg_match('/example[0]{0,1}(\d+)_(.*?)\.php/',($f ?? ''),$m)) {
 		$num = intval($m[1]);
-		$files[$num] = array(ucfirst(preg_replace('/_/',' ',$m[2])), $m[0]);
+		$files[$num] = array(ucfirst((preg_replace('/_/',' ',($m[2] ?? '')) ?? '')), $m[0]);
 	}
 }
 echo '<html><body><h3>mPDF Example Files</h3>';
--- a/intranet/mpdf60/examples/example52_new_mPDF_4-2_features.php
+++ b/intranet/mpdf60/examples/example52_new_mPDF_4-2_features.php
@@ -468,10 +468,10 @@
 	$red   = imagecolorallocate($img, 255,   0,   0);
 	$green = imagecolorallocate($img,   0, 255,   0);
 	$blue  = imagecolorallocate($img,   0,   0, 255);
-	imagearc($img, 100, 100, 200, 200,  0, 360, $white);
-	imagearc($img, 100, 100, 150, 150, 25, 155, $red);
-	imagearc($img,  60,  75,  50,  50,  0, 360, $green);
-	imagearc($img, 140,  75,  50,  50,  0, 360, $blue);
+	imagearc($img, 100, 100, 200, 200,  0, 360, (int) ($white));
+	imagearc($img, 100, 100, 150, 150, 25, 155, (int) ($red));
+	imagearc($img,  60,  75,  50,  50,  0, 360, (int) ($green));
+	imagearc($img, 140,  75,  50,  50,  0, 360, (int) ($blue));
 	ob_start();
 	imagejpeg($img);
 	$mpdf->smileyface = ob_get_clean(); 
--- a/intranet/mpdf60/examples/example26_RTL.php
+++ b/intranet/mpdf60/examples/example26_RTL.php
@@ -290,18 +290,18 @@
 //==============================================================
 // Create Index entries from random words in $html
 	// Split $html into words
-	$a =preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+	$a =preg_split('/<(.*?)>/ms',($html ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 	$html = '';
 	foreach($a as $i => $e) {
 	   if($i%2==0) {
 
-		$words = preg_split('/([\s,\.]+)/',$e,-1,PREG_SPLIT_DELIM_CAPTURE);
+		$words = preg_split('/([\s,\.]+)/',($e ?? ''),-1,PREG_SPLIT_DELIM_CAPTURE);
 		foreach($words as $w) {
 
 			$y =  rand(1,10); 	// every tenth word
 			// If it is just a word use it as an index entry
-			if (preg_match("/^(&#x[0]{0,1}6[0-9a-f][0-9a-f];){4,30}$/i",$w) && ($y > 8)) {
-				$content = trim($w);
+			if (preg_match("/^(&#x[0]{0,1}6[0-9a-f][0-9a-f];){4,30}$/i",($w ?? '')) && ($y > 8)) {
+				$content = trim(($w ?? ''));
 				$html .= '<indexentry content="'.$content.'" />';
 			}
 			$html .= $w;
--- a/intranet/mpdf60/examples/formsubmit.php
+++ b/intranet/mpdf60/examples/formsubmit.php
@@ -12,20 +12,20 @@
 ';
 
 
-if (count($_POST)) {
+if (count(($_POST ?? []))) {
   // To display HTML output from PDF form
   echo '<h4>HTML format data sent as POST</h4>';
   foreach($_POST AS $name=>$val) {
-	$t =  mb_convert_encoding(PDFDocEncodingToWin1252($val), 'UTF-8', 'Windows-1252' );	// If from core fonts doc
-	echo '<p>PDFDocEnc: '.$name.' => '.htmlspecialchars($t).'</p>';
+	$t =  mb_convert_encoding((PDFDocEncodingToWin1252($val) ?? ''), 'UTF-8', 'Windows-1252' );	// If from core fonts doc
+	echo '<p>PDFDocEnc: '.$name.' => '.htmlspecialchars(($t ?? '')).'</p>';
   }
 }
-else if (count($_GET)) {
+else if (count(($_GET ?? []))) {
   // To display HTML output from PDF form
   echo '<h4>HTML format data sent as GET</h4>';
   foreach($_GET AS $name=>$val) {
-	$t =  mb_convert_encoding(PDFDocEncodingToWin1252($val), 'UTF-8', 'Windows-1252' );	// If from core fonts doc
-	echo '<p>PDFDocEnc: '.$name.' => '.htmlspecialchars($t).'</p>';
+	$t =  mb_convert_encoding((PDFDocEncodingToWin1252($val) ?? ''), 'UTF-8', 'Windows-1252' );	// If from core fonts doc
+	echo '<p>PDFDocEnc: '.$name.' => '.htmlspecialchars(($t ?? '')).'</p>';
   }
 }
 
@@ -35,11 +35,11 @@
  if ($postdata) {
   echo '<h4>XFDF format data detected</h4>';
   // To parse XFDF
-  if (preg_match_all('/<field name="([^>]*)"\s*>\s*(<value\s*>(.*?)<\/value\s*>)\s*<\/field\s*>/s', $postdata, $m)) {
-	for($i=0; $i<count($m[0]); $i++) {
+  if (preg_match_all('/<field name="([^>]*)"\s*>\s*(<value\s*>(.*?)<\/value\s*>)\s*<\/field\s*>/s', ($postdata ?? ''), $m)) {
+	for($i=0; $i<count(($m[0] ?? [])); $i++) {
 		// if multiple values in response e.g. from multiple selected options
-  		preg_match_all('/<value\s*>(.*?)<\/value\s*>/s', $m[2][$i], $v);
-		if (count($v[0])>1) {
+  		preg_match_all('/<value\s*>(.*?)<\/value\s*>/s', ($m[2][$i] ?? ''), $v);
+		if (count(($v[0] ?? []))>1) {
 			$values = array();
 			foreach($v[1] AS $val) { $values[] = $val; }
 			//foreach($v[1] AS $val) { $values[] = htmlspecialchars_decode($val); }
@@ -51,13 +51,13 @@
 		}
 	}
   }
-  if (preg_match_all('/<field name="([^>]*)"\s*>\s*<value\s*\/\s*>\s*<\/field\s*>/s', $postdata, $m)) {
-	for($i=0; $i<count($m[0]); $i++) {
+  if (preg_match_all('/<field name="([^>]*)"\s*>\s*<value\s*\/\s*>\s*<\/field\s*>/s', ($postdata ?? ''), $m)) {
+	for($i=0; $i<count(($m[0] ?? [])); $i++) {
 		echo '<p>Field: '.$m[1][$i].' => [blank]</p>';
 	}
   }
-  if (preg_match_all('/<field name="([^>]*)"\s*\/\s*>/s', $postdata, $m)) {
-	for($i=0; $i<count($m[0]); $i++) {
+  if (preg_match_all('/<field name="([^>]*)"\s*\/\s*>/s', ($postdata ?? ''), $m)) {
+	for($i=0; $i<count(($m[0] ?? [])); $i++) {
 		echo '<p>Field: '.$m[1][$i].' => [no value]</p>';
 	}
   }
@@ -87,7 +87,7 @@
 		chr(0202) => chr(0221), chr(0232) => chr(0235), chr(0230) => chr(0037), chr(0231) => chr(0222),
 		chr(0216) => chr(0231)
 	); 
-	return strtr($txt, array_flip($Win1252ToPDFDocEncoding) );
+	return strtr(($txt ?? ''), (array_flip($Win1252ToPDFDocEncoding) ?? '') );
 }
 
 
--- a/intranet/mpdf60/examples/example44_MPDFI_yearbook.php
+++ b/intranet/mpdf60/examples/example44_MPDFI_yearbook.php
@@ -110,7 +110,7 @@
 			$mpdf->page--;
 		}
 		// mPDF 2.4 Float Images
-		if (count($mpdf->floatbuffer)) {
+		if (count(($mpdf->floatbuffer ?? []))) {
 			$mpdf->objectbuffer[] = $mpdf->floatbuffer['objattr'];
 			$mpdf->printobjectbuffer(false);
 			$mpdf->objectbuffer = array();
--- a/intranet/mpdf60/examples/example_test.php
+++ b/intranet/mpdf60/examples/example_test.php
@@ -1948,7 +1948,7 @@
 
 //$mpdf->Output('test.pdf','D'); exit;
 
-$s = $mpdf->Output('','S');  echo nl2br(htmlspecialchars($s));  exit;
+$s = $mpdf->Output('','S');  echo nl2br(htmlspecialchars(($s ?? '')));  exit;
 
 
 exit;
--- a/intranet/marketplaces-api/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/OutputFormat.php
+++ b/intranet/marketplaces-api/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/OutputFormat.php
@@ -9,6 +9,7 @@
  *
  * @method OutputFormat setSemicolonAfterLastRule( bool $bSemicolonAfterLastRule ) Set whether semicolons are added after last rule.
  */
+#[\AllowDynamicProperties]
 class OutputFormat {
 	/**
 	* Value format
--- a/intranet/marketplaces-api/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/Property/Charset.php
+++ b/intranet/marketplaces-api/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/Property/Charset.php
@@ -10,6 +10,9 @@
  * â€¢ Must not appear more than once.
  */
 class Charset implements AtRule {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $aComments;
+
 
 	private $sCharset;
 	protected $iLineNo;
--- a/intranet/marketplaces-api/vendor/Intranet/Model.php
+++ b/intranet/marketplaces-api/vendor/Intranet/Model.php
@@ -1,6 +1,7 @@
 <?php
 namespace Intranet;
 
+#[\AllowDynamicProperties]
 class Model {
     private static $manager;
 
--- a/intranet/marketplaces-api/vendor/Intranet/Product.php
+++ b/intranet/marketplaces-api/vendor/Intranet/Product.php
@@ -3,6 +3,9 @@
 use Exception;
 
 class Product extends Model {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $images;
+
     public const STATUS_ACTIVE = "A";
     public const STATUS_DISCONTINUED = "D";
 
--- a/intranet/marketplaces-api/vendor/composer/html2pdf-5.2.4/src/MyPdf.php
+++ b/intranet/marketplaces-api/vendor/composer/html2pdf-5.2.4/src/MyPdf.php
@@ -16,6 +16,9 @@
 
 class MyPdf extends \TCPDF
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $ws;
+
     protected $_footerParam = array();
     protected $_transf      = array();
     protected $_myLastPageGroup = null;
--- a/intranet/marketplaces-api/vendor/composer/html2pdf-5.2.4/src/Html2Pdf.php
+++ b/intranet/marketplaces-api/vendor/composer/html2pdf-5.2.4/src/Html2Pdf.php
@@ -31,6 +31,9 @@
 
 class Html2Pdf
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_pdfa;
+
     /**
      * myPdf object, extends from TCPDF
      * @var MyPdf
--- a/intranet/marketplaces-api/vendor/Spipu/Html2Pdf/MyPdf.php
+++ b/intranet/marketplaces-api/vendor/Spipu/Html2Pdf/MyPdf.php
@@ -16,6 +16,9 @@
 
 class MyPdf extends \TCPDF
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $ws;
+
     protected $_footerParam = array();
     protected $_transf      = array();
     protected $_myLastPageGroup = null;
--- a/intranet/marketplaces-api/vendor/Spipu/Html2Pdf/Html2Pdf.php
+++ b/intranet/marketplaces-api/vendor/Spipu/Html2Pdf/Html2Pdf.php
@@ -31,6 +31,9 @@
 
 class Html2Pdf
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_pdfa;
+
     /**
      * myPdf object, extends from TCPDF
      * @var MyPdf
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/BinaryStream.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/BinaryStream.php
@@ -154,7 +154,7 @@
   }
 
   public function readUInt8() {
-    return ord($this->read(1));
+    return ord(($this->read(1) ?? ''));
   }
 
   public function readUInt8Many($count) {
@@ -162,7 +162,7 @@
   }
 
   public function writeUInt8($data) {
-    return $this->write(chr($data), 1);
+    return $this->write(chr((int) ($data)), 1);
   }
 
   public function readInt8() {
@@ -282,7 +282,7 @@
       $date = 0;
     }
 
-    return strftime("%Y-%m-%d %H:%M:%S", $date);
+    return date("Y-m-d H:i:s", $date);
   }
 
   public function writeLongDateTime($data) {
@@ -439,6 +439,6 @@
    * @return string The string
    */
   public function convertUInt32ToStr($uint32) {
-    return chr(($uint32 >> 24) & 0xFF) . chr(($uint32 >> 16) & 0xFF) . chr(($uint32 >> 8) & 0xFF) . chr($uint32 & 0xFF);
+    return chr((int) (($uint32 >> 24) & 0xFF)) . chr((int) (($uint32 >> 16) & 0xFF)) . chr((int) (($uint32 >> 8) & 0xFF)) . chr((int) ($uint32 & 0xFF));
   }
 }
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EncodingMap.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EncodingMap.php
@@ -24,7 +24,7 @@
     $map = array();
 
     while ($line = fgets($this->f)) {
-      if (preg_match('/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/', $line, $matches)) {
+      if (preg_match('/^[\!\=]([0-9A-F]{2,})\s+U\+([0-9A-F]{2})([0-9A-F]{2})\s+([^\s]+)/', ($line ?? ''), $matches)) {
         $unicode = (hexdec($matches[2]) << 8) + hexdec($matches[3]);
         $map[hexdec($matches[1])] = array($unicode, $matches[4]);
       }
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Font.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Font.php
@@ -28,7 +28,7 @@
           throw new FontNotFoundException($file);
       }
 
-    $header = file_get_contents($file, false, null, null, 4);
+    $header = file_get_contents(($file ?? ''), (false ?? false), null, null, 4);
     $class  = null;
 
     switch ($header) {
@@ -52,7 +52,7 @@
 
       // Unknown type or EOT
       default:
-        $magicNumber = file_get_contents($file, false, null, 34, 2);
+        $magicNumber = file_get_contents(($file ?? ''), (false ?? false), null, 34, 2);
 
         if ($magicNumber === "LP") {
           $class = "EOT\\File";
@@ -80,10 +80,10 @@
   }
 
   static function UTF16ToUTF8($str) {
-    return mb_convert_encoding($str, "utf-8", "utf-16");
+    return mb_convert_encoding(($str ?? ''), "utf-8", "utf-16");
   }
 
   static function UTF8ToUTF16($str) {
-    return mb_convert_encoding($str, "utf-16", "utf-8");
+    return mb_convert_encoding(($str ?? ''), "utf-16", "utf-8");
   }
 }
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Autoloader.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Autoloader.php
@@ -29,9 +29,9 @@
    * @param string
    */
   public static function autoload($class) {
-    $prefixLength = strlen(self::PREFIX);
+    $prefixLength = strlen((self::PREFIX ?? ''));
     if (0 === strncmp(self::PREFIX, $class, $prefixLength)) {
-      $file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
+      $file = str_replace('\\', (DIRECTORY_SEPARATOR ?? ''), (substr(($class ?? ''), $prefixLength) ?? ''));
       $file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
       if (file_exists($file)) {
         require_once $file;
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/AdobeFontMetrics.php
@@ -32,7 +32,7 @@
     $map_data = array();
 
     if ($encoding) {
-      $encoding = preg_replace("/[^a-z0-9-_]/", "", $encoding);
+      $encoding = preg_replace("/[^a-z0-9-_]/", "", ($encoding ?? ''));
       $map_file = dirname(__FILE__) . "/../maps/$encoding.map";
       if (!file_exists($map_file)) {
         throw new \Exception("Unkown encoding ($encoding)");
@@ -55,7 +55,7 @@
 
     $records = $font->getData("name", "records");
     foreach ($records as $id => $record) {
-      if (!isset(name::$nameIdCodes[$id]) || preg_match("/[\r\n]/", $record->string)) {
+      if (!isset(name::$nameIdCodes[$id]) || preg_match("/[\r\n]/", ($record->string ?? ''))) {
         continue;
       }
 
@@ -98,7 +98,7 @@
       $hmtx  = $font->getData("hmtx");
       $names = $font->getData("post", "names");
 
-      $this->startSection("CharMetrics", count($hmtx));
+      $this->startSection("CharMetrics", count(($hmtx ?? [])));
 
       if ($encoding) {
         foreach ($map_data as $code => $value) {
@@ -143,7 +143,7 @@
 
       if (!$encoding && is_array($tree)) {
         $this->startSection("KernData");
-        $this->startSection("KernPairs", count($tree, COUNT_RECURSIVE) - count($tree));
+        $this->startSection("KernPairs", count(($tree ?? []), COUNT_RECURSIVE) - count(($tree ?? [])));
 
         foreach ($tree as $left => $values) {
           if (!is_array($values)) {
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/WOFF/File.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/WOFF/File.php
@@ -31,7 +31,7 @@
     parent::load($file);
 
     $this->parseTableEntries();
-    $dataOffset = $this->pos() + count($this->directory) * 20;
+    $dataOffset = $this->pos() + count(($this->directory ?? [])) * 20;
 
     $fw = $this->getTempFile(false);
     $fr = $this->f;
@@ -50,7 +50,7 @@
       }
 
       // Prepare data ...
-      $length        = strlen($data);
+      $length        = strlen(($data ?? ''));
       $entry->length = $entry->origLength = $length;
       $entry->offset = $dataOffset;
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EOT/Header.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EOT/Header.php
@@ -95,7 +95,7 @@
     }
 
     if (!empty($this->data["RootString"])) {
-      $this->data["RootString"] = explode("\0", $this->data["RootString"]);
+      $this->data["RootString"] = explode("\0", ($this->data["RootString"] ?? ''));
     }
   }
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EOT/File.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/EOT/File.php
@@ -74,7 +74,7 @@
     }
 
     $string = fread($this->f, $n);
-    $chunks = str_split($string, 2);
+    $chunks = str_split(($string ?? ''), 2);
     $chunks = array_map("strrev", $chunks);
 
     return implode("", $chunks);
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/OutlineComposite.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/OutlineComposite.php
@@ -169,7 +169,7 @@
         $flags |= self::WE_HAVE_A_TWO_BY_TWO;
       }
 
-      if ($_i < count($this->components) - 1) {
+      if ($_i < count(($this->components ?? [])) - 1) {
         $flags |= self::MORE_COMPONENTS;
       }
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/OutlineSimple.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/OutlineSimple.php
@@ -117,14 +117,14 @@
   }
 
   public function splitSVGPath($path) {
-    preg_match_all('/([a-z])|(-?\d+(?:\.\d+)?)/i', $path, $matches, PREG_PATTERN_ORDER);
+    preg_match_all('/([a-z])|(-?\d+(?:\.\d+)?)/i', ($path ?? ''), $matches, PREG_PATTERN_ORDER);
 
     return $matches[0];
   }
 
   public function makePoints($path) {
     $path = $this->splitSVGPath($path);
-    $l    = count($path);
+    $l    = count(($path ?? []));
     $i    = 0;
 
     $points = array();
@@ -170,7 +170,7 @@
         // closePath
         /** @noinspection PhpMissingBreakStatementInspection */
         case "z":
-          $points[count($points) - 1]["endOfContour"] = true;
+          $points[count(($points ?? [])) - 1]["endOfContour"] = true;
 
         default:
           $i++;
@@ -239,18 +239,18 @@
     $font = $this->getFont();
 
     $l = 0;
-    $l += $font->writeInt16(count($endPtsOfContours)); // endPtsOfContours
+    $l += $font->writeInt16(count(($endPtsOfContours ?? []))); // endPtsOfContours
     $l += $font->writeFWord(isset($this->xMin) ? $this->xMin : $xMin); // xMin
     $l += $font->writeFWord(isset($this->yMin) ? $this->yMin : $yMin); // yMin
     $l += $font->writeFWord(isset($this->xMax) ? $this->xMax : $xMax); // xMax
     $l += $font->writeFWord(isset($this->yMax) ? $this->yMax : $yMax); // yMax
 
     // Simple glyf
-    $l += $font->w(array(self::uint16, count($endPtsOfContours)), $endPtsOfContours); // endPtsOfContours
+    $l += $font->w(array(self::uint16, count(($endPtsOfContours ?? []))), $endPtsOfContours); // endPtsOfContours
     $l += $font->writeUInt16(0); // instructionLength
-    $l += $font->w(array(self::uint8, count($flags)), $flags); // flags
-    $l += $font->w(array(self::int16, count($coords_x)), $coords_x); // xCoordinates
-    $l += $font->w(array(self::int16, count($coords_y)), $coords_y); // yCoordinates
+    $l += $font->w(array(self::uint8, count(($flags ?? []))), $flags); // flags
+    $l += $font->w(array(self::int16, count(($coords_x ?? []))), $coords_x); // xCoordinates
+    $l += $font->w(array(self::int16, count(($coords_y ?? []))), $coords_y); // yCoordinates
     return $l;
   }
 
@@ -265,7 +265,7 @@
       $points = $this->points;
     }
 
-    $length     = count($points);
+    $length     = count(($points ?? []));
     $firstIndex = 0;
     $count      = 0;
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/Outline.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Glyph/Outline.php
@@ -96,7 +96,7 @@
   function encode() {
     $font = $this->getFont();
 
-    return $font->write($this->raw, strlen($this->raw));
+    return $font->write($this->raw, strlen(($this->raw ?? '')));
   }
 
   function getSVGContours() {
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/DirectoryEntry.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/DirectoryEntry.php
@@ -37,21 +37,21 @@
   protected $origF;
 
   static function computeChecksum($data) {
-    $len = strlen($data);
+    $len = strlen(($data ?? ''));
     $mod = $len % 4;
 
     if ($mod) {
-      $data = str_pad($data, $len + (4 - $mod), "\0");
+      $data = str_pad(($data ?? ''), $len + (4 - $mod), "\0");
     }
 
-    $len = strlen($data);
+    $len = strlen(($data ?? ''));
 
     $hi = 0x0000;
     $lo = 0x0000;
 
     for ($i = 0; $i < $len; $i += 4) {
-      $hi += (ord($data[$i]) << 8) + ord($data[$i + 1]);
-      $lo += (ord($data[$i + 2]) << 8) + ord($data[$i + 3]);
+      $hi += (ord(($data[$i] ?? '')) << 8) + ord(($data[$i + 1] ?? ''));
+      $lo += (ord(($data[$i + 2] ?? '')) << 8) + ord(($data[$i + 3] ?? ''));
       $hi += $lo >> 16;
       $lo = $lo & 0xFFFF;
       $hi = $hi & 0xFFFF;
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/nameRecord.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/nameRecord.php
@@ -15,6 +15,7 @@
  *
  * @package php-font-lib
  */
+#[\AllowDynamicProperties]
 class nameRecord extends BinaryStream {
   public $platformID;
   public $platformSpecificID;
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/cmap.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/cmap.php
@@ -211,7 +211,7 @@
       $idDelta[]   = $start[1] - $start[0];
     }
 
-    $segCount      = count($startCode);
+    $segCount      = count(($startCode ?? []));
     $idRangeOffset = array_fill(0, $segCount, 0);
 
     $searchRange   = 1;
@@ -249,7 +249,7 @@
 
     $data = array(
       "version"         => 0,
-      "numberSubtables" => count($subtables),
+      "numberSubtables" => count(($subtables ?? [])),
       "subtables"       => $subtables,
     );
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/maxp.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/maxp.php
@@ -35,7 +35,7 @@
 
   function _encode() {
     $font                    = $this->getFont();
-    $this->data["numGlyphs"] = count($font->getSubset());
+    $this->data["numGlyphs"] = count(($font->getSubset() ?? []));
 
     return parent::_encode();
   }
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/hhea.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/hhea.php
@@ -37,7 +37,7 @@
 
   function _encode() {
     $font                              = $this->getFont();
-    $this->data["numOfLongHorMetrics"] = count($font->getSubset());
+    $this->data["numOfLongHorMetrics"] = count(($font->getSubset() ?? []));
 
     return parent::_encode();
   }
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/glyf.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/glyf.php
@@ -76,7 +76,7 @@
 
     $n = 500;
 
-    $s = "<h3>" . "Only the first $n simple glyphs are shown (" . count($this->data) . " total)
+    $s = "<h3>" . "Only the first $n simple glyphs are shown (" . count(($this->data ?? [])) . " total)
     <div class='glyph-view simple'>Simple glyph</div>
     <div class='glyph-view composite'>Composite glyph</div>
     Zoom: <input type='range' value='100' max='400' onchange='Glyph.resize(this.value)' />
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/name.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/Table/Type/name.php
@@ -168,7 +168,7 @@
 
     /** @var nameRecord[] $records */
     $records       = $this->data["records"];
-    $count_records = count($records);
+    $count_records = count(($records ?? []));
 
     $this->data["count"]        = $count_records;
     $this->data["stringOffset"] = 6 + $count_records * 12; // 6 => uint16 * 3, 12 => sizeof self::$record_format
@@ -177,7 +177,7 @@
 
     $offset = 0;
     foreach ($records as $record) {
-      $record->length = mb_strlen($record->getUTF16(), "8bit");
+      $record->length = mb_strlen(($record->getUTF16() ?? ''), "8bit");
       $record->offset = $offset;
       $offset += $record->length;
       $length += $font->pack(nameRecord::$format, (array)$record);
@@ -185,7 +185,7 @@
 
     foreach ($records as $record) {
       $str = $record->getUTF16();
-      $length += $font->write($str, mb_strlen($str, "8bit"));
+      $length += $font->write($str, mb_strlen(($str ?? ''), "8bit"));
     }
 
     return $length;
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/TrueType/Collection.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/TrueType/Collection.php
@@ -70,29 +70,30 @@
     return $this->collection[$fontId] = $font;
   }
 
-  function current() {
+  function current(): mixed {
     return $this->getFont($this->position);
   }
 
-  function key() {
+  function key(): mixed {
     return $this->position;
   }
 
-  function next() {
+  #[\ReturnTypeWillChange]
+    function next() {
     return ++$this->position;
   }
 
-  function rewind() {
+  function rewind(): void {
     $this->position = 0;
   }
 
-  function valid() {
+  function valid(): bool {
     $this->parse();
 
     return isset($this->collectionOffsets[$this->position]);
   }
 
-  function count() {
+  function count(): int {
     $this->parse();
 
     return $this->numFonts;
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/TrueType/File.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/src/FontLib/TrueType/File.php
@@ -124,25 +124,25 @@
   }
 
   function utf8toUnicode($str) {
-    $len = strlen($str);
+    $len = strlen(($str ?? ''));
     $out = array();
 
     for ($i = 0; $i < $len; $i++) {
       $uni = -1;
-      $h   = ord($str[$i]);
+      $h   = ord(($str[$i] ?? ''));
 
       if ($h <= 0x7F) {
         $uni = $h;
       }
       elseif ($h >= 0xC2) {
         if (($h <= 0xDF) && ($i < $len - 1)) {
-          $uni = ($h & 0x1F) << 6 | (ord($str[++$i]) & 0x3F);
+          $uni = ($h & 0x1F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
         }
         elseif (($h <= 0xEF) && ($i < $len - 2)) {
-          $uni = ($h & 0x0F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | (ord($str[++$i]) & 0x3F);
+          $uni = ($h & 0x0F) << 12 | (ord(($str[++$i] ?? '')) & 0x3F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
         }
         elseif (($h <= 0xF4) && ($i < $len - 3)) {
-          $uni = ($h & 0x0F) << 18 | (ord($str[++$i]) & 0x3F) << 12 | (ord($str[++$i]) & 0x3F) << 6 | (ord($str[++$i]) & 0x3F);
+          $uni = ($h & 0x0F) << 18 | (ord(($str[++$i] ?? '')) & 0x3F) << 12 | (ord(($str[++$i] ?? '')) & 0x3F) << 6 | (ord(($str[++$i] ?? '')) & 0x3F);
         }
       }
 
@@ -223,7 +223,7 @@
       $tags = array_keys($this->directory);
     }
 
-    $num_tables = count($tags);
+    $num_tables = count(($tags ?? []));
     $n          = 16; // @todo
 
     Font::d("Tables : " . implode(", ", $tags));
@@ -265,7 +265,7 @@
   }
 
   function getFontType(){
-    $class_parts = explode("\\", get_class($this));
+    $class_parts = explode("\\", (get_class($this) ?? ''));
     return $class_parts[1];
   }
 
@@ -301,7 +301,7 @@
     $this->parseTableEntries();
 
     if (!self::$raw) {
-      $name_canon = preg_replace("/[^a-z0-9]/", "", strtolower($tag));
+      $name_canon = preg_replace("/[^a-z0-9]/", "", (strtolower(($tag ?? '')) ?? ''));
 
       $class = "FontLib\\Table\\Type\\$name_canon";
 
--- a/intranet/marketplaces-api/vendor/phenx/php-font-lib/tests/FontLib/FontTest.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-font-lib/tests/FontLib/FontTest.php
@@ -33,16 +33,16 @@
 
         $this->assertEquals(4, $cmapFormat4Table['format']);
         $this->assertEquals(6, $cmapFormat4Table['segCount']);
-        $this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['startCode']));
-        $this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['endCode']));
+        $this->assertEquals($cmapFormat4Table['segCount'], count(($cmapFormat4Table['startCode'] ?? [])));
+        $this->assertEquals($cmapFormat4Table['segCount'], count(($cmapFormat4Table['endCode'] ?? [])));
 
         $cmapFormat12Table = $cmapTable[1];
 
         $this->assertEquals(12, $cmapFormat12Table['format']);
         $this->assertEquals(6, $cmapFormat12Table['ngroups']);
-        $this->assertEquals(6, count($cmapFormat12Table['startCode']));
-        $this->assertEquals(6, count($cmapFormat12Table['endCode']));
-        $this->assertEquals(53, count($cmapFormat12Table['glyphIndexArray']));
+        $this->assertEquals(6, count(($cmapFormat12Table['startCode'] ?? [])));
+        $this->assertEquals(6, count(($cmapFormat12Table['endCode'] ?? [])));
+        $this->assertEquals(53, count(($cmapFormat12Table['glyphIndexArray'] ?? [])));
     }
 
 }
\ No newline at end of file
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/autoload.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/autoload.php
@@ -7,8 +7,8 @@
  */
 
 spl_autoload_register(function($class) {
-  if (0 === strpos($class, "Svg")) {
-    $file = str_replace('\\', DIRECTORY_SEPARATOR, $class);
+  if (0 === strpos(($class ?? ''), "Svg")) {
+    $file = str_replace('\\', (DIRECTORY_SEPARATOR ?? ''), ($class ?? ''));
     $file = realpath(__DIR__ . DIRECTORY_SEPARATOR . $file . '.php');
     if (file_exists($file)) {
       include_once $file;
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Style.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Style.php
@@ -10,6 +10,7 @@
 
 use Svg\Tag\AbstractTag;
 
+#[\AllowDynamicProperties]
 class Style
 {
     const TYPE_COLOR = 1;
@@ -98,7 +99,7 @@
     }
 
     public function fromStyleSheets(AbstractTag $tag, $attributes) {
-        $class = isset($attributes["class"]) ? preg_split('/\s+/', trim($attributes["class"])) : null;
+        $class = isset($attributes["class"]) ? preg_split('/\s+/', (trim(($attributes["class"] ?? '')) ?? '')) : null;
 
         $stylesheets = $tag->getDocument()->getStyleSheets();
 
@@ -171,11 +172,11 @@
 
     static function parseColor($color)
     {
-        $color = strtolower(trim($color));
-
-        $parts = preg_split('/[^,]\s+/', $color, 2);
-
-        if (count($parts) == 2) {
+        $color = strtolower((trim(($color ?? '')) ?? ''));
+
+        $parts = preg_split('/[^,]\s+/', ($color ?? ''), 2);
+
+        if (count(($parts ?? [])) == 2) {
             $color = $parts[1];
         }
         else {
@@ -197,12 +198,12 @@
         }
 
         // RGB color
-        if (strpos($color, "rgb") !== false) {
+        if (strpos(($color ?? ''), "rgb") !== false) {
             return self::getTriplet($color);
         }
 
         // RGB color
-        if (strpos($color, "hsl") !== false) {
+        if (strpos(($color ?? ''), "hsl") !== false) {
             $triplet = self::getTriplet($color, true);
 
             if ($triplet == null) {
@@ -267,41 +268,41 @@
         }
 
         // Gradient
-        if (strpos($color, "url(#") !== false) {
-            $i = strpos($color, "(");
-            $j = strpos($color, ")");
+        if (strpos(($color ?? ''), "url(#") !== false) {
+            $i = strpos(($color ?? ''), "(");
+            $j = strpos(($color ?? ''), ")");
 
             // Bad url format
             if ($i === false || $j === false) {
                 return null;
             }
 
-            return trim(substr($color, $i + 1, $j - $i - 1));
+            return trim((substr(($color ?? ''), $i + 1, $j - $i - 1) ?? ''));
         }
 
         return null;
     }
 
     static function getTriplet($color, $percent = false) {
-        $i = strpos($color, "(");
-        $j = strpos($color, ")");
+        $i = strpos(($color ?? ''), "(");
+        $j = strpos(($color ?? ''), ")");
 
         // Bad color value
         if ($i === false || $j === false) {
             return null;
         }
 
-        $triplet = preg_split("/\\s*,\\s*/", trim(substr($color, $i + 1, $j - $i - 1)));
-
-        if (count($triplet) != 3) {
+        $triplet = preg_split("/\\s*,\\s*/", (trim((substr(($color ?? ''), $i + 1, $j - $i - 1) ?? '')) ?? ''));
+
+        if (count(($triplet ?? [])) != 3) {
             return null;
         }
 
         foreach (array_keys($triplet) as $c) {
-            $triplet[$c] = trim($triplet[$c]);
+            $triplet[$c] = trim(($triplet[$c] ?? ''));
 
             if ($percent) {
-                if ($triplet[$c][strlen($triplet[$c]) - 1] === "%") {
+                if ($triplet[$c][strlen(($triplet[$c] ?? '')) - 1] === "%") {
                     $triplet[$c] = floatval($triplet[$c]) / 100;
                 }
                 else {
@@ -309,7 +310,7 @@
                 }
             }
             else {
-                if ($triplet[$c][strlen($triplet[$c]) - 1] === "%") {
+                if ($triplet[$c][strlen(($triplet[$c] ?? '')) - 1] === "%") {
                     $triplet[$c] = round(floatval($triplet[$c]) * 2.55);
                 }
             }
@@ -324,9 +325,9 @@
 
         // #FFFFFF
         if (isset($hex[6])) {
-            $c[0] = hexdec(substr($hex, 1, 2));
-            $c[1] = hexdec(substr($hex, 3, 2));
-            $c[2] = hexdec(substr($hex, 5, 2));
+            $c[0] = hexdec(substr(($hex ?? ''), 1, 2));
+            $c[1] = hexdec(substr(($hex ?? ''), 3, 2));
+            $c[2] = hexdec(substr(($hex ?? ''), 5, 2));
         } else {
             $c[0] = hexdec($hex[1] . $hex[1]);
             $c[1] = hexdec($hex[2] . $hex[2]);
@@ -346,7 +347,7 @@
     static function parseCssStyle($style)
     {
         $matches = array();
-        preg_match_all("/([a-z-]+)\\s*:\\s*([^;$]+)/si", $style, $matches, PREG_SET_ORDER);
+        preg_match_all("/([a-z-]+)\\s*:\\s*([^;$]+)/si", ($style ?? ''), $matches, PREG_SET_ORDER);
 
         $styles = array();
         foreach ($matches as $match) {
@@ -366,30 +367,30 @@
      * @return float|null
      */
     static function convertSize($size, $referenceSize = 11.0, $dpi = 96.0) {
-        $size = trim(strtolower($size));
+        $size = trim((strtolower(($size ?? '')) ?? ''));
 
         if (is_numeric($size)) {
             return $size;
         }
 
-        if ($pos = strpos($size, "px")) {
-            return floatval(substr($size, 0, $pos));
-        }
-
-        if ($pos = strpos($size, "pt")) {
-            return floatval(substr($size, 0, $pos));
-        }
-
-        if ($pos = strpos($size, "cm")) {
-            return floatval(substr($size, 0, $pos)) * $dpi;
-        }
-
-        if ($pos = strpos($size, "%")) {
-            return $referenceSize * substr($size, 0, $pos) / 100;
-        }
-
-        if ($pos = strpos($size, "em")) {
-            return $referenceSize * substr($size, 0, $pos);
+        if ($pos = strpos(($size ?? ''), "px")) {
+            return floatval(substr(($size ?? ''), 0, $pos));
+        }
+
+        if ($pos = strpos(($size ?? ''), "pt")) {
+            return floatval(substr(($size ?? ''), 0, $pos));
+        }
+
+        if ($pos = strpos(($size ?? ''), "cm")) {
+            return floatval(substr(($size ?? ''), 0, $pos)) * $dpi;
+        }
+
+        if ($pos = strpos(($size ?? ''), "%")) {
+            return $referenceSize * substr(($size ?? ''), 0, $pos) / 100;
+        }
+
+        if ($pos = strpos(($size ?? ''), "em")) {
+            return $referenceSize * substr(($size ?? ''), 0, $pos);
         }
 
         // TODO cm, mm, pc, in, etc
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Document.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Document.php
@@ -148,8 +148,8 @@
             }
 
             if (isset($attributes['viewbox'])) {
-                $viewBox = preg_split('/[\s,]+/is', trim($attributes['viewbox']));
-                if (count($viewBox) == 4) {
+                $viewBox = preg_split('/[\s,]+/is', (trim(($attributes['viewbox'] ?? '')) ?? ''));
+                if (count(($viewBox ?? [])) == 4) {
                     $this->x = $viewBox[0];
                     $this->y = $viewBox[1];
 
@@ -236,7 +236,7 @@
     }
 
     public function getDef($id) {
-        $id = ltrim($id, "#");
+        $id = ltrim(($id ?? ''), "#");
 
         return isset($this->defs[$id]) ? $this->defs[$id] : null;
     }
@@ -250,13 +250,13 @@
 
         $attributes = array_change_key_case($attributes, CASE_LOWER);
 
-        switch (strtolower($name)) {
+        switch (strtolower(($name ?? ''))) {
             case 'defs':
                 $this->inDefs = true;
                 return;
 
             case 'svg':
-                if (count($this->attributes)) {
+                if (count(($this->attributes ?? []))) {
                     $tag = new Group($this, $name);
                 }
                 else {
@@ -369,7 +369,7 @@
     {
         /** @var AbstractTag $tag */
         $tag = null;
-        switch (strtolower($name)) {
+        switch (strtolower(($name ?? ''))) {
             case 'defs':
                 $this->inDefs = false;
                 return;
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Polyline.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Polyline.php
@@ -13,10 +13,10 @@
     public function start($attributes)
     {
         $tmp = array();
-        preg_match_all('/([\-]*[0-9\.]+)/', $attributes['points'], $tmp);
+        preg_match_all('/([\-]*[0-9\.]+)/', ($attributes['points'] ?? ''), $tmp);
 
         $points = $tmp[0];
-        $count = count($points);
+        $count = count(($points ?? []));
 
         $surface = $this->document->getSurface();
         list($x, $y) = $points;
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/AbstractTag.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/AbstractTag.php
@@ -43,7 +43,7 @@
      */
     public function getParentGroup() {
         $stack = $this->getDocument()->getStack();
-        for ($i = count($stack)-2; $i >= 0; $i--) {
+        for ($i = count(($stack ?? []))-2; $i >= 0; $i--) {
             $tag = $stack[$i];
 
             if ($tag instanceof Group || $tag instanceof Document) {
@@ -137,15 +137,15 @@
             $match = array();
             preg_match_all(
                 '/(matrix|translate|scale|rotate|skewX|skewY)\((.*?)\)/is',
-                $transform,
+                ($transform ?? ''),
                 $match,
                 PREG_SET_ORDER
             );
 
             $transformations = array();
-            if (count($match[0])) {
+            if (count(($match[0] ?? []))) {
                 foreach ($match as $_match) {
-                    $arguments = preg_split('/[ ,]+/', $_match[2]);
+                    $arguments = preg_split('/[ ,]+/', ($_match[2] ?? ''));
                     array_unshift($arguments, $_match[1]);
                     $transformations[] = $arguments;
                 }
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Rect.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Rect.php
@@ -27,16 +27,16 @@
         }
 
         if (isset($attributes['width'])) {
-            if ('%' === substr($attributes['width'], -1)) {
-                $factor = substr($attributes['width'], 0, -1) / 100;
+            if ('%' === substr(($attributes['width'] ?? ''), -1)) {
+                $factor = substr(($attributes['width'] ?? ''), 0, -1) / 100;
                 $this->width = $this->document->getWidth() * $factor;
             } else {
                 $this->width = $attributes['width'];
             }
         }
         if (isset($attributes['height'])) {
-            if ('%' === substr($attributes['height'], -1)) {
-                $factor = substr($attributes['height'], 0, -1) / 100;
+            if ('%' === substr(($attributes['height'] ?? ''), -1)) {
+                $factor = substr(($attributes['height'] ?? ''), 0, -1) / 100;
                 $this->height = $this->document->getHeight() * $factor;
             } else {
                 $this->height = $attributes['height'];
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Path.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Path.php
@@ -38,25 +38,25 @@
         }
 
         $commands = array();
-        preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', $attributes['d'], $commands, PREG_SET_ORDER);
+        preg_match_all('/([MZLHVCSQTAmzlhvcsqta])([eE ,\-.\d]+)*/', ($attributes['d'] ?? ''), $commands, PREG_SET_ORDER);
 
         $path = array();
         foreach ($commands as $c) {
-            if (count($c) == 3) {
+            if (count(($c ?? [])) == 3) {
                 $arguments = array();
-                preg_match_all('/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/i', $c[2], $arguments, PREG_PATTERN_ORDER);
+                preg_match_all('/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/i', ($c[2] ?? ''), $arguments, PREG_PATTERN_ORDER);
                 $item = $arguments[0];
-                $commandLower = strtolower($c[1]);
+                $commandLower = strtolower(($c[1] ?? ''));
 
                 if (
                     isset(self::$commandLengths[$commandLower]) &&
                     ($commandLength = self::$commandLengths[$commandLower]) &&
-                    count($item) > $commandLength
+                    count(($item ?? [])) > $commandLength
                 ) {
                     $repeatedCommand = isset(self::$repeatedCommands[$c[1]]) ? self::$repeatedCommands[$c[1]] : $c[1];
                     $command = $c[1];
 
-                    for ($k = 0, $klen = count($item); $k < $klen; $k += $commandLength) {
+                    for ($k = 0, $klen = count(($item ?? [])); $k < $klen; $k += $commandLength) {
                         $_item = array_slice($item, $k, $k + $commandLength);
                         array_unshift($_item, $command);
                         $path[] = $_item;
@@ -182,7 +182,7 @@
                     $tempX = $x + $current[3];
                     $tempY = $y + $current[4];
 
-                    if (!preg_match('/[CcSs]/', $previous[0])) {
+                    if (!preg_match('/[CcSs]/', ($previous[0] ?? ''))) {
                         // If there is no previous command or if the previous command was not a C, c, S, or s,
                         // the control point is coincident with the current point
                         $controlX = $x;
@@ -216,7 +216,7 @@
                     $tempX = $current[3];
                     $tempY = $current[4];
 
-                    if (!preg_match('/[CcSs]/', $previous[0])) {
+                    if (!preg_match('/[CcSs]/', ($previous[0] ?? ''))) {
                         // If there is no previous command or if the previous command was not a C, c, S, or s,
                         // the control point is coincident with the current point
                         $controlX = $x;
@@ -287,7 +287,7 @@
                     $tempX = $x + $current[1];
                     $tempY = $y + $current[2];
 
-                    if (preg_match("/[QqTt]/", $previous[0])) {
+                    if (preg_match("/[QqTt]/", ($previous[0] ?? ''))) {
                         // If there is no previous command or if the previous command was not a Q, q, T or t,
                         // assume the control point is coincident with the current point
                         $controlX = $x;
@@ -407,7 +407,7 @@
 
         $segsNorm = $this->arcToSegments($tx - $fx, $ty - $fy, $rx, $ry, $large, $sweep, $rot);
 
-        for ($i = 0, $len = count($segsNorm); $i < $len; $i++) {
+        for ($i = 0, $len = count(($segsNorm ?? [])); $i < $len; $i++) {
             $segs[$i][0] = $segsNorm[$i][0] + $fx;
             $segs[$i][1] = $segsNorm[$i][1] + $fy;
             $segs[$i][2] = $segsNorm[$i][2] + $fx;
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Text.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Text.php
@@ -65,6 +65,6 @@
 
     public function getText()
     {
-        return trim($this->text);
+        return trim(($this->text ?? ''));
     }
 } 
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Polygon.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Tag/Polygon.php
@@ -13,10 +13,10 @@
     public function start($attributes)
     {
         $tmp = array();
-        preg_match_all('/([\-]*[0-9\.]+)/', $attributes['points'], $tmp);
+        preg_match_all('/([\-]*[0-9\.]+)/', ($attributes['points'] ?? ''), $tmp);
 
         $points = $tmp[0];
-        $count = count($points);
+        $count = count(($points ?? []));
 
         $surface = $this->document->getSurface();
         list($x, $y) = $points;
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfacePDFLib.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfacePDFLib.php
@@ -149,14 +149,14 @@
     {
         if (self::DEBUG) echo __FUNCTION__ . "\n";
 
-        if (strpos($image, "data:") === 0) {
-            $data = substr($image, strpos($image, ";") + 1);
-            if (strpos($data, "base64") === 0) {
-                $data = base64_decode(substr($data, 7));
+        if (strpos(($image ?? ''), "data:") === 0) {
+            $data = substr(($image ?? ''), strpos(($image ?? ''), ";") + 1);
+            if (strpos(($data ?? ''), "base64") === 0) {
+                $data = base64_decode((substr(($data ?? ''), 7) ?? ''));
             }
         }
         else {
-            $data = file_get_contents($image);
+            $data = file_get_contents(($image ?? ''));
         }
 
         $image = tempnam("", "svg");
@@ -337,7 +337,7 @@
             );
         }
 
-        if ($fillRule = strtolower($style->fillRule)) {
+        if ($fillRule = strtolower(($style->fillRule ?? ''))) {
             $map = array(
                 "nonzero" => "winding",
                 "evenodd" => "evenodd",
@@ -383,7 +383,7 @@
             }
         }
 
-        if (count($opts)) {
+        if (count(($opts ?? []))) {
             $gs = $canvas->create_gstate(implode(" ", $opts));
             $canvas->set_gstate($gs);
         }
@@ -407,7 +407,7 @@
             "verdana"    => "Helvetica",
         );
 
-        $family = strtolower($family);
+        $family = strtolower(($family ?? ''));
         if (isset($map[$family])) {
             $family = $map[$family];
         }
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/CPdf.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/CPdf.php
@@ -18,6 +18,7 @@
 
 namespace Svg\Surface;
 
+#[\AllowDynamicProperties]
 class CPdf
 {
 
@@ -570,7 +571,7 @@
                             }
 
                             if ($k >= 0) {
-                                for ($j = count($o['info']['pages']) - 1; $j >= $k; $j--) {
+                                for ($j = count(($o['info']['pages'] ?? [])) - 1; $j >= $k; $j--) {
                                     $o['info']['pages'][$j + 1] = $o['info']['pages'][$j];
                                 }
 
@@ -604,17 +605,17 @@
                 break;
 
             case 'out':
-                if (count($o['info']['pages'])) {
+                if (count(($o['info']['pages'] ?? []))) {
                     $res = "\n$id 0 obj\n<< /Type /Pages\n/Kids [";
                     foreach ($o['info']['pages'] as $v) {
                         $res .= "$v 0 R\n";
                     }
 
-                    $res .= "]\n/Count " . count($this->objects[$id]['info']['pages']);
-
-                    if ((isset($o['info']['fonts']) && count($o['info']['fonts'])) ||
+                    $res .= "]\n/Count " . count(($this->objects[$id]['info']['pages'] ?? []));
+
+                    if ((isset($o['info']['fonts']) && count(($o['info']['fonts'] ?? []))) ||
                         isset($o['info']['procset']) ||
-                        (isset($o['info']['extGStates']) && count($o['info']['extGStates']))
+                        (isset($o['info']['extGStates']) && count(($o['info']['extGStates'] ?? [])))
                     ) {
                         $res .= "\n/Resources <<";
 
@@ -622,7 +623,7 @@
                             $res .= "\n/ProcSet " . $o['info']['procset'] . " 0 R";
                         }
 
-                        if (isset($o['info']['fonts']) && count($o['info']['fonts'])) {
+                        if (isset($o['info']['fonts']) && count(($o['info']['fonts'] ?? []))) {
                             $res .= "\n/Font << ";
                             foreach ($o['info']['fonts'] as $finfo) {
                                 $res .= "\n/F" . $finfo['fontNum'] . " " . $finfo['objNum'] . " 0 R";
@@ -630,7 +631,7 @@
                             $res .= "\n>>";
                         }
 
-                        if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) {
+                        if (isset($o['info']['xObjects']) && count(($o['info']['xObjects'] ?? []))) {
                             $res .= "\n/XObject << ";
                             foreach ($o['info']['xObjects'] as $finfo) {
                                 $res .= "\n/" . $finfo['label'] . " " . $finfo['objNum'] . " 0 R";
@@ -638,7 +639,7 @@
                             $res .= "\n>>";
                         }
 
-                        if (isset($o['info']['extGStates']) && count($o['info']['extGStates'])) {
+                        if (isset($o['info']['extGStates']) && count(($o['info']['extGStates'] ?? []))) {
                             $res .= "\n/ExtGState << ";
                             foreach ($o['info']['extGStates'] as $gstate) {
                                 $res .= "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
@@ -688,13 +689,13 @@
                 break;
 
             case 'out':
-                if (count($o['info']['outlines'])) {
+                if (count(($o['info']['outlines'] ?? []))) {
                     $res = "\n$id 0 obj\n<< /Type /Outlines /Kids [";
                     foreach ($o['info']['outlines'] as $v) {
                         $res .= "$v 0 R ";
                     }
 
-                    $res .= "] /Count " . count($o['info']['outlines']) . " >>\nendobj";
+                    $res .= "] /Count " . count(($o['info']['outlines'] ?? [])) . " >>\nendobj";
                 } else {
                     $res = "\n$id 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
                 }
@@ -789,7 +790,7 @@
 end
 EOT;
 
-                    $res = "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
+                    $res = "<</Length " . mb_strlen(($stream ?? ''), '8bit') . " >>\n";
                     $res .= "stream\n" . $stream . "endstream";
 
                     $this->objects[$toUnicodeId]['c'] = $res;
@@ -916,7 +917,7 @@
                         case 'StemH':
                         case 'XHeight':
                         case 'CharSet':
-                            if (mb_strlen($value, '8bit')) {
+                            if (mb_strlen(($value ?? ''), '8bit')) {
                                 $res .= "/$label $value\n";
                             }
 
@@ -1095,7 +1096,7 @@
             case 'out':
                 $res = "\n$id 0 obj\n";
                 $fontFileName = $o['info']['fontFileName'];
-                $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode($this->fonts[$fontFileName]['CIDtoGID']);
+                $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode(($this->fonts[$fontFileName]['CIDtoGID'] ?? ''));
 
                 $compressed = isset($this->fonts[$fontFileName]['CIDtoGID_Compressed']) &&
                     $this->fonts[$fontFileName]['CIDtoGID_Compressed'];
@@ -1114,7 +1115,7 @@
                         $res .= "\n/Filter /FlateDecode";
                     }
 
-                    $res .= "\n/Length " . mb_strlen($tmp, '8bit') . ">>\nstream\n$tmp\nendstream";
+                    $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . ">>\nstream\n$tmp\nendstream";
                 }
 
                 $res .= "\nendobj";
@@ -1404,7 +1405,7 @@
                     $res .= " ]";
                 }
 
-                $count = count($o['info']['contents']);
+                $count = count(($o['info']['contents'] ?? []));
                 if ($count == 1) {
                     $res .= "\n/Contents " . $o['info']['contents'][0] . " 0 R";
                 } else {
@@ -1439,7 +1440,7 @@
         switch ($action) {
             case 'new':
                 $this->objects[$id] = array('t' => 'contents', 'c' => '', 'info' => array());
-                if (mb_strlen($options, '8bit') && intval($options)) {
+                if (mb_strlen(($options ?? ''), '8bit') && intval($options)) {
                     // then this contents is the primary for a page
                     $this->objects[$id]['onPage'] = $options;
                 } else {
@@ -1479,7 +1480,7 @@
                         $res .= "\n/$k $v";
                     }
 
-                    $res .= "\n/Length " . mb_strlen($tmp, '8bit') . " >>\nstream\n$tmp\nendstream";
+                    $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . " >>\nstream\n$tmp\nendstream";
                 }
 
                 $res .= "\nendobj";
@@ -1599,8 +1600,8 @@
                         if ($options['isMask']) {
                             $info['ColorSpace'] = '/DeviceGray';
                         } else {
-                            if (mb_strlen($options['pdata'], '8bit')) {
-                                $tmp = ' [ /Indexed /DeviceRGB ' . (mb_strlen($options['pdata'], '8bit') / 3 - 1) . ' ';
+                            if (mb_strlen(($options['pdata'] ?? ''), '8bit')) {
+                                $tmp = ' [ /Indexed /DeviceRGB ' . (mb_strlen(($options['pdata'] ?? ''), '8bit') / 3 - 1) . ' ';
                                 $this->numObj++;
                                 $this->o_contents($this->numObj, 'new');
                                 $this->objects[$this->numObj]['c'] = $options['pdata'];
@@ -1675,7 +1676,7 @@
                     $tmp = $this->ARC4($tmp);
                 }
 
-                $res .= "\n/Length " . mb_strlen($tmp, '8bit') . ">>\nstream\n$tmp\nendstream\nendobj";
+                $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . ">>\nstream\n$tmp\nendstream\nendobj";
 
                 return $res;
         }
@@ -1765,41 +1766,41 @@
                     . chr(0x2E) . chr(0x2E) . chr(0x00) . chr(0xB6) . chr(0xD0) . chr(0x68) . chr(0x3E) . chr(0x80)
                     . chr(0x2F) . chr(0x0C) . chr(0xA9) . chr(0xFE) . chr(0x64) . chr(0x53) . chr(0x69) . chr(0x7A);
 
-                $len = mb_strlen($options['owner'], '8bit');
+                $len = mb_strlen(($options['owner'] ?? ''), '8bit');
 
                 if ($len > 32) {
-                    $owner = substr($options['owner'], 0, 32);
+                    $owner = substr(($options['owner'] ?? ''), 0, 32);
                 } else {
                     if ($len < 32) {
-                        $owner = $options['owner'] . substr($pad, 0, 32 - $len);
+                        $owner = $options['owner'] . substr(($pad ?? ''), 0, 32 - $len);
                     } else {
                         $owner = $options['owner'];
                     }
                 }
 
-                $len = mb_strlen($options['user'], '8bit');
+                $len = mb_strlen(($options['user'] ?? ''), '8bit');
                 if ($len > 32) {
-                    $user = substr($options['user'], 0, 32);
+                    $user = substr(($options['user'] ?? ''), 0, 32);
                 } else {
                     if ($len < 32) {
-                        $user = $options['user'] . substr($pad, 0, 32 - $len);
+                        $user = $options['user'] . substr(($pad ?? ''), 0, 32 - $len);
                     } else {
                         $user = $options['user'];
                     }
                 }
 
                 $tmp = $this->md5_16($owner);
-                $okey = substr($tmp, 0, 5);
+                $okey = substr(($tmp ?? ''), 0, 5);
                 $this->ARC4_init($okey);
                 $ovalue = $this->ARC4($user);
                 $this->objects[$id]['info']['O'] = $ovalue;
 
                 // now make the u value, phew.
                 $tmp = $this->md5_16(
-                    $user . $ovalue . chr($options['p']) . chr(255) . chr(255) . chr(255) . $this->fileIdentifier
+                    $user . $ovalue . chr((int) ($options['p'])) . chr(255) . chr(255) . chr(255) . $this->fileIdentifier
                 );
 
-                $ukey = substr($tmp, 0, 5);
+                $ukey = substr(($tmp ?? ''), 0, 5);
                 $this->ARC4_init($ukey);
                 $this->encryptionKey = $ukey;
                 $this->encrypted = true;
@@ -1835,10 +1836,10 @@
      */
     function md5_16($string)
     {
-        $tmp = md5($string);
+        $tmp = md5(($string ?? ''));
         $out = '';
         for ($i = 0; $i <= 30; $i = $i + 2) {
-            $out .= chr(hexdec(substr($tmp, $i, 2)));
+            $out .= chr((int) (hexdec(substr(($tmp ?? ''), $i, 2))));
         }
 
         return $out;
@@ -1851,14 +1852,14 @@
     {
         $tmp = $this->encryptionKey;
         $hex = dechex($id);
-        if (mb_strlen($hex, '8bit') < 6) {
-            $hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')) . $hex;
-        }
-        $tmp .= chr(hexdec(substr($hex, 4, 2))) . chr(hexdec(substr($hex, 2, 2))) . chr(
-                hexdec(substr($hex, 0, 2))
+        if (mb_strlen(($hex ?? ''), '8bit') < 6) {
+            $hex = substr('000000', 0, 6 - mb_strlen(($hex ?? ''), '8bit')) . $hex;
+        }
+        $tmp .= chr((int) (hexdec(substr(($hex ?? ''), 4, 2)))) . chr((int) (hexdec(substr(($hex ?? ''), 2, 2)))) . chr(
+                (int) (hexdec(substr(($hex ?? ''), 0, 2)))
             ) . chr(0) . chr(0);
         $key = $this->md5_16($tmp);
-        $this->ARC4_init(substr($key, 0, 10));
+        $this->ARC4_init(substr(($key ?? ''), 0, 10));
     }
 
     /**
@@ -1869,25 +1870,25 @@
         $this->arc4 = '';
 
         // setup the control array
-        if (mb_strlen($key, '8bit') == 0) {
+        if (mb_strlen(($key ?? ''), '8bit') == 0) {
             return;
         }
 
         $k = '';
-        while (mb_strlen($k, '8bit') < 256) {
+        while (mb_strlen(($k ?? ''), '8bit') < 256) {
             $k .= $key;
         }
 
-        $k = substr($k, 0, 256);
+        $k = substr(($k ?? ''), 0, 256);
         for ($i = 0; $i < 256; $i++) {
-            $this->arc4 .= chr($i);
+            $this->arc4 .= chr((int) ($i));
         }
 
         $j = 0;
 
         for ($i = 0; $i < 256; $i++) {
             $t = $this->arc4[$i];
-            $j = ($j + ord($t) + ord($k[$i])) % 256;
+            $j = ($j + ord(($t ?? '')) + ord(($k[$i] ?? ''))) % 256;
             $this->arc4[$i] = $this->arc4[$j];
             $this->arc4[$j] = $t;
         }
@@ -1898,7 +1899,7 @@
      */
     function ARC4($text)
     {
-        $len = mb_strlen($text, '8bit');
+        $len = mb_strlen(($text ?? ''), '8bit');
         $a = 0;
         $b = 0;
         $c = $this->arc4;
@@ -1906,11 +1907,11 @@
         for ($i = 0; $i < $len; $i++) {
             $a = ($a + 1) % 256;
             $t = $c[$a];
-            $b = ($b + ord($t)) % 256;
+            $b = ($b + ord(($t ?? ''))) % 256;
             $c[$a] = $c[$b];
             $c[$b] = $t;
-            $k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
-            $out .= chr(ord($text[$i]) ^ $k);
+            $k = ord(($c[(ord(($c[$a] ?? '')) + ord(($c[$b] ?? ''))) % 256] ?? ''));
+            $out .= chr((int) (ord(($text[$i] ?? '')) ^ $k));
         }
 
         return $out;
@@ -1965,7 +1966,7 @@
         if ($this->arc4_objnum == 0) {
             // then the block does not exist already, add it.
             $this->numObj++;
-            if (mb_strlen($ownerPass) == 0) {
+            if (mb_strlen(($ownerPass ?? '')) == 0) {
                 $ownerPass = $userPass;
             }
 
@@ -2010,30 +2011,30 @@
 
         $xref = array();
         $content = '%PDF-1.3';
-        $pos = mb_strlen($content, '8bit');
+        $pos = mb_strlen(($content ?? ''), '8bit');
 
         foreach ($this->objects as $k => $v) {
             $tmp = 'o_' . $v['t'];
             $cont = $this->$tmp($k, 'out');
             $content .= $cont;
             $xref[] = $pos;
-            $pos += mb_strlen($cont, '8bit');
-        }
-
-        $content .= "\nxref\n0 " . (count($xref) + 1) . "\n0000000000 65535 f \n";
+            $pos += mb_strlen(($cont ?? ''), '8bit');
+        }
+
+        $content .= "\nxref\n0 " . (count(($xref ?? [])) + 1) . "\n0000000000 65535 f \n";
 
         foreach ($xref as $p) {
-            $content .= str_pad($p, 10, "0", STR_PAD_LEFT) . " 00000 n \n";
-        }
-
-        $content .= "trailer\n<<\n/Size " . (count($xref) + 1) . "\n/Root 1 0 R\n/Info $this->infoObject 0 R\n";
+            $content .= str_pad(($p ?? ''), 10, "0", STR_PAD_LEFT) . " 00000 n \n";
+        }
+
+        $content .= "trailer\n<<\n/Size " . (count(($xref ?? [])) + 1) . "\n/Root 1 0 R\n/Info $this->infoObject 0 R\n";
 
         // if encryption has been applied to this document then add the marker for this dictionary
         if ($this->arc4_objnum > 0) {
             $content .= "/Encrypt $this->arc4_objnum 0 R\n";
         }
 
-        if (mb_strlen($this->fileIdentifier, '8bit')) {
+        if (mb_strlen(($this->fileIdentifier ?? ''), '8bit')) {
             $content .= "/ID[<$this->fileIdentifier><$this->fileIdentifier>]\n";
         }
 
@@ -2091,14 +2092,14 @@
     private function openFont($font)
     {
         // assume that $font contains the path and file but not the extension
-        $pos = strrpos($font, '/');
+        $pos = strrpos(($font ?? ''), '/');
 
         if ($pos === false) {
             $dir = './';
             $name = $font;
         } else {
-            $dir = substr($font, 0, $pos + 1);
-            $name = substr($font, $pos + 1);
+            $dir = substr(($font ?? ''), 0, $pos + 1);
+            $name = substr(($font ?? ''), $pos + 1);
         }
 
         $fontcache = $this->fontcache;
@@ -2156,7 +2157,7 @@
 
             // Since we're not going to enable Unicode for the core fonts we need to use a font-based
             // setting for Unicode support rather than a global setting.
-            $data['isUnicode'] = (strtolower(substr($metrics_name, -3)) !== 'afm');
+            $data['isUnicode'] = (strtolower((substr(($metrics_name ?? ''), -3) ?? '')) !== 'afm');
 
             $cidtogid = '';
             if ($data['isUnicode']) {
@@ -2166,12 +2167,12 @@
             $file = file($dir . $metrics_name);
 
             foreach ($file as $rowA) {
-                $row = trim($rowA);
-                $pos = strpos($row, ' ');
+                $row = trim(($rowA ?? ''));
+                $pos = strpos(($row ?? ''), ' ');
 
                 if ($pos) {
                     // then there must be some keyword
-                    $key = substr($row, 0, $pos);
+                    $key = substr(($row ?? ''), 0, $pos);
                     switch ($key) {
                         case 'FontName':
                         case 'FullName':
@@ -2193,31 +2194,31 @@
                         case 'StdVW':
                         case 'StartCharMetrics':
                         case 'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font.  Otherwise it's too big.
-                            $data[$key] = trim(substr($row, $pos));
+                            $data[$key] = trim((substr(($row ?? ''), $pos) ?? ''));
                             break;
 
                         case 'FontBBox':
-                            $data[$key] = explode(' ', trim(substr($row, $pos)));
+                            $data[$key] = explode(' ', (trim((substr(($row ?? ''), $pos) ?? '')) ?? ''));
                             break;
 
                         //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ;
                         case 'C': // Found in AFM files
-                            $bits = explode(';', trim($row));
+                            $bits = explode(';', (trim(($row ?? '')) ?? ''));
                             $dtmp = array();
 
                             foreach ($bits as $bit) {
-                                $bits2 = explode(' ', trim($bit));
-                                if (mb_strlen($bits2[0], '8bit') == 0) {
+                                $bits2 = explode(' ', (trim(($bit ?? '')) ?? ''));
+                                if (mb_strlen(($bits2[0] ?? ''), '8bit') == 0) {
                                     continue;
                                 }
 
-                                if (count($bits2) > 2) {
+                                if (count(($bits2 ?? [])) > 2) {
                                     $dtmp[$bits2[0]] = array();
-                                    for ($i = 1; $i < count($bits2); $i++) {
+                                    for ($i = 1; $i < count(($bits2 ?? [])); $i++) {
                                         $dtmp[$bits2[0]][] = $bits2[$i];
                                     }
                                 } else {
-                                    if (count($bits2) == 2) {
+                                    if (count(($bits2 ?? [])) == 2) {
                                         $dtmp[$bits2[0]] = $bits2[1];
                                     }
                                 }
@@ -2248,22 +2249,22 @@
                                 break;
                             }
 
-                            $bits = explode(';', trim($row));
+                            $bits = explode(';', (trim(($row ?? '')) ?? ''));
                             $dtmp = array();
 
                             foreach ($bits as $bit) {
-                                $bits2 = explode(' ', trim($bit));
-                                if (mb_strlen($bits2[0], '8bit') === 0) {
+                                $bits2 = explode(' ', (trim(($bit ?? '')) ?? ''));
+                                if (mb_strlen(($bits2[0] ?? ''), '8bit') === 0) {
                                     continue;
                                 }
 
-                                if (count($bits2) > 2) {
+                                if (count(($bits2 ?? [])) > 2) {
                                     $dtmp[$bits2[0]] = array();
-                                    for ($i = 1; $i < count($bits2); $i++) {
+                                    for ($i = 1; $i < count(($bits2 ?? [])); $i++) {
                                         $dtmp[$bits2[0]][] = $bits2[$i];
                                     }
                                 } else {
-                                    if (count($bits2) == 2) {
+                                    if (count(($bits2 ?? [])) == 2) {
                                         $dtmp[$bits2[0]] = $bits2[1];
                                     }
                                 }
@@ -2277,8 +2278,8 @@
                             if ($c >= 0) {
                                 // Set values in CID to GID map
                                 if ($c >= 0 && $c < 0xFFFF && $glyph) {
-                                    $cidtogid[$c * 2] = chr($glyph >> 8);
-                                    $cidtogid[$c * 2 + 1] = chr($glyph & 0xFF);
+                                    $cidtogid[$c * 2] = chr((int) ($glyph >> 8));
+                                    $cidtogid[$c * 2 + 1] = chr((int) ($glyph & 0xFF));
                                 }
 
                                 if ($c != hexdec($n)) {
@@ -2298,7 +2299,7 @@
                         case 'KPX':
                             break; // don't include them as they are not used yet
                             //KPX Adieresis yacute -40
-                            $bits = explode(' ', trim($row));
+                            $bits = explode(' ', (trim(($row ?? '')) ?? ''));
                             $data['KPX'][$bits[1]][$bits[2]] = $bits[3];
                             break;
                     }
@@ -2310,13 +2311,13 @@
                 $data['CIDtoGID_Compressed'] = true;
                 $cidtogid = gzcompress($cidtogid, 6);
             }
-            $data['CIDtoGID'] = base64_encode($cidtogid);
+            $data['CIDtoGID'] = base64_encode(($cidtogid ?? ''));
             $data['_version_'] = $this->fontcacheVersion;
             $this->fonts[$font] = $data;
 
             //Because of potential trouble with php safe mode, expect that the folder already exists.
             //If not existing, this will hit performance because of missing cached results.
-            if (is_dir(substr($fontcache, 0, -1)) && is_writable(substr($fontcache, 0, -1))) {
+            if (is_dir(substr(($fontcache ?? ''), 0, -1)) && is_writable(substr(($fontcache ?? ''), 0, -1))) {
                 file_put_contents($fontcache . $cache_name, '<?php return ' . var_export($data, true) . ';');
             }
             $data = null;
@@ -2339,9 +2340,9 @@
      */
     function selectFont($fontName, $encoding = '', $set = true)
     {
-        $ext = substr($fontName, -4);
+        $ext = substr(($fontName ?? ''), -4);
         if ($ext === '.afm' || $ext === '.ufm') {
-            $fontName = substr($fontName, 0, mb_strlen($fontName) - 4);
+            $fontName = substr(($fontName ?? ''), 0, mb_strlen(($fontName ?? '')) - 4);
         }
 
         if (!isset($this->fonts[$fontName])) {
@@ -2357,9 +2358,9 @@
                 $font = &$this->fonts[$fontName];
 
                 //$this->numFonts = md5($fontName);
-                $pos = strrpos($fontName, '/');
+                $pos = strrpos(($fontName ?? ''), '/');
                 //      $dir = substr($fontName,0,$pos+1);
-                $name = substr($fontName, $pos + 1);
+                $name = substr(($fontName ?? ''), $pos + 1);
                 $options = array('name' => $name, 'fontFileName' => $fontName);
 
                 if (is_array($encoding)) {
@@ -2372,7 +2373,7 @@
                         $options['differences'] = $encoding['differences'];
                     }
                 } else {
-                    if (mb_strlen($encoding, '8bit')) {
+                    if (mb_strlen(($encoding ?? ''), '8bit')) {
                         // then perhaps only the encoding has been set
                         $options['encoding'] = $encoding;
                     }
@@ -2490,7 +2491,7 @@
                     if (isset($font['StdVW'])) {
                         $stemV = $font['StdVW'];
                     } else {
-                        if (isset($font['Weight']) && preg_match('!(bold|black)!i', $font['Weight'])) {
+                        if (isset($font['Weight']) && preg_match('!(bold|black)!i', ($font['Weight'] ?? ''))) {
                             $stemV = 120;
                         }
                     }
@@ -2500,7 +2501,7 @@
                     // simple utility to convert them from pfa to pfb.
                     // FIXME: should we move font subset creation to CPDF::output? See notes in issue #750.
                     if (!$this->isUnicode || $fbtype !== 'ttf' || empty($this->stringSubsets)) {
-                        $data = file_get_contents($fbfile);
+                        $data = file_get_contents(($fbfile ?? ''));
                     } else {
                         $this->stringSubsets[$fontName][] = 32; // Force space if not in yet
 
@@ -2543,20 +2544,20 @@
                             $font['CIDWidths'] = array();
                             foreach ($glyphIndexArray as $cid => $gid) {
                                 if ($cid >= 0 && $cid < 0xFFFF && $gid) {
-                                    $cidtogid[$cid * 2] = chr($gid >> 8);
-                                    $cidtogid[$cid * 2 + 1] = chr($gid & 0xFF);
+                                    $cidtogid[$cid * 2] = chr((int) ($gid >> 8));
+                                    $cidtogid[$cid * 2 + 1] = chr((int) ($gid & 0xFF));
                                 }
 
                                 $width = $font_obj->normalizeFUnit(isset($hmtx[$gid]) ? $hmtx[$gid][0] : $hmtx[0][0]);
                                 $font['CIDWidths'][$cid] = $width;
                             }
 
-                            $font['CIDtoGID'] = base64_encode(gzcompress($cidtogid));
+                            $font['CIDtoGID'] = base64_encode((gzcompress($cidtogid) ?? ''));
                             $font['CIDtoGID_Compressed'] = true;
 
-                            $data = file_get_contents($tmp_name);
+                            $data = file_get_contents(($tmp_name ?? ''));
                         } else {
-                            $data = file_get_contents($fbfile);
+                            $data = file_get_contents(($fbfile ?? ''));
                         }
 
                         $font_obj->close();
@@ -2618,9 +2619,9 @@
 
                     // determine the cruicial lengths within this file
                     if ($fbtype === 'pfb') {
-                        $l1 = strpos($data, 'eexec') + 6;
-                        $l2 = strpos($data, '00000000') - $l1;
-                        $l3 = mb_strlen($data, '8bit') - $l2 - $l1;
+                        $l1 = strpos(($data ?? ''), 'eexec') + 6;
+                        $l2 = strpos(($data ?? ''), '00000000') - $l1;
+                        $l3 = mb_strlen(($data ?? ''), '8bit') - $l2 - $l1;
                         $this->o_contents(
                             $this->numObj,
                             'add',
@@ -2628,7 +2629,7 @@
                         );
                     } else {
                         if ($fbtype == 'ttf') {
-                            $l1 = mb_strlen($data, '8bit');
+                            $l1 = mb_strlen(($data ?? ''), '8bit');
                             $this->o_contents($this->numObj, 'add', array('Length1' => $l1));
                         }
                     }
@@ -3269,7 +3270,7 @@
         }
 
         // if there is a line style set, then put this in too
-        if (mb_strlen($this->currentLineStyle, '8bit')) {
+        if (mb_strlen(($this->currentLineStyle ?? ''), '8bit')) {
             $this->addContent("\n$this->currentLineStyle");
         }
 
@@ -3301,13 +3302,13 @@
         }
 
         $debug = empty($options['compression']);
-        $tmp = ltrim($this->output($debug));
+        $tmp = ltrim(($this->output($debug) ?? ''));
 
         header("Cache-Control: private");
         header("Content-type: application/pdf");
 
         //FIXME: I don't know that this is sufficient for determining content length (i.e. what about transport compression?)
-        header("Content-Length: " . mb_strlen($tmp, '8bit'));
+        header("Content-Length: " . mb_strlen(($tmp ?? ''), '8bit'));
         $fileName = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'file.pdf');
 
         if (!isset($options["Attachment"])) {
@@ -3318,9 +3319,9 @@
 
         // detect the character encoding of the incoming file
         $encoding = mb_detect_encoding($fileName);
-        $fallbackfilename = mb_convert_encoding($fileName, "ISO-8859-1", $encoding);
-        $encodedfallbackfilename = rawurlencode($fallbackfilename);
-        $encodedfilename = rawurlencode($fileName);
+        $fallbackfilename = mb_convert_encoding(($fileName ?? ''), "ISO-8859-1", $encoding);
+        $encodedfallbackfilename = rawurlencode(($fallbackfilename ?? ''));
+        $encodedfilename = rawurlencode(($fileName ?? ''));
 
         header(
             "Content-Disposition: $attachment; filename=" . $encodedfallbackfilename . "; filename*=UTF-8''$encodedfilename"
@@ -3328,7 +3329,7 @@
 
         if (isset($options['Accept-Ranges']) && $options['Accept-Ranges'] == 1) {
             //FIXME: Is this the correct value ... spec says 1#range-unit
-            header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
+            header("Accept-Ranges: " . mb_strlen(($tmp ?? ''), '8bit'));
         }
 
         echo $tmp;
@@ -3424,12 +3425,12 @@
                 $text = $this->utf8toUtf16BE($text, $bom);
             } else {
                 //$text = html_entity_decode($text, ENT_QUOTES);
-                $text = mb_convert_encoding($text, self::$targetEncoding, 'UTF-8');
+                $text = mb_convert_encoding(($text ?? ''), (self::$targetEncoding ?? ''), 'UTF-8');
             }
         }
 
         // the chr(13) substitution fixes a bug seen in TCPDF (bug #1421290)
-        return strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
+        return strtr(($text ?? ''), array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
     }
 
     /**
@@ -3442,8 +3443,8 @@
         $w = $this->getTextWidth($size, $text);
 
         // need to adjust for the number of spaces in this text
-        $words = explode(' ', $text);
-        $nspaces = count($words) - 1;
+        $words = explode(' ', ($text ?? ''));
+        $nspaces = count(($words ?? [])) - 1;
         $w += $wa * $nspaces;
         $a = deg2rad((float)$angle);
 
@@ -3499,14 +3500,14 @@
             $this->selectFont($this->defaultFont);
         }
 
-        $text = str_replace(array("\r", "\n"), "", $text);
+        $text = str_replace(array("\r", "\n"), "", ($text ?? ''));
 
         if ($smallCaps) {
-            preg_match_all("/(\P{Ll}+)/u", $text, $matches, PREG_SET_ORDER);
+            preg_match_all("/(\P{Ll}+)/u", ($text ?? ''), $matches, PREG_SET_ORDER);
             $lower = $this->concatMatches($matches);
             d($lower);
 
-            preg_match_all("/(\p{Ll}+)/u", $text, $matches, PREG_SET_ORDER);
+            preg_match_all("/(\p{Ll}+)/u", ($text ?? ''), $matches, PREG_SET_ORDER);
             $other = $this->concatMatches($matches);
             d($other);
 
@@ -3552,7 +3553,7 @@
             $this->addContent(sprintf(" %.3F Tc", $charSpaceAdjust));
         }
 
-        $len = mb_strlen($text);
+        $len = mb_strlen(($text ?? ''));
         $start = 0;
 
         if ($start < $len) {
@@ -3563,7 +3564,7 @@
             if ($this->fonts[$cf]['isUnicode'] && $wordSpaceAdjust != 0) {
                 $space_scale = 1000 / $size;
                 //$place_text = str_replace(' ', ') ( ) '.($this->getTextWidth($size, chr(32), $wordSpaceAdjust)*-75).' (', $place_text);
-                $place_text = str_replace(' ', ' ) ' . (-round($space_scale * $wordSpaceAdjust)) . ' (', $place_text);
+                $place_text = str_replace(' ', ' ) ' . (-round($space_scale * $wordSpaceAdjust)) . ' (', ($place_text ?? ''));
             }
             $this->addContent(" /F$this->currentFontNum " . sprintf('%.1F Tf ', $size));
             $this->addContent(" [($place_text)] TJ");
@@ -3609,7 +3610,7 @@
             $this->selectFont($this->defaultFont);
         }
 
-        $text = str_replace(array("\r", "\n"), "", $text);
+        $text = str_replace(array("\r", "\n"), "", ($text ?? ''));
 
         // converts a number or a float to a string so it can get the width
         $text = "$text";
@@ -3649,20 +3650,20 @@
 
             // add additionnal char spacing
             if ($char_spacing != 0) {
-                $w += $char_spacing * $space_scale * (count($unicode) + $n_spaces);
+                $w += $char_spacing * $space_scale * (count(($unicode ?? [])) + $n_spaces);
             }
 
         } else {
             // If CPDF is in Unicode mode but the current font does not support Unicode we need to convert the character set to Windows-1252
             if ($this->isUnicode) {
-                $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
+                $text = mb_convert_encoding(($text ?? ''), 'Windows-1252', 'UTF-8');
             }
 
-            $len = mb_strlen($text, 'Windows-1252');
+            $len = mb_strlen(($text ?? ''), 'Windows-1252');
 
             for ($i = 0; $i < $len; $i++) {
                 $c = $text[$i];
-                $char = isset($ord_cache[$c]) ? $ord_cache[$c] : ($ord_cache[$c] = ord($c));
+                $char = isset($ord_cache[$c]) ? $ord_cache[$c] : ($ord_cache[$c] = ord(($c ?? '')));
 
                 // check if we have to replace character
                 if (isset($current_font['differences'][$char])) {
@@ -3925,7 +3926,7 @@
         $ret = 0;
         for ($i = 0; $i < $num; $i++) {
             $ret *= 256;
-            $ret += ord($data[$pos + $i]);
+            $ret += ord(($data[$pos + $i] ?? ''));
         }
 
         return $ret;
@@ -3953,7 +3954,7 @@
      * @param bool     $is_mask true if the image is a mask
      * @param bool     $mask    true if the image is masked
      */
-    function addImagePng($file, $x, $y, $w = 0.0, $h = 0.0, &$img, $is_mask = false, $mask = null)
+    function addImagePng($file, $x, $y, $w, $h, &$img, $is_mask = false, $mask = null)
     {
         if (!function_exists("imagepng")) {
             throw new Exception("The PHP GD extension is required, but is not installed.");
@@ -4025,12 +4026,12 @@
         @unlink($tempfile_plain);
         $tempfile_plain = "$tempfile_plain.png";
 
-        $imgalpha = imagecreate($wpx, $hpx);
+        $imgalpha = imagecreate((int) ($wpx), (int) ($hpx));
         imagesavealpha($imgalpha, false);
 
         // generate gray scale palette (0 -> 255)
         for ($c = 0; $c < 256; ++$c) {
-            imagecolorallocate($imgalpha, $c, $c, $c);
+            imagecolorallocate($imgalpha, (int) ($c), (int) ($c), (int) ($c));
         }
 
         // Use PECL gmagick + Graphics Magic to process transparent PNG images
@@ -4051,7 +4052,7 @@
 
             // Cast to 8bit+palette
             $imgalpha_ = imagecreatefrompng($tempfile_alpha);
-            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx);
+            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
             imagedestroy($imgalpha_);
             imagepng($imgalpha, $tempfile_alpha);
 
@@ -4084,7 +4085,7 @@
 
             // Cast to 8bit+palette
             $imgalpha_ = imagecreatefrompng($tempfile_alpha);
-            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx);
+            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
             imagedestroy($imgalpha_);
             imagepng($imgalpha, $tempfile_alpha);
 
@@ -4104,8 +4105,8 @@
             // extract alpha channel
             for ($xpx = 0; $xpx < $wpx; ++$xpx) {
                 for ($ypx = 0; $ypx < $hpx; ++$ypx) {
-                    $color = imagecolorat($img, $xpx, $ypx);
-                    $col = imagecolorsforindex($img, $color);
+                    $color = imagecolorat($img, (int) ($xpx), (int) ($ypx));
+                    $col = imagecolorsforindex($img, (int) ($color));
                     $alpha = $col['alpha'];
 
                     if ($eight_bit) {
@@ -4119,22 +4120,22 @@
                         $key = $col['red'] . $col['green'] . $col['blue'];
 
                         if (!isset($allocated_colors[$key])) {
-                            $pixel_img = imagecolorallocate($img, $col['red'], $col['green'], $col['blue']);
+                            $pixel_img = imagecolorallocate($img, (int) ($col['red']), (int) ($col['green']), (int) ($col['blue']));
                             $allocated_colors[$key] = $pixel_img;
                         } else {
                             $pixel_img = $allocated_colors[$key];
                         }
 
-                        imagesetpixel($img, $xpx, $ypx, $pixel_img);
-                    }
-
-                    imagesetpixel($imgalpha, $xpx, $ypx, $pixel);
+                        imagesetpixel($img, (int) ($xpx), (int) ($ypx), (int) ($pixel_img));
+                    }
+
+                    imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), (int) ($pixel));
                 }
             }
 
             // extract image without alpha channel
-            $imgplain = imagecreatetruecolor($wpx, $hpx);
-            imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
+            $imgplain = imagecreatetruecolor((int) ($wpx), (int) ($hpx));
+            imagecopy($imgplain, $img, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
             imagedestroy($img);
 
             imagepng($imgalpha, $tempfile_alpha);
@@ -4168,7 +4169,7 @@
         if (isset($this->imagelist[$file])) {
             $img = null;
         } else {
-            $info = file_get_contents($file, false, null, 24, 5);
+            $info = file_get_contents(($file ?? ''), (false ?? false), null, 24, 5);
             $meta = unpack("CbitDepth/CcolorType/CcompressionMethod/CfilterMethod/CinterlaceMethod", $info);
             $bit_depth = $meta["bitDepth"];
             $color_type = $meta["colorType"];
@@ -4199,21 +4200,21 @@
             }
             $sx = imagesx($imgtmp);
             $sy = imagesy($imgtmp);
-            $img = imagecreatetruecolor($sx, $sy);
+            $img = imagecreatetruecolor((int) ($sx), (int) ($sy));
             imagealphablending($img, true);
 
             // @todo is it still needed ??
             $ti = imagecolortransparent($imgtmp);
             if ($ti >= 0) {
-                $tc = imagecolorsforindex($imgtmp, $ti);
-                $ti = imagecolorallocate($img, $tc['red'], $tc['green'], $tc['blue']);
-                imagefill($img, 0, 0, $ti);
+                $tc = imagecolorsforindex($imgtmp, (int) ($ti));
+                $ti = imagecolorallocate($img, (int) ($tc['red']), (int) ($tc['green']), (int) ($tc['blue']));
+                imagefill($img, 0, 0, (int) ($ti));
                 imagecolortransparent($img, $ti);
             } else {
-                imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255));
+                imagefill($img, 1, 1, (int) (imagecolorallocate($img, 255, 255, 255)));
             }
 
-            imagecopy($img, $imgtmp, 0, 0, 0, 0, $sx, $sy);
+            imagecopy($img, $imgtmp, 0, 0, 0, 0, (int) ($sx), (int) ($sy));
             imagedestroy($imgtmp);
         }
         $this->addImagePng($file, $x, $y, $w, $h, $img);
@@ -4226,7 +4227,7 @@
     /**
      * add a PNG image into the document, from a memory buffer of the file
      */
-    function addPngFromBuf($file, $x, $y, $w = 0.0, $h = 0.0, &$data, $is_mask = false, $mask = null)
+    function addPngFromBuf($file, $x, $y, $w, $h, &$data, $is_mask = false, $mask = null)
     {
         if (isset($this->imagelist[$file])) {
             $data = null;
@@ -4245,7 +4246,7 @@
             if (!$error) {
                 $header = chr(137) . chr(80) . chr(78) . chr(71) . chr(13) . chr(10) . chr(26) . chr(10);
 
-                if (mb_substr($data, 0, 8, '8bit') != $header) {
+                if (mb_substr(($data ?? ''), 0, 8, '8bit') != $header) {
                     $error = 1;
 
                     $errormsg = 'this file does not have a valid header';
@@ -4255,7 +4256,7 @@
             if (!$error) {
                 // set pointer
                 $p = 8;
-                $len = mb_strlen($data, '8bit');
+                $len = mb_strlen(($data ?? ''), '8bit');
 
                 // cycle through the file, identifying chunks
                 $haveHeader = 0;
@@ -4265,18 +4266,18 @@
 
                 while ($p < $len) {
                     $chunkLen = $this->getBytes($data, $p, 4);
-                    $chunkType = mb_substr($data, $p + 4, 4, '8bit');
+                    $chunkType = mb_substr(($data ?? ''), $p + 4, 4, '8bit');
 
                     switch ($chunkType) {
                         case 'IHDR':
                             // this is where all the file information comes from
                             $info['width'] = $this->getBytes($data, $p + 8, 4);
                             $info['height'] = $this->getBytes($data, $p + 12, 4);
-                            $info['bitDepth'] = ord($data[$p + 16]);
-                            $info['colorType'] = ord($data[$p + 17]);
-                            $info['compressionMethod'] = ord($data[$p + 18]);
-                            $info['filterMethod'] = ord($data[$p + 19]);
-                            $info['interlaceMethod'] = ord($data[$p + 20]);
+                            $info['bitDepth'] = ord(($data[$p + 16] ?? ''));
+                            $info['colorType'] = ord(($data[$p + 17] ?? ''));
+                            $info['compressionMethod'] = ord(($data[$p + 18] ?? ''));
+                            $info['filterMethod'] = ord(($data[$p + 19] ?? ''));
+                            $info['interlaceMethod'] = ord(($data[$p + 20] ?? ''));
 
                             //print_r($info);
                             $haveHeader = 1;
@@ -4304,11 +4305,11 @@
                             break;
 
                         case 'PLTE':
-                            $pdata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
+                            $pdata .= mb_substr(($data ?? ''), $p + 8, $chunkLen, '8bit');
                             break;
 
                         case 'IDAT':
-                            $idata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
+                            $idata .= mb_substr(($data ?? ''), $p + 8, $chunkLen, '8bit');
                             break;
 
                         case 'tRNS':
@@ -4330,7 +4331,7 @@
                                     $trans = 0;
 
                                     for ($i = $chunkLen; $i >= 0; $i--) {
-                                        if (ord($data[$p + 8 + $i]) == 0) {
+                                        if (ord(($data[$p + 8 + $i] ?? '')) == 0) {
                                             $trans = $i;
                                         }
                                     }
@@ -4345,7 +4346,7 @@
                 */
                                     //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
                                     $transparency['type'] = 'indexed';
-                                    $transparency['data'] = ord($data[$p + 8 + 1]);
+                                    $transparency['data'] = ord(($data[$p + 8 + 1] ?? ''));
                                     break;
 
                                 // truecolor
@@ -4530,7 +4531,7 @@
                 $channels = 3;
             }
 
-            $data = file_get_contents($img);
+            $data = file_get_contents(($img ?? ''));
         }
 
         if ($w <= 0 && $h <= 0) {
@@ -4555,11 +4556,11 @@
         &$data,
         $x,
         $y,
-        $w = 0,
-        $h = 0,
+        $w,
+        $h,
         $imageWidth,
         $imageHeight,
-        $channels = 3,
+        $channels,
         $imgname
     ) {
         if ($this->image_iscached($imgname)) {
@@ -4701,7 +4702,7 @@
 
             // the user is trying to set a font family
             // note that this can also be used to set the base ones to something else
-            if (mb_strlen($family)) {
+            if (mb_strlen(($family ?? ''))) {
                 $this->fontFamilies[$family] = $options;
             }
         }
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfaceCpdf.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfaceCpdf.php
@@ -150,8 +150,8 @@
     {
         if (self::DEBUG) echo __FUNCTION__ . "\n";
 
-        if (strpos($image, "data:") === 0) {
-            $parts = explode(',', $image, 2);
+        if (strpos(($image ?? ''), "data:") === 0) {
+            $parts = explode(',', ($image ?? ''), 2);
 
             $data = $parts[1];
             $base64 = false;
@@ -166,11 +166,11 @@
             }
 
             if ($base64) {
-                $data = base64_decode($data);
+                $data = base64_decode(($data ?? ''));
             }
         }
         else {
-            $data = file_get_contents($image);
+            $data = file_get_contents(($image ?? ''));
         }
 
         $image = tempnam("", "svg");
@@ -193,9 +193,9 @@
         list($width, $height, $type) = getimagesize($filename);
 
         if ($width == null || $height == null) {
-            $data = file_get_contents($filename, null, null, 0, 26);
-
-            if (substr($data, 0, 2) === "BM") {
+            $data = file_get_contents(($filename ?? ''), (null ?? false), null, 0, 26);
+
+            if (substr(($data ?? ''), 0, 2) === "BM") {
                 $meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
                 $width = (int)$meta['width'];
                 $height = (int)$meta['height'];
@@ -384,7 +384,7 @@
             $canvas->setColor(array((float)$fill[0]/255, (float)$fill[1]/255, (float)$fill[2]/255), true);
         }
 
-        if ($fillRule = strtolower($style->fillRule)) {
+        if ($fillRule = strtolower(($style->fillRule ?? ''))) {
             $canvas->setFillRule($fillRule);
         }
 
@@ -412,7 +412,7 @@
 
         $dashArray = null;
         if ($style->strokeDasharray) {
-            $dashArray = preg_split('/\s*,\s*/', $style->strokeDasharray);
+            $dashArray = preg_split('/\s*,\s*/', ($style->strokeDasharray ?? ''));
         }
 
         $canvas->setLineStyle(
@@ -457,9 +457,9 @@
             ),
         );
 
-        $family = strtolower($family);
-        $style  = strtolower($style);
-        $weight = strtolower($weight);
+        $family = strtolower(($family ?? ''));
+        $style  = strtolower(($style ?? ''));
+        $weight = strtolower(($weight ?? ''));
 
         if (isset($map[$family])) {
             $family = $map[$family];
--- a/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfaceGmagick.php
+++ b/intranet/marketplaces-api/vendor/phenx/php-svg-lib/src/Svg/Surface/SurfaceGmagick.php
@@ -50,7 +50,7 @@
 
         $image->write($tmp);
 
-        return file_get_contents($tmp);
+        return file_get_contents(($tmp ?? ''));
     }
 
     public function save()
@@ -132,10 +132,10 @@
     {
         if (self::DEBUG) echo __FUNCTION__ . "\n";
 
-        if (strpos($image, "data:") === 0) {
-            $data = substr($image, strpos($image, ";") + 1);
-            if (strpos($data, "base64") === 0) {
-                $data = base64_decode(substr($data, 7));
+        if (strpos(($image ?? ''), "data:") === 0) {
+            $data = substr(($image ?? ''), strpos(($image ?? ''), ";") + 1);
+            if (strpos(($data ?? ''), "base64") === 0) {
+                $data = base64_decode((substr(($data ?? ''), 7) ?? ''));
             }
 
             $image = tempnam("", "svg");
@@ -293,7 +293,7 @@
             "monospance" => "Courier",
         );
 
-        $family = strtolower($family);
+        $family = strtolower(($family ?? ''));
         if (isset($map[$family])) {
             $family = $map[$family];
         }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/Cpdf.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/Cpdf.php
@@ -18,6 +18,7 @@
 use FontLib\Font;
 use FontLib\BinaryStream;
 
+#[\AllowDynamicProperties]
 class Cpdf
 {
 
@@ -343,7 +344,7 @@
     function __construct($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '')
     {
         $this->isUnicode = $isUnicode;
-        $this->fontcache = rtrim($fontcache, DIRECTORY_SEPARATOR."/\\");
+        $this->fontcache = rtrim(($fontcache ?? ''), DIRECTORY_SEPARATOR."/\\");
         $this->tmp = ($tmp !== '' ? $tmp : sys_get_temp_dir());
         $this->newDocument($pageSize);
 
@@ -648,7 +649,7 @@
                             }
 
                             if ($k >= 0) {
-                                for ($j = count($o['info']['pages']) - 1; $j >= $k; $j--) {
+                                for ($j = count(($o['info']['pages'] ?? [])) - 1; $j >= $k; $j--) {
                                     $o['info']['pages'][$j + 1] = $o['info']['pages'][$j];
                                 }
 
@@ -682,17 +683,17 @@
                 break;
 
             case 'out':
-                if (count($o['info']['pages'])) {
+                if (count(($o['info']['pages'] ?? []))) {
                     $res = "\n$id 0 obj\n<< /Type /Pages\n/Kids [";
                     foreach ($o['info']['pages'] as $v) {
                         $res .= "$v 0 R\n";
                     }
 
-                    $res .= "]\n/Count " . count($this->objects[$id]['info']['pages']);
-
-                    if ((isset($o['info']['fonts']) && count($o['info']['fonts'])) ||
+                    $res .= "]\n/Count " . count(($this->objects[$id]['info']['pages'] ?? []));
+
+                    if ((isset($o['info']['fonts']) && count(($o['info']['fonts'] ?? []))) ||
                         isset($o['info']['procset']) ||
-                        (isset($o['info']['extGStates']) && count($o['info']['extGStates']))
+                        (isset($o['info']['extGStates']) && count(($o['info']['extGStates'] ?? [])))
                     ) {
                         $res .= "\n/Resources <<";
 
@@ -700,7 +701,7 @@
                             $res .= "\n/ProcSet " . $o['info']['procset'] . " 0 R";
                         }
 
-                        if (isset($o['info']['fonts']) && count($o['info']['fonts'])) {
+                        if (isset($o['info']['fonts']) && count(($o['info']['fonts'] ?? []))) {
                             $res .= "\n/Font << ";
                             foreach ($o['info']['fonts'] as $finfo) {
                                 $res .= "\n/F" . $finfo['fontNum'] . " " . $finfo['objNum'] . " 0 R";
@@ -708,7 +709,7 @@
                             $res .= "\n>>";
                         }
 
-                        if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) {
+                        if (isset($o['info']['xObjects']) && count(($o['info']['xObjects'] ?? []))) {
                             $res .= "\n/XObject << ";
                             foreach ($o['info']['xObjects'] as $finfo) {
                                 $res .= "\n/" . $finfo['label'] . " " . $finfo['objNum'] . " 0 R";
@@ -716,7 +717,7 @@
                             $res .= "\n>>";
                         }
 
-                        if (isset($o['info']['extGStates']) && count($o['info']['extGStates'])) {
+                        if (isset($o['info']['extGStates']) && count(($o['info']['extGStates'] ?? []))) {
                             $res .= "\n/ExtGState << ";
                             foreach ($o['info']['extGStates'] as $gstate) {
                                 $res .= "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
@@ -773,13 +774,13 @@
                 break;
 
             case 'out':
-                if (count($o['info']['outlines'])) {
+                if (count(($o['info']['outlines'] ?? []))) {
                     $res = "\n$id 0 obj\n<< /Type /Outlines /Kids [";
                     foreach ($o['info']['outlines'] as $v) {
                         $res .= "$v 0 R ";
                     }
 
-                    $res .= "] /Count " . count($o['info']['outlines']) . " >>\nendobj";
+                    $res .= "] /Count " . count(($o['info']['outlines'] ?? [])) . " >>\nendobj";
                 } else {
                     $res = "\n$id 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
                 }
@@ -1002,7 +1003,7 @@
 EOT;
 
                 $res = "\n$id 0 obj\n";
-                $res .= "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
+                $res .= "<</Length " . mb_strlen(($stream ?? ''), '8bit') . " >>\n";
                 $res .= "stream\n" . $stream . "\nendstream" . "\nendobj";;
 
                 return $res;
@@ -1047,7 +1048,7 @@
                         case 'StemH':
                         case 'XHeight':
                         case 'CharSet':
-                            if (mb_strlen($value, '8bit')) {
+                            if (mb_strlen(($value ?? ''), '8bit')) {
                                 $res .= "/$label $value\n";
                             }
 
@@ -1285,7 +1286,7 @@
             case 'out':
                 $res = "\n$id 0 obj\n";
                 $fontFileName = $o['info']['fontFileName'];
-                $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode($this->fonts[$fontFileName]['CIDtoGID']);
+                $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode(($this->fonts[$fontFileName]['CIDtoGID'] ?? ''));
 
                 $compressed = isset($this->fonts[$fontFileName]['CIDtoGID_Compressed']) &&
                     $this->fonts[$fontFileName]['CIDtoGID_Compressed'];
@@ -1309,7 +1310,7 @@
                         $tmp = $this->ARC4($tmp);
                     }
 
-                    $res .= "\n/Length " . mb_strlen($tmp, '8bit') . ">>\nstream\n$tmp\nendstream";
+                    $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . ">>\nstream\n$tmp\nendstream";
                 }
 
                 $res .= "\nendobj";
@@ -1645,7 +1646,7 @@
                     $res .= " ]";
                 }
 
-                $count = count($o['info']['contents']);
+                $count = count(($o['info']['contents'] ?? []));
                 if ($count == 1) {
                     $res .= "\n/Contents " . $o['info']['contents'][0] . " 0 R";
                 } else {
@@ -1687,7 +1688,7 @@
         switch ($action) {
             case 'new':
                 $this->objects[$id] = array('t' => 'contents', 'c' => '', 'info' => array());
-                if (mb_strlen($options, '8bit') && intval($options)) {
+                if (mb_strlen(($options ?? ''), '8bit') && intval($options)) {
                     // then this contents is the primary for a page
                     $this->objects[$id]['onPage'] = $options;
                 } else {
@@ -1727,7 +1728,7 @@
                         $res .= "\n/$k $v";
                     }
 
-                    $res .= "\n/Length " . mb_strlen($tmp, '8bit') . " >>\nstream\n$tmp\nendstream";
+                    $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . " >>\nstream\n$tmp\nendstream";
                 }
 
                 $res .= "\nendobj";
@@ -1860,8 +1861,8 @@
                         if ($options['isMask']) {
                             $info['ColorSpace'] = '/DeviceGray';
                         } else {
-                            if (mb_strlen($options['pdata'], '8bit')) {
-                                $tmp = ' [ /Indexed /DeviceRGB ' . (mb_strlen($options['pdata'], '8bit') / 3 - 1) . ' ';
+                            if (mb_strlen(($options['pdata'] ?? ''), '8bit')) {
+                                $tmp = ' [ /Indexed /DeviceRGB ' . (mb_strlen(($options['pdata'] ?? ''), '8bit') / 3 - 1) . ' ';
                                 $this->numObj++;
                                 $this->o_contents($this->numObj, 'new');
                                 $this->objects[$this->numObj]['c'] = $options['pdata'];
@@ -1937,7 +1938,7 @@
                     $tmp = $this->ARC4($tmp);
                 }
 
-                $res .= "\n/Length " . mb_strlen($tmp, '8bit') . ">>\nstream\n$tmp\nendstream\nendobj";
+                $res .= "\n/Length " . mb_strlen(($tmp ?? ''), '8bit') . ">>\nstream\n$tmp\nendstream\nendobj";
 
                 return $res;
         }
@@ -2038,41 +2039,41 @@
 
                 $info = $this->objects[$id]['info'];
 
-                $len = mb_strlen($info['owner'], '8bit');
+                $len = mb_strlen(($info['owner'] ?? ''), '8bit');
 
                 if ($len > 32) {
-                    $owner = substr($info['owner'], 0, 32);
+                    $owner = substr(($info['owner'] ?? ''), 0, 32);
                 } else {
                     if ($len < 32) {
-                        $owner = $info['owner'] . substr($pad, 0, 32 - $len);
+                        $owner = $info['owner'] . substr(($pad ?? ''), 0, 32 - $len);
                     } else {
                         $owner = $info['owner'];
                     }
                 }
 
-                $len = mb_strlen($info['user'], '8bit');
+                $len = mb_strlen(($info['user'] ?? ''), '8bit');
                 if ($len > 32) {
-                    $user = substr($info['user'], 0, 32);
+                    $user = substr(($info['user'] ?? ''), 0, 32);
                 } else {
                     if ($len < 32) {
-                        $user = $info['user'] . substr($pad, 0, 32 - $len);
+                        $user = $info['user'] . substr(($pad ?? ''), 0, 32 - $len);
                     } else {
                         $user = $info['user'];
                     }
                 }
 
                 $tmp = $this->md5_16($owner);
-                $okey = substr($tmp, 0, 5);
+                $okey = substr(($tmp ?? ''), 0, 5);
                 $this->ARC4_init($okey);
                 $ovalue = $this->ARC4($user);
                 $this->objects[$id]['info']['O'] = $ovalue;
 
                 // now make the u value, phew.
                 $tmp = $this->md5_16(
-                    $user . $ovalue . chr($info['p']) . chr(255) . chr(255) . chr(255) . hex2bin($this->fileIdentifier)
+                    $user . $ovalue . chr((int) ($info['p'])) . chr(255) . chr(255) . chr(255) . hex2bin(($this->fileIdentifier ?? ''))
                 );
 
-                $ukey = substr($tmp, 0, 5);
+                $ukey = substr(($tmp ?? ''), 0, 5);
                 $this->ARC4_init($ukey);
                 $this->encryptionKey = $ukey;
                 $this->encrypted = true;
@@ -2114,10 +2115,10 @@
      */
     function md5_16($string)
     {
-        $tmp = md5($string);
+        $tmp = md5(($string ?? ''));
         $out = '';
         for ($i = 0; $i <= 30; $i = $i + 2) {
-            $out .= chr(hexdec(substr($tmp, $i, 2)));
+            $out .= chr((int) (hexdec(substr(($tmp ?? ''), $i, 2))));
         }
 
         return $out;
@@ -2132,17 +2133,17 @@
     {
         $tmp = $this->encryptionKey;
         $hex = dechex($id);
-        if (mb_strlen($hex, '8bit') < 6) {
-            $hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')) . $hex;
-        }
-        $tmp .= chr(hexdec(substr($hex, 4, 2)))
-            . chr(hexdec(substr($hex, 2, 2)))
-            . chr(hexdec(substr($hex, 0, 2)))
+        if (mb_strlen(($hex ?? ''), '8bit') < 6) {
+            $hex = substr('000000', 0, 6 - mb_strlen(($hex ?? ''), '8bit')) . $hex;
+        }
+        $tmp .= chr((int) (hexdec(substr(($hex ?? ''), 4, 2))))
+            . chr((int) (hexdec(substr(($hex ?? ''), 2, 2))))
+            . chr((int) (hexdec(substr(($hex ?? ''), 0, 2))))
             . chr(0)
             . chr(0)
         ;
         $key = $this->md5_16($tmp);
-        $this->ARC4_init(substr($key, 0, 10));
+        $this->ARC4_init(substr(($key ?? ''), 0, 10));
     }
 
     /**
@@ -2155,25 +2156,25 @@
         $this->arc4 = '';
 
         // setup the control array
-        if (mb_strlen($key, '8bit') == 0) {
+        if (mb_strlen(($key ?? ''), '8bit') == 0) {
             return;
         }
 
         $k = '';
-        while (mb_strlen($k, '8bit') < 256) {
+        while (mb_strlen(($k ?? ''), '8bit') < 256) {
             $k .= $key;
         }
 
-        $k = substr($k, 0, 256);
+        $k = substr(($k ?? ''), 0, 256);
         for ($i = 0; $i < 256; $i++) {
-            $this->arc4 .= chr($i);
+            $this->arc4 .= chr((int) ($i));
         }
 
         $j = 0;
 
         for ($i = 0; $i < 256; $i++) {
             $t = $this->arc4[$i];
-            $j = ($j + ord($t) + ord($k[$i])) % 256;
+            $j = ($j + ord(($t ?? '')) + ord(($k[$i] ?? ''))) % 256;
             $this->arc4[$i] = $this->arc4[$j];
             $this->arc4[$j] = $t;
         }
@@ -2187,7 +2188,7 @@
      */
     function ARC4($text)
     {
-        $len = mb_strlen($text, '8bit');
+        $len = mb_strlen(($text ?? ''), '8bit');
         $a = 0;
         $b = 0;
         $c = $this->arc4;
@@ -2195,11 +2196,11 @@
         for ($i = 0; $i < $len; $i++) {
             $a = ($a + 1) % 256;
             $t = $c[$a];
-            $b = ($b + ord($t)) % 256;
+            $b = ($b + ord(($t ?? ''))) % 256;
             $c[$a] = $c[$b];
             $c[$b] = $t;
-            $k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
-            $out .= chr(ord($text[$i]) ^ $k);
+            $k = ord(($c[(ord(($c[$a] ?? '')) + ord(($c[$b] ?? ''))) % 256] ?? ''));
+            $out .= chr((int) (ord(($text[$i] ?? '')) ^ $k));
         }
 
         return $out;
@@ -2270,7 +2271,7 @@
         if ($this->arc4_objnum == 0) {
             // then the block does not exist already, add it.
             $this->numObj++;
-            if (mb_strlen($ownerPass) == 0) {
+            if (mb_strlen(($ownerPass ?? '')) == 0) {
                 $ownerPass = $userPass;
             }
 
@@ -2324,24 +2325,24 @@
 
         $xref = array();
         $content = '%PDF-1.3';
-        $pos = mb_strlen($content, '8bit');
+        $pos = mb_strlen(($content ?? ''), '8bit');
 
         foreach ($this->objects as $k => $v) {
             $tmp = 'o_' . $v['t'];
             $cont = $this->$tmp($k, 'out');
             $content .= $cont;
             $xref[] = $pos + 1; //+1 to account for \n at the start of each object
-            $pos += mb_strlen($cont, '8bit');
-        }
-
-        $content .= "\nxref\n0 " . (count($xref) + 1) . "\n0000000000 65535 f \n";
+            $pos += mb_strlen(($cont ?? ''), '8bit');
+        }
+
+        $content .= "\nxref\n0 " . (count(($xref ?? [])) + 1) . "\n0000000000 65535 f \n";
 
         foreach ($xref as $p) {
-            $content .= str_pad($p, 10, "0", STR_PAD_LEFT) . " 00000 n \n";
+            $content .= str_pad(($p ?? ''), 10, "0", STR_PAD_LEFT) . " 00000 n \n";
         }
 
         $content .= "trailer\n<<\n" .
-            '/Size ' . (count($xref) + 1) . "\n" .
+            '/Size ' . (count(($xref ?? [])) + 1) . "\n" .
             '/Root 1 0 R' . "\n" .
             '/Info ' . $this->infoObject . " 0 R\n"
         ;
@@ -2416,7 +2417,7 @@
 
         $fontcache = $this->fontcache;
         if ($fontcache == '') {
-            $fontcache = rtrim($dir, DIRECTORY_SEPARATOR."/\\");
+            $fontcache = rtrim(($dir ?? ''), DIRECTORY_SEPARATOR."/\\");
         }
 
         //$name       filename without folder and extension of font metrics
@@ -2470,7 +2471,7 @@
 
             // Since we're not going to enable Unicode for the core fonts we need to use a font-based
             // setting for Unicode support rather than a global setting.
-            $data['isUnicode'] = (strtolower(substr($metrics_name, -3)) !== 'afm');
+            $data['isUnicode'] = (strtolower((substr(($metrics_name ?? ''), -3) ?? '')) !== 'afm');
 
             $cidtogid = '';
             if ($data['isUnicode']) {
@@ -2480,12 +2481,12 @@
             $file = file($dir . $metrics_name);
 
             foreach ($file as $rowA) {
-                $row = trim($rowA);
-                $pos = strpos($row, ' ');
+                $row = trim(($rowA ?? ''));
+                $pos = strpos(($row ?? ''), ' ');
 
                 if ($pos) {
                     // then there must be some keyword
-                    $key = substr($row, 0, $pos);
+                    $key = substr(($row ?? ''), 0, $pos);
                     switch ($key) {
                         case 'FontName':
                         case 'FullName':
@@ -2507,31 +2508,31 @@
                         case 'StdVW':
                         case 'StartCharMetrics':
                         case 'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font.  Otherwise it's too big.
-                            $data[$key] = trim(substr($row, $pos));
+                            $data[$key] = trim((substr(($row ?? ''), $pos) ?? ''));
                             break;
 
                         case 'FontBBox':
-                            $data[$key] = explode(' ', trim(substr($row, $pos)));
+                            $data[$key] = explode(' ', (trim((substr(($row ?? ''), $pos) ?? '')) ?? ''));
                             break;
 
                         //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ;
                         case 'C': // Found in AFM files
-                            $bits = explode(';', trim($row));
+                            $bits = explode(';', (trim(($row ?? '')) ?? ''));
                             $dtmp = array();
 
                             foreach ($bits as $bit) {
-                                $bits2 = explode(' ', trim($bit));
-                                if (mb_strlen($bits2[0], '8bit') == 0) {
+                                $bits2 = explode(' ', (trim(($bit ?? '')) ?? ''));
+                                if (mb_strlen(($bits2[0] ?? ''), '8bit') == 0) {
                                     continue;
                                 }
 
-                                if (count($bits2) > 2) {
+                                if (count(($bits2 ?? [])) > 2) {
                                     $dtmp[$bits2[0]] = array();
-                                    for ($i = 1; $i < count($bits2); $i++) {
+                                    for ($i = 1; $i < count(($bits2 ?? [])); $i++) {
                                         $dtmp[$bits2[0]][] = $bits2[$i];
                                     }
                                 } else {
-                                    if (count($bits2) == 2) {
+                                    if (count(($bits2 ?? [])) == 2) {
                                         $dtmp[$bits2[0]] = $bits2[1];
                                     }
                                 }
@@ -2562,22 +2563,22 @@
                                 break;
                             }
 
-                            $bits = explode(';', trim($row));
+                            $bits = explode(';', (trim(($row ?? '')) ?? ''));
                             $dtmp = array();
 
                             foreach ($bits as $bit) {
-                                $bits2 = explode(' ', trim($bit));
-                                if (mb_strlen($bits2[0], '8bit') === 0) {
+                                $bits2 = explode(' ', (trim(($bit ?? '')) ?? ''));
+                                if (mb_strlen(($bits2[0] ?? ''), '8bit') === 0) {
                                     continue;
                                 }
 
-                                if (count($bits2) > 2) {
+                                if (count(($bits2 ?? [])) > 2) {
                                     $dtmp[$bits2[0]] = array();
-                                    for ($i = 1; $i < count($bits2); $i++) {
+                                    for ($i = 1; $i < count(($bits2 ?? [])); $i++) {
                                         $dtmp[$bits2[0]][] = $bits2[$i];
                                     }
                                 } else {
-                                    if (count($bits2) == 2) {
+                                    if (count(($bits2 ?? [])) == 2) {
                                         $dtmp[$bits2[0]] = $bits2[1];
                                     }
                                 }
@@ -2591,8 +2592,8 @@
                             if ($c >= 0) {
                                 // Set values in CID to GID map
                                 if ($c >= 0 && $c < 0xFFFF && $glyph) {
-                                    $cidtogid[$c * 2] = chr($glyph >> 8);
-                                    $cidtogid[$c * 2 + 1] = chr($glyph & 0xFF);
+                                    $cidtogid[$c * 2] = chr((int) ($glyph >> 8));
+                                    $cidtogid[$c * 2 + 1] = chr((int) ($glyph & 0xFF));
                                 }
 
                                 if ($c != hexdec($n)) {
@@ -2624,7 +2625,7 @@
                 $data['CIDtoGID_Compressed'] = true;
                 $cidtogid = gzcompress($cidtogid, 6);
             }
-            $data['CIDtoGID'] = base64_encode($cidtogid);
+            $data['CIDtoGID'] = base64_encode(($cidtogid ?? ''));
             $data['_version_'] = $this->fontcacheVersion;
             $this->fonts[$font] = $data;
 
@@ -2657,9 +2658,9 @@
      */
     function selectFont($fontName, $encoding = '', $set = true)
     {
-        $ext = substr($fontName, -4);
+        $ext = substr(($fontName ?? ''), -4);
         if ($ext === '.afm' || $ext === '.ufm') {
-            $fontName = substr($fontName, 0, mb_strlen($fontName) - 4);
+            $fontName = substr(($fontName ?? ''), 0, mb_strlen(($fontName ?? '')) - 4);
         }
 
         if (!isset($this->fonts[$fontName])) {
@@ -2688,7 +2689,7 @@
                         $options['differences'] = $encoding['differences'];
                     }
                 } else {
-                    if (mb_strlen($encoding, '8bit')) {
+                    if (mb_strlen(($encoding ?? ''), '8bit')) {
                         // then perhaps only the encoding has been set
                         $options['encoding'] = $encoding;
                     }
@@ -2808,7 +2809,7 @@
                     if (isset($font['StdVW'])) {
                         $stemV = $font['StdVW'];
                     } else {
-                        if (isset($font['Weight']) && preg_match('!(bold|black)!i', $font['Weight'])) {
+                        if (isset($font['Weight']) && preg_match('!(bold|black)!i', ($font['Weight'] ?? ''))) {
                             $stemV = 120;
                         }
                     }
@@ -2817,8 +2818,8 @@
                     // note that pdf supports only binary format type 1 font files, though there is a
                     // simple utility to convert them from pfa to pfb.
                     // FIXME: should we move font subset creation to CPDF::output? See notes in issue #750.
-                    if (!$this->isUnicode || strtolower($fbtype) !== 'ttf' || empty($this->stringSubsets)) {
-                        $data = file_get_contents($fbfile);
+                    if (!$this->isUnicode || strtolower(($fbtype ?? '')) !== 'ttf' || empty($this->stringSubsets)) {
+                        $data = file_get_contents(($fbfile ?? ''));
                     } else {
                         $this->stringSubsets[$fontName][] = 32; // Force space if not in yet
 
@@ -2861,20 +2862,20 @@
                             $font['CIDWidths'] = array();
                             foreach ($glyphIndexArray as $cid => $gid) {
                                 if ($cid >= 0 && $cid < 0xFFFF && $gid) {
-                                    $cidtogid[$cid * 2] = chr($gid >> 8);
-                                    $cidtogid[$cid * 2 + 1] = chr($gid & 0xFF);
+                                    $cidtogid[$cid * 2] = chr((int) ($gid >> 8));
+                                    $cidtogid[$cid * 2 + 1] = chr((int) ($gid & 0xFF));
                                 }
 
                                 $width = $font_obj->normalizeFUnit(isset($hmtx[$gid]) ? $hmtx[$gid][0] : $hmtx[0][0]);
                                 $font['CIDWidths'][$cid] = $width;
                             }
 
-                            $font['CIDtoGID'] = base64_encode(gzcompress($cidtogid));
+                            $font['CIDtoGID'] = base64_encode((gzcompress($cidtogid) ?? ''));
                             $font['CIDtoGID_Compressed'] = true;
 
-                            $data = file_get_contents($tmp_name);
+                            $data = file_get_contents(($tmp_name ?? ''));
                         } else {
-                            $data = file_get_contents($fbfile);
+                            $data = file_get_contents(($fbfile ?? ''));
                         }
 
                         $font_obj->close();
@@ -2920,9 +2921,9 @@
                         }
                     }
 
-                    if (strtolower($fbtype) === 'pfb') {
+                    if (strtolower(($fbtype ?? '')) === 'pfb') {
                         $fdopt['FontFile'] = $pfbid;
-                    } elseif (strtolower($fbtype) === 'ttf') {
+                    } elseif (strtolower(($fbtype ?? '')) === 'ttf') {
                         $fdopt['FontFile2'] = $pfbid;
                     }
 
@@ -2933,17 +2934,17 @@
                     $this->objects[$pfbid]['c'] .= $data;
 
                     // determine the cruicial lengths within this file
-                    if (strtolower($fbtype) === 'pfb') {
-                        $l1 = strpos($data, 'eexec') + 6;
-                        $l2 = strpos($data, '00000000') - $l1;
-                        $l3 = mb_strlen($data, '8bit') - $l2 - $l1;
+                    if (strtolower(($fbtype ?? '')) === 'pfb') {
+                        $l1 = strpos(($data ?? ''), 'eexec') + 6;
+                        $l2 = strpos(($data ?? ''), '00000000') - $l1;
+                        $l3 = mb_strlen(($data ?? ''), '8bit') - $l2 - $l1;
                         $this->o_contents(
                             $this->numObj,
                             'add',
                             array('Length1' => $l1, 'Length2' => $l2, 'Length3' => $l3)
                         );
-                    } elseif (strtolower($fbtype) == 'ttf') {
-                        $l1 = mb_strlen($data, '8bit');
+                    } elseif (strtolower(($fbtype ?? '')) == 'ttf') {
+                        $l1 = mb_strlen(($data ?? ''), '8bit');
                         $this->o_contents($this->numObj, 'add', array('Length1' => $l1));
                     }
 
@@ -2957,7 +2958,7 @@
                         'FontDescriptor' => $fontDescriptorId
                     );
 
-                    if (strtolower($fbtype) === 'ttf') {
+                    if (strtolower(($fbtype ?? '')) === 'ttf') {
                         $tmp['SubType'] = 'TrueType';
                     }
 
@@ -3860,7 +3861,7 @@
         }
 
         // if there is a line style set, then put this in too
-        if (mb_strlen($this->currentLineStyle, '8bit')) {
+        if (mb_strlen(($this->currentLineStyle ?? ''), '8bit')) {
             $this->addContent("\n$this->currentLineStyle");
         }
 
@@ -3884,19 +3885,19 @@
         if (!isset($options["Attachment"])) $options["Attachment"] = true;
 
         $debug = !$options['compress'];
-        $tmp = ltrim($this->output($debug));
+        $tmp = ltrim(($this->output($debug) ?? ''));
 
         header("Cache-Control: private");
         header("Content-Type: application/pdf");
-        header("Content-Length: " . mb_strlen($tmp, "8bit"));
-
-        $filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
+        header("Content-Length: " . mb_strlen(($tmp ?? ''), "8bit"));
+
+        $filename = str_replace(array("\n", "'"), "", (basename($filename, ".pdf") ?? '')) . ".pdf";
         $attachment = $options["Attachment"] ? "attachment" : "inline";
 
         $encoding = mb_detect_encoding($filename);
-        $fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding);
-        $fallbackfilename = str_replace("\"", "", $fallbackfilename);
-        $encodedfilename = rawurlencode($filename);
+        $fallbackfilename = mb_convert_encoding(($filename ?? ''), "ISO-8859-1", $encoding);
+        $fallbackfilename = str_replace("\"", "", ($fallbackfilename ?? ''));
+        $encodedfilename = rawurlencode(($filename ?? ''));
 
         $contentDisposition = "Content-Disposition: $attachment; filename=\"$fallbackfilename\"";
         if ($fallbackfilename !== $filename) {
@@ -4011,14 +4012,14 @@
                 $text = $this->utf8toUtf16BE($text, $bom);
             } else {
                 //$text = html_entity_decode($text, ENT_QUOTES);
-                $text = mb_convert_encoding($text, self::$targetEncoding, 'UTF-8');
+                $text = mb_convert_encoding(($text ?? ''), (self::$targetEncoding ?? ''), 'UTF-8');
             }
         } else if ($bom) {
             $text = $this->utf8toUtf16BE($text, $bom);
         }
 
         // the chr(13) substitution fixes a bug seen in TCPDF (bug #1421290)
-        return strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
+        return strtr(($text ?? ''), array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
     }
 
     /**
@@ -4038,14 +4039,14 @@
      */
     function utf8toCodePointsArray(&$text)
     {
-        $length = mb_strlen($text, '8bit'); // http://www.php.net/manual/en/function.mb-strlen.php#77040
+        $length = mb_strlen(($text ?? ''), '8bit'); // http://www.php.net/manual/en/function.mb-strlen.php#77040
         $unicode = array(); // array containing unicode values
         $bytes = array(); // array containing single character byte sequences
         $numbytes = 1; // number of octets needed to represent the UTF-8 character
 
         for ($i = 0; $i < $length; $i++) {
-            $c = ord($text[$i]); // get one string character at time
-            if (count($bytes) === 0) { // get starting octect
+            $c = ord(($text[$i] ?? '')); // get one string character at time
+            if (count(($bytes ?? [])) === 0) { // get starting octect
                 if ($c <= 0x7F) {
                     $unicode[] = $c; // use the character "as is" because is ASCII
                     $numbytes = 1;
@@ -4066,7 +4067,7 @@
                 }
             } elseif (($c >> 0x06) === 0x02) { // bytes 2, 3 and 4 must start with 0x02 = 10 BIN
                 $bytes[] = $c - 0x80;
-                if (count($bytes) === $numbytes) {
+                if (count(($bytes ?? [])) === $numbytes) {
                     // compose UTF-8 bytes to a single unicode value
                     $c = $bytes[0];
                     for ($j = 1; $j < $numbytes; $j++) {
@@ -4121,12 +4122,12 @@
             if ($c === 0xFFFD) {
                 $out .= "\xFF\xFD"; // replacement character
             } elseif ($c < 0x10000) {
-                $out .= chr($c >> 0x08) . chr($c & 0xFF);
+                $out .= chr((int) ($c >> 0x08)) . chr((int) ($c & 0xFF));
             } else {
                 $c -= 0x10000;
                 $w1 = 0xD800 | ($c >> 0x10);
                 $w2 = 0xDC00 | ($c & 0x3FF);
-                $out .= chr($w1 >> 0x08) . chr($w1 & 0xFF) . chr($w2 >> 0x08) . chr($w2 & 0xFF);
+                $out .= chr((int) ($w1 >> 0x08)) . chr((int) ($w1 & 0xFF)) . chr((int) ($w2 >> 0x08)) . chr((int) ($w2 & 0xFF));
             }
         }
 
@@ -4151,8 +4152,8 @@
         $w = $this->getTextWidth($size, $text);
 
         // need to adjust for the number of spaces in this text
-        $words = explode(' ', $text);
-        $nspaces = count($words) - 1;
+        $words = explode(' ', ($text ?? ''));
+        $nspaces = count(($words ?? [])) - 1;
         $w += $wa * $nspaces;
         $a = deg2rad((float)$angle);
 
@@ -4220,14 +4221,14 @@
             $this->selectFont($this->defaultFont);
         }
 
-        $text = str_replace(array("\r", "\n"), "", $text);
+        $text = str_replace(array("\r", "\n"), "", ($text ?? ''));
 
         if ($smallCaps) {
-            preg_match_all("/(\P{Ll}+)/u", $text, $matches, PREG_SET_ORDER);
+            preg_match_all("/(\P{Ll}+)/u", ($text ?? ''), $matches, PREG_SET_ORDER);
             $lower = $this->concatMatches($matches);
             d($lower);
 
-            preg_match_all("/(\p{Ll}+)/u", $text, $matches, PREG_SET_ORDER);
+            preg_match_all("/(\p{Ll}+)/u", ($text ?? ''), $matches, PREG_SET_ORDER);
             $other = $this->concatMatches($matches);
             d($other);
 
@@ -4271,7 +4272,7 @@
             $this->addContent(sprintf(" %.3F Tc", $charSpaceAdjust));
         }
 
-        $len = mb_strlen($text);
+        $len = mb_strlen(($text ?? ''));
         $start = 0;
 
         if ($start < $len) {
@@ -4281,7 +4282,7 @@
             $cf = $this->currentFont;
             if ($this->fonts[$cf]['isUnicode'] && $wordSpaceAdjust != 0) {
                 $space_scale = 1000 / $size;
-                $place_text = str_replace("\x00\x20", "\x00\x20)\x00\x20" . (-round($space_scale * $wordSpaceAdjust)) . "\x00\x20(", $place_text);
+                $place_text = str_replace("\x00\x20", "\x00\x20)\x00\x20" . (-round($space_scale * $wordSpaceAdjust)) . "\x00\x20(", ($place_text ?? ''));
             }
             $this->addContent(" /F$this->currentFontNum " . sprintf('%.1F Tf ', $size));
             $this->addContent(" [($place_text)] TJ");
@@ -4341,7 +4342,7 @@
             $this->selectFont($this->defaultFont);
         }
 
-        $text = str_replace(array("\r", "\n"), "", $text);
+        $text = str_replace(array("\r", "\n"), "", ($text ?? ''));
 
         // converts a number or a float to a string so it can get the width
         $text = "$text";
@@ -4381,20 +4382,20 @@
 
             // add additional char spacing
             if ($char_spacing != 0) {
-                $w += $char_spacing * $space_scale * (count($unicode) + $n_spaces);
+                $w += $char_spacing * $space_scale * (count(($unicode ?? [])) + $n_spaces);
             }
 
         } else {
             // If CPDF is in Unicode mode but the current font does not support Unicode we need to convert the character set to Windows-1252
             if ($this->isUnicode) {
-                $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
+                $text = mb_convert_encoding(($text ?? ''), 'Windows-1252', 'UTF-8');
             }
 
-            $len = mb_strlen($text, 'Windows-1252');
+            $len = mb_strlen(($text ?? ''), 'Windows-1252');
 
             for ($i = 0; $i < $len; $i++) {
                 $c = $text[$i];
-                $char = isset($ord_cache[$c]) ? $ord_cache[$c] : ($ord_cache[$c] = ord($c));
+                $char = isset($ord_cache[$c]) ? $ord_cache[$c] : ($ord_cache[$c] = ord(($c ?? '')));
 
                 // check if we have to replace character
                 if (isset($current_font['differences'][$char])) {
@@ -4688,7 +4689,7 @@
         $ret = 0;
         for ($i = 0; $i < $num; $i++) {
             $ret *= 256;
-            $ret += ord($data[$pos + $i]);
+            $ret += ord(($data[$pos + $i] ?? ''));
         }
 
         return $ret;
@@ -4720,7 +4721,7 @@
      * @param bool $mask true if the image is masked
      * @throws Exception
      */
-    function addImagePng($file, $x, $y, $w = 0.0, $h = 0.0, &$img, $is_mask = false, $mask = null)
+    function addImagePng($file, $x, $y, $w, $h, &$img, $is_mask = false, $mask = null)
     {
         if (!function_exists("imagepng")) {
             throw new \Exception("The PHP GD extension is required, but is not installed.");
@@ -4810,12 +4811,12 @@
         @unlink($tempfile_plain);
         $tempfile_plain = "$tempfile_plain.png";
 
-        $imgalpha = imagecreate($wpx, $hpx);
+        $imgalpha = imagecreate((int) ($wpx), (int) ($hpx));
         imagesavealpha($imgalpha, false);
 
         // generate gray scale palette (0 -> 255)
         for ($c = 0; $c < 256; ++$c) {
-            imagecolorallocate($imgalpha, $c, $c, $c);
+            imagecolorallocate($imgalpha, (int) ($c), (int) ($c), (int) ($c));
         }
 
         // Use PECL gmagick + Graphics Magic to process transparent PNG images
@@ -4836,7 +4837,7 @@
 
             // Cast to 8bit+palette
             $imgalpha_ = imagecreatefrompng($tempfile_alpha);
-            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx);
+            imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
             imagedestroy($imgalpha_);
             imagepng($imgalpha, $tempfile_alpha);
 
@@ -4871,7 +4872,7 @@
 
                 // Cast to 8bit+palette
                 $imgalpha_ = imagecreatefrompng($tempfile_alpha);
-                imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx);
+                imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
                 imagedestroy($imgalpha_);
                 imagepng($imgalpha, $tempfile_alpha);
             } else {
@@ -4894,8 +4895,8 @@
             // extract alpha channel
             for ($xpx = 0; $xpx < $wpx; ++$xpx) {
                 for ($ypx = 0; $ypx < $hpx; ++$ypx) {
-                    $color = imagecolorat($img, $xpx, $ypx);
-                    $col = imagecolorsforindex($img, $color);
+                    $color = imagecolorat($img, (int) ($xpx), (int) ($ypx));
+                    $col = imagecolorsforindex($img, (int) ($color));
                     $alpha = $col['alpha'];
 
                     if ($eight_bit) {
@@ -4909,22 +4910,22 @@
                         $key = $col['red'] . $col['green'] . $col['blue'];
 
                         if (!isset($allocated_colors[$key])) {
-                            $pixel_img = imagecolorallocate($img, $col['red'], $col['green'], $col['blue']);
+                            $pixel_img = imagecolorallocate($img, (int) ($col['red']), (int) ($col['green']), (int) ($col['blue']));
                             $allocated_colors[$key] = $pixel_img;
                         } else {
                             $pixel_img = $allocated_colors[$key];
                         }
 
-                        imagesetpixel($img, $xpx, $ypx, $pixel_img);
-                    }
-
-                    imagesetpixel($imgalpha, $xpx, $ypx, $pixel);
+                        imagesetpixel($img, (int) ($xpx), (int) ($ypx), (int) ($pixel_img));
+                    }
+
+                    imagesetpixel($imgalpha, (int) ($xpx), (int) ($ypx), (int) ($pixel));
                 }
             }
 
             // extract image without alpha channel
-            $imgplain = imagecreatetruecolor($wpx, $hpx);
-            imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
+            $imgplain = imagecreatetruecolor((int) ($wpx), (int) ($hpx));
+            imagecopy($imgplain, $img, 0, 0, 0, 0, (int) ($wpx), (int) ($hpx));
             imagedestroy($img);
 
             imagepng($imgalpha, $tempfile_alpha);
@@ -4969,7 +4970,7 @@
         if (isset($this->imagelist[$file])) {
             $img = null;
         } else {
-            $info = file_get_contents($file, false, null, 24, 5);
+            $info = file_get_contents(($file ?? ''), (false ?? false), null, 24, 5);
             $meta = unpack("CbitDepth/CcolorType/CcompressionMethod/CfilterMethod/CinterlaceMethod", $info);
             $bit_depth = $meta["bitDepth"];
             $color_type = $meta["colorType"];
@@ -5001,21 +5002,21 @@
             }
             $sx = imagesx($imgtmp);
             $sy = imagesy($imgtmp);
-            $img = imagecreatetruecolor($sx, $sy);
+            $img = imagecreatetruecolor((int) ($sx), (int) ($sy));
             imagealphablending($img, true);
 
             // @todo is it still needed ??
             $ti = imagecolortransparent($imgtmp);
             if ($ti >= 0) {
-                $tc = imagecolorsforindex($imgtmp, $ti);
-                $ti = imagecolorallocate($img, $tc['red'], $tc['green'], $tc['blue']);
-                imagefill($img, 0, 0, $ti);
+                $tc = imagecolorsforindex($imgtmp, (int) ($ti));
+                $ti = imagecolorallocate($img, (int) ($tc['red']), (int) ($tc['green']), (int) ($tc['blue']));
+                imagefill($img, 0, 0, (int) ($ti));
                 imagecolortransparent($img, $ti);
             } else {
-                imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255));
+                imagefill($img, 1, 1, (int) (imagecolorallocate($img, 255, 255, 255)));
             }
 
-            imagecopy($img, $imgtmp, 0, 0, 0, 0, $sx, $sy);
+            imagecopy($img, $imgtmp, 0, 0, 0, 0, (int) ($sx), (int) ($sy));
             imagedestroy($imgtmp);
         }
         $this->addImagePng($file, $x, $y, $w, $h, $img);
@@ -5063,7 +5064,7 @@
      * @param bool $is_mask
      * @param null $mask
      */
-    function addPngFromBuf($file, $x, $y, $w = 0.0, $h = 0.0, &$data, $is_mask = false, $mask = null)
+    function addPngFromBuf($file, $x, $y, $w, $h, &$data, $is_mask = false, $mask = null)
     {
         if (isset($this->imagelist[$file])) {
             $data = null;
@@ -5082,7 +5083,7 @@
             if (!$error) {
                 $header = chr(137) . chr(80) . chr(78) . chr(71) . chr(13) . chr(10) . chr(26) . chr(10);
 
-                if (mb_substr($data, 0, 8, '8bit') != $header) {
+                if (mb_substr(($data ?? ''), 0, 8, '8bit') != $header) {
                     $error = 1;
 
                     if (defined("DEBUGPNG") && DEBUGPNG) {
@@ -5096,7 +5097,7 @@
             if (!$error) {
                 // set pointer
                 $p = 8;
-                $len = mb_strlen($data, '8bit');
+                $len = mb_strlen(($data ?? ''), '8bit');
 
                 // cycle through the file, identifying chunks
                 $haveHeader = 0;
@@ -5106,18 +5107,18 @@
 
                 while ($p < $len) {
                     $chunkLen = $this->getBytes($data, $p, 4);
-                    $chunkType = mb_substr($data, $p + 4, 4, '8bit');
+                    $chunkType = mb_substr(($data ?? ''), $p + 4, 4, '8bit');
 
                     switch ($chunkType) {
                         case 'IHDR':
                             // this is where all the file information comes from
                             $info['width'] = $this->getBytes($data, $p + 8, 4);
                             $info['height'] = $this->getBytes($data, $p + 12, 4);
-                            $info['bitDepth'] = ord($data[$p + 16]);
-                            $info['colorType'] = ord($data[$p + 17]);
-                            $info['compressionMethod'] = ord($data[$p + 18]);
-                            $info['filterMethod'] = ord($data[$p + 19]);
-                            $info['interlaceMethod'] = ord($data[$p + 20]);
+                            $info['bitDepth'] = ord(($data[$p + 16] ?? ''));
+                            $info['colorType'] = ord(($data[$p + 17] ?? ''));
+                            $info['compressionMethod'] = ord(($data[$p + 18] ?? ''));
+                            $info['filterMethod'] = ord(($data[$p + 19] ?? ''));
+                            $info['interlaceMethod'] = ord(($data[$p + 20] ?? ''));
 
                             //print_r($info);
                             $haveHeader = 1;
@@ -5145,11 +5146,11 @@
                             break;
 
                         case 'PLTE':
-                            $pdata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
+                            $pdata .= mb_substr(($data ?? ''), $p + 8, $chunkLen, '8bit');
                             break;
 
                         case 'IDAT':
-                            $idata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
+                            $idata .= mb_substr(($data ?? ''), $p + 8, $chunkLen, '8bit');
                             break;
 
                         case 'tRNS':
@@ -5171,7 +5172,7 @@
                                     $trans = 0;
 
                                     for ($i = $chunkLen; $i >= 0; $i--) {
-                                        if (ord($data[$p + 8 + $i]) == 0) {
+                                        if (ord(($data[$p + 8 + $i] ?? '')) == 0) {
                                             $trans = $i;
                                         }
                                     }
@@ -5186,7 +5187,7 @@
                                     */
                                     //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
                                     $transparency['type'] = 'indexed';
-                                    $transparency['data'] = ord($data[$p + 8 + 1]);
+                                    $transparency['data'] = ord(($data[$p + 8 + 1] ?? ''));
                                     break;
 
                                 // truecolor
@@ -5377,7 +5378,7 @@
                 $channels = 3;
             }
 
-            $data = file_get_contents($img);
+            $data = file_get_contents(($img ?? ''));
         }
 
         if ($w <= 0 && $h <= 0) {
@@ -5411,11 +5412,11 @@
         &$data,
         $x,
         $y,
-        $w = 0,
-        $h = 0,
+        $w,
+        $h,
         $imageWidth,
         $imageHeight,
-        $channels = 3,
+        $channels,
         $imgname
     ) {
         if ($this->image_iscached($imgname)) {
@@ -5569,7 +5570,7 @@
 
             // the user is trying to set a font family
             // note that this can also be used to set the base ones to something else
-            if (mb_strlen($family)) {
+            if (mb_strlen(($family ?? ''))) {
                 $this->fontFamilies[$family] = $options;
             }
         }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/TreeBuilder.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/TreeBuilder.php
@@ -35,6 +35,9 @@
 //          this is not (yet) in helper functions.
 
 class HTML5_TreeBuilder {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $pendingTableCharactersNull;
+
     public $stack = array();
     public $content_model;
 
@@ -251,8 +254,8 @@
                         // So... don't.
                         $this->dom->emptyDoctype = true;
                     }
-                    $public = is_null($token['public']) ? false : strtolower($token['public']);
-                    $system = is_null($token['system']) ? false : strtolower($token['system']);
+                    $public = is_null($token['public']) ? false : strtolower(($token['public'] ?? ''));
+                    $system = is_null($token['system']) ? false : strtolower(($token['system'] ?? ''));
                     $publicStartsWithForQuirks = array(
                      "+//silmaril//dtd html pro v0r11 19970101//",
                      "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
@@ -328,14 +331,14 @@
                     // first, do easy checks
                     if (
                         !empty($token['force-quirks']) ||
-                        strtolower($token['name']) !== 'html'
+                        strtolower(($token['name'] ?? '')) !== 'html'
                     ) {
                         $this->quirks_mode = self::QUIRKS_MODE;
                     } else {
                         do {
                             if ($system) {
                                 foreach ($publicStartsWithAndSystemForQuirks as $x) {
-                                    if (strncmp($public, $x, strlen($x)) === 0) {
+                                    if (strncmp($public, $x, strlen(($x ?? ''))) === 0) {
                                         $this->quirks_mode = self::QUIRKS_MODE;
                                         break;
                                     }
@@ -344,7 +347,7 @@
                                     break;
                                 }
                                 foreach ($publicStartsWithAndSystemForLimitedQuirks as $x) {
-                                    if (strncmp($public, $x, strlen($x)) === 0) {
+                                    if (strncmp($public, $x, strlen(($x ?? ''))) === 0) {
                                         $this->quirks_mode = self::LIMITED_QUIRKS_MODE;
                                         break;
                                     }
@@ -363,7 +366,7 @@
                                 break;
                             }
                             foreach ($publicStartsWithForLimitedQuirks as $x) {
-                                if (strncmp($public, $x, strlen($x)) === 0) {
+                                if (strncmp($public, $x, strlen(($x ?? ''))) === 0) {
                                     $this->quirks_mode = self::LIMITED_QUIRKS_MODE;
                                 }
                             }
@@ -375,7 +378,7 @@
                                 break;
                             }
                             foreach ($publicStartsWithForQuirks as $x) {
-                                if (strncmp($public, $x, strlen($x)) === 0) {
+                                if (strncmp($public, $x, strlen(($x ?? ''))) === 0) {
                                     $this->quirks_mode = self::QUIRKS_MODE;
                                     break;
                                 }
@@ -765,7 +768,7 @@
                          * U+000A LINE FEED (LF), U+000C FORM FEED (FF),  or U+0020
                          * SPACE, then set the frameset-ok flag to "not ok". */
                         // i.e., if any of the characters is not whitespace
-                        if (strlen($token['data']) !== strspn($token['data'], HTML5_Tokenizer::WHITESPACE)) {
+                        if (strlen(($token['data'] ?? '')) !== strspn($token['data'], HTML5_Tokenizer::WHITESPACE)) {
                             $this->flag_frameset_ok = false;
                         }
                     break;
@@ -813,7 +816,7 @@
                             elements is not a body element, or, if the stack of open
                             elements has only one node on it, then ignore the token.
                             (fragment case) */
-                            if (count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') {
+                            if (count(($this->stack ?? [])) === 1 || $this->stack[1]->tagName !== 'body') {
                                 $this->ignored = true;
                                 // Ignore
 
@@ -837,7 +840,7 @@
                              * not a body element, or, if the stack of open elements
                              * has only one node on it, then ignore the token.
                              * (fragment case) */
-                            if (count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') {
+                            if (count(($this->stack ?? [])) === 1 || $this->stack[1]->tagName !== 'body') {
                                 $this->ignored = true;
                                 // Ignore
                             } elseif (!$this->flag_frameset_ok) {
@@ -958,7 +961,7 @@
                             /* 1. Set the frameset-ok flag to "not ok". */
                             $this->flag_frameset_ok = false;
 
-                            $stack_length = count($this->stack) - 1;
+                            $stack_length = count(($this->stack ?? [])) - 1;
                             for($n = $stack_length; 0 <= $n; $n--) {
                                 /* 2. Initialise node to be the current node (the
                                 bottommost node of the stack). */
@@ -1044,7 +1047,7 @@
                             of active formatting elements and the stack of open
                             elements if the end tag didn't already remove it (it
                             might not have if the element is not in table scope). */
-                            $leng = count($this->a_formatting);
+                            $leng = count(($this->a_formatting ?? []));
 
                             for ($n = $leng - 1; $n >= 0; $n--) {
                                 if ($this->a_formatting[$n] === self::MARKER) {
@@ -1709,7 +1712,7 @@
                                 * has the same tag name as the token.
                             */
                             while (true) {
-                                for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) {
+                                for ($a = count(($this->a_formatting ?? [])) - 1; $a >= 0; $a--) {
                                     if ($this->a_formatting[$a] === self::MARKER) {
                                         break;
                                     } elseif ($this->a_formatting[$a]->tagName === $token['name']) {
@@ -1756,7 +1759,7 @@
                                 the phrasing or formatting categories. There might
                                 not be one. */
                                 $fe_s_pos = array_search($formatting_element, $this->stack, true);
-                                $length = count($this->stack);
+                                $length = count(($this->stack ?? []));
 
                                 for ($s = $fe_s_pos + 1; $s < $length; $s++) {
                                     $category = $this->getElementCategory($this->stack[$s]);
@@ -1952,7 +1955,7 @@
                                 $keys = array_keys($this->a_formatting, self::MARKER, true);
                                 $marker = end($keys);
 
-                                for ($n = count($this->a_formatting) - 1; $n > $marker; $n--) {
+                                for ($n = count(($this->a_formatting ?? [])) - 1; $n > $marker; $n--) {
                                     array_pop($this->a_formatting);
                                 }
                             }
@@ -1971,7 +1974,7 @@
 
                         /* An end tag token not covered by the previous entries */
                         default:
-                            for ($n = count($this->stack) - 1; $n >= 0; $n--) {
+                            for ($n = count(($this->stack ?? [])) - 1; $n >= 0; $n--) {
                                 /* Initialise node to be the current node (the bottommost
                                 node of the stack). */
                                 $node = $this->stack[$n];
@@ -2177,7 +2180,7 @@
                  * if it does, but that attribute's value is not an ASCII
                  * case-insensitive match for the string "hidden", then: act as
                  * described in the "anything else" entry below. */
-                ($type = $this->getAttr($token, 'type')) && strtolower($type) === 'hidden') {
+                ($type = $this->getAttr($token, 'type')) && strtolower(($type ?? '')) === 'hidden') {
                     // I.e., if its an input with the type attribute == 'hidden'
                     /* Otherwise */
                     // parse error
@@ -2716,7 +2719,7 @@
                     immediately before it in the stack of open elements is an optgroup
                     element, then act as if an end tag with the tag name "option" had
                     been seen. */
-                    $elements_in_stack = count($this->stack);
+                    $elements_in_stack = count(($this->stack ?? []));
 
                     if ($this->stack[$elements_in_stack - 1]->tagName === 'option' &&
                     $this->stack[$elements_in_stack - 2]->tagName === 'optgroup') {
@@ -2889,7 +2892,7 @@
                     if ($this->mode === self::IN_FOREIGN_CONTENT) {
                         $found = false;
                         // this basically duplicates elementInScope()
-                        for ($i = count($this->stack) - 1; $i >= 0; $i--) {
+                        for ($i = count(($this->stack ?? [])) - 1; $i >= 0; $i--) {
                             // XDOM
                             $node = $this->stack[$i];
                             if ($node->namespaceURI !== self::NS_HTML) {
@@ -3199,7 +3202,7 @@
 
         if (!empty($token['attr'])) {
             foreach ($token['attr'] as $attr) {
-                if (!$el->hasAttribute($attr['name']) && preg_match("/^[a-zA-Z_:]/", $attr['name'])) {
+                if (!$el->hasAttribute($attr['name']) && preg_match("/^[a-zA-Z_:]/", ($attr['name'] ?? ''))) {
                     $el->setAttribute($attr['name'], $attr['value']);
                 }
             }
@@ -3221,7 +3224,7 @@
         }
         if ($this->ignore_lf_token) {
             if ($data[0] === "\n") {
-                $data = substr($data, 1);
+                $data = substr(($data ?? ''), 1);
                 if ($data === false) {
                     return;
                 }
@@ -3276,7 +3279,7 @@
             return false;
         }
 
-        $leng = count($this->stack);
+        $leng = count(($this->stack ?? []));
 
         for ($n = 0; $n < $leng; $n++) {
             /* 1. Initialise node to be the current node (the bottommost node of
@@ -3324,7 +3327,7 @@
     private function reconstructActiveFormattingElements() {
         /* 1. If there are no entries in the list of active formatting elements,
         then there is nothing to reconstruct; stop this algorithm. */
-        $formatting_elements = count($this->a_formatting);
+        $formatting_elements = count(($this->a_formatting ?? []));
 
         if ($formatting_elements === 0) {
             return false;
@@ -3481,7 +3484,7 @@
     private function resetInsertionMode($context = null) {
         /* 1. Let last be false. */
         $last = false;
-        $leng = count($this->stack);
+        $leng = count(($this->stack ?? []));
 
         for ($n = $leng - 1; $n >= 0; $n--) {
             /* 2. Let node be the last node in the stack of open elements. */
@@ -3663,7 +3666,7 @@
          * elements, if there is one. If there is no table element in the stack
          * of open elements (fragment case), then the current table is the
          * first element in the stack of open elements (the html element). */
-        for ($i = count($this->stack) - 1; $i >= 0; $i--) {
+        for ($i = count(($this->stack ?? [])) - 1; $i >= 0; $i--) {
             if ($this->stack[$i]->tagName === 'table') {
                 return $this->stack[$i];
             }
@@ -3686,7 +3689,7 @@
         its parent node is not an element, then the foster parent
         element is the element before the last table element in the
         stack of open elements. */
-        for ($n = count($this->stack) - 1; $n >= 0; $n--) {
+        for ($n = count(($this->stack ?? [])) - 1; $n >= 0; $n--) {
             if ($this->stack[$n]->tagName === 'table') {
                 $table = $this->stack[$n];
                 break;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/Data.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/Data.php
@@ -107,15 +107,15 @@
         // set up the actual character
         $ret = '';
         if ($w) {
-            $ret .= chr($w);
+            $ret .= chr((int) ($w));
         }
         if ($z) {
-            $ret .= chr($z);
+            $ret .= chr((int) ($z));
         }
         if ($y) {
-            $ret .= chr($y);
+            $ret .= chr((int) ($y));
         }
-        $ret .= chr($x);
+        $ret .= chr((int) ($x));
 
         return $ret;
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/Tokenizer.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/Tokenizer.php
@@ -148,8 +148,8 @@
                     /* Consume the next input character */
                     $char = $this->stream->char();
                     $lastFourChars .= $char;
-                    if (strlen($lastFourChars) > 4) {
-                        $lastFourChars = substr($lastFourChars, -4);
+                    if (strlen(($lastFourChars ?? '')) > 4) {
+                        $lastFourChars = substr(($lastFourChars ?? ''), -4);
                     }
 
                     // see below for meaning
@@ -228,7 +228,7 @@
                     } elseif (
                         $char === '>' &&
                         $gt_cond === true &&
-                        substr($lastFourChars, 1) === '-->'
+                        substr(($lastFourChars ?? ''), 1) === '-->'
                     ) {
                         /* If the content model flag is set to either the RCDATA state or
                         the CDATA state, and the escape flag is true, and the last three
@@ -263,8 +263,8 @@
                             'data' => $char . $chars
                         ));
                         $lastFourChars .= $chars;
-                        if (strlen($lastFourChars) > 4) {
-                            $lastFourChars = substr($lastFourChars, -4);
+                        if (strlen(($lastFourChars ?? '')) > 4) {
+                            $lastFourChars = substr(($lastFourChars ?? ''), -4);
                         }
                     } else {
                         /* Anything else
@@ -298,8 +298,8 @@
                         ));
 
                         $lastFourChars .= $chars;
-                        if (strlen($lastFourChars) > 4) {
-                            $lastFourChars = substr($lastFourChars, -4);
+                        if (strlen(($lastFourChars ?? '')) > 4) {
+                            $lastFourChars = substr(($lastFourChars ?? ''), -4);
                         }
 
                         $state = 'data';
@@ -376,7 +376,7 @@
                                 point), then switch to the tag name state. (Don't emit the token
                                 yet; further details will be filled in before it is emitted.) */
                                 $this->token = array(
-                                    'name'  => strtolower($char),
+                                    'name'  => strtolower(($char ?? '')),
                                     'type'  => self::STARTTAG,
                                     'attr'  => array()
                                 );
@@ -452,7 +452,7 @@
                     ) {
                         /* If the content model flag is set to the RCDATA or CDATA
                         states... */
-                        $name = strtolower($this->stream->charsWhile(self::ALPHA));
+                        $name = strtolower(($this->stream->charsWhile(self::ALPHA) ?? ''));
                         $following = $this->stream->char();
                         $this->stream->unget();
                         if (
@@ -514,7 +514,7 @@
                             switch to the tag name state. (Don't emit the token yet; further details
                             will be filled in before it is emitted.) */
                             $this->token = array(
-                                'name'  => strtolower($char),
+                                'name'  => strtolower(($char ?? '')),
                                 'type'  => self::ENDTAG
                             );
 
@@ -660,7 +660,7 @@
                         point), and its value to the empty string. Switch to the
                         attribute name state.*/
                         $this->token['attr'][] = array(
-                            'name'  => strtolower($char),
+                            'name'  => strtolower(($char ?? '')),
                             'value' => ''
                         );
 
@@ -741,7 +741,7 @@
                         state. */
                         $chars = $this->stream->charsWhile(self::UPPER_ALPHA);
 
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['name'] .= strtolower($char . $chars);
 
                         $state = 'attribute name';
@@ -775,7 +775,7 @@
                         Stay in the attribute name state. */
                         $chars = $this->stream->charsUntil("\t\n\x0C /=>\"'" . self::UPPER_ALPHA);
 
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['name'] .= $char . $chars;
 
                         $state = 'attribute name';
@@ -828,7 +828,7 @@
                         point), and its value to the empty string. Switch to the
                         attribute name state. */
                         $this->token['attr'][] = array(
-                            'name'  => strtolower($char),
+                            'name'  => strtolower(($char ?? '')),
                             'value' => ''
                         );
 
@@ -935,7 +935,7 @@
                         /* Anything else
                         Append the current input character to the current attribute's value.
                         Switch to the attribute value (unquoted) state. */
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['value'] .= $char;
 
                         $state = 'attribute value (unquoted)';
@@ -975,7 +975,7 @@
                         Stay in the attribute value (double-quoted) state. */
                         $chars = $this->stream->charsUntil('"&');
 
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['value'] .= $char . $chars;
 
                         $state = 'attribute value (double-quoted)';
@@ -1013,7 +1013,7 @@
                         Stay in the attribute value (single-quoted) state. */
                         $chars = $this->stream->charsUntil("'&");
 
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['value'] .= $char . $chars;
 
                         $state = 'attribute value (single-quoted)';
@@ -1074,7 +1074,7 @@
                         Stay in the attribute value (unquoted) state. */
                         $chars = $this->stream->charsUntil("\t\n\x0c &>\"'=");
 
-                        $last = count($this->token['attr']) - 1;
+                        $last = count(($this->token['attr'] ?? [])) - 1;
                         $this->token['attr'][$last]['value'] .= $char . $chars;
 
                         $state = 'attribute value (unquoted)';
@@ -1204,7 +1204,7 @@
                     /* Otherwise if the next seven characters are a case-insensitive match
                     for the word "DOCTYPE", then consume those characters and switch to the
                     DOCTYPE state. */
-                    } elseif (strtoupper($alpha) === 'DOCTYPE') {
+                    } elseif (strtoupper(($alpha ?? '')) === 'DOCTYPE') {
                         $state = 'DOCTYPE';
 
                     // XXX not implemented
@@ -1551,7 +1551,7 @@
                         the character's code point). Switch to the DOCTYPE name
                         state. */
                         $this->token = array(
-                            'name' => strtolower($char),
+                            'name' => strtolower(($char ?? '')),
                             'type' => self::DOCTYPE,
                             'error' => true
                         );
@@ -1614,7 +1614,7 @@
                         Append the lowercase version of the input character
                         (add 0x0020 to the character's code point) to the current
                         DOCTYPE token's name. Stay in the DOCTYPE name state. */
-                        $this->token['name'] .= strtolower($char);
+                        $this->token['name'] .= strtolower(($char ?? ''));
 
                     } elseif ($char === false) {
                         /* EOF
@@ -2330,7 +2330,7 @@
             // alphanumeric so we can just concat it to whatever we get later).
             $this->stream->unget();
             if ($char !== false) {
-                $chars = substr($chars, 0, -1);
+                $chars = substr(($chars ?? ''), 0, -1);
             }
 
             /* If no match can be made, then this is a parse error.
@@ -2346,7 +2346,7 @@
             /* If the last character matched is not a U+003B SEMICOLON
             (;), there is a parse error. */
             $semicolon = true;
-            if (substr($id, -1) !== ';') {
+            if (substr(($id ?? ''), -1) !== ';') {
                 $this->emitToken(array(
                     'type' => self::PARSEERROR,
                     'data' => 'named-entity-without-semicolon'
@@ -2365,8 +2365,8 @@
             and nothing is returned. */
             if ($inattr && !$semicolon) {
                 // The next character is either the next character in $chars or in the stream.
-                if (strlen($chars) > strlen($id)) {
-                    $next = substr($chars, strlen($id), 1);
+                if (strlen(($chars ?? '')) > strlen(($id ?? ''))) {
+                    $next = substr(($chars ?? ''), strlen(($id ?? '')), 1);
                 } else {
                     $next = $this->stream->char();
                     $this->stream->unget();
@@ -2383,7 +2383,7 @@
             /* Otherwise, return a character token for the character
             corresponding to the character reference name (as given
             by the second column of the named character references table). */
-            return HTML5_Data::utf8chr($codepoint) . substr($chars, strlen($id));
+            return HTML5_Data::utf8chr($codepoint) . substr(($chars ?? ''), strlen(($id ?? '')));
         }
     }
 
@@ -2403,7 +2403,7 @@
             ? '&'
             : $entity;
 
-        $last = count($this->token['attr']) - 1;
+        $last = count(($this->token['attr'] ?? [])) - 1;
         $this->token['attr'][$last]['value'] .= $char;
 
         /* Finally, switch back to the attribute value state that you
@@ -2425,7 +2425,7 @@
             }
         }
         if ($token['type'] === self::ENDTAG && !empty($token['attr'])) {
-            for ($i = 0; $i < count($token['attr']); $i++) {
+            for ($i = 0; $i < count(($token['attr'] ?? [])); $i++) {
                 $this->emitToken(array(
                     'type' => self::PARSEERROR,
                     'data' => 'attributes-in-end-tag'
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/InputStream.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/lib/html5lib/InputStream.php
@@ -74,7 +74,7 @@
         // omitted.
         if (extension_loaded('iconv')) {
             // non-conforming
-            $data = @iconv('UTF-8', 'UTF-8//IGNORE', $data);
+            $data = @iconv('UTF-8', 'UTF-8//IGNORE', ($data ?? ''));
         } else {
             // we can make a conforming native implementation
             throw new Exception('Not implemented, please install iconv');
@@ -82,8 +82,8 @@
 
         /* One leading U+FEFF BYTE ORDER MARK character must be
         ignored if any are present. */
-        if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
-            $data = substr($data, 3);
+        if (substr(($data ?? ''), 0, 3) === "\xEF\xBB\xBF") {
+            $data = substr(($data ?? ''), 3);
         }
 
         /* All U+0000 NULL characters in the input must be replaced
@@ -113,7 +113,7 @@
                 "\n",
                 "\n"
             ),
-            $data
+            ($data ?? '')
         );
 
         /* Any occurrences of any characters in the ranges U+0001 to
@@ -142,7 +142,7 @@
                 |
                     [\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
                 )/x',
-                $data,
+                ($data ?? ''),
                 $matches
             );
             for ($i = 0; $i < $count; $i++) {
@@ -157,7 +157,7 @@
 
         $this->data = $data;
         $this->char = 0;
-        $this->EOF  = strlen($data);
+        $this->EOF  = strlen(($data ?? ''));
     }
 
     /**
@@ -188,23 +188,23 @@
         // one (to make it point to the next character, the one we want the
         // position of) added to it because strrpos's behaviour includes the
         // final offset byte.
-        $lastLine = strrpos($this->data, "\n", $this->char - 1 - strlen($this->data));
+        $lastLine = strrpos(($this->data ?? ''), "\n", $this->char - 1 - strlen(($this->data ?? '')));
 
         // However, for here we want the length up until the next byte to be
         // processed, so add one to the current byte ($this->char).
         if ($lastLine !== false) {
-            $findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine);
-        } else {
-            $findLengthOf = substr($this->data, 0, $this->char);
+            $findLengthOf = substr(($this->data ?? ''), $lastLine + 1, $this->char - 1 - $lastLine);
+        } else {
+            $findLengthOf = substr(($this->data ?? ''), 0, $this->char);
         }
 
         // Get the length for the string we need.
         if (extension_loaded('iconv')) {
             return iconv_strlen($findLengthOf, 'utf-8');
         } elseif (extension_loaded('mbstring')) {
-            return mb_strlen($findLengthOf, 'utf-8');
+            return mb_strlen(($findLengthOf ?? ''), 'utf-8');
         } elseif (extension_loaded('xml')) {
-            return strlen(utf8_decode($findLengthOf));
+            return strlen((mb_convert_encoding(($findLengthOf ?? ''), 'ISO-8859-1', 'UTF-8') ?? ''));
         } else {
             $count = count_chars($findLengthOf);
             // 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
@@ -234,7 +234,7 @@
      */
     public function remainingChars() {
         if ($this->char < $this->EOF) {
-            $data = substr($this->data, $this->char);
+            $data = substr(($this->data ?? ''), $this->char);
             $this->char = $this->EOF;
             return $data;
         } else {
@@ -257,7 +257,7 @@
             } else {
                 $len = strcspn($this->data, $bytes, $this->char);
             }
-            $string = (string) substr($this->data, $this->char, $len);
+            $string = (string) substr(($this->data ?? ''), $this->char, $len);
             $this->char += $len;
             return $string;
         } else {
@@ -280,7 +280,7 @@
             } else {
                 $len = strspn($this->data, $bytes, $this->char);
             }
-            $string = (string) substr($this->data, $this->char, $len);
+            $string = (string) substr(($this->data ?? ''), $this->char, $len);
             $this->char += $len;
             return $string;
         } else {
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Canvas.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Canvas.php
@@ -24,7 +24,7 @@
  */
 interface Canvas
 {
-    function __construct($paper = "letter", $orientation = "portrait", Dompdf $dompdf);
+    function __construct($paper, $orientation, Dompdf $dompdf);
 
     /**
      * @return Dompdf
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame.php
@@ -227,7 +227,7 @@
             $node = $this->_node;
 
             if ($node->nodeName === "#text" && !empty($node->nodeValue)) {
-                $node->nodeValue = preg_replace("/[ \t\r\n\f]+/u", " ", trim($node->nodeValue));
+                $node->nodeValue = preg_replace("/[ \t\r\n\f]+/u", " ", (trim(($node->nodeValue ?? '')) ?? ''));
                 self::$_ws_state = self::WS_TEXT;
             }
         }
@@ -259,7 +259,7 @@
         }
 
         if ($this->is_text_node()) {
-            return trim($node->nodeValue) !== "";
+            return trim(($node->nodeValue ?? '')) !== "";
         }
 
         return true;
@@ -1144,9 +1144,9 @@
         $str .= "Class: " . get_class($this) . "<br/>";
 
         if ($this->is_text_node()) {
-            $tmp = htmlspecialchars($this->_node->nodeValue);
-            $str .= "<pre>'" . mb_substr($tmp, 0, 70) .
-                (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>";
+            $tmp = htmlspecialchars(($this->_node->nodeValue ?? ''));
+            $str .= "<pre>'" . mb_substr(($tmp ?? ''), 0, 70) .
+                (mb_strlen(($tmp ?? '')) > 70 ? "..." : "") . "'</pre>";
         } elseif ($css_class = $this->_node->getAttribute("class")) {
             $str .= "CSS class: '$css_class'<br/>";
         }
@@ -1188,7 +1188,7 @@
                 foreach ($line->get_frames() as $frame) {
                     if ($frame instanceof FrameDecorator\Text) {
                         $str .= "\ntext: ";
-                        $str .= "'" . htmlspecialchars($frame->get_text()) . "'";
+                        $str .= "'" . htmlspecialchars(($frame->get_text() ?? '')) . "'";
                     } else {
                         $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")";
                     }
@@ -1208,7 +1208,7 @@
         if (php_sapi_name() === "cli") {
             $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"),
                 array("\n", "", ""),
-                $str));
+                ($str ?? '')));
         }
 
         return $str;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FontMetrics.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FontMetrics.php
@@ -97,8 +97,8 @@
             $cacheData .= sprintf("  '%s' => array(%s", addslashes($family), PHP_EOL);
             foreach ($variants as $variant => $path) {
                 $path = sprintf("'%s'", $path);
-                $path = str_replace('\'' . $this->getOptions()->getFontDir() , '$fontDir . \'' , $path);
-                $path = str_replace('\'' . $this->getOptions()->getRootDir() , '$rootDir . \'' , $path);
+                $path = str_replace('\'' . $this->getOptions()->getFontDir() , '$fontDir . \'' , ($path ?? ''));
+                $path = str_replace('\'' . $this->getOptions()->getRootDir() , '$rootDir . \'' , ($path ?? ''));
                 $cacheData .= sprintf("    '%s' => %s,%s", $variant, $path, PHP_EOL);
             }
             $cacheData .= sprintf("  ),%s", PHP_EOL);
@@ -184,11 +184,11 @@
         }
 
         $fontDir = $this->getOptions()->getFontDir();
-        $remoteHash = md5($remoteFile);
+        $remoteHash = md5(($remoteFile ?? ''));
         $localFile = $fontDir . DIRECTORY_SEPARATOR . $remoteHash;
 
         $cacheEntry = $localFile;
-        $localFile .= ".".strtolower(pathinfo(parse_url($remoteFile, PHP_URL_PATH),PATHINFO_EXTENSION));
+        $localFile .= ".".strtolower((pathinfo(parse_url($remoteFile, PHP_URL_PATH),PATHINFO_EXTENSION) ?? ''));
 
         $entry[$styleString] = $cacheEntry;
 
@@ -349,10 +349,10 @@
          * Only on checking the fallback font, check various subtypes on same font.
          */
 
-        $subtype = strtolower($subtypeRaw);
+        $subtype = strtolower(($subtypeRaw ?? ''));
 
         if ($familyRaw) {
-            $family = str_replace(array("'", '"'), "", strtolower($familyRaw));
+            $family = str_replace(array("'", '"'), "", (strtolower(($familyRaw ?? '')) ?? ''));
 
             if (isset($this->fontLookup[$family][$subtype])) {
                 return $cache[$familyRaw][$subtypeRaw] = $this->fontLookup[$family][$subtype];
@@ -374,7 +374,7 @@
         $family = $this->fontLookup[$family];
 
         foreach ($family as $sub => $font) {
-            if (strpos($subtype, $sub) !== false) {
+            if (strpos(($subtype ?? ''), ($sub ?? '')) !== false) {
                 return $cache[$familyRaw][$subtypeRaw] = $font;
             }
         }
@@ -412,7 +412,7 @@
      */
     public function getFamily($family)
     {
-        $family = str_replace(array("'", '"'), "", mb_strtolower($family));
+        $family = str_replace(array("'", '"'), "", (mb_strtolower($family) ?? ''));
 
         if (isset($this->fontLookup[$family])) {
             return $this->fontLookup[$family];
@@ -437,13 +437,13 @@
      */
     public function getType($type)
     {
-        if (preg_match("/bold/i", $type)) {
-            if (preg_match("/italic|oblique/i", $type)) {
+        if (preg_match("/bold/i", ($type ?? ''))) {
+            if (preg_match("/italic|oblique/i", ($type ?? ''))) {
                 $type = "bold_italic";
             } else {
                 $type = "bold";
             }
-        } elseif (preg_match("/italic|oblique/i", $type)) {
+        } elseif (preg_match("/italic|oblique/i", ($type ?? ''))) {
             $type = "italic";
         } else {
             $type = "normal";
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Helpers.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Helpers.php
@@ -57,13 +57,13 @@
     public static function build_url($protocol, $host, $base_path, $url)
     {
         $protocol = mb_strtolower($protocol);
-        if (strlen($url) == 0) {
+        if (strlen(($url ?? '')) == 0) {
             //return $protocol . $host . rtrim($base_path, "/\\") . "/";
             return $protocol . $host . $base_path;
         }
 
         // Is the url already fully qualified, a Data URI, or a reference to a named anchor?
-        if (mb_strpos($url, "://") !== false || mb_substr($url, 0, 1) === "#" || mb_strpos($url, "data:") === 0 || mb_strpos($url, "mailto:") === 0 || mb_strpos($url, "tel:") === 0) {
+        if (mb_strpos(($url ?? ''), "://") !== false || mb_substr(($url ?? ''), 0, 1) === "#" || mb_strpos(($url ?? ''), "data:") === 0 || mb_strpos(($url ?? ''), "mailto:") === 0 || mb_strpos(($url ?? ''), "tel:") === 0) {
             return $url;
         }
 
@@ -74,18 +74,18 @@
             //drive: followed by a relative path would be a drive specific default folder.
             //not known in php app code, treat as abs path
             //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/'))
-            if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || (mb_strlen($url) > 1 && $url[0] !== '\\' && $url[1] !== ':'))) {
+            if ($url[0] !== '/' && (strtoupper((substr((PHP_OS ?? ''), 0, 3) ?? '')) !== 'WIN' || (mb_strlen(($url ?? '')) > 1 && $url[0] !== '\\' && $url[1] !== ':'))) {
                 // For rel path and local acess we ignore the host, and run the path through realpath()
                 $ret .= realpath($base_path) . '/';
             }
             $ret .= $url;
-            $ret = preg_replace('/\?(.*)$/', "", $ret);
+            $ret = preg_replace('/\?(.*)$/', "", ($ret ?? ''));
             return $ret;
         }
 
         // Protocol relative urls (e.g. "//example.org/style.css")
-        if (strpos($url, '//') === 0) {
-            $ret .= substr($url, 2);
+        if (strpos(($url ?? ''), '//') === 0) {
+            $ret .= substr(($url ?? ''), 2);
             //remote urls with backslash in html/css are not really correct, but lets be genereous
         } elseif ($url[0] === '/' || $url[0] === '\\') {
             // Absolute path
@@ -114,9 +114,9 @@
     public static function buildContentDispositionHeader($dispositionType, $filename)
     {
         $encoding = mb_detect_encoding($filename);
-        $fallbackfilename = mb_convert_encoding($filename, "ISO-8859-1", $encoding);
-        $fallbackfilename = str_replace("\"", "", $fallbackfilename);
-        $encodedfilename = rawurlencode($filename);
+        $fallbackfilename = mb_convert_encoding(($filename ?? ''), "ISO-8859-1", $encoding);
+        $fallbackfilename = str_replace("\"", "", ($fallbackfilename ?? ''));
+        $encodedfilename = rawurlencode(($filename ?? ''));
 
         $contentDisposition = "Content-Disposition: $dispositionType; filename=\"$fallbackfilename\"";
         if ($fallbackfilename !== $filename) {
@@ -153,7 +153,7 @@
         $num = strrev((string)$num);
 
         $ret = "";
-        switch (mb_strlen($num)) {
+        switch (mb_strlen(($num ?? ''))) {
             /** @noinspection PhpMissingBreakStatementInspection */
             case 4:
                 $ret .= $thou[$num[3]];
@@ -182,7 +182,7 @@
      */
     public static function is_percent($value)
     {
-        return false !== mb_strpos($value, "%");
+        return false !== mb_strpos(($value ?? ''), "%");
     }
 
     /**
@@ -195,15 +195,15 @@
      */
     public static function parse_data_uri($data_uri)
     {
-        if (!preg_match('/^data:(?P<mime>[a-z0-9\/+-.]+)(;charset=(?P<charset>[a-z0-9-])+)?(?P<base64>;base64)?\,(?P<data>.*)?/is', $data_uri, $match)) {
+        if (!preg_match('/^data:(?P<mime>[a-z0-9\/+-.]+)(;charset=(?P<charset>[a-z0-9-])+)?(?P<base64>;base64)?\,(?P<data>.*)?/is', ($data_uri ?? ''), $match)) {
             return false;
         }
 
-        $match['data'] = rawurldecode($match['data']);
+        $match['data'] = rawurldecode(($match['data'] ?? ''));
         $result = array(
             'charset' => $match['charset'] ? $match['charset'] : 'US-ASCII',
             'mime' => $match['mime'] ? $match['mime'] : 'text/plain',
-            'data' => $match['base64'] ? base64_decode($match['data']) : $match['data'],
+            'data' => $match['base64'] ? base64_decode(($match['data'] ?? '')) : $match['data'],
         );
 
         return $result;
@@ -237,7 +237,7 @@
         $score = array(
             '%23'=>'#'
         );
-        return strtr(rawurlencode(rawurldecode($uri)), array_merge($reserved,$unescaped,$score));
+        return strtr((rawurlencode((rawurldecode(($uri ?? '')) ?? '')) ?? ''), (array_merge($reserved,$unescaped,$score) ?? ''));
     }
 
     /**
@@ -253,31 +253,31 @@
     {
         $lineWidth = $width + (3 - ($width - 1) % 4);
         $out = '';
-        $cnt = strlen($str);
+        $cnt = strlen(($str ?? ''));
 
         for ($i = 0; $i < $cnt; $i++) {
-            $o = ord($str[$i]);
+            $o = ord(($str[$i] ?? ''));
             switch ($o) {
                 case 0: # ESCAPE
                     $i++;
-                    switch (ord($str[$i])) {
+                    switch (ord(($str[$i] ?? ''))) {
                         case 0: # NEW LINE
-                            $padCnt = $lineWidth - strlen($out) % $lineWidth;
+                            $padCnt = $lineWidth - strlen(($out ?? '')) % $lineWidth;
                             if ($padCnt < $lineWidth) {
-                                $out .= str_repeat(chr(0), $padCnt); # pad line
+                                $out .= str_repeat((chr(0) ?? ''), $padCnt); # pad line
                             }
                             break;
                         case 1: # END OF FILE
-                            $padCnt = $lineWidth - strlen($out) % $lineWidth;
+                            $padCnt = $lineWidth - strlen(($out ?? '')) % $lineWidth;
                             if ($padCnt < $lineWidth) {
-                                $out .= str_repeat(chr(0), $padCnt); # pad line
+                                $out .= str_repeat((chr(0) ?? ''), $padCnt); # pad line
                             }
                             break 3;
                         case 2: # DELTA
                             $i += 2;
                             break;
                         default: # ABSOLUTE MODE
-                            $num = ord($str[$i]);
+                            $num = ord(($str[$i] ?? ''));
                             for ($j = 0; $j < $num; $j++) {
                                 $out .= $str[++$i];
                             }
@@ -287,7 +287,7 @@
                     }
                     break;
                 default:
-                    $out .= str_repeat($str[++$i], $o);
+                    $out .= str_repeat(($str[++$i] ?? ''), $o);
             }
         }
         return $out;
@@ -307,22 +307,22 @@
         $w = floor($width / 2) + ($width % 2);
         $lineWidth = $w + (3 - (($width - 1) / 2) % 4);
         $pixels = array();
-        $cnt = strlen($str);
+        $cnt = strlen(($str ?? ''));
         $c = 0;
 
         for ($i = 0; $i < $cnt; $i++) {
-            $o = ord($str[$i]);
+            $o = ord(($str[$i] ?? ''));
             switch ($o) {
                 case 0: # ESCAPE
                     $i++;
-                    switch (ord($str[$i])) {
+                    switch (ord(($str[$i] ?? ''))) {
                         case 0: # NEW LINE
-                            while (count($pixels) % $lineWidth != 0) {
+                            while (count(($pixels ?? [])) % $lineWidth != 0) {
                                 $pixels[] = 0;
                             }
                             break;
                         case 1: # END OF FILE
-                            while (count($pixels) % $lineWidth != 0) {
+                            while (count(($pixels ?? [])) % $lineWidth != 0) {
                                 $pixels[] = 0;
                             }
                             break 3;
@@ -330,10 +330,10 @@
                             $i += 2;
                             break;
                         default: # ABSOLUTE MODE
-                            $num = ord($str[$i]);
+                            $num = ord(($str[$i] ?? ''));
                             for ($j = 0; $j < $num; $j++) {
                                 if ($j % 2 == 0) {
-                                    $c = ord($str[++$i]);
+                                    $c = ord(($str[++$i] ?? ''));
                                     $pixels[] = ($c & 240) >> 4;
                                 } else {
                                     $pixels[] = $c & 15;
@@ -346,7 +346,7 @@
                     }
                     break;
                 default:
-                    $c = ord($str[++$i]);
+                    $c = ord(($str[++$i] ?? ''));
                     for ($j = 0; $j < $o; $j++) {
                         $pixels[] = ($j % 2 == 0 ? ($c & 240) >> 4 : $c & 15);
                     }
@@ -354,14 +354,14 @@
         }
 
         $out = '';
-        if (count($pixels) % 2) {
+        if (count(($pixels ?? [])) % 2) {
             $pixels[] = 0;
         }
 
-        $cnt = count($pixels) / 2;
+        $cnt = count(($pixels ?? [])) / 2;
 
         for ($i = 0; $i < $cnt; $i++) {
-            $out .= chr(16 * $pixels[2 * $i] + $pixels[2 * $i + 1]);
+            $out .= chr((int) (16 * $pixels[2 * $i] + $pixels[2 * $i + 1]));
         }
 
         return $out;
@@ -387,7 +387,7 @@
         }
 
         // Exclude windows drive letters...
-        if (isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1) {
+        if (isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen(($arr["scheme"] ?? '')) > 1) {
             $protocol = $arr["scheme"] . "://";
 
             if (isset($arr["user"])) {
@@ -410,11 +410,11 @@
 
             if (isset($arr["path"]) && $arr["path"] !== "") {
                 // Do we have a trailing slash?
-                if ($arr["path"][mb_strlen($arr["path"]) - 1] === "/") {
+                if ($arr["path"][mb_strlen(($arr["path"] ?? '')) - 1] === "/") {
                     $path = $arr["path"];
                     $file = "";
                 } else {
-                    $path = rtrim(dirname($arr["path"]), '/\\') . "/";
+                    $path = rtrim((dirname($arr["path"]) ?? ''), '/\\') . "/";
                     $file = basename($arr["path"]);
                 }
             }
@@ -431,7 +431,7 @@
 
             $i = mb_stripos($url, "file://");
             if ($i !== false) {
-                $url = mb_substr($url, $i + 7);
+                $url = mb_substr(($url ?? ''), $i + 7);
             }
 
             $protocol = ""; // "file://"; ? why doesn't this work... It's because of
@@ -452,10 +452,10 @@
 
                 $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
 
-                if (substr($arr["path"], 0, 1) === '/') {
+                if (substr(($arr["path"] ?? ''), 0, 1) === '/') {
                     $path = dirname($arr["path"]);
                 } else {
-                    $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
+                    $path = '/' . rtrim((dirname($_SERVER["SCRIPT_NAME"]) ?? ''), '/') . '/' . $arr["path"];
                 }
             }
         }
@@ -524,16 +524,16 @@
     public static function unichr($c)
     {
         if ($c <= 0x7F) {
-            return chr($c);
+            return chr((int) ($c));
         } else if ($c <= 0x7FF) {
-            return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
+            return chr((int) (0xC0 | $c >> 6)) . chr((int) (0x80 | $c & 0x3F));
         } else if ($c <= 0xFFFF) {
-            return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
-            . chr(0x80 | $c & 0x3F);
+            return chr((int) (0xE0 | $c >> 12)) . chr((int) (0x80 | $c >> 6 & 0x3F))
+            . chr((int) (0x80 | $c & 0x3F));
         } else if ($c <= 0x10FFFF) {
-            return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
-            . chr(0x80 | $c >> 6 & 0x3F)
-            . chr(0x80 | $c & 0x3F);
+            return chr((int) (0xF0 | $c >> 18)) . chr((int) (0x80 | $c >> 12 & 0x3F))
+            . chr((int) (0x80 | $c >> 6 & 0x3F))
+            . chr((int) (0x80 | $c & 0x3F));
         }
         return false;
     }
@@ -609,14 +609,14 @@
         if ($width == null || $height == null) {
             list($data, $headers) = Helpers::getFileContent($filename, $context);
 
-            if (substr($data, 0, 2) === "BM") {
+            if (substr(($data ?? ''), 0, 2) === "BM") {
                 $meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
                 $width = (int)$meta['width'];
                 $height = (int)$meta['height'];
                 $type = "bmp";
             }
             else {
-                if (strpos($data, "<svg") !== false) {
+                if (strpos(($data ?? ''), "<svg") !== false) {
                     $doc = new \Svg\Document();
                     $doc->loadFile($filename);
 
@@ -710,7 +710,7 @@
         }
 
         // create gd image
-        $im = imagecreatetruecolor($meta['width'], $meta['height']);
+        $im = imagecreatetruecolor((int) ($meta['width']), (int) ($meta['height']));
         $data = fread($fh, $meta['imagesize']);
 
         // uncompress data
@@ -735,14 +735,14 @@
                 switch ($meta['bits']) {
                     case 32:
                     case 24:
-                        if (!($part = substr($data, $p, 3 /*$meta['bytes']*/))) {
+                        if (!($part = substr(($data ?? ''), $p, 3 /*$meta['bytes']*/))) {
                             trigger_error($error, E_USER_WARNING);
                             return $im;
                         }
                         $color = unpack('V', $part . $vide);
                         break;
                     case 16:
-                        if (!($part = substr($data, $p, 2 /*$meta['bytes']*/))) {
+                        if (!($part = substr(($data ?? ''), $p, 2 /*$meta['bytes']*/))) {
                             trigger_error($error, E_USER_WARNING);
                             return $im;
                         }
@@ -755,16 +755,16 @@
                         }
                         break;
                     case 8:
-                        $color = unpack('n', $vide . substr($data, $p, 1));
+                        $color = unpack('n', $vide . substr(($data ?? ''), $p, 1));
                         $color[1] = $palette[$color[1] + 1];
                         break;
                     case 4:
-                        $color = unpack('n', $vide . substr($data, floor($p), 1));
+                        $color = unpack('n', $vide . substr(($data ?? ''), floor($p), 1));
                         $color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
                         $color[1] = $palette[$color[1] + 1];
                         break;
                     case 1:
-                        $color = unpack('n', $vide . substr($data, floor($p), 1));
+                        $color = unpack('n', $vide . substr(($data ?? ''), floor($p), 1));
                         switch (($p * 8) % 8) {
                             case 0:
                                 $color[1] = $color[1] >> 7;
@@ -797,7 +797,7 @@
                         trigger_error('imagecreatefrombmp: ' . $filename . ' has ' . $meta['bits'] . ' bits and this is not supported!', E_USER_WARNING);
                         return false;
                 }
-                imagesetpixel($im, $x, $y, $color[1]);
+                imagesetpixel($im, (int) ($x), (int) ($y), (int) ($color[1]));
                 $x++;
                 $p += $meta['bytes'];
             }
@@ -834,9 +834,9 @@
                 $uri = Helpers::encodeURI($uri);
             }
             if (isset($maxlen)) {
-                $result = file_get_contents($uri, null, $context, $offset, $maxlen);
+                $result = file_get_contents(($uri ?? ''), (null ?? false), $context, $offset, $maxlen);
             } else {
-                $result = file_get_contents($uri, null, $context, $offset);
+                $result = file_get_contents(($uri ?? ''), (null ?? false), $context, $offset);
             }
             if (isset($http_response_header)) {
                 $headers = $http_response_header;
@@ -855,9 +855,9 @@
             }
 
             $data = curl_exec($curl);
-            $raw_headers = substr($data, 0, curl_getinfo($curl, CURLINFO_HEADER_SIZE));
-            $headers = preg_split("/[\n\r]+/", trim($raw_headers));
-            $result = substr($data, curl_getinfo($curl, CURLINFO_HEADER_SIZE));
+            $raw_headers = substr(($data ?? ''), 0, curl_getinfo($curl, CURLINFO_HEADER_SIZE));
+            $headers = preg_split("/[\n\r]+/", (trim(($raw_headers ?? '')) ?? ''));
+            $result = substr(($data ?? ''), curl_getinfo($curl, CURLINFO_HEADER_SIZE));
             curl_close($curl);
         }
 
@@ -867,24 +867,24 @@
     }
 
     public static function mb_ucwords($str) {
-        $max_len = mb_strlen($str);
+        $max_len = mb_strlen(($str ?? ''));
         if ($max_len === 1) {
             return mb_strtoupper($str);
         }
 
-        $str = mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1);
+        $str = mb_strtoupper(mb_substr(($str ?? ''), 0, 1)) . mb_substr(($str ?? ''), 1);
 
         foreach (array(' ', '.', ',', '!', '?', '-', '+') as $s) {
             $pos = 0;
-            while (($pos = mb_strpos($str, $s, $pos)) !== false) {
+            while (($pos = mb_strpos(($str ?? ''), ($s ?? ''), $pos)) !== false) {
                 $pos++;
                 // Nothing to do if the separator is the last char of the string
                 if ($pos !== false && $pos < $max_len) {
                     // If the char we want to upper is the last char there is nothing to append behind
                     if ($pos + 1 < $max_len) {
-                        $str = mb_substr($str, 0, $pos) . mb_strtoupper(mb_substr($str, $pos, 1)) . mb_substr($str, $pos + 1);
+                        $str = mb_substr(($str ?? ''), 0, $pos) . mb_strtoupper(mb_substr(($str ?? ''), $pos, 1)) . mb_substr(($str ?? ''), $pos + 1);
                     } else {
-                        $str = mb_substr($str, 0, $pos) . mb_strtoupper(mb_substr($str, $pos, 1));
+                        $str = mb_substr(($str ?? ''), 0, $pos) . mb_strtoupper(mb_substr(($str ?? ''), $pos, 1));
                     }
                 }
             }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/LineBox.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/LineBox.php
@@ -102,7 +102,7 @@
     {
         $floating_frames = $root->get_floating_frames();
 
-        if (count($floating_frames) == 0) {
+        if (count(($floating_frames ?? [])) == 0) {
             return $floating_frames;
         }
 
@@ -284,7 +284,7 @@
         foreach ($props as $prop) {
             $s .= "$prop: " . $this->$prop . "\n";
         }
-        $s .= count($this->_frames) . " frames\n";
+        $s .= count(($this->_frames ?? [])) . " frames\n";
 
         return $s;
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Dompdf.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Dompdf.php
@@ -287,7 +287,7 @@
         }
 
         $versionFile = realpath(__DIR__ . '/../VERSION');
-        if (file_exists($versionFile) && ($version = file_get_contents($versionFile)) !== false && $version !== '$Format:<%h>$') {
+        if (file_exists($versionFile) && ($version = file_get_contents(($versionFile ?? ''))) !== false && $version !== '$Format:<%h>$') {
           $this->version = sprintf('dompdf %s', $version);
         }
 
@@ -353,7 +353,7 @@
         if (!$this->protocol && !$this->baseHost && !$this->basePath) {
             list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($file);
         }
-        $protocol = strtolower($this->protocol);
+        $protocol = strtolower(($this->protocol ?? ''));
 
         if ( !in_array($protocol, $this->allowedProtocols) ) {
             throw new Exception("Permission denied on $file. The communication protocol is not supported.");
@@ -367,11 +367,11 @@
             $realfile = realpath($file);
 
             $chroot = realpath($this->options->getChroot());
-            if ($chroot && strpos($realfile, $chroot) !== 0) {
+            if ($chroot && strpos(($realfile ?? ''), ($chroot ?? '')) !== 0) {
                 throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
             }
 
-            $ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
+            $ext = strtolower((pathinfo($realfile, PATHINFO_EXTENSION) ?? ''));
             if (!in_array($ext, $this->allowedLocalFileExtensions)) {
                 throw new Exception("Permission denied on $file. This file extension is forbidden");
             }
@@ -389,8 +389,8 @@
         // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
         if (isset($http_response_header)) {
             foreach ($http_response_header as $_header) {
-                if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", $_header, $matches)) {
-                    $encoding = strtoupper($matches[1]);
+                if (preg_match("@Content-Type:\s*[\w/]+;\s*?charset=([^\s]+)@i", ($_header ?? ''), $matches)) {
+                    $encoding = strtoupper(($matches[1] ?? ''));
                     break;
                 }
             }
@@ -429,8 +429,8 @@
         if (($file_encoding = mb_detect_encoding($str, null, true)) === false) {
             $file_encoding = "auto";
         }
-        if (in_array(strtoupper($file_encoding), array('UTF-8','UTF8')) === false) {
-            $str = mb_convert_encoding($str, 'UTF-8', $file_encoding);
+        if (in_array(strtoupper(($file_encoding ?? '')), array('UTF-8','UTF8')) === false) {
+            $str = mb_convert_encoding(($str ?? ''), 'UTF-8', $file_encoding);
         }
 
         $metatags = array(
@@ -439,17 +439,17 @@
             '@<meta [^>]*charset\s*=\s*["\']?\s*([^"\' ]+)@i',
         );
         foreach ($metatags as $metatag) {
-            if (preg_match($metatag, $str, $matches)) {
+            if (preg_match(($metatag ?? ''), ($str ?? ''), $matches)) {
                 if (isset($matches[1]) && in_array($matches[1], $known_encodings)) {
                     $document_encoding = $matches[1];
                     break;
                 }
             }
         }
-        if (isset($document_encoding) && in_array(strtoupper($document_encoding), array('UTF-8','UTF8')) === false) {
-            $str = preg_replace('/charset=([^\s"]+)/i', 'charset=UTF-8', $str);
-        } elseif (isset($document_encoding) === false && strpos($str, '<head>') !== false) {
-            $str = str_replace('<head>', '<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">', $str);
+        if (isset($document_encoding) && in_array(strtoupper(($document_encoding ?? '')), array('UTF-8','UTF8')) === false) {
+            $str = preg_replace('/charset=([^\s"]+)/i', 'charset=UTF-8', ($str ?? ''));
+        } elseif (isset($document_encoding) === false && strpos(($str ?? ''), '<head>') !== false) {
+            $str = str_replace('<head>', '<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">', ($str ?? ''));
         } elseif (isset($document_encoding) === false) {
             $str = '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">' . $str;
         }
@@ -458,8 +458,8 @@
 
         // remove BOM mark from UTF-8, it's treated as document text by DOMDocument
         // FIXME: roll this into the encoding detection using UTF-8/16/32 BOM (http://us2.php.net/manual/en/function.mb-detect-encoding.php#91051)?
-        if (substr($str, 0, 3) == chr(0xEF) . chr(0xBB) . chr(0xBF)) {
-            $str = substr($str, 3);
+        if (substr(($str ?? ''), 0, 3) == chr(0xEF) . chr(0xBB) . chr(0xBF)) {
+            $str = substr(($str ?? ''), 3);
         }
 
         // Store parsing warnings as messages
@@ -506,10 +506,10 @@
             }
 
             // If some text is before the doctype, we are in quirksmode
-            if (preg_match("/^(.+)<!doctype/i", ltrim($str), $matches)) {
+            if (preg_match("/^(.+)<!doctype/i", (ltrim(($str ?? '')) ?? ''), $matches)) {
                 $quirksmode = true;
             } // If no doctype is provided, we are in quirksmode
-            elseif (!preg_match("/^<!doctype/i", ltrim($str), $matches)) {
+            elseif (!preg_match("/^<!doctype/i", (ltrim(($str ?? '')) ?? ''), $matches)) {
                 $quirksmode = true;
             } else {
                 // HTML5 <!DOCTYPE html>
@@ -518,7 +518,7 @@
                 }
 
                 // not XHTML
-                if (!preg_match("/xhtml/i", $doc->doctype->publicId)) {
+                if (!preg_match("/xhtml/i", ($doc->doctype->publicId ?? ''))) {
                     $quirksmode = true;
                 }
             }
@@ -591,19 +591,19 @@
 
         /** @var \DOMElement $tag */
         foreach ($stylesheets as $tag) {
-            switch (strtolower($tag->nodeName)) {
+            switch (strtolower(($tag->nodeName ?? ''))) {
                 // load <link rel="STYLESHEET" ... /> tags
                 case "link":
-                    if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || // may be "appendix stylesheet"
+                    if (mb_strtolower(stripos(($tag->getAttribute("rel") ?? ''), "stylesheet") !== false) || // may be "appendix stylesheet"
                         mb_strtolower($tag->getAttribute("type")) === "text/css"
                     ) {
                         //Check if the css file is for an accepted media type
                         //media not given then always valid
-                        $formedialist = preg_split("/[\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
-                        if (count($formedialist) > 0) {
+                        $formedialist = preg_split("/[\s\n,]/", ($tag->getAttribute("media") ?? ''), -1, PREG_SPLIT_NO_EMPTY);
+                        if (count(($formedialist ?? [])) > 0) {
                             $accept = false;
                             foreach ($formedialist as $type) {
-                                if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
+                                if (in_array(mb_strtolower(trim(($type ?? ''))), $acceptedmedia)) {
                                     $accept = true;
                                     break;
                                 }
@@ -690,7 +690,7 @@
     {
         $valid = array("XYZ", "Fit", "FitH", "FitV", "FitR", "FitB", "FitBH", "FitBV");
 
-        $options = preg_split("/\s*,\s*/", trim($value));
+        $options = preg_split("/\s*,\s*/", (trim(($value ?? '')) ?? ''));
         $defaultView = array_shift($options);
 
         if (!in_array($defaultView, $valid)) {
@@ -792,7 +792,7 @@
                     // the hex-decoded text of the content property, duplicated from AbstrctFrameReflower::_parse_string
                     $decoded_string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/",
                         function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); },
-                        $style->content);
+                        ($style->content ?? ''));
                     $chars = mb_strtoupper($style->content) . mb_strtolower($style->content) . mb_strtoupper($decoded_string) . mb_strtolower($decoded_string);
                     $canvas->register_string_subset($style->font_family, $chars);
                     continue;
@@ -816,7 +816,7 @@
         // Add meta information
         $title = $this->dom->getElementsByTagName("title");
         if ($title->length) {
-            $canvas->add_info("Title", trim($title->item(0)->nodeValue));
+            $canvas->add_info("Title", trim(($title->item(0)->nodeValue ?? '')));
         }
 
         $metas = $this->dom->getElementsByTagName("meta");
@@ -828,7 +828,7 @@
         /** @var \DOMElement $meta */
         foreach ($metas as $meta) {
             $name = mb_strtolower($meta->getAttribute("name"));
-            $value = trim($meta->getAttribute("content"));
+            $value = trim(($meta->getAttribute("content") ?? ''));
 
             if (isset($labels[$name])) {
                 $canvas->add_info($labels[$name], $value);
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Autoloader.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Autoloader.php
@@ -30,9 +30,9 @@
             return;
         }
 
-        $prefixLength = strlen(self::PREFIX);
+        $prefixLength = strlen((self::PREFIX ?? ''));
         if (0 === strncmp(self::PREFIX, $class, $prefixLength)) {
-            $file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
+            $file = str_replace('\\', (DIRECTORY_SEPARATOR ?? ''), (substr(($class ?? ''), $prefixLength) ?? ''));
             $file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
             if (file_exists($file)) {
                 require_once $file;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Cellmap.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Cellmap.php
@@ -650,7 +650,7 @@
             $val = null;
             if (Helpers::is_percent($width)) {
                 $var = "percent";
-                $val = (float)rtrim($width, "% ") / $colspan;
+                $val = (float)rtrim(($width ?? ''), "% ") / $colspan;
             } else if ($width !== "auto") {
                 $var = "absolute";
                 $val = $style->length_in_pt($frame_min) / $colspan;
@@ -745,7 +745,7 @@
                     unset($this->_cells[$r][$c]);
 
                     // has multiple rows?
-                    if (isset($this->_frames[$id]) && count($this->_frames[$id]["rows"]) > 1) {
+                    if (isset($this->_frames[$id]) && count(($this->_frames[$id]["rows"] ?? [])) > 1) {
                         // remove just the desired row, but leave the frame
                         if (($row_key = array_search($r, $this->_frames[$id]["rows"])) !== false) {
                             unset($this->_frames[$id]["rows"][$row_key]);
@@ -906,7 +906,7 @@
         if (php_sapi_name() == "cli") {
             $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"),
                 array("\n", chr(27) . "[01;33m", chr(27) . "[0m"),
-                $str));
+                ($str ?? '')));
         }
 
         return $str;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/CanvasFactory.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/CanvasFactory.php
@@ -34,7 +34,7 @@
      */
     static function get_instance(Dompdf $dompdf, $paper = null, $orientation = null, $class = null)
     {
-        $backend = strtolower($dompdf->getOptions()->getPdfBackend());
+        $backend = strtolower(($dompdf->getOptions()->getPdfBackend() ?? ''));
 
         if (isset($class) && class_exists($class, false)) {
             $class .= "_Adapter";
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Image/Cache.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Image/Cache.php
@@ -67,7 +67,7 @@
 
         $remote = ($protocol && $protocol !== "file://") || ($parsed_url['protocol'] != "");
 
-        $data_uri = strpos($parsed_url['protocol'], "data:") === 0;
+        $data_uri = strpos(($parsed_url['protocol'] ?? ''), "data:") === 0;
         $full_url = null;
         $enable_remote = $dompdf->getOptions()->getIsRemoteEnabled();
 
@@ -100,7 +100,7 @@
                         }
 
                         // Image not found or invalid
-                        if (strlen($image) == 0) {
+                        if (strlen(($image ?? '')) == 0) {
                             $msg = ($data_uri ? "Data-URI could not be parsed" : "Image not found");
                             throw new ImageException($msg, E_WARNING);
                         } // Image found, put in cache and process
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Image.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Image.php
@@ -92,7 +92,7 @@
                     break;
                 }
             }
-            $width = ((float)rtrim($width, "%") * $t) / 100; //maybe 0
+            $width = ((float)rtrim(($width ?? ''), "%") * $t) / 100; //maybe 0
         } else {
             // Don't set image original size if "%" branch was 0 or size not given.
             // Otherwise aspect changed on %/auto combination for width/height
@@ -111,7 +111,7 @@
                     break;
                 }
             }
-            $height = ((float)rtrim($height, "%") * $t) / 100; //maybe 0
+            $height = ((float)rtrim(($height ?? ''), "%") * $t) / 100; //maybe 0
         } else {
             // Don't set image original size if "%" branch was 0 or size not given.
             // Otherwise aspect changed on %/auto combination for width/height
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Text.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Text.php
@@ -57,7 +57,7 @@
         //$text = $this->_frame->get_text();
 //     if ( $this->_block_parent->get_current_line_box->w == 0 )
 //       $text = ltrim($text, " \n\r\t");
-        return preg_replace(self::$_whitespace_pattern, " ", $text);
+        return preg_replace((self::$_whitespace_pattern ?? ''), " ", ($text ?? ''));
     }
 
     /**
@@ -109,8 +109,8 @@
         }
 
         // split the text into words
-        $words = preg_split('/([\s-]+)/u', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
-        $wc = count($words);
+        $words = preg_split('/([\s-]+)/u', ($text ?? ''), -1, PREG_SPLIT_DELIM_CAPTURE);
+        $wc = count(($words ?? []));
 
         // Determine the split point
         $width = 0;
@@ -137,7 +137,7 @@
             $last_width = 0;
 
             if ($break_word) {
-                for ($j = 0; $j < strlen($word); $j++) {
+                for ($j = 0; $j < strlen(($word ?? '')); $j++) {
                     $s .= $word[$j];
                     $_width = $this->getFontMetrics()->getTextWidth($s, $font, $size, $word_spacing, $char_spacing);
                     if ($_width > $available_width) {
@@ -150,14 +150,14 @@
 
             if ($break_word && $last_width > 0) {
                 //$width += $last_width;
-                $str .= substr($s, 0, -1);
+                $str .= substr(($s ?? ''), 0, -1);
             } else {
                 //$width += $word_width;
                 $str .= $word;
             }
         }
 
-        $offset = mb_strlen($str);
+        $offset = mb_strlen(($str ?? ''));
 
         // More debugging:
         //     var_dump($str);
@@ -175,7 +175,7 @@
      */
     protected function _newline_break($text)
     {
-        if (($i = mb_strpos($text, "\n")) === false) {
+        if (($i = mb_strpos(($text ?? ''), "\n")) === false) {
             return false;
         }
 
@@ -201,7 +201,7 @@
 
         // Handle text transform:
         // http://www.w3.org/TR/CSS21/text.html#propdef-text-transform
-        switch (strtolower($style->text_transform)) {
+        switch (strtolower(($style->text_transform ?? ''))) {
             default:
                 break;
             case "capitalize":
@@ -250,7 +250,7 @@
 
             case "pre-line":
                 // Collapse white-space except for \n
-                $frame->set_text($text = preg_replace("/[ \t]+/u", " ", $text));
+                $frame->set_text($text = preg_replace("/[ \t]+/u", " ", ($text ?? '')));
 
                 if ($text == "") {
                     break;
@@ -291,7 +291,7 @@
 
                 // Layout the new line
                 $this->_layout_line();
-            } else if ($split < mb_strlen($frame->get_text())) {
+            } else if ($split < mb_strlen(($frame->get_text() ?? ''))) {
                 // split the line if required
                 $frame->split_text($split);
 
@@ -299,7 +299,7 @@
 
                 // Remove any trailing newlines
                 if ($split > 1 && $t[$split - 1] === "\n" && !$frame->is_pre()) {
-                    $frame->set_text(mb_substr($t, 0, -1));
+                    $frame->set_text(mb_substr(($t ?? ''), 0, -1));
                 }
 
                 // Do we need to trim spaces on wrapped lines? This might be desired, however, we
@@ -327,13 +327,13 @@
             if ((!$is_inline_frame && !$frame->get_next_sibling()) /* ||
             ( $is_inline_frame && !$parent->get_next_sibling())*/
             ) { // fails <b>BOLD <u>UNDERLINED</u></b> becomes <b>BOLD<u>UNDERLINED</u></b>
-                $t = rtrim($t);
+                $t = rtrim(($t ?? ''));
             }
 
             if ((!$is_inline_frame && !$frame->get_prev_sibling()) /* ||
             ( $is_inline_frame && !$parent->get_prev_sibling())*/
             ) { //  <span><span>A<span>B</span> C</span></span> fails (the whitespace is removed)
-                $t = ltrim($t);
+                $t = ltrim(($t ?? ''));
             }
 
             $frame->set_text($t);
@@ -399,7 +399,7 @@
         switch ($style->white_space) {
             default:
             case "normal":
-                $str = preg_replace(self::$_whitespace_pattern, " ", $str);
+                $str = preg_replace((self::$_whitespace_pattern ?? ''), " ", ($str ?? ''));
             case "pre-wrap":
             case "pre-line":
 
@@ -408,7 +408,7 @@
                 // This technique (using arrays & an anonymous function) is actually
                 // faster than doing a single-pass character by character scan.  Heh,
                 // yes I took the time to bench it ;)
-                $words = array_flip(preg_split("/[\s-]+/u", $str, -1, PREG_SPLIT_DELIM_CAPTURE));
+                $words = array_flip(preg_split("/[\s-]+/u", ($str ?? ''), -1, PREG_SPLIT_DELIM_CAPTURE));
                 $root = $this;
                 array_walk($words, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                     $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
@@ -419,7 +419,7 @@
                 break;
 
             case "pre":
-                $lines = array_flip(preg_split("/\n/u", $str));
+                $lines = array_flip(preg_split("/\n/u", ($str ?? '')));
                 $root = $this;
                 array_walk($lines, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                     $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
@@ -438,16 +438,16 @@
             default:
             case "normal":
             case "nowrap":
-                $str = preg_replace(self::$_whitespace_pattern, " ", $text);
+                $str = preg_replace((self::$_whitespace_pattern ?? ''), " ", ($text ?? ''));
                 break;
 
             case "pre-line":
                 //XXX: Is this correct?
-                $str = preg_replace("/[ \t]+/u", " ", $text);
+                $str = preg_replace("/[ \t]+/u", " ", ($text ?? ''));
 
             case "pre-wrap":
                 // Find the longest word (i.e. minimum length)
-                $lines = array_flip(preg_split("/\n/", $text));
+                $lines = array_flip(preg_split("/\n/", ($text ?? '')));
                 $root = $this;
                 array_walk($lines, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                     $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
@@ -473,7 +473,7 @@
         if ($style->word_wrap === 'break-word') {
             // If it is allowed to break words, the min width is the widest character.
             // But for performance reasons, we only check the first character.
-            $char = mb_substr($str, 0, 1);
+            $char = mb_substr(($str ?? ''), 0, 1);
             $min_char = $this->getFontMetrics()->getTextWidth($char, $font, $size, $word_spacing, $char_spacing);
             $min = $delta + $min_char;
         }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/TableCell.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/TableCell.php
@@ -104,7 +104,7 @@
         $height = max($style_height, (float)$this->_frame->get_content_height());
 
         // Let the cellmap know our height
-        $cell_height = $height / count($cells["rows"]);
+        $cell_height = $height / count(($cells["rows"] ?? []));
 
         if ($style_height <= $height) {
             $cell_height += $top_space + $bottom_space;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Table.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Table.php
@@ -177,15 +177,15 @@
 
             // Case 2
             if ($absolute_used > 0 && $percent_used == 0) {
-                if (count($auto) > 0) {
-                    $increment = ($width - $auto_min - $absolute_used) / count($auto);
+                if (count(($auto ?? [])) > 0) {
+                    $increment = ($width - $auto_min - $absolute_used) / count(($auto ?? []));
                 }
 
                 // Use the absolutely specified width or the increment
                 foreach (array_keys($columns) as $i) {
-                    if ($columns[$i]["absolute"] > 0 && count($auto)) {
+                    if ($columns[$i]["absolute"] > 0 && count(($auto ?? []))) {
                         $cellmap->set_column_width($i, $columns[$i]["min-width"]);
-                    } else if (count($auto)) {
+                    } else if (count(($auto ?? []))) {
                         $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
                     } else {
                         // All absolute columns
@@ -205,7 +205,7 @@
 
                 // Scale percent values if the total percentage is > 100, or if all
                 // values are specified as percentages.
-                if ($percent_used > 100 || count($auto) == 0) {
+                if ($percent_used > 100 || count(($auto ?? [])) == 0) {
                     $scale = 100 / $percent_used;
                 } else {
                     $scale = 1;
@@ -232,8 +232,8 @@
 
                 // This works because $used_width includes the min-width of each
                 // unassigned column
-                if (count($auto) > 0) {
-                    $increment = ($width - $used_width) / count($auto);
+                if (count(($auto ?? [])) > 0) {
+                    $increment = ($width - $used_width) / count(($auto ?? []));
 
                     foreach ($auto as $i) {
                         $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
@@ -256,7 +256,7 @@
 
                 // Scale percent values if the total percentage is > 100 or there
                 // are no auto values to take up slack
-                if ($percent_used > 100 || count($auto) == 0) {
+                if ($percent_used > 100 || count(($auto ?? [])) == 0) {
                     $scale = 100 / $percent_used;
                 } else {
                     $scale = 1;
@@ -278,8 +278,8 @@
                     $used_width += $w;
                 }
 
-                if (count($auto) > 0) {
-                    $increment = ($width - $used_width) / count($auto);
+                if (count(($auto ?? [])) > 0) {
+                    $increment = ($width - $used_width) / count(($auto ?? []));
 
                     foreach ($auto as $i) {
                         $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
@@ -331,12 +331,12 @@
                 $max_height = $style->length_in_pt($max_height, $cb["h"]);
 
             } else if (isset($cb["w"])) {
-                if (mb_strpos($min_height, "%") !== false) {
+                if (mb_strpos(($min_height ?? ''), "%") !== false) {
                     $min_height = 0;
                 } else {
                     $min_height = $style->length_in_pt($min_height, $cb["w"]);
                 }
-                if (mb_strpos($max_height, "%") !== false) {
+                if (mb_strpos(($max_height ?? ''), "%") !== false) {
                     $max_height = "none";
                 } else {
                     $max_height = $style->length_in_pt($max_height, $cb["w"]);
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/AbstractFrameReflower.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/AbstractFrameReflower.php
@@ -269,8 +269,8 @@
                 continue;
             }
         }
-        $min = count($low) ? max($low) : 0;
-        $max = count($high) ? max($high) : 0;
+        $min = count(($low ?? [])) ? max($low) : 0;
+        $max = count(($high ?? [])) ? max($high) : 0;
 
         // Use specified width if it is greater than the minimum defined by the
         // content.  If the width is a percentage ignore it for now.
@@ -300,19 +300,19 @@
     protected function _parse_string($string, $single_trim = false)
     {
         if ($single_trim) {
-            $string = preg_replace('/^[\"\']/', "", $string);
-            $string = preg_replace('/[\"\']$/', "", $string);
+            $string = preg_replace('/^[\"\']/', "", ($string ?? ''));
+            $string = preg_replace('/[\"\']$/', "", ($string ?? ''));
         } else {
-            $string = trim($string, "'\"");
+            $string = trim(($string ?? ''), "'\"");
         }
 
         $string = str_replace(array("\\\n", '\\"', "\\'"),
-            array("", '"', "'"), $string);
+            array("", '"', "'"), ($string ?? ''));
 
         // Convert escaped hex characters into ascii characters (e.g. \A => newline)
         $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/",
             function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); },
-            $string);
+            ($string ?? ''));
         return $string;
     }
 
@@ -329,7 +329,7 @@
         $quotes = $this->_frame->get_style()->quotes;
 
         // split on spaces, except within quotes
-        if (!preg_match_all($re, "$quotes", $matches, PREG_SET_ORDER)) {
+        if (!preg_match_all(($re ?? ''), "$quotes", $matches, PREG_SET_ORDER)) {
             return null;
         }
 
@@ -367,7 +367,7 @@
         $quotes = $this->_parse_quotes();
 
         // split on spaces, except within quotes
-        if (!preg_match_all($re, $content, $matches, PREG_SET_ORDER)) {
+        if (!preg_match_all(($re ?? ''), ($content ?? ''), $matches, PREG_SET_ORDER)) {
             return null;
         }
 
@@ -388,22 +388,22 @@
 
             if (isset($match[1]) && $match[1] !== "") {
                 // counters?(...)
-                $match[1] = mb_strtolower(trim($match[1]));
+                $match[1] = mb_strtolower(trim(($match[1] ?? '')));
 
                 // Handle counter() references:
                 // http://www.w3.org/TR/CSS21/generate.html#content
 
-                $i = mb_strpos($match[1], ")");
+                $i = mb_strpos(($match[1] ?? ''), ")");
                 if ($i === false) {
                     continue;
                 }
 
-                preg_match('/(counters?)(^\()*?\(\s*([^\s,]+)\s*(,\s*["\']?([^"\'\)]*)["\']?\s*(,\s*([^\s)]+)\s*)?)?\)/i', $match[1], $args);
+                preg_match('/(counters?)(^\()*?\(\s*([^\s,]+)\s*(,\s*["\']?([^"\'\)]*)["\']?\s*(,\s*([^\s)]+)\s*)?)?\)/i', ($match[1] ?? ''), $args);
                 $counter_id = $args[3];
-                if (strtolower($args[1]) == 'counter') {
+                if (strtolower(($args[1] ?? '')) == 'counter') {
                     // counter(name [,style])
                     if (isset($args[5])) {
-                        $type = trim($args[5]);
+                        $type = trim(($args[5] ?? ''));
                     } else {
                         $type = null;
                     }
@@ -411,7 +411,7 @@
 
                     $text .= $p->counter_value($counter_id, $type);
 
-                } else if (strtolower($args[1]) == 'counters') {
+                } else if (strtolower(($args[1] ?? '')) == 'counters') {
                     // counters(name, string [,style])
                     if (isset($args[5])) {
                         $string = $this->_parse_string($args[5]);
@@ -420,7 +420,7 @@
                     }
 
                     if (isset($args[7])) {
-                        $type = trim($args[7]);
+                        $type = trim(($args[7] ?? ''));
                     } else {
                         $type = null;
                     }
@@ -456,13 +456,13 @@
                     // FIXME:
                 } else if ($match[7] === "no-close-quote") {
                     // FIXME:
-                } else if (mb_strpos($match[7], "attr(") === 0) {
-                    $i = mb_strpos($match[7], ")");
+                } else if (mb_strpos(($match[7] ?? ''), "attr(") === 0) {
+                    $i = mb_strpos(($match[7] ?? ''), ")");
                     if ($i === false) {
                         continue;
                     }
 
-                    $attr = mb_substr($match[7], 5, $i - 5);
+                    $attr = mb_substr(($match[7] ?? ''), 5, $i - 5);
                     if ($attr == "") {
                         continue;
                     }
@@ -487,7 +487,7 @@
 
         // if the element was pushed to a new page use the saved counter value, otherwise use the CSS reset value
         if ($style->counter_reset && ($reset = $style->counter_reset) !== "none") {
-            $vars = preg_split('/\s+/', trim($reset), 2);
+            $vars = preg_split('/\s+/', (trim(($reset ?? '')) ?? ''), 2);
             $frame->reset_counter($vars[0], (isset($frame->_counters['__' . $vars[0]]) ? $frame->_counters['__' . $vars[0]] : (isset($vars[1]) ? $vars[1] : 0)));
         }
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Page.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Page.php
@@ -53,7 +53,7 @@
         $page_styles = $style->get_stylesheet()->get_page_styles();
 
         // http://www.w3.org/TR/CSS21/page.html#page-selectors
-        if (count($page_styles) > 1) {
+        if (count(($page_styles ?? [])) > 1) {
             $odd = $page_number % 2 == 1;
             $first = $page_number == 1;
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Block.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameReflower/Block.php
@@ -237,7 +237,7 @@
     {
         $height = 0;
         $lines = $this->_frame->get_line_boxes();
-        if (count($lines) > 0) {
+        if (count(($lines ?? [])) > 0) {
             $last_line = end($lines);
             $content_box = $this->_frame->get_content_box();
             $height = $last_line->y + $last_line->h - $content_box["y"];
@@ -391,13 +391,13 @@
                     $min_height = $style->length_in_pt($min_height, $cb["h"]);
                     $max_height = $style->length_in_pt($max_height, $cb["h"]);
                 } else if (isset($cb["w"])) {
-                    if (mb_strpos($min_height, "%") !== false) {
+                    if (mb_strpos(($min_height ?? ''), "%") !== false) {
                         $min_height = 0;
                     } else {
                         $min_height = $style->length_in_pt($min_height, $cb["w"]);
                     }
 
-                    if (mb_strpos($max_height, "%") !== false) {
+                    if (mb_strpos(($max_height ?? ''), "%") !== false) {
                         $max_height = "none";
                     } else {
                         $max_height = $style->length_in_pt($max_height, $cb["w"]);
@@ -582,7 +582,7 @@
                 //FIXME: The 0.8 ratio applied to the height is arbitrary (used to accommodate descenders?)
                 if($isInlineBlock) {
                     $lineFrames = $line->get_frames();
-                    if (count($lineFrames) == 1) {
+                    if (count(($lineFrames ?? [])) == 1) {
                         continue;
                     }
                     $frameBox = $frame->get_frame()->get_border_box();
@@ -721,7 +721,7 @@
             // Remove next frame's beginning whitespace
             $next = $child->get_next_sibling();
             if ($next && $next instanceof TextFrameDecorator) {
-                $next->set_text(ltrim($next->get_text()));
+                $next->set_text(ltrim(($next->get_text() ?? '')));
             }
 
             $line_box = $this->_frame->get_current_line_box();
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/GD.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/GD.php
@@ -138,11 +138,11 @@
      * @param float $aa_factor Anti-aliasing factor, 1 for no AA
      * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
      */
-    public function __construct($size = 'letter', $orientation = "portrait", Dompdf $dompdf, $aa_factor = 1.0, $bg_color = array(1, 1, 1, 0))
+    public function __construct($size, $orientation, Dompdf $dompdf, $aa_factor = 1.0, $bg_color = array(1, 1, 1, 0))
     {
 
         if (!is_array($size)) {
-            $size = strtolower($size);
+            $size = strtolower(($size ?? ''));
 
             if (isset(CPDF::$PAPER_SIZES[$size])) {
                 $size = CPDF::$PAPER_SIZES[$size];
@@ -151,7 +151,7 @@
             }
         }
 
-        if (strtolower($orientation) === "landscape") {
+        if (strtolower(($orientation ?? '')) === "landscape") {
             list($size[2], $size[3]) = array($size[3], $size[2]);
         }
 
@@ -311,9 +311,9 @@
         }
 
         if ($a != 0) {
-            $this->_colors[$key] = imagecolorallocatealpha($this->get_image(), $r, $g, $b, $a);
+            $this->_colors[$key] = imagecolorallocatealpha($this->get_image(), (int) ($r), (int) ($g), (int) ($b), (int) ($a));
         } else {
-            $this->_colors[$key] = imagecolorallocate($this->get_image(), $r, $g, $b);
+            $this->_colors[$key] = imagecolorallocate($this->get_image(), (int) ($r), (int) ($g), (int) ($b));
         }
 
         return $this->_colors[$key];
@@ -369,10 +369,10 @@
         $c = $this->_allocate_color($color);
 
         // Convert the style array if required
-        if (is_array($style) && count($style) > 0) {
+        if (is_array($style) && count(($style ?? [])) > 0) {
             $gd_style = array();
 
-            if (count($style) == 1) {
+            if (count(($style ?? [])) == 1) {
                 for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
                     $gd_style[] = $c;
                 }
@@ -405,9 +405,9 @@
             }
         }
 
-        imagesetthickness($this->get_image(), $width);
-
-        imageline($this->get_image(), $x1, $y1, $x2, $y2, $c);
+        imagesetthickness($this->get_image(), (int) ($width));
+
+        imageline($this->get_image(), (int) ($x1), (int) ($y1), (int) ($x2), (int) ($y2), (int) ($c));
     }
 
     /**
@@ -454,7 +454,7 @@
         $c = $this->_allocate_color($color);
 
         // Convert the style array if required
-        if (is_array($style) && count($style) > 0) {
+        if (is_array($style) && count(($style ?? [])) > 0) {
             $gd_style = array();
 
             foreach ($style as $length) {
@@ -469,9 +469,9 @@
             }
         }
 
-        imagesetthickness($this->get_image(), $width);
-
-        imagerectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c);
+        imagesetthickness($this->get_image(), (int) ($width));
+
+        imagerectangle($this->get_image(), (int) ($x1), (int) ($y1), (int) ($x1 + $w), (int) ($y1 + $h), (int) ($c));
     }
 
     /**
@@ -495,7 +495,7 @@
 
         $c = $this->_allocate_color($color);
 
-        imagefilledrectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c);
+        imagefilledrectangle($this->get_image(), (int) ($x1), (int) ($y1), (int) ($x1 + $w), (int) ($y1 + $h), (int) ($c));
     }
 
     /**
@@ -629,7 +629,7 @@
         $c = $this->_allocate_color($color);
 
         // Convert the style array if required
-        if (is_array($style) && count($style) > 0 && !$fill) {
+        if (is_array($style) && count(($style ?? [])) > 0 && !$fill) {
             $gd_style = array();
 
             foreach ($style as $length) {
@@ -644,12 +644,12 @@
             }
         }
 
-        imagesetthickness($this->get_image(), $width);
+        imagesetthickness($this->get_image(), (int) ($width));
 
         if ($fill) {
-            imagefilledpolygon($this->get_image(), $points, count($points) / 2, $c);
+            imagefilledpolygon($this->get_image(), $points, (int) ($c));
         } else {
-            imagepolygon($this->get_image(), $points, count($points) / 2, $c);
+            imagepolygon($this->get_image(), $points, (int) ($c));
         }
     }
 
@@ -678,7 +678,7 @@
         $c = $this->_allocate_color($color);
 
         // Convert the style array if required
-        if (is_array($style) && count($style) > 0 && !$fill) {
+        if (is_array($style) && count(($style ?? [])) > 0 && !$fill) {
             $gd_style = array();
 
             foreach ($style as $length) {
@@ -693,12 +693,12 @@
             }
         }
 
-        imagesetthickness($this->get_image(), $width);
+        imagesetthickness($this->get_image(), (int) ($width));
 
         if ($fill) {
-            imagefilledellipse($this->get_image(), $x, $y, $r, $r, $c);
+            imagefilledellipse($this->get_image(), (int) ($x), (int) ($y), (int) ($r), (int) ($r), (int) ($c));
         } else {
-            imageellipse($this->get_image(), $x, $y, $r, $r, $c);
+            imageellipse($this->get_image(), (int) ($x), (int) ($y), (int) ($r), (int) ($r), (int) ($c));
         }
     }
 
@@ -749,7 +749,7 @@
         $img_w = imagesx($src);
         $img_h = imagesy($src);
 
-        imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
+        imagecopyresampled($this->get_image(), $src, (int) ($x), (int) ($y), 0, 0, (int) ($w), (int) ($h), (int) ($img_w), (int) ($img_h));
     }
 
     /**
@@ -782,14 +782,14 @@
         // character. Preserve any originally double encoded entities to be
         // represented as is.
         // eg: &amp;#160; will render &#160; rather than its character.
-        $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&#38;\1', $text);
+        $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&#38;\1', ($text ?? ''));
 
         $text = mb_encode_numericentity($text, array(0x0080, 0xff, 0, 0xff), 'UTF-8');
 
         $font = $this->get_ttf_file($font);
 
         // FIXME: word spacing
-        imagettftext($this->get_image(), $size, $angle, $x, $y + $h, $c, $font, $text);
+        imagettftext($this->get_image(), $size, $angle, (int) ($x), (int) ($y + $h), (int) ($c), $font, $text);
     }
 
     public function javascript($code)
@@ -861,7 +861,7 @@
         // character. Preserve any originally double encoded entities to be
         // represented as is.
         // eg: &amp;#160; will render &#160; rather than its character.
-        $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&#38;\1', $text);
+        $text = preg_replace('/&(#(?:x[a-fA-F0-9]+|[0-9]+);)/', '&#38;\1', ($text ?? ''));
 
         $text = mb_encode_numericentity($text, array(0x0080, 0xffff, 0, 0xffff), 'UTF-8');
 
@@ -878,7 +878,7 @@
      */
     public function get_ttf_file($font)
     {
-        if ( stripos($font, ".ttf") === false ) {
+        if ( stripos(($font ?? ''), ".ttf") === false ) {
             $font .= ".ttf";
         }
 
@@ -886,11 +886,11 @@
             $font_metrics = $this->_dompdf->getFontMetrics();
             $font = $font_metrics->getFont($this->_dompdf->getOptions()->getDefaultFont()) . ".ttf";
             if (!file_exists($font)) {
-                if (strpos($font, "mono")) {
+                if (strpos(($font ?? ''), "mono")) {
                     $font = $font_metrics->getFont("DejaVu Mono") . ".ttf";
-                } elseif (strpos($font, "sans") !== false) {
+                } elseif (strpos(($font ?? ''), "sans") !== false) {
                     $font = $font_metrics->getFont("DejaVu Sans") . ".ttf";
-                } elseif (strpos($font, "serif")) {
+                } elseif (strpos(($font ?? ''), "serif")) {
                     $font = $font_metrics->getFont("DejaVu Serif") . ".ttf";
                 } else {
                     $font = $font_metrics->getFont("DejaVu Sans") . ".ttf";
@@ -948,12 +948,12 @@
         $this->_page_number++;
         $this->_page_count++;
 
-        $this->_img = imagecreatetruecolor($this->_actual_width, $this->_actual_height);
+        $this->_img = imagecreatetruecolor((int) ($this->_actual_width), (int) ($this->_actual_height));
 
         $this->_bg_color = $this->_allocate_color($this->_bg_color_array);
         imagealphablending($this->_img, true);
         imagesavealpha($this->_img, true);
-        imagefill($this->_img, 0, 0, $this->_bg_color);
+        imagefill($this->_img, 0, 0, (int) ($this->_bg_color));
 
         $this->_imgs[] = $this->_img;
     }
@@ -998,7 +998,7 @@
 
         if (!isset($options["type"])) $options["type"] = "png";
         if (!isset($options["Attachment"])) $options["Attachment"] = true;
-        $type = strtolower($options["type"]);
+        $type = strtolower(($options["type"] ?? ''));
 
         switch ($type) {
             case "jpg":
@@ -1016,7 +1016,7 @@
         header("Cache-Control: private");
         header("Content-Type: $contentType");
 
-        $filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
+        $filename = str_replace(array("\n", "'"), "", (basename($filename, ".$type") ?? '')) . $extension;
         $attachment = $options["Attachment"] ? "attachment" : "inline";
         header(Helpers::buildContentDispositionHeader($attachment, $filename));
 
@@ -1050,7 +1050,7 @@
     {
         if (!isset($options["type"])) $options["type"] = "png";
         if (!isset($options["page"])) $options["page"] = 1;
-        $type = strtolower($options["type"]);
+        $type = strtolower(($options["type"] ?? ''));
 
         if (isset($this->_imgs[$options["page"] - 1])) {
             $img = $this->_imgs[$options["page"] - 1];
@@ -1062,10 +1062,10 @@
         if ($this->_aa_factor != 1) {
             $dst_w = $this->_actual_width / $this->_aa_factor;
             $dst_h = $this->_actual_height / $this->_aa_factor;
-            $dst = imagecreatetruecolor($dst_w, $dst_h);
+            $dst = imagecreatetruecolor((int) ($dst_w), (int) ($dst_h));
             imagecopyresampled($dst, $img, 0, 0, 0, 0,
-                $dst_w, $dst_h,
-                $this->_actual_width, $this->_actual_height);
+                (int) ($dst_w), (int) ($dst_h),
+                (int) ($this->_actual_width), (int) ($this->_actual_height));
         } else {
             $dst = $img;
         }
@@ -1077,7 +1077,7 @@
                     $options["quality"] = 75;
                 }
 
-                imagejpeg($dst, null, $options["quality"]);
+                imagejpeg($dst, null, (int) ($options["quality"]));
                 break;
             case "png":
             default:
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/PDFLib.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/PDFLib.php
@@ -205,7 +205,7 @@
      * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
      * @param Dompdf $dompdf
      */
-    public function __construct($paper = "letter", $orientation = "portrait", Dompdf $dompdf)
+    public function __construct($paper, $orientation, Dompdf $dompdf)
     {
         if (is_array($paper)) {
             $size = $paper;
@@ -227,7 +227,7 @@
         $this->_pdf = new \PDFLib();
 
         $license = $dompdf->getOptions()->getPdflibLicense();
-        if (strlen($license) > 0) {
+        if (strlen(($license ?? '')) > 0) {
             $this->setPDFLibParameter("license", $license);
         }
 
@@ -389,9 +389,9 @@
     public function add_object($object, $where = 'all')
     {
 
-        if (mb_strpos($where, "next") !== false) {
+        if (mb_strpos(($where ?? ''), "next") !== false) {
             $this->_objs[$object]["start_page"]++;
-            $where = str_replace("next", "", $where);
+            $where = str_replace("next", "", ($where ?? ''));
             if ($where == "") {
                 $where = "add";
             }
@@ -513,18 +513,18 @@
      */
     protected function _set_line_style($width, $cap, $join, $dash)
     {
-        if (count($dash) == 1) {
+        if (count(($dash ?? [])) == 1) {
             $dash[] = $dash[0];
         }
 
         if ($this->getPDFLibMajorVersion() >= 9) {
-            if (count($dash) > 1) {
+            if (count(($dash ?? [])) > 1) {
                 $this->_pdf->set_graphics_option("dasharray={" . implode(" ", $dash) . "}");
             } else {
                 $this->_pdf->set_graphics_option("dasharray=none");
             }
         } else {
-            if (count($dash) > 1) {
+            if (count(($dash ?? [])) > 1) {
                 $this->_pdf->setdashpattern("dasharray={" . implode(" ", $dash) . "}");
             } else {
                 $this->_pdf->setdash(0, 0);
@@ -752,7 +752,7 @@
 
         // Check if the font is a native PDF font
         // Embed non-native fonts
-        $test = strtolower($baseFont);
+        $test = strtolower(($baseFont ?? ''));
         if (in_array($test, DOMPDF::$nativeFonts)) {
             $font = basename($font);
         } else {
@@ -763,7 +763,7 @@
         if (is_null($encoding)) {
             // Unicode encoding is only available for the commerical
             // version of PDFlib and not PDFlib-Lite
-            if (strlen($this->_dompdf->getOptions()->getPdflibLicense()) > 0) {
+            if (strlen(($this->_dompdf->getOptions()->getPdflibLicense() ?? '')) > 0) {
                 $encoding = "unicode";
             } else {
                 $encoding = "auto";
@@ -1092,7 +1092,7 @@
         $x = array_pop($points);
         $this->_pdf->moveto($x, $y);
 
-        while (count($points) > 1) {
+        while (count(($points ?? [])) > 1) {
             $y = $this->y(array_pop($points));
             $x = array_pop($points);
             $this->_pdf->lineto($x, $y);
@@ -1199,7 +1199,7 @@
      */
     public function javascript($code)
     {
-        if (strlen($this->_dompdf->getOptions()->getPdflibLicense()) > 0) {
+        if (strlen(($this->_dompdf->getOptions()->getPdflibLicense() ?? '')) > 0) {
             $this->_pdf->create_action("JavaScript", $code);
         }
     }
@@ -1226,12 +1226,12 @@
     public function add_link($url, $x, $y, $width, $height)
     {
         $y = $this->y($y) - $height;
-        if (strpos($url, '#') === 0) {
+        if (strpos(($url ?? ''), '#') === 0) {
             // Local link
-            $name = substr($url, 1);
+            $name = substr(($url ?? ''), 1);
             if ($name) {
                 $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link',
-                    "contents={$url} destname=" . substr($url, 1) . " linewidth=0");
+                    "contents={$url} destname=" . substr(($url ?? ''), 1) . " linewidth=0");
             }
         } else {
             list($proto, $host, $path, $file) = Helpers::explode_url($url);
@@ -1240,7 +1240,7 @@
                 return; // Local links are not allowed
             }
             $url = Helpers::build_url($proto, $host, $path, $file);
-            $url = '{' . rawurldecode($url) . '}';
+            $url = '{' . rawurldecode(($url ?? '')) . '}';
 
             $action = $this->_pdf->create_action("URI", "url=" . $url);
             $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
@@ -1264,7 +1264,7 @@
         $delta = $word_spacing * $num_spaces;
 
         if ($letter_spacing) {
-            $num_chars = mb_strlen($text);
+            $num_chars = mb_strlen(($text ?? ''));
             $delta += ($num_chars - $num_spaces) * $letter_spacing;
         }
 
@@ -1364,7 +1364,7 @@
      */
     protected function _add_page_text()
     {
-        if (!count($this->_page_text)) {
+        if (!count(($this->_page_text ?? []))) {
             return;
         }
 
@@ -1380,7 +1380,7 @@
                 switch ($_t) {
                     case "text":
                         $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
-                            array($p, $this->_page_count), $text);
+                            array($p, $this->_page_count), ($text ?? ''));
                         $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
                         break;
 
@@ -1438,7 +1438,7 @@
 
         if (self::$IN_MEMORY) {
             $data = $this->_pdf->get_buffer();
-            $size = mb_strlen($data, "8bit");
+            $size = mb_strlen(($data ?? ''), "8bit");
         } else {
             $size = filesize($this->_file);
         }
@@ -1447,7 +1447,7 @@
         header("Content-Type: application/pdf");
         header("Content-Length: " . $size);
 
-        $filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
+        $filename = str_replace(array("\n", "'"), "", (basename($filename, ".pdf") ?? '')) . ".pdf";
         $attachment = $options["Attachment"] ? "attachment" : "inline";
         header(Helpers::buildContentDispositionHeader($attachment, $filename));
 
@@ -1505,7 +1505,7 @@
         if (self::$IN_MEMORY) {
             $data = $this->_pdf->get_buffer();
         } else {
-            $data = file_get_contents($this->_file);
+            $data = file_get_contents(($this->_file ?? ''));
 
             //debugpng
             if ($this->_dompdf->getOptions()->getDebugPng()) {
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/CPDF.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Adapter/CPDF.php
@@ -179,7 +179,7 @@
      * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
      * @param Dompdf $dompdf The Dompdf instance
      */
-    public function __construct($paper = "letter", $orientation = "portrait", Dompdf $dompdf)
+    public function __construct($paper, $orientation, Dompdf $dompdf)
     {
         if (is_array($paper)) {
             $size = $paper;
@@ -203,7 +203,7 @@
         );
 
         $this->_pdf->addInfo("Producer", sprintf("%s + CPDF", $dompdf->version));
-        $time = substr_replace(date('YmdHisO'), '\'', -2, 0) . '\'';
+        $time = substr_replace((date('YmdHisO') ?? ''), '\'', -2, 0) . '\'';
         $this->_pdf->addInfo("CreationDate", "D:$time");
         $this->_pdf->addInfo("ModDate", "D:$time");
 
@@ -791,11 +791,11 @@
         $this->_set_stroke_color($color);
 
         // Adjust y values
-        for ($i = 1; $i < count($points); $i += 2) {
+        for ($i = 1; $i < count(($points ?? [])); $i += 2) {
             $points[$i] = $this->y($points[$i]);
         }
 
-        $this->_pdf->polygon($points, count($points) / 2, $fill);
+        $this->_pdf->polygon($points, count(($points ?? [])) / 2, $fill);
 
         $this->_set_fill_transparency("Normal", $this->_current_opacity);
         $this->_set_line_transparency("Normal", $this->_current_opacity);
@@ -962,14 +962,14 @@
     {
         $y = $this->y($y) - $height;
 
-        if (strpos($url, '#') === 0) {
+        if (strpos(($url ?? ''), '#') === 0) {
             // Local link
-            $name = substr($url, 1);
+            $name = substr(($url ?? ''), 1);
             if ($name) {
                 $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
             }
         } else {
-            $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
+            $this->_pdf->addLink(rawurldecode(($url ?? '')), $x, $y, $x + $width, $y + $height);
         }
     }
 
@@ -1085,7 +1085,7 @@
      */
     protected function _add_page_text()
     {
-        if (!count($this->_page_text)) {
+        if (!count(($this->_page_text ?? []))) {
             return;
         }
 
@@ -1101,7 +1101,7 @@
                 switch ($_t) {
                     case "text":
                         $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
-                            array($page_number, $this->_page_count), $text);
+                            array($page_number, $this->_page_count), ($text ?? ''));
                         $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
                         break;
 
@@ -1141,13 +1141,13 @@
         $this->_add_page_text();
 
         $debug = !$options['compress'];
-        $tmp = ltrim($this->_pdf->output($debug));
+        $tmp = ltrim(($this->_pdf->output($debug) ?? ''));
 
         header("Cache-Control: private");
         header("Content-Type: application/pdf");
-        header("Content-Length: " . mb_strlen($tmp, "8bit"));
-
-        $filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
+        header("Content-Length: " . mb_strlen(($tmp ?? ''), "8bit"));
+
+        $filename = str_replace(array("\n", "'"), "", (basename($filename, ".pdf") ?? '')) . ".pdf";
         $attachment = $options["Attachment"] ? "attachment" : "inline";
         header(Helpers::buildContentDispositionHeader($attachment, $filename));
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Image.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Image.php
@@ -115,9 +115,9 @@
         }
 
         if ($msg = $frame->get_image_msg()) {
-            $parts = preg_split("/\s*\n\s*/", $msg);
+            $parts = preg_split("/\s*\n\s*/", ($msg ?? ''));
             $height = 10;
-            $_y = $alt ? $y + $h - count($parts) * $height : $y;
+            $_y = $alt ? $y + $h - count(($parts ?? [])) * $height : $y;
 
             foreach ($parts as $i => $_part) {
                 $this->_canvas->text($x, $_y + $i * $height, $_part, "times", $height * 0.8, array(0.5, 0.5, 0.5));
@@ -132,7 +132,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/TableRowGroup.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/TableRowGroup.php
@@ -43,7 +43,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Inline.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Inline.php
@@ -182,7 +182,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Text.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Text.php
@@ -46,7 +46,7 @@
     function render(Frame $frame)
     {
         $text = $frame->get_text();
-        if (trim($text) === "") {
+        if (trim(($text ?? '')) === "") {
             return;
         }
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/TableCell.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/TableCell.php
@@ -25,7 +25,7 @@
     {
         $style = $frame->get_style();
 
-        if (trim($frame->get_node()->nodeValue) === "" && $style->empty_cells === "hide") {
+        if (trim(($frame->get_node()->nodeValue ?? '')) === "" && $style->empty_cells === "hide") {
             return;
         }
 
@@ -172,7 +172,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/AbstractRenderer.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/AbstractRenderer.php
@@ -251,9 +251,9 @@
             $bg = null;
         } else {
             // Create a new image to fit over the background rectangle
-            $bg = imagecreatetruecolor($bg_width, $bg_height);
-
-            switch (strtolower($type)) {
+            $bg = imagecreatetruecolor((int) ($bg_width), (int) ($bg_height));
+
+            switch (strtolower(($type ?? ''))) {
                 case "png":
                     $is_png = true;
                     imagesavealpha($bg, true);
@@ -289,9 +289,9 @@
             $ti = imagecolortransparent($src);
 
             if ($ti >= 0) {
-                $tc = imagecolorsforindex($src, $ti);
-                $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']);
-                imagefill($bg, 0, 0, $ti);
+                $tc = imagecolorsforindex($src, (int) ($ti));
+                $ti = imagecolorallocate($bg, (int) ($tc['red']), (int) ($tc['green']), (int) ($tc['blue']));
+                imagefill($bg, 0, 0, (int) ($ti));
                 imagecolortransparent($bg, $ti);
             }
 
@@ -321,7 +321,7 @@
             // Copy regions from the source image to the background
             if ($repeat === "no-repeat") {
                 // Simply place the image on the background
-                imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
+                imagecopy($bg, $src, (int) ($dst_x), (int) ($dst_y), (int) ($src_x), (int) ($src_y), (int) ($img_w), (int) ($img_h));
 
             } else if ($repeat === "repeat-x") {
                 for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
@@ -334,7 +334,7 @@
                         $src_x = 0;
                         $w = $img_w;
                     }
-                    imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
+                    imagecopy($bg, $src, (int) ($dst_x), (int) ($dst_y), (int) ($src_x), (int) ($src_y), (int) ($w), (int) ($img_h));
                 }
             } else if ($repeat === "repeat-y") {
 
@@ -348,7 +348,7 @@
                         $src_y = 0;
                         $h = $img_h;
                     }
-                    imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h);
+                    imagecopy($bg, $src, (int) ($dst_x), (int) ($dst_y), (int) ($src_x), (int) ($src_y), (int) ($img_w), (int) ($h));
                 }
             } else if ($repeat === "repeat") {
                 for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
@@ -372,7 +372,7 @@
                             $src_y = 0;
                             $h = $img_h;
                         }
-                        imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
+                        imagecopy($bg, $src, (int) ($dst_x), (int) ($dst_y), (int) ($src_x), (int) ($src_y), (int) ($w), (int) ($h));
                     }
                 }
             } else {
@@ -824,7 +824,7 @@
      *
      * @var $top
      */
-    protected function _border_line($x, $y, $length, $color, $widths, $side, $corner_style = "bevel", $pattern_name, $r1 = 0, $r2 = 0)
+    protected function _border_line($x, $y, $length, $color, $widths, $side, $corner_style, $pattern_name, $r1 = 0, $r2 = 0)
     {
         /** used by $$side */
         list($top, $right, $bottom, $left) = $widths;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Block.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/Block.php
@@ -83,7 +83,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/ListBullet.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Renderer/ListBullet.php
@@ -68,7 +68,7 @@
         }
 
         if ($uppercase) {
-            $text = strtoupper($text);
+            $text = strtoupper(($text ?? ''));
         }
 
         return $cache[$type] = "$text.";
@@ -92,7 +92,7 @@
             case "decimal":
             case "1":
                 if ($pad) {
-                    $text = str_pad($n, $pad, "0", STR_PAD_LEFT);
+                    $text = str_pad(($n ?? ''), $pad, "0", STR_PAD_LEFT);
                 } else {
                     $text = $n;
                 }
@@ -105,7 +105,7 @@
             case "lower-alpha":
             case "lower-latin":
             case "a":
-                $text = chr(($n % 26) + ord('a') - 1);
+                $text = chr((int) (($n % 26) + ord('a') - 1));
                 break;
 
             case "upper-roman":
@@ -122,7 +122,7 @@
         }
 
         if ($uppercase) {
-            $text = strtoupper($text);
+            $text = strtoupper(($text ?? ''));
         }
 
         return "$text.";
@@ -159,8 +159,8 @@
             //$h = $frame->get_height();
             list($width, $height) = Helpers::dompdf_getimagesize($img, $this->_dompdf->getHttpContext());
             $dpi = $this->_dompdf->getOptions()->getDpi();
-            $w = ((float)rtrim($width, "px") * 72) / $dpi;
-            $h = ((float)rtrim($height, "px") * 72) / $dpi;
+            $w = ((float)rtrim(($width ?? ''), "px") * 72) / $dpi;
+            $h = ((float)rtrim(($height ?? ''), "px") * 72) / $dpi;
 
             $x -= $w;
             $y -= ($line_height - $font_size) / 2; //Reverse hinting of list_bullet_positioner
@@ -210,7 +210,7 @@
                 case "I":
                     $pad = null;
                     if ($bullet_style === "decimal-leading-zero") {
-                        $pad = strlen($li->get_parent()->get_node()->getAttribute("dompdf-children-count"));
+                        $pad = strlen(($li->get_parent()->get_node()->getAttribute("dompdf-children-count") ?? ''));
                     }
 
                     $node = $frame->get_node();
@@ -222,7 +222,7 @@
                     $index = $node->getAttribute("dompdf-counter");
                     $text = $this->make_counter($index, $bullet_style, $pad);
 
-                    if (trim($text) == "") {
+                    if (trim(($text ?? '')) == "") {
                         return;
                     }
 
@@ -248,7 +248,7 @@
         }
 
         $id = $frame->get_node()->getAttribute("id");
-        if (strlen($id) > 0)  {
+        if (strlen(($id ?? '')) > 0)  {
             $this->_canvas->add_named_dest($id);
         }
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Style.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Style.php
@@ -564,60 +564,60 @@
                 continue;
             }
 
-            if (($i = mb_strpos($l, "px")) !== false) {
+            if (($i = mb_strpos(($l ?? ''), "px")) !== false) {
                 $dpi = $this->_stylesheet->get_dompdf()->getOptions()->getDpi();
-                $ret += ((float)mb_substr($l, 0, $i) * 72) / $dpi;
+                $ret += ((float)mb_substr(($l ?? ''), 0, $i) * 72) / $dpi;
                 continue;
             }
 
-            if (($i = mb_strpos($l, "pt")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i);
+            if (($i = mb_strpos(($l ?? ''), "pt")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i);
                 continue;
             }
 
-            if (($i = mb_strpos($l, "%")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) / 100 * (float)$ref_size;
+            if (($i = mb_strpos(($l ?? ''), "%")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) / 100 * (float)$ref_size;
                 continue;
             }
 
-            if (($i = mb_strpos($l, "rem")) !== false) {
+            if (($i = mb_strpos(($l ?? ''), "rem")) !== false) {
                 if ($this->_stylesheet->get_dompdf()->getTree()->get_root()->get_style() === null) {
                     // Interpreting it as "em", see https://github.com/dompdf/dompdf/issues/1406
-                    $ret += (float)mb_substr($l, 0, $i) * $this->__get("font_size");
+                    $ret += (float)mb_substr(($l ?? ''), 0, $i) * $this->__get("font_size");
                 } else {
-                    $ret += (float)mb_substr($l, 0, $i) * $this->_stylesheet->get_dompdf()->getTree()->get_root()->get_style()->font_size;
+                    $ret += (float)mb_substr(($l ?? ''), 0, $i) * $this->_stylesheet->get_dompdf()->getTree()->get_root()->get_style()->font_size;
                 }
                 continue;
             }
 
-            if (($i = mb_strpos($l, "em")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * $this->__get("font_size");
+            if (($i = mb_strpos(($l ?? ''), "em")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * $this->__get("font_size");
                 continue;
             }
 
-            if (($i = mb_strpos($l, "cm")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * 72 / 2.54;
+            if (($i = mb_strpos(($l ?? ''), "cm")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * 72 / 2.54;
                 continue;
             }
 
-            if (($i = mb_strpos($l, "mm")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * 72 / 25.4;
+            if (($i = mb_strpos(($l ?? ''), "mm")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * 72 / 25.4;
                 continue;
             }
 
             // FIXME: em:ex ratio?
-            if (($i = mb_strpos($l, "ex")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * $this->__get("font_size") / 2;
+            if (($i = mb_strpos(($l ?? ''), "ex")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * $this->__get("font_size") / 2;
                 continue;
             }
 
-            if (($i = mb_strpos($l, "in")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * 72;
+            if (($i = mb_strpos(($l ?? ''), "in")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * 72;
                 continue;
             }
 
-            if (($i = mb_strpos($l, "pc")) !== false) {
-                $ret += (float)mb_substr($l, 0, $i) * 12;
+            if (($i = mb_strpos(($l ?? ''), "pc")) !== false) {
+                $ret += (float)mb_substr(($l ?? ''), 0, $i) * 12;
                 continue;
             }
 
@@ -709,7 +709,7 @@
 
                 // Clear out "inherit" shorthand properties if specific properties have been set
                 $shorthands = array_filter($shorthand_properties, function($el) use ($prop) {
-                    return ( strpos($prop, $el."_") !== false );
+                    return ( strpos(($prop ?? ''), $el."_") !== false );
                 });
                 foreach ($shorthands as $shorthand) {
                     if (array_key_exists($shorthand, $this->_props) && $this->_props[$shorthand] === "inherit") {
@@ -744,7 +744,7 @@
      */
     function important_set($prop)
     {
-        $prop = str_replace("-", "_", $prop);
+        $prop = str_replace("-", "_", ($prop ?? ''));
         $this->_important_props[$prop] = true;
     }
 
@@ -786,7 +786,7 @@
      */
     function __set($prop, $val)
     {
-        $prop = str_replace("-", "_", $prop);
+        $prop = str_replace("-", "_", ($prop ?? ''));
         $this->_prop_cache[$prop] = null;
 
         if (!isset(self::$_defaults[$prop])) {
@@ -795,9 +795,9 @@
             return;
         }
 
-        if ($prop !== "content" && is_string($val) && strlen($val) > 5 && mb_strpos($val, "url") === false) {
-            $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));
-            $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);
+        if ($prop !== "content" && is_string($val) && strlen(($val ?? '')) > 5 && mb_strpos(($val ?? ''), "url") === false) {
+            $val = mb_strtolower(trim((str_replace(array("\n", "\t"), array(" "), ($val ?? '')) ?? '')));
+            $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", ($val ?? ''));
         }
 
         $method = "set_$prop";
@@ -903,7 +903,7 @@
      */
     function get_font_family_raw()
     {
-        return trim($this->_props["font_family"], " \t\n\r\x0B\"'");
+        return trim(($this->_props["font_family"] ?? ''), " \t\n\r\x0B\"'");
     }
 
     /**
@@ -961,13 +961,13 @@
             print '(' . $this->_props["font_family"] . '.' . $font_style . '.' . $this->__get("font_weight") . '.' . $weight . '.' . $subtype . ')';
         }
 
-        $families = preg_split("/\s*,\s*/", $this->_props["font_family"]);
+        $families = preg_split("/\s*,\s*/", ($this->_props["font_family"] ?? ''));
 
         $font = null;
         foreach ($families as $family) {
             //remove leading and trailing string delimiters, e.g. on font names with spaces;
             //remove leading and trailing whitespace
-            $family = trim($family, " \t\n\r\x0B\"'");
+            $family = trim(($family ?? ''), " \t\n\r\x0B\"'");
             if ($DEBUGCSS) {
                 print '(' . $family . ')';
             }
@@ -1045,10 +1045,10 @@
         }
 
         // Ensure relative sizes resolve to something
-        if (($i = mb_strpos($fs, "em")) !== false) {
-            $fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
-        } else if (($i = mb_strpos($fs, "ex")) !== false) {
-            $fs = (float)mb_substr($fs, 0, $i) * $this->_parent_font_size;
+        if (($i = mb_strpos(($fs ?? ''), "em")) !== false) {
+            $fs = (float)mb_substr(($fs ?? ''), 0, $i) * $this->_parent_font_size;
+        } else if (($i = mb_strpos(($fs ?? ''), "ex")) !== false) {
+            $fs = (float)mb_substr(($fs ?? ''), 0, $i) * $this->_parent_font_size;
         } else {
             $fs = (float)$this->length_in_pt($fs);
         }
@@ -1147,7 +1147,7 @@
      */
     function get_background_position()
     {
-        $tmp = explode(" ", $this->_props["background_position"]);
+        $tmp = explode(" ", ($this->_props["background_position"] ?? ''));
 
         switch ($tmp[0]) {
             case "left":
@@ -1572,8 +1572,8 @@
      */
     function get_border_spacing()
     {
-        $arr = explode(" ", $this->_props["border_spacing"]);
-        if (count($arr) == 1) {
+        $arr = explode(" ", ($this->_props["border_spacing"] ?? ''));
+        if (count(($arr ?? [])) == 1) {
             $arr[1] = $arr[0];
         }
         return $arr;
@@ -1678,10 +1678,10 @@
      */
     protected function _set_style_type($style, $type, $val, $important)
     {
-        $val = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
-        $arr = explode(" ", $val);
-
-        switch (count($arr)) {
+        $val = preg_replace("/\s*\,\s*/", ",", ($val ?? '')); // when rgb() has spaces
+        $arr = explode(" ", ($val ?? ''));
+
+        switch (count(($arr ?? []))) {
             case 1:
                 $this->_set_style_sides_type($style, $arr[0], $arr[0], $arr[0], $arr[0], $type, $important);
                 break;
@@ -1726,7 +1726,7 @@
         }
         //see __set and __get, on all assignments clear cache!
         $this->_prop_cache[$style . '_' . $side] = null;
-        $this->_props[$style . '_' . $side] = str_replace("none", "0px", $val);
+        $this->_props[$style . '_' . $side] = str_replace("none", "0px", ($val ?? ''));
     }
 
     /**
@@ -1755,10 +1755,10 @@
         $DEBUGCSS = $this->_stylesheet->get_dompdf()->getOptions()->getDebugCss();
         $parsed_url = "none";
 
-        if (mb_strpos($val, "url") === false) {
+        if (mb_strpos(($val ?? ''), "url") === false) {
             $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
         } else {
-            $val = preg_replace("/url\(\s*['\"]?([^'\")]+)['\"]?\s*\)/", "\\1", trim($val));
+            $val = preg_replace("/url\(\s*['\"]?([^'\")]+)['\"]?\s*\)/", "\\1", (trim(($val ?? '')) ?? ''));
 
             // Resolve the url now in the context of the current stylesheet
             $parsed_url = Helpers::explode_url($val);
@@ -1908,7 +1908,7 @@
      */
     function set_background($val)
     {
-        $val = trim($val);
+        $val = trim(($val ?? ''));
         $important = isset($this->_important_props["background"]);
 
         if ($val === "none") {
@@ -1916,11 +1916,11 @@
             $this->_set_style("background_color", "transparent", $important);
         } else {
             $pos = array();
-            $tmp = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
-            $tmp = preg_split("/\s+/", $tmp);
+            $tmp = preg_replace("/\s*\,\s*/", ",", ($val ?? '')); // when rgb() has spaces
+            $tmp = preg_split("/\s+/", ($tmp ?? ''));
 
             foreach ($tmp as $attr) {
-                if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
+                if (mb_substr(($attr ?? ''), 0, 3) === "url" || $attr === "none") {
                     $this->_set_style("background_image", $this->_image($attr), $important);
                 } elseif ($attr === "fixed" || $attr === "scroll") {
                     $this->_set_style("background_attachment", $attr, $important);
@@ -1933,7 +1933,7 @@
                 }
             }
 
-            if (count($pos)) {
+            if (count(($pos ?? []))) {
                 $this->_set_style("background_position", implode(" ", $pos), $important);
             }
         }
@@ -1992,14 +1992,14 @@
 
         $important = isset($this->_important_props["font"]);
 
-        if (preg_match("/^(italic|oblique|normal)\s*(.*)$/i", $val, $match)) {
+        if (preg_match("/^(italic|oblique|normal)\s*(.*)$/i", ($val ?? ''), $match)) {
             $this->_set_style("font_style", $match[1], $important);
             $val = $match[2];
         } else {
             $this->_set_style("font_style", self::$_defaults["font_style"], $important);
         }
 
-        if (preg_match("/^(small-caps|normal)\s*(.*)$/i", $val, $match)) {
+        if (preg_match("/^(small-caps|normal)\s*(.*)$/i", ($val ?? ''), $match)) {
             $this->_set_style("font_variant", $match[1], $important);
             $val = $match[2];
         } else {
@@ -2007,8 +2007,8 @@
         }
 
         //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip!
-        if (preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i", $val, $match) &&
-            !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/", $match[2])
+        if (preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i", ($val ?? ''), $match) &&
+            !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/", ($match[2] ?? ''))
         ) {
             $this->_set_style("font_weight", $match[1], $important);
             $val = $match[2];
@@ -2016,10 +2016,10 @@
             $this->_set_style("font_weight", self::$_defaults["font_weight"], $important);
         }
 
-        if (preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))(?:\/|\s*)(.*)$/i", $val, $match)) {
+        if (preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))(?:\/|\s*)(.*)$/i", ($val ?? ''), $match)) {
             $this->_set_style("font_size", $match[1], $important);
             $val = $match[2];
-            if (preg_match("/^(?:\/|\s*)(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%)?)\s*(.*)$/i", $val, $match)) {
+            if (preg_match("/^(?:\/|\s*)(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%)?)\s*(.*)$/i", ($val ?? ''), $match)) {
                 $this->_set_style("line_height", $match[1], $important);
                 $val = $match[2];
             } else {
@@ -2030,7 +2030,7 @@
             $this->_set_style("line_height", self::$_defaults["line_height"], $important);
         }
 
-        if (strlen($val) != 0) {
+        if (strlen(($val ?? '')) != 0) {
             $this->_set_style("font_family", $val, $important);
         } else {
             $this->_set_style("font_family", self::$_defaults["font_family"], $important);
@@ -2108,7 +2108,7 @@
      */
     function set_margin($val)
     {
-        $val = str_replace("none", "0px", $val);
+        $val = str_replace("none", "0px", ($val ?? ''));
         $this->_set_style_type_important('margin', '', $val);
     }
 
@@ -2152,7 +2152,7 @@
      */
     function set_padding($val)
     {
-        $val = str_replace("none", "0px", $val);
+        $val = str_replace("none", "0px", ($val ?? ''));
         $this->_set_style_type_important('padding', '', $val);
     }
     /**#@-*/
@@ -2166,9 +2166,9 @@
      */
     protected function _set_border($side, $border_spec, $important)
     {
-        $border_spec = preg_replace("/\s*\,\s*/", ",", $border_spec);
+        $border_spec = preg_replace("/\s*\,\s*/", ",", ($border_spec ?? ''));
         //$border_spec = str_replace(",", " ", $border_spec); // Why did we have this ?? rbg(10, 102, 10) > rgb(10  102  10)
-        $arr = explode(" ", $border_spec);
+        $arr = explode(" ", ($border_spec ?? ''));
 
         // FIXME: handle partial values
 
@@ -2179,10 +2179,10 @@
         $this->_set_style_side_type('border', $side, '_color', self::$_defaults['border_' . $side . '_color'], $important);
 
         foreach ($arr as $value) {
-            $value = trim($value);
+            $value = trim(($value ?? ''));
             if (in_array($value, self::$BORDER_STYLES)) {
                 $this->_set_style_side_type('border', $side, '_style', $value, $important);
-            } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
+            } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", ($value ?? ''))) {
                 $this->_set_style_side_type('border', $side, '_width', $value, $important);
             } else {
                 // must be color
@@ -2310,10 +2310,10 @@
      */
     function set_border_radius($val)
     {
-        $val = preg_replace("/\s*\,\s*/", ",", $val); // when border-radius has spaces
-        $arr = explode(" ", $val);
-
-        switch (count($arr)) {
+        $val = preg_replace("/\s*\,\s*/", ",", ($val ?? '')); // when border-radius has spaces
+        $arr = explode(" ", ($val ?? ''));
+
+        switch (count(($arr ?? []))) {
             case 1:
                 $this->_set_border_radii($arr[0], $arr[0], $arr[0], $arr[0]);
                 break;
@@ -2431,14 +2431,14 @@
             }
         }
 
-        $val = preg_replace("/\s*\,\s*/", ",", $val); // when rgb() has spaces
-        $arr = explode(" ", $val);
+        $val = preg_replace("/\s*\,\s*/", ",", ($val ?? '')); // when rgb() has spaces
+        $arr = explode(" ", ($val ?? ''));
         foreach ($arr as $value) {
-            $value = trim($value);
+            $value = trim(($value ?? ''));
 
             if (in_array($value, self::$BORDER_STYLES)) {
                 $this->set_outline_style($value);
-            } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
+            } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", ($value ?? ''))) {
                 $this->set_outline_width($value);
             } else {
                 // must be color
@@ -2483,9 +2483,9 @@
      */
     function set_border_spacing($val)
     {
-        $arr = explode(" ", $val);
-
-        if (count($arr) == 1) {
+        $arr = explode(" ", ($val ?? ''));
+
+        if (count(($arr ?? [])) == 1) {
             $arr[1] = $arr[0];
         }
 
@@ -2516,7 +2516,7 @@
     function set_list_style($val)
     {
         $important = isset($this->_important_props["list_style"]);
-        $arr = explode(" ", str_replace(",", " ", $val));
+        $arr = explode(" ", (str_replace(",", " ", ($val ?? '')) ?? ''));
 
         static $types = array(
             "disc", "circle", "square",
@@ -2547,7 +2547,7 @@
             //Firefox is wrong here (list_style_image gets overwritten on explicit list_style_type)
             //Internet Explorer 7/8 and dompdf is right.
 
-            if (mb_substr($value, 0, 3) === "url") {
+            if (mb_substr(($value ?? ''), 0, 3) === "url") {
                 $this->_set_style("list_style_image", $this->_image($value), $important);
                 continue;
             }
@@ -2577,13 +2577,13 @@
             return;
         }
 
-        $parts = preg_split("/\s+/", $val);
+        $parts = preg_split("/\s+/", ($val ?? ''));
 
         $computed = array();
-        if (preg_match($length_re, $parts[0])) {
+        if (preg_match(($length_re ?? ''), ($parts[0] ?? ''))) {
             $computed[] = $this->length_in_pt($parts[0]);
 
-            if (isset($parts[1]) && preg_match($length_re, $parts[1])) {
+            if (isset($parts[1]) && preg_match(($length_re ?? ''), ($parts[1] ?? ''))) {
                 $computed[] = $this->length_in_pt($parts[1]);
             } else {
                 $computed[] = $computed[0];
@@ -2617,7 +2617,7 @@
         $tr_value = "\s*([^,\s]+)\s*";
         $angle = "\s*([^,\s]+(?:deg|rad)?)\s*";
 
-        if (!preg_match_all("/[a-z]+\([^\)]+\)/i", $this->_props["transform"], $parts, PREG_SET_ORDER)) {
+        if (!preg_match_all("/[a-z]+\([^\)]+\)/i", ($this->_props["transform"] ?? ''), $parts, PREG_SET_ORDER)) {
             return null;
         }
 
@@ -2645,7 +2645,7 @@
             $t = $part[0];
 
             foreach ($functions as $name => $pattern) {
-                if (preg_match("/$name\s*$pattern/i", $t, $matches)) {
+                if (preg_match("/$name\s*$pattern/i", ($t ?? ''), $matches)) {
                     $values = array_slice($matches, 1);
 
                     switch ($name) {
@@ -2656,7 +2656,7 @@
                         case "skewY":
 
                             foreach ($values as $i => $value) {
-                                if (strpos($value, "rad")) {
+                                if (strpos(($value ?? ''), "rad")) {
                                     $values[$i] = rad2deg(floatval($value));
                                 } else {
                                     $values[$i] = floatval($value);
@@ -2776,10 +2776,10 @@
      * @return mixed[]
      */
     function get_transform_origin() {
-        $values = preg_split("/\s+/", $this->_props['transform_origin']);
-
-        if (count($values) === 0) {
-            $values = preg_split("/\s+/", self::$_defaults["transform_origin"]);
+        $values = preg_split("/\s+/", ($this->_props['transform_origin'] ?? ''));
+
+        if (count(($values ?? [])) === 0) {
+            $values = preg_split("/\s+/", (self::$_defaults["transform_origin"] ?? ''));
         }
 
         $values = array_map(function($value) {
@@ -2810,7 +2810,7 @@
 
         $re = '/^\s*(\d+|normal|auto)\s*$/';
 
-        if (!preg_match($re, $val, $matches)) {
+        if (!preg_match(($re ?? ''), ($val ?? ''), $matches)) {
             return null;
         }
 
@@ -2877,13 +2877,13 @@
      */
     function set_counter_increment($val)
     {
-        $val = trim($val);
+        $val = trim(($val ?? ''));
         $value = null;
 
         if (in_array($val, array("none", "inherit"))) {
             $value = $val;
         } else {
-            if (preg_match_all("/(" . self::CSS_IDENTIFIER . ")(?:\s+(" . self::CSS_INTEGER . "))?/", $val, $matches, PREG_SET_ORDER)) {
+            if (preg_match_all("/(" . self::CSS_IDENTIFIER . ")(?:\s+(" . self::CSS_INTEGER . "))?/", ($val ?? ''), $matches, PREG_SET_ORDER)) {
                 $value = array();
                 foreach ($matches as $match) {
                     $value[$match[1]] = isset($match[2]) ? $match[2] : 1;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Color.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Color.php
@@ -178,7 +178,7 @@
 
         static $cache = array();
 
-        $color = strtolower($color);
+        $color = strtolower(($color ?? ''));
 
         if (isset($cache[$color])) {
             return $cache[$color];
@@ -192,7 +192,7 @@
             return $cache[$color] = self::getArray(self::$cssColorNames[$color]);
         }
 
-        $length = mb_strlen($color);
+        $length = mb_strlen(($color ?? ''));
 
         // #rgb format
         if ($length == 4 && $color[0] === "#") {
@@ -203,40 +203,40 @@
             return $cache[$color] = self::getArray($color[1] . $color[1] . $color[2] . $color[2] . $color[3] . $color[3], $alpha);
         } // #rrggbb format
         else if ($length == 7 && $color[0] === "#") {
-            return $cache[$color] = self::getArray(mb_substr($color, 1, 6));
+            return $cache[$color] = self::getArray(mb_substr(($color ?? ''), 1, 6));
         } // #rrggbbaa format
         else if ($length == 9 && $color[0] === "#") {
-            $alpha = round(hexdec(mb_substr($color, 7, 2))/255, 2);
-            return $cache[$color] = self::getArray(mb_substr($color, 1, 8), $alpha);
+            $alpha = round(hexdec(mb_substr(($color ?? ''), 7, 2))/255, 2);
+            return $cache[$color] = self::getArray(mb_substr(($color ?? ''), 1, 8), $alpha);
         } // rgb( r,g,b ) / rgba( r,g,b,Î± ) format
-        else if (mb_strpos($color, "rgb") !== false) {
-            $i = mb_strpos($color, "(");
-            $j = mb_strpos($color, ")");
+        else if (mb_strpos(($color ?? ''), "rgb") !== false) {
+            $i = mb_strpos(($color ?? ''), "(");
+            $j = mb_strpos(($color ?? ''), ")");
 
             // Bad color value
             if ($i === false || $j === false) {
                 return null;
             }
 
-            $triplet = explode(",", mb_substr($color, $i + 1, $j - $i - 1));
+            $triplet = explode(",", (mb_substr(($color ?? ''), $i + 1, $j - $i - 1) ?? ''));
 
             // alpha transparency
             // FIXME: not currently using transparency
             $alpha = 1.0;
-            if (count($triplet) == 4) {
-                $alpha = (float)(trim(array_pop($triplet)));
+            if (count(($triplet ?? [])) == 4) {
+                $alpha = (float)(trim((array_pop($triplet) ?? '')));
                 // bad value, set to fully opaque
                 if ($alpha > 1.0 || $alpha < 0.0) {
                     $alpha = 1.0;
                 }
             }
 
-            if (count($triplet) != 3) {
+            if (count(($triplet ?? [])) != 3) {
                 return null;
             }
 
             foreach (array_keys($triplet) as $c) {
-                $triplet[$c] = trim($triplet[$c]);
+                $triplet[$c] = trim(($triplet[$c] ?? ''));
 
                 if (Helpers::is_percent($triplet[$c])) {
                     $triplet[$c] = round((float)$triplet[$c] * 2.55);
@@ -249,23 +249,23 @@
 
         // cmyk( c,m,y,k ) format
         // http://www.w3.org/TR/css3-gcpm/#cmyk-colors
-        else if (mb_strpos($color, "cmyk") !== false) {
-            $i = mb_strpos($color, "(");
-            $j = mb_strpos($color, ")");
+        else if (mb_strpos(($color ?? ''), "cmyk") !== false) {
+            $i = mb_strpos(($color ?? ''), "(");
+            $j = mb_strpos(($color ?? ''), ")");
 
             // Bad color value
             if ($i === false || $j === false) {
                 return null;
             }
 
-            $values = explode(",", mb_substr($color, $i + 1, $j - $i - 1));
-
-            if (count($values) != 4) {
+            $values = explode(",", (mb_substr(($color ?? ''), $i + 1, $j - $i - 1) ?? ''));
+
+            if (count(($values ?? [])) != 4) {
                 return null;
             }
 
             $values = array_map(function($c) {
-                return min(1.0, max(0.0, floatval(trim($c))));
+                return min(1.0, max(0.0, floatval(trim(($c ?? '')))));
             }, $values);
 
             return $cache[$color] = self::getArray($values);
@@ -292,14 +292,14 @@
             $c["alpha"] = $alpha;
             $c["hex"] = "cmyk($c[0],$c[1],$c[2],$c[3])";
         } else {
-            $c[0] = hexdec(mb_substr($color, 0, 2)) / 0xff;
-            $c[1] = hexdec(mb_substr($color, 2, 2)) / 0xff;
-            $c[2] = hexdec(mb_substr($color, 4, 2)) / 0xff;
+            $c[0] = hexdec(mb_substr(($color ?? ''), 0, 2)) / 0xff;
+            $c[1] = hexdec(mb_substr(($color ?? ''), 2, 2)) / 0xff;
+            $c[2] = hexdec(mb_substr(($color ?? ''), 4, 2)) / 0xff;
             $c["r"] = $c[0];
             $c["g"] = $c[1];
             $c["b"] = $c[2];
             $c["alpha"] = $alpha;
-            $c["hex"] = sprintf("#%s%02X", mb_substr($color, 0, 6), round($alpha * 255));
+            $c["hex"] = sprintf("#%s%02X", mb_substr(($color ?? ''), 0, 6), round($alpha * 255));
         }
 
         return $c;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/AttributeTranslator.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/AttributeTranslator.php
@@ -220,7 +220,7 @@
 
         $valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag];
         $attrs = $node->attributes;
-        $style = rtrim($node->getAttribute(self::$_style_attr), "; ");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), "; ");
         if ($style != "") {
             $style .= ";";
         }
@@ -246,7 +246,7 @@
         }
 
         if (!is_null($style)) {
-            $style = ltrim($style);
+            $style = ltrim(($style ?? ''));
             $node->setAttribute(self::$_style_attr, $style);
         }
 
@@ -263,7 +263,7 @@
     {
         if ($target[0] === "!") {
             // Function call
-            $func = "_" . mb_substr($target, 1);
+            $func = "_" . mb_substr(($target ?? ''), 1);
 
             return self::$func($node, $value);
         }
@@ -277,9 +277,9 @@
      */
     static function append_style(\DOMElement $node, $new_style)
     {
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
         $style .= $new_style;
-        $style = ltrim($style, ";");
+        $style = ltrim(($style ?? ''), ";");
         $node->setAttribute(self::$_style_attr, $style);
     }
 
@@ -319,7 +319,7 @@
      */
     static protected function _get_valid_color($value)
     {
-        if (preg_match('/^#?([0-9A-F]{6})$/i', $value, $matches)) {
+        if (preg_match('/^#?([0-9A-F]{6})$/i', ($value ?? ''), $matches)) {
             $value = "#$matches[1]";
         }
 
@@ -380,16 +380,16 @@
         $cell_list = self::get_cell_list($node);
 
         foreach ($cell_list as $cell) {
-            $style = rtrim($cell->getAttribute(self::$_style_attr));
+            $style = rtrim(($cell->getAttribute(self::$_style_attr) ?? ''));
             $style .= "; border-width: " . ($value > 0 ? 1 : 0) . "pt; border-style: inset;";
-            $style = ltrim($style, ";");
+            $style = ltrim(($style ?? ''), ";");
             $cell->setAttribute(self::$_style_attr, $style);
         }
 
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
         $style .= "; border-width: $value" . "px; ";
 
-        return ltrim($style, "; ");
+        return ltrim(($style ?? ''), "; ");
     }
 
     /**
@@ -400,7 +400,7 @@
      */
     static protected function _set_table_cellspacing(\DOMElement $node, $value)
     {
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
 
         if ($value == 0) {
             $style .= "; border-collapse: collapse;";
@@ -408,7 +408,7 @@
             $style .= "; border-spacing: {$value}px; border-collapse: separate;";
         }
 
-        return ltrim($style, ";");
+        return ltrim(($style ?? ''), ";");
     }
 
     /**
@@ -455,10 +455,10 @@
             $cell->setAttribute(self::$_style_attr, $style);
         }
 
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
         $style .= "; border-collapse: collapse; ";
 
-        return ltrim($style, "; ");
+        return ltrim(($style ?? ''), "; ");
     }
 
     /**
@@ -469,10 +469,10 @@
      */
     static protected function _set_hr_size(\DOMElement $node, $value)
     {
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
         $style .= "; border-width: " . max(0, $value - 2) . "; ";
 
-        return ltrim($style, "; ");
+        return ltrim(($style ?? ''), "; ");
     }
 
     /**
@@ -483,14 +483,14 @@
      */
     static protected function _set_hr_align(\DOMElement $node, $value)
     {
-        $style = rtrim($node->getAttribute(self::$_style_attr), ";");
+        $style = rtrim(($node->getAttribute(self::$_style_attr) ?? ''), ";");
         $width = $node->getAttribute("width");
 
         if ($width == "") {
             $width = "100%";
         }
 
-        $remainder = 100 - (double)rtrim($width, "% ");
+        $remainder = 100 - (double)rtrim(($width ?? ''), "% ");
 
         switch ($value) {
             case "left":
@@ -509,7 +509,7 @@
                 return null;
         }
 
-        return ltrim($style, "; ");
+        return ltrim(($style ?? ''), "; ");
     }
 
     /**
@@ -522,7 +522,7 @@
     {
         if (empty($value)) { return null; }
 
-        if ($node->hasAttribute("type") && in_array(strtolower($node->getAttribute("type")), array("text","password"))) {
+        if ($node->hasAttribute("type") && in_array(strtolower(($node->getAttribute("type") ?? '')), array("text","password"))) {
             return sprintf("width: %Fem", (((int)$value * .65)+2));
         } else {
             return sprintf("width: %upx;", (int)$value);
@@ -634,6 +634,6 @@
             $style .= "; font-size: $value;";
         }
 
-        return ltrim($style, "; ");
+        return ltrim(($style ?? ''), "; ");
     }
 }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Stylesheet.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Css/Stylesheet.php
@@ -349,7 +349,7 @@
 
         $this->_loaded_files[$file] = true;
 
-        if (strpos($file, "data:") === 0) {
+        if (strpos(($file ?? ''), "data:") === 0) {
             $parsed = Helpers::parse_data_uri($file);
             $css = $parsed["data"];
         } else {
@@ -371,7 +371,7 @@
             // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
             if (isset($http_response_header) && !$this->_dompdf->getQuirksmode()) {
                 foreach ($http_response_header as $_header) {
-                    if (preg_match("@Content-Type:\s*([\w/]+)@i", $_header, $matches) &&
+                    if (preg_match("@Content-Type:\s*([\w/]+)@i", ($_header ?? ''), $matches) &&
                         ($matches[1] !== "text/css")
                     ) {
                         $good_mime_type = false;
@@ -482,7 +482,7 @@
         }
 
         $tok = "";
-        $len = mb_strlen($selector);
+        $len = mb_strlen(($selector ?? ''));
         $i = 0;
 
         while ($i < $len) {
@@ -530,12 +530,12 @@
                     // the current token
                     $expr = $s === " " ? "descendant" : "child";
 
-                    if (mb_substr($query, -1, 1) !== "/") {
+                    if (mb_substr(($query ?? ''), -1, 1) !== "/") {
                         $query .= "/";
                     }
 
                     // Tag names are case-insensitive
-                    $tok = strtolower($tok);
+                    $tok = strtolower(($tok ?? ''));
 
                     if (!$tok) {
                         $tok = "*";
@@ -553,7 +553,7 @@
                     $attr = $s === "." ? "class" : "id";
 
                     // empty class/id == *
-                    if (mb_substr($query, -1, 1) === "/") {
+                    if (mb_substr(($query ?? ''), -1, 1) === "/") {
                         $query .= "*";
                     }
 
@@ -571,7 +571,7 @@
 
                 case "+":
                     // All sibling elements that follow the current token
-                    if (mb_substr($query, -1, 1) !== "/") {
+                    if (mb_substr(($query ?? ''), -1, 1) !== "/") {
                         $query .= "/";
                     }
 
@@ -580,8 +580,8 @@
                     break;
 
                 case ":":
-                    $i2 = $i - strlen($tok) - 2; // the char before ":"
-                    if (($i2 < 0 || !isset($selector[$i2]) || (in_array($selector[$i2], $delimiters) && $selector[$i2] != ":")) && substr($query, -1) != "*") {
+                    $i2 = $i - strlen(($tok ?? '')) - 2; // the char before ":"
+                    if (($i2 < 0 || !isset($selector[$i2]) || (in_array($selector[$i2], $delimiters) && $selector[$i2] != ":")) && substr(($query ?? ''), -1) != "*") {
                         $query .= "*";
                     }
 
@@ -616,17 +616,17 @@
                             $last = true;
                         case "nth-of-type":
                             //FIXME: this fix-up is pretty ugly, would parsing the selector in reverse work better generally?
-                            $descendant_delimeter = strrpos($query, "::");
-                            $isChild = substr($query, $descendant_delimeter-5, 5) == "child";
-                            $el = substr($query, $descendant_delimeter+2);
-                            $query = substr($query, 0, strrpos($query, "/")) . ($isChild ? "/" : "//") . $el;
+                            $descendant_delimeter = strrpos(($query ?? ''), "::");
+                            $isChild = substr(($query ?? ''), $descendant_delimeter-5, 5) == "child";
+                            $el = substr(($query ?? ''), $descendant_delimeter+2);
+                            $query = substr(($query ?? ''), 0, strrpos(($query ?? ''), "/")) . ($isChild ? "/" : "//") . $el;
 
                             $pseudo_classes[$tok] = true;
                             $p = $i + 1;
-                            $nth = trim(mb_substr($selector, $p, strpos($selector, ")", $i) - $p));
+                            $nth = trim((mb_substr(($selector ?? ''), $p, strpos(($selector ?? ''), ")", $i) - $p) ?? ''));
 
                             // 1
-                            if (preg_match("/^\d+$/", $nth)) {
+                            if (preg_match("/^\d+$/", ($nth ?? ''))) {
                                 $condition = "position() = $nth";
                             } // odd
                             elseif ($nth === "odd") {
@@ -647,17 +647,17 @@
                             $last = true;
                         case "nth-child":
                             //FIXME: this fix-up is pretty ugly, would parsing the selector in reverse work better generally?
-                            $descendant_delimeter = strrpos($query, "::");
-                            $isChild = substr($query, $descendant_delimeter-5, 5) == "child";
-                            $el = substr($query, $descendant_delimeter+2);
-                            $query = substr($query, 0, strrpos($query, "/")) . ($isChild ? "/" : "//") . "*";
+                            $descendant_delimeter = strrpos(($query ?? ''), "::");
+                            $isChild = substr(($query ?? ''), $descendant_delimeter-5, 5) == "child";
+                            $el = substr(($query ?? ''), $descendant_delimeter+2);
+                            $query = substr(($query ?? ''), 0, strrpos(($query ?? ''), "/")) . ($isChild ? "/" : "//") . "*";
 
                             $pseudo_classes[$tok] = true;
                             $p = $i + 1;
-                            $nth = trim(mb_substr($selector, $p, strpos($selector, ")", $i) - $p));
+                            $nth = trim((mb_substr(($selector ?? ''), $p, strpos(($selector ?? ''), ")", $i) - $p) ?? ''));
 
                             // 1
-                            if (preg_match("/^\d+$/", $nth)) {
+                            if (preg_match("/^\d+$/", ($nth ?? ''))) {
                                 $condition = "position() = $nth";
                             } // odd
                             elseif ($nth === "odd") {
@@ -681,10 +681,10 @@
                         case "matches":
                             $pseudo_classes[$tok] = true;
                             $p = $i + 1;
-                            $matchList = trim(mb_substr($selector, $p, strpos($selector, ")", $i) - $p));
+                            $matchList = trim((mb_substr(($selector ?? ''), $p, strpos(($selector ?? ''), ")", $i) - $p) ?? ''));
 
                             // Tag names are case-insensitive
-                            $elements = array_map("trim", explode(",", strtolower($matchList)));
+                            $elements = array_map("trim", explode(",", (strtolower(($matchList ?? '')) ?? '')));
                             foreach ($elements as &$element) {
                                 $element = "name() = '$element'";
                             }
@@ -703,7 +703,7 @@
                         case "first-letter":
                         case ":first-letter":
                             // TODO
-                            $el = trim($tok, ":");
+                            $el = trim(($tok ?? ''), ":");
                             $pseudo_elements[$el] = true;
                             break;
 
@@ -721,7 +721,7 @@
                         case ":before":
                         case "after":
                         case ":after":
-                            $pos = trim($tok, ":");
+                            $pos = trim(($tok ?? ''), ":");
                             $pseudo_elements[$pos] = true;
                             if (!$first_pass) {
                                 $query .= "/*[@$pos]";
@@ -758,7 +758,7 @@
                 case "[":
                     // Attribute selectors.  All with an attribute matching the following token(s)
                     $attr_delimiters = array("=", "]", "~", "|", "$", "^", "*");
-                    $tok_len = mb_strlen($tok);
+                    $tok_len = mb_strlen(($tok ?? ''));
                     $j = 0;
 
                     $attr = "";
@@ -809,7 +809,7 @@
                         throw new Exception("Invalid CSS selector syntax: missing attribute name");
                     }
 
-                    $value = trim($value, "\"'");
+                    $value = trim(($value ?? ''), "\"'");
 
                     switch ($op) {
 
@@ -824,29 +824,29 @@
                         case "~=":
                             // FIXME: this will break if $value contains quoted strings
                             // (e.g. [type~="a b c" "d e f"])
-                            $values = explode(" ", $value);
+                            $values = explode(" ", ($value ?? ''));
                             $query .= "[";
 
                             foreach ($values as $val) {
                                 $query .= "@$attr=\"$val\" or ";
                             }
 
-                            $query = rtrim($query, " or ") . "]";
+                            $query = rtrim(($query ?? ''), " or ") . "]";
                             break;
 
                         case "|=":
-                            $values = explode("-", $value);
+                            $values = explode("-", ($value ?? ''));
                             $query .= "[";
 
                             foreach ($values as $val) {
                                 $query .= "starts-with(@$attr, \"$val\") or ";
                             }
 
-                            $query = rtrim($query, " or ") . "]";
+                            $query = rtrim(($query ?? ''), " or ") . "]";
                             break;
 
                         case "$=":
-                            $query .= "[substring(@$attr, string-length(@$attr)-" . (strlen($value) - 1) . ")=\"$value\"]";
+                            $query .= "[substring(@$attr, string-length(@$attr)-" . (strlen(($value ?? '')) - 1) . ")=\"$value\"]";
                             break;
 
                         case "^=":
@@ -885,8 +885,8 @@
 
 
         // Trim the trailing '/' from the query
-        if (mb_strlen($query) > 2) {
-            $query = rtrim($query, "/");
+        if (mb_strlen(($query ?? '')) > 2) {
+            $query = rtrim(($query ?? ''), "/");
         }
 
         return array("query" => $query, "pseudo_elements" => $pseudo_elements);
@@ -901,8 +901,8 @@
      */
     protected function _selector_an_plus_b($expr, $last = false)
     {
-        $expr = preg_replace("/\s/", "", $expr);
-        if (!preg_match("/^(?P<a>-?[0-9]*)?n(?P<b>[-+]?[0-9]+)?$/", $expr, $matches)) {
+        $expr = preg_replace("/\s/", "", ($expr ?? ''));
+        if (!preg_match("/^(?P<a>-?[0-9]*)?n(?P<b>[-+]?[0-9]+)?$/", ($expr ?? ''), $matches)) {
             return "false()";
         }
 
@@ -954,7 +954,7 @@
         foreach ($this->_styles as $selector => $selector_styles) {
             /** @var Style $style */
             foreach ($selector_styles as $style) {
-                if (strpos($selector, ":before") === false && strpos($selector, ":after") === false) {
+                if (strpos(($selector ?? ''), ":before") === false && strpos(($selector ?? ''), ":after") === false) {
                     continue;
                 }
 
@@ -1079,7 +1079,7 @@
             // Locate any additional style attributes
             if (($str = $frame->get_node()->getAttribute("style")) !== "") {
                 // Destroy CSS comments
-                $str = preg_replace("'/\*.*?\*/'si", "", $str);
+                $str = preg_replace("'/\*.*?\*/'si", "", ($str ?? ''));
 
                 $spec = $this->_specificity("!attr", self::ORIG_AUTHOR);
                 $styles[$id][$spec][] = $this->_parse_properties($str);
@@ -1120,7 +1120,7 @@
                             // if any of the Style's media queries fail then do not apply the style
                             //TODO: When the media query logic is fully developed we should not apply the Style when any of the media queries fail or are bad, per https://www.w3.org/TR/css3-mediaqueries/#error-handling
                             if (in_array($media_query_feature, self::$VALID_MEDIA_TYPES)) {
-                                if ((strlen($media_query_feature) === 0 && !in_array($media_query, $acceptedmedia)) || (in_array($media_query, $acceptedmedia) && $media_query_value == "not")) {
+                                if ((strlen(($media_query_feature ?? '')) === 0 && !in_array($media_query, $acceptedmedia)) || (in_array($media_query, $acceptedmedia) && $media_query_value == "not")) {
                                     continue (3);
                                 }
                             } else {
@@ -1235,14 +1235,14 @@
     private function _parse_css($str)
     {
 
-        $str = trim($str);
+        $str = trim(($str ?? ''));
 
         // Destroy comments and remove HTML comments
         $css = preg_replace(array(
             "'/\*.*?\*/'si",
             "/^<!--/",
             "/-->$/"
-        ), "", $str);
+        ), "", ($str ?? ''));
 
         // FIXME: handle '{' within strings, e.g. [attr="string {}"]
 
@@ -1260,7 +1260,7 @@
             "([^{]*{[^}]*}))                        # Parse normal rulesets                               \n" .
             "/xs";
 
-        if (preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false) {
+        if (preg_match_all(($re ?? ''), ($css ?? ''), $matches, PREG_SET_ORDER) === false) {
             // An error occurred
             throw new Exception("Error parsing css file: preg_match_all() failed.");
         }
@@ -1281,7 +1281,7 @@
 
         //Helpers::pre_r($matches);
         foreach ($matches as $match) {
-            $match[2] = trim($match[2]);
+            $match[2] = trim(($match[2] ?? ''));
 
             if ($match[2] !== "") {
                 // Handle @rules
@@ -1295,7 +1295,7 @@
                         $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
                         $acceptedmedia[] = $this->_dompdf->getOptions()->getDefaultMediaType();
 
-                        $media_queries = preg_split("/\s*,\s*/", mb_strtolower(trim($match[3])));
+                        $media_queries = preg_split("/\s*,\s*/", (mb_strtolower(trim(($match[3] ?? ''))) ?? ''));
                         foreach ($media_queries as $media_query) {
                             if (in_array($media_query, $acceptedmedia)) {
                                 //if we have a media type match go ahead and parse the stylesheet
@@ -1303,16 +1303,16 @@
                                 break;
                             } elseif (!in_array($media_query, self::$VALID_MEDIA_TYPES)) {
                                 // otherwise conditionally parse the stylesheet assuming there are parseable media queries
-                                if (preg_match_all($media_query_regex, $media_query, $media_query_matches, PREG_SET_ORDER) !== false) {
+                                if (preg_match_all(($media_query_regex ?? ''), ($media_query ?? ''), $media_query_matches, PREG_SET_ORDER) !== false) {
                                     $mq = array();
                                     foreach ($media_query_matches as $media_query_match) {
                                         if (empty($media_query_match[1]) === false) {
-                                            $media_query_feature = strtolower($media_query_match[3]);
-                                            $media_query_value = strtolower($media_query_match[2]);
+                                            $media_query_feature = strtolower(($media_query_match[3] ?? ''));
+                                            $media_query_value = strtolower(($media_query_match[2] ?? ''));
                                             $mq[] = array($media_query_feature, $media_query_value);
                                         } else if (empty($media_query_match[4]) === false) {
-                                            $media_query_feature = strtolower($media_query_match[5]);
-                                            $media_query_value = (array_key_exists(8, $media_query_match) ? strtolower($media_query_match[8]) : null);
+                                            $media_query_feature = strtolower(($media_query_match[5] ?? ''));
+                                            $media_query_value = (array_key_exists(8, $media_query_match) ? strtolower(($media_query_match[8] ?? '')) : null);
                                             $mq[] = array($media_query_feature, $media_query_value);
                                         }
                                     }
@@ -1344,7 +1344,7 @@
                         //assign it to the <body> tag, possibly only for the css of the correct media type.
 
                         // If the page has a name, skip the style.
-                        $page_selector = trim($match[3]);
+                        $page_selector = trim(($match[3] ?? ''));
 
                         $key = null;
                         switch ($page_selector) {
@@ -1402,10 +1402,10 @@
         $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
         $parsed_url = "none";
 
-        if (mb_strpos($val, "url") === false) {
+        if (mb_strpos(($val ?? ''), "url") === false) {
             $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
         } else {
-            $val = preg_replace("/url\(\s*['\"]?([^'\")]+)['\"]?\s*\)/", "\\1", trim($val));
+            $val = preg_replace("/url\(\s*['\"]?([^'\")]+)['\"]?\s*\)/", "\\1", (trim(($val ?? '')) ?? ''));
 
             // Resolve the url now in the context of the current stylesheet
             $parsed_url = Helpers::explode_url($val);
@@ -1448,17 +1448,17 @@
      */
     private function _parse_import($url)
     {
-        $arr = preg_split("/[\s\n,]/", $url, -1, PREG_SPLIT_NO_EMPTY);
+        $arr = preg_split("/[\s\n,]/", ($url ?? ''), -1, PREG_SPLIT_NO_EMPTY);
         $url = array_shift($arr);
         $accept = false;
 
-        if (count($arr) > 0) {
+        if (count(($arr ?? [])) > 0) {
             $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
             $acceptedmedia[] = $this->_dompdf->getOptions()->getDefaultMediaType();
 
             // @import url media_type [media_type...]
             foreach ($arr as $type) {
-                if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
+                if (in_array(mb_strtolower(trim(($type ?? ''))), $acceptedmedia)) {
                     $accept = true;
                     break;
                 }
@@ -1503,16 +1503,16 @@
     {
         $descriptors = $this->_parse_properties($str);
 
-        preg_match_all("/(url|local)\s*\([\"\']?([^\"\'\)]+)[\"\']?\)\s*(format\s*\([\"\']?([^\"\'\)]+)[\"\']?\))?/i", $descriptors->src, $src);
+        preg_match_all("/(url|local)\s*\([\"\']?([^\"\'\)]+)[\"\']?\)\s*(format\s*\([\"\']?([^\"\'\)]+)[\"\']?\))?/i", ($descriptors->src ?? ''), $src);
 
         $sources = array();
         $valid_sources = array();
 
         foreach ($src[0] as $i => $value) {
             $source = array(
-                "local" => strtolower($src[1][$i]) === "local",
+                "local" => strtolower(($src[1][$i] ?? '')) === "local",
                 "uri" => $src[2][$i],
-                "format" => strtolower($src[4][$i]),
+                "format" => strtolower(($src[4][$i] ?? '')),
                 "path" => Helpers::build_url($this->_protocol, $this->_base_host, $this->_base_path, $src[2][$i]),
             );
 
@@ -1548,7 +1548,7 @@
      */
     private function _parse_properties($str)
     {
-        $properties = preg_split("/;(?=(?:[^\(]*\([^\)]*\))*(?![^\)]*\)))/", $str);
+        $properties = preg_split("/;(?=(?:[^\(]*\([^\)]*\))*(?![^\)]*\)))/", ($str ?? ''));
         $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
 
         if ($DEBUGCSS) {
@@ -1584,13 +1584,13 @@
             if ($DEBUGCSS) print '(';
 
             $important = false;
-            $prop = trim($prop);
-
-            if (substr($prop, -9) === 'important') {
-                $prop_tmp = rtrim(substr($prop, 0, -9));
-
-                if (substr($prop_tmp, -1) === '!') {
-                    $prop = rtrim(substr($prop_tmp, 0, -1));
+            $prop = trim(($prop ?? ''));
+
+            if (substr(($prop ?? ''), -9) === 'important') {
+                $prop_tmp = rtrim((substr(($prop ?? ''), 0, -9) ?? ''));
+
+                if (substr(($prop_tmp ?? ''), -1) === '!') {
+                    $prop = rtrim((substr(($prop_tmp ?? ''), 0, -1) ?? ''));
                     $important = true;
                 }
             }
@@ -1600,14 +1600,14 @@
                 continue;
             }
 
-            $i = mb_strpos($prop, ":");
+            $i = mb_strpos(($prop ?? ''), ":");
             if ($i === false) {
                 if ($DEBUGCSS) print 'novalue' . $prop . ')';
                 continue;
             }
 
-            $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i)));
-            $value = ltrim(mb_substr($prop, $i + 1));
+            $prop_name = rtrim((mb_strtolower(mb_substr(($prop ?? ''), 0, $i)) ?? ''));
+            $value = ltrim((mb_substr(($prop ?? ''), $i + 1) ?? ''));
             if ($DEBUGCSS) print $prop_name . ':=' . $value . ($important ? '!IMPORTANT' : '') . ')';
             //New style, anyway empty
             //if ($important || !$style->important_get($prop_name) ) {
@@ -1640,24 +1640,24 @@
 
         $patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
         $replacements = array(" ", "\\1");
-        $str = preg_replace($patterns, $replacements, $str);
+        $str = preg_replace(($patterns ?? ''), ($replacements ?? ''), ($str ?? ''));
         $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
 
-        $sections = explode("}", $str);
+        $sections = explode("}", ($str ?? ''));
         if ($DEBUGCSS) print '[_parse_sections';
         foreach ($sections as $sect) {
-            $i = mb_strpos($sect, "{");
+            $i = mb_strpos(($sect ?? ''), "{");
             if ($i === false) { continue; }
 
             //$selectors = explode(",", mb_substr($sect, 0, $i));
-            $selectors = preg_split("/,(?![^\(]*\))/", mb_substr($sect, 0, $i),0, PREG_SPLIT_NO_EMPTY);
+            $selectors = preg_split("/,(?![^\(]*\))/", (mb_substr(($sect ?? ''), 0, $i) ?? ''),0, PREG_SPLIT_NO_EMPTY);
             if ($DEBUGCSS) print '[section';
 
-            $style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));
+            $style = $this->_parse_properties(trim((mb_substr(($sect ?? ''), $i + 1) ?? '')));
 
             // Assign it to the selected elements
             foreach ($selectors as $selector) {
-                $selector = trim($selector);
+                $selector = trim(($selector ?? ''));
 
                 if ($selector == "") {
                     if ($DEBUGCSS) print '#empty#';
@@ -1667,7 +1667,7 @@
                 //if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }
 
                 //FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here
-                if (count($media_queries) > 0) {
+                if (count(($media_queries ?? [])) > 0) {
                     $style->set_media_queries($media_queries);
                 }
                 $this->add_style($selector, $style);
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameListIterator.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameListIterator.php
@@ -44,7 +44,7 @@
     /**
      *
      */
-    public function rewind()
+    public function rewind(): void
     {
         $this->_cur = $this->_parent->get_first_child();
         $this->_num = 0;
@@ -53,7 +53,7 @@
     /**
      * @return bool
      */
-    public function valid()
+    public function valid(): bool
     {
         return isset($this->_cur); // && ($this->_cur->get_prev_sibling() === $this->_prev);
     }
@@ -61,7 +61,7 @@
     /**
      * @return int
      */
-    public function key()
+    public function key(): mixed
     {
         return $this->_num;
     }
@@ -69,7 +69,7 @@
     /**
      * @return Frame
      */
-    public function current()
+    public function current(): mixed
     {
         return $this->_cur;
     }
@@ -77,6 +77,7 @@
     /**
      * @return Frame
      */
+    #[\ReturnTypeWillChange]
     public function next()
     {
         $ret = $this->_cur;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTreeList.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTreeList.php
@@ -28,7 +28,7 @@
     /**
      * @return FrameTreeIterator
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new FrameTreeIterator($this->_root);
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTreeIterator.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTreeIterator.php
@@ -41,7 +41,7 @@
     /**
      *
      */
-    public function rewind()
+    public function rewind(): void
     {
         $this->_stack = array($this->_root);
         $this->_num = 0;
@@ -50,15 +50,15 @@
     /**
      * @return bool
      */
-    public function valid()
+    public function valid(): bool
     {
-        return count($this->_stack) > 0;
+        return count(($this->_stack ?? [])) > 0;
     }
 
     /**
      * @return int
      */
-    public function key()
+    public function key(): mixed
     {
         return $this->_num;
     }
@@ -66,7 +66,7 @@
     /**
      * @return Frame
      */
-    public function current()
+    public function current(): mixed
     {
         return end($this->_stack);
     }
@@ -74,6 +74,7 @@
     /**
      * @return Frame
      */
+    #[\ReturnTypeWillChange]
     public function next()
     {
         $b = end($this->_stack);
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameList.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameList.php
@@ -28,7 +28,7 @@
     /**
      * @return FrameListIterator
      */
-    function getIterator()
+    function getIterator(): \Traversable
     {
         return new FrameListIterator($this->_frame);
     }
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTree.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/Frame/FrameTree.php
@@ -246,9 +246,9 @@
         }
         $index = 0;
         // INFO: We don't advance $index if a node is removed to avoid skipping nodes
-        while ($index < count($children)) {
+        while ($index < count(($children ?? []))) {
             $child = $children[$index];
-            $nodeName = strtolower($child->nodeName);
+            $nodeName = strtolower(($child->nodeName ?? ''));
 
             // Skip non-displaying nodes
             if (in_array($nodeName, self::$HIDDEN_TAGS)) {
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/AbstractFrameDecorator.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/AbstractFrameDecorator.php
@@ -744,7 +744,7 @@
 
         // If this node resets a counter save the current value to use when rendering on the next page
         if ($style->counter_reset && ($reset = $style->counter_reset) !== "none") {
-            $vars = preg_split('/\s+/', trim($reset), 2);
+            $vars = preg_split('/\s+/', (trim(($reset ?? '')) ?? ''), 2);
             $split->_counters['__' . $vars[0]] = $this->lookup_counter_frame($vars[0])->_counters[$vars[0]];
         }
     }
@@ -842,7 +842,7 @@
                 return $value;
 
             case "decimal-leading-zero":
-                return str_pad($value, 2, "0", STR_PAD_LEFT);
+                return str_pad(($value ?? ''), 2, "0", STR_PAD_LEFT);
 
             case "lower-roman":
                 return Helpers::dec2roman($value);
@@ -852,11 +852,11 @@
 
             case "lower-latin":
             case "lower-alpha":
-                return chr(($value % 26) + ord('a') - 1);
+                return chr((int) (($value % 26) + ord('a') - 1));
 
             case "upper-latin":
             case "upper-alpha":
-                return chr(($value % 26) + ord('A') - 1);
+                return chr((int) (($value % 26) + ord('A') - 1));
 
             case "lower-greek":
                 return Helpers::unichr($value + 944);
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/ListBulletImage.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/ListBulletImage.php
@@ -60,8 +60,8 @@
         // See also Image::get_min_max_width
         // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary.
         $dpi = $this->_dompdf->getOptions()->getDpi();
-        $this->_width = ((float)rtrim($width, "px") * 72) / $dpi;
-        $this->_height = ((float)rtrim($height, "px") * 72) / $dpi;
+        $this->_width = ((float)rtrim(($width ?? ''), "px") * 72) / $dpi;
+        $this->_height = ((float)rtrim(($height ?? ''), "px") * 72) / $dpi;
 
         //If an image is taller as the containing block/box, the box should be extended.
         //Neighbour elements are overwriting the overlapping image areas.
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Table.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Table.php
@@ -129,7 +129,7 @@
 
         // If $child is a header or if it is the first non-header row, do
         // not duplicate headers, simply move the table to the next page.
-        if (count($this->_headers) && !in_array($child, $this->_headers, true) &&
+        if (count(($this->_headers ?? [])) && !in_array($child, $this->_headers, true) &&
             !in_array($child->get_prev_sibling(), $this->_headers, true)
         ) {
             $first_header = null;
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Page.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Page.php
@@ -363,7 +363,7 @@
 
                 // Rule C
                 $block_parent = $frame->find_block_parent();
-                if (count($block_parent->get_line_boxes()) < $frame->get_style()->orphans) {
+                if (count(($block_parent->get_line_boxes() ?? [])) < $frame->get_style()->orphans) {
                     Helpers::dompdf_debug("page-break", "orphans");
 
                     return false;
@@ -387,7 +387,7 @@
                 // page-break-inside: avoid, ensure that at least one frame with
                 // some content is on the page before splitting.
                 $prev = $frame->get_prev_sibling();
-                while ($prev && ($prev->is_text_node() && trim($prev->get_node()->nodeValue) == "")) {
+                while ($prev && ($prev->is_text_node() && trim(($prev->get_node()->nodeValue ?? '')) == "")) {
                     $prev = $prev->get_prev_sibling();
                 }
 
--- a/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Block.php
+++ b/intranet/marketplaces-api/vendor/dompdf/dompdf/src/FrameDecorator/Block.php
@@ -87,7 +87,7 @@
      */
     function set_current_line_number($line_number)
     {
-        $line_boxes_count = count($this->_line_boxes);
+        $line_boxes_count = count(($this->_line_boxes ?? []));
         $cl = max(min($line_number, $line_boxes_count), 0);
         return ($this->_cl = $cl);
     }
@@ -148,7 +148,7 @@
             $frame->is_text_node() &&
             !$frame->is_pre()
         ) {
-            $frame->set_text(ltrim($frame->get_text()));
+            $frame->set_text(ltrim(($frame->get_text() ?? '')));
             $frame->recalculate_width();
         }
 
@@ -188,7 +188,7 @@
         $current_line->add_frame($frame);
 
         if ($frame->is_text_node()) {
-            $current_line->wc += count(preg_split("/\s+/", trim($frame->get_text())));
+            $current_line->wc += count((preg_split("/\s+/", (trim(($frame->get_text() ?? '')) ?? '')) ?? []));
         }
 
         $this->increase_line_width($w);
@@ -218,7 +218,7 @@
         }
 
         // Remove $frame and all frames that follow
-        while ($j < count($this->_line_boxes[$i]->get_frames())) {
+        while ($j < count(($this->_line_boxes[$i]->get_frames() ?? []))) {
             $frames = $this->_line_boxes[$i]->get_frames();
             $f = $frames[$j];
             $frames[$j] = null;
--- a/intranet/marketplaces-api/vendor/Mailer/phpmailer.php
+++ b/intranet/marketplaces-api/vendor/Mailer/phpmailer.php
@@ -28,6 +28,7 @@
  * @author  Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  * @author  Brent R. Matzelle (original founder)
  */
+#[\AllowDynamicProperties]
 class PHPMailer
 {
     const CHARSET_ISO88591 = 'iso-8859-1';
@@ -801,7 +802,7 @@
     private function mailPassthru($to, $subject, $body, $header, $params)
     {
         //Check overloading of mail function to avoid double-encoding
-        if (ini_get('mbstring.func_overload') & 1) {
+        if ('0' & 1) {
             $subject = $this->secureHeader($subject);
         } else {
             $subject = $this->encodeHeader($this->secureHeader($subject));
@@ -4328,11 +4329,11 @@
             $privKey = openssl_pkey_get_private($privKeyStr);
         }
         if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
-            openssl_pkey_free($privKey);
+            unset($privKey);
 
             return base64_encode($signature);
         }
-        openssl_pkey_free($privKey);
+        unset($privKey);
 
         return '';
     }
--- a/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/GDLuminanceSource.php
+++ b/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/GDLuminanceSource.php
@@ -52,7 +52,7 @@
         $this->dataHeight = $height;
         $this->left       = 0;
         $this->top        = 0;
-        $this->$gdImage   = $gdImage;
+        $this->gdImage   = $gdImage;
 
 
 // In order to measure pure decoding speed, we convert the entire image to a greyscale array
@@ -65,8 +65,8 @@
 
         for ($j = 0; $j < $height; $j++) {
             for ($i = 0; $i < $width; $i++) {
-                $argb  = imagecolorat($this->$gdImage, $i, $j);
-                $pixel = imagecolorsforindex($this->$gdImage, $argb);
+                $argb  = imagecolorat($this->gdImage, (int) ($i), (int) ($j));
+                $pixel = imagecolorsforindex($this->gdImage, (int) ($argb));
                 $r     = $pixel['red'];
                 $g     = $pixel['green'];
                 $b     = $pixel['blue'];
@@ -76,7 +76,7 @@
                     $this->luminances[] = $r;//(($r + 128) % 256) - 128;
                 } else {
 // Calculate luminance cheaply, favoring green.
-                    $this->luminances[] = ($r + 2 * $g + $b) / 4;//(((($r + 2 * $g + $b) / 4) + 128) % 256) - 128;
+                    $this->luminances[] = intdiv($r + 2 * $g + $b, 4);//(((intdiv($r + 2 * $g + $b, 4)) + 128) % 256) - 128;
                 }
             }
         }
@@ -95,7 +95,7 @@
                     $this->luminances[(int)($offset + $x)] = (($r+128) % 256) - 128;
                 } else {
 // Calculate luminance cheaply, favoring green.
-                    $this->luminances[(int)($offset + $x)] =  (((($r + 2 * $g + $b) / 4)+128)%256) - 128;
+                    $this->luminances[(int)($offset + $x)] =  (((intdiv($r + 2 * $g + $b, 4))+128)%256) - 128;
                 }
 
 
--- a/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php
+++ b/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php
@@ -62,7 +62,7 @@
             $height = $im->getImageHeight();
             $source = new IMagickLuminanceSource($im, $width, $height);
         } else {
-            if (!is_resource($im)) {
+            if (!($im instanceof \GdImage)) {
                 throw new \InvalidArgumentException('Invalid image source.');
             }
             $width  = imagesx($im);
--- a/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/BitMatrix.php
+++ b/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/BitMatrix.php
@@ -39,7 +39,7 @@
         $nRows       = 0;
         $pos         = 0;
         while ($pos < strlen($stringRepresentation)) {
-            if ($stringRepresentation{$pos} == '\n' ||
+            if ($stringRepresentation[$pos] == '\n' ||
                 $stringRepresentation->{$pos} == '\r') {
                 if ($bitsPos > $rowStartPos) {
                     if ($rowLength == -1) {
@@ -93,6 +93,8 @@
      */
     public function set($x, $y)
     {
+        $x = (int) $x;
+        $y = (int) $y;
         $offset = (int)($y * $this->rowSize + ($x / 32));
         if (!isset($this->bits[$offset])) {
             $this->bits[$offset] = 0;
@@ -111,7 +113,9 @@
     }
 
     public function _unset($x, $y)
-    {//Ð±Ñ‹Ð»Ð¾ unset, php Ð½Ðµ Ð¿Ð¾Ð·Ð²Ð¾Ð»Ñ�ÐµÑ‚ Ð¸Ñ�Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÑŒ unset
+    {
+        $x = (int) $x;
+        $y = (int) $y;//Ð±Ñ‹Ð»Ð¾ unset, php Ð½Ðµ Ð¿Ð¾Ð·Ð²Ð¾Ð»Ñ�ÐµÑ‚ Ð¸Ñ�Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÑŒ unset
         $offset              = (int)($y * $this->rowSize + ($x / 32));
         $this->bits[$offset] &= ~(1 << ($x & 0x1f));
     }
@@ -124,6 +128,8 @@
      */
     public function flip($x, $y)
     {
+        $x = (int) $x;
+        $y = (int) $y;
         $offset = $y * $this->rowSize + (int)($x / 32);
 
         $this->bits[$offset] = ($this->bits[$offset] ^ (1 << ($x & 0x1f)));
@@ -439,6 +445,8 @@
      */
     public function get($x, $y)
     {
+        $x = (int) $x;
+        $y = (int) $y;
 
         $offset = (int)($y * $this->rowSize + ($x / 32));
         if (!isset($this->bits[$offset])) {
--- a/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/BitArray.php
+++ b/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/BitArray.php
@@ -30,6 +30,7 @@
  * @author Sean Owen
  */
 
+#[\AllowDynamicProperties]
 final class BitArray
 {
 
--- a/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Qrcode/Decoder/DecodedBitStreamParser.php
+++ b/intranet/libs/qrlib/vendor/khanamiryan/qrcode-detector-decoder/lib/Qrcode/Decoder/DecodedBitStreamParser.php
@@ -266,8 +266,8 @@
         if ($fc1InEffect) {
             // We need to massage the result a bit if in an FNC1 mode:
             for ($i = $start; $i < strlen($result); $i++) {
-                if ($result{$i} == '%') {
-                    if ($i < strlen($result) - 1 && $result{$i + 1} == '%') {
+                if ($result[$i] == '%') {
+                    if ($i < strlen($result) - 1 && $result[$i + 1] == '%') {
                         // %% is rendered as %
                         $result = substr_replace($result, '', $i + 1, 1);//deleteCharAt(i + 1);
                     } else {
--- a/intranet/libs/qrlib/vendor/dasprid/enum/src/EnumMap.php
+++ b/intranet/libs/qrlib/vendor/dasprid/enum/src/EnumMap.php
@@ -261,6 +261,11 @@
 
     public function serialize() : string
     {
+        return serialize($this->__serialize());
+    }
+
+    public function __serialize() : array
+    {
         $values = [];
 
         foreach ($this->values as $ordinal => $value) {
@@ -271,17 +276,21 @@
             $values[$ordinal] = $this->unmaskNull($value);
         }
 
-        return serialize([
+        return [
             'keyType' => $this->keyType,
             'valueType' => $this->valueType,
             'allowNullValues' => $this->allowNullValues,
             'values' => $values,
-        ]);
+        ];
     }
 
     public function unserialize($serialized) : void
     {
-        $data = unserialize($serialized);
+        $this->__unserialize(unserialize($serialized));
+    }
+
+    public function __unserialize(array $data) : void
+    {
         $this->__construct($data['keyType'], $data['valueType'], $data['allowNullValues']);
 
         foreach ($this->keyUniverse as $key) {
--- a/intranet/libs/qrlib/vendor/dasprid/enum/src/AbstractEnum.php
+++ b/intranet/libs/qrlib/vendor/dasprid/enum/src/AbstractEnum.php
@@ -85,7 +85,7 @@
     /**
      * @return static
      */
-    final private static function createValue(string $name, int $ordinal, array $arguments) : self
+    private static function createValue(string $name, int $ordinal, array $arguments) : self
     {
         $instance = new static(...$arguments);
         $instance->name = $name;
@@ -125,7 +125,7 @@
         return self::$values[static::class];
     }
 
-    final private static function constants() : array
+    private static function constants() : array
     {
         if (isset(self::$constants[static::class])) {
             return self::$constants[static::class];
@@ -214,7 +214,7 @@
      *
      * @throws SerializeNotSupportedException
      */
-    final public function __sleep() : void
+    final public function __sleep() : array
     {
         throw new SerializeNotSupportedException();
     }
--- a/intranet/libs/qrlib/vendor/dasprid/enum/src/NullValue.php
+++ b/intranet/libs/qrlib/vendor/dasprid/enum/src/NullValue.php
@@ -38,7 +38,7 @@
      *
      * @throws SerializeNotSupportedException
      */
-    final public function __sleep() : void
+    final public function __sleep() : array
     {
         throw new SerializeNotSupportedException();
     }
--- a/intranet/libs/qrlib/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php
+++ b/intranet/libs/qrlib/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php
@@ -204,7 +204,7 @@
                 break;
 
             case 4:
-                $intermediate = (BitUtils::unsignedRightShift($y, 1) + ($x / 3)) & 0x1;
+                $intermediate = (BitUtils::unsignedRightShift($y, 1) + intdiv($x, 3)) & 0x1;
                 break;
 
             case 5:
--- a/intranet/libs/qrlib/vendor/endroid/qr-code/src/Writer/PngWriter.php
+++ b/intranet/libs/qrlib/vendor/endroid/qr-code/src/Writer/PngWriter.php
@@ -62,20 +62,20 @@
     /** @return resource */
     private function createBaseImage(int $baseSize, array $data, QrCodeInterface $qrCode)
     {
-        $image = imagecreatetruecolor($data['block_count'] * $baseSize, $data['block_count'] * $baseSize);
-
-        if (!is_resource($image)) {
+        $image = imagecreatetruecolor((int) ($data['block_count'] * $baseSize), (int) ($data['block_count'] * $baseSize));
+
+        if (!($image instanceof \GdImage)) {
             throw new GenerateImageException('Unable to generate image: check your GD installation');
         }
 
-        $foregroundColor = imagecolorallocatealpha($image, $qrCode->getForegroundColor()['r'], $qrCode->getForegroundColor()['g'], $qrCode->getForegroundColor()['b'], $qrCode->getForegroundColor()['a']);
-        $backgroundColor = imagecolorallocatealpha($image, $qrCode->getBackgroundColor()['r'], $qrCode->getBackgroundColor()['g'], $qrCode->getBackgroundColor()['b'], $qrCode->getBackgroundColor()['a']);
-        imagefill($image, 0, 0, $backgroundColor);
+        $foregroundColor = imagecolorallocatealpha($image, (int) ($qrCode->getForegroundColor()['r']), (int) ($qrCode->getForegroundColor()['g']), (int) ($qrCode->getForegroundColor()['b']), (int) ($qrCode->getForegroundColor()['a']));
+        $backgroundColor = imagecolorallocatealpha($image, (int) ($qrCode->getBackgroundColor()['r']), (int) ($qrCode->getBackgroundColor()['g']), (int) ($qrCode->getBackgroundColor()['b']), (int) ($qrCode->getBackgroundColor()['a']));
+        imagefill($image, 0, 0, (int) ($backgroundColor));
 
         foreach ($data['matrix'] as $row => $values) {
             foreach ($values as $column => $value) {
                 if (1 === $value) {
-                    imagefilledrectangle($image, $column * $baseSize, $row * $baseSize, intval(($column + 1) * $baseSize), intval(($row + 1) * $baseSize), $foregroundColor);
+                    imagefilledrectangle($image, (int) ($column * $baseSize), (int) ($row * $baseSize), (int) (intval(($column + 1) * $baseSize)), (int) (intval(($row + 1) * $baseSize)), (int) ($foregroundColor));
                 }
             }
         }
@@ -90,15 +90,15 @@
      */
     private function createInterpolatedImage($baseImage, array $data, QrCodeInterface $qrCode)
     {
-        $image = imagecreatetruecolor($data['outer_width'], $data['outer_height']);
-
-        if (!is_resource($image)) {
+        $image = imagecreatetruecolor((int) ($data['outer_width']), (int) ($data['outer_height']));
+
+        if (!($image instanceof \GdImage)) {
             throw new GenerateImageException('Unable to generate image: check your GD installation');
         }
 
-        $backgroundColor = imagecolorallocatealpha($image, $qrCode->getBackgroundColor()['r'], $qrCode->getBackgroundColor()['g'], $qrCode->getBackgroundColor()['b'], $qrCode->getBackgroundColor()['a']);
-        imagefill($image, 0, 0, $backgroundColor);
-        imagecopyresampled($image, $baseImage, (int) $data['margin_left'], (int) $data['margin_left'], 0, 0, (int) $data['inner_width'], (int) $data['inner_height'], imagesx($baseImage), imagesy($baseImage));
+        $backgroundColor = imagecolorallocatealpha($image, (int) ($qrCode->getBackgroundColor()['r']), (int) ($qrCode->getBackgroundColor()['g']), (int) ($qrCode->getBackgroundColor()['b']), (int) ($qrCode->getBackgroundColor()['a']));
+        imagefill($image, 0, 0, (int) ($backgroundColor));
+        imagecopyresampled($image, $baseImage, (int) $data['margin_left'], (int) $data['margin_left'], 0, 0, (int) $data['inner_width'], (int) $data['inner_height'], (int) (imagesx($baseImage)), (int) (imagesy($baseImage)));
         imagesavealpha($image, true);
 
         return $image;
@@ -118,7 +118,7 @@
             throw new MissingLogoHeightException('SVG Logos require an explicit height set via setLogoSize($width, $height)');
         }
 
-        if (!is_resource($logoImage)) {
+        if (!($logoImage instanceof \GdImage)) {
             throw new GenerateImageException('Unable to generate image: check your GD installation or logo path');
         }
 
@@ -137,7 +137,7 @@
         $logoX = imagesx($sourceImage) / 2 - $logoWidth / 2;
         $logoY = imagesy($sourceImage) / 2 - $logoHeight / 2;
 
-        imagecopyresampled($sourceImage, $logoImage, intval($logoX), intval($logoY), 0, 0, $logoWidth, $logoHeight, $logoSourceWidth, $logoSourceHeight);
+        imagecopyresampled($sourceImage, $logoImage, (int) (intval($logoX)), (int) (intval($logoY)), 0, 0, (int) ($logoWidth), (int) ($logoHeight), (int) ($logoSourceWidth), (int) ($logoSourceHeight));
 
         return $sourceImage;
     }
@@ -163,18 +163,18 @@
         $targetHeight = $sourceHeight + $labelBoxHeight + $labelMargin['t'] + $labelMargin['b'];
 
         // Create empty target image
-        $targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
-
-        if (!is_resource($targetImage)) {
+        $targetImage = imagecreatetruecolor((int) ($targetWidth), (int) ($targetHeight));
+
+        if (!($targetImage instanceof \GdImage)) {
             throw new GenerateImageException('Unable to generate image: check your GD installation');
         }
 
-        $foregroundColor = imagecolorallocate($targetImage, $foregroundColor['r'], $foregroundColor['g'], $foregroundColor['b']);
-        $backgroundColor = imagecolorallocate($targetImage, $backgroundColor['r'], $backgroundColor['g'], $backgroundColor['b']);
-        imagefill($targetImage, 0, 0, $backgroundColor);
+        $foregroundColor = imagecolorallocate($targetImage, (int) ($foregroundColor['r']), (int) ($foregroundColor['g']), (int) ($foregroundColor['b']));
+        $backgroundColor = imagecolorallocate($targetImage, (int) ($backgroundColor['r']), (int) ($backgroundColor['g']), (int) ($backgroundColor['b']));
+        imagefill($targetImage, 0, 0, (int) ($backgroundColor));
 
         // Copy source image to target image
-        imagecopyresampled($targetImage, $sourceImage, 0, 0, 0, 0, $sourceWidth, $sourceHeight, $sourceWidth, $sourceHeight);
+        imagecopyresampled($targetImage, $sourceImage, 0, 0, 0, 0, (int) ($sourceWidth), (int) ($sourceHeight), (int) ($sourceWidth), (int) ($sourceHeight));
 
         switch ($labelAlignment) {
             case LabelAlignment::LEFT:
@@ -189,7 +189,7 @@
         }
 
         $labelY = $targetHeight - $labelMargin['b'];
-        imagettftext($targetImage, $labelFontSize, 0, $labelX, $labelY, $foregroundColor, $labelFontPath, $label);
+        imagettftext($targetImage, $labelFontSize, 0, (int) ($labelX), (int) ($labelY), (int) ($foregroundColor), $labelFontPath, $label);
 
         return $targetImage;
     }
--- a/intranet/libs/qrlib/vendor/endroid/qr-code/src/Writer/SvgWriter.php
+++ b/intranet/libs/qrlib/vendor/endroid/qr-code/src/Writer/SvgWriter.php
@@ -97,7 +97,7 @@
         if (null === $logoHeight || null === $logoWidth) {
             $logoImage = imagecreatefromstring(strval($imageData));
 
-            if (!is_resource($logoImage)) {
+            if (!($logoImage instanceof \GdImage)) {
                 throw new GenerateImageException('Unable to generate image: check your GD installation or logo path');
             }
 
--- a/intranet/libs/qrlib/vendor/endroid/qr-code/tests/QrCodeTest.php
+++ b/intranet/libs/qrlib/vendor/endroid/qr-code/tests/QrCodeTest.php
@@ -167,7 +167,7 @@
 
         $image = imagecreatefromstring(file_get_contents($filename));
 
-        $this->assertTrue(is_resource($image));
+        $this->assertTrue(($image instanceof \GdImage));
     }
 
     public function testData(): void
--- a/intranet/libs/qrlib/vendor/symfony/http-foundation/HeaderBag.php
+++ b/intranet/libs/qrlib/vendor/symfony/http-foundation/HeaderBag.php
@@ -252,7 +252,7 @@
      *
      * @return \ArrayIterator An \ArrayIterator instance
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new \ArrayIterator($this->headers);
     }
@@ -262,7 +262,7 @@
      *
      * @return int The number of headers
      */
-    public function count()
+    public function count(): int
     {
         return \count($this->headers);
     }
--- a/intranet/libs/qrlib/vendor/symfony/http-foundation/ParameterBag.php
+++ b/intranet/libs/qrlib/vendor/symfony/http-foundation/ParameterBag.php
@@ -188,7 +188,7 @@
      *
      * @return \ArrayIterator An \ArrayIterator instance
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new \ArrayIterator($this->parameters);
     }
@@ -198,7 +198,7 @@
      *
      * @return int The number of parameters
      */
-    public function count()
+    public function count(): int
     {
         return \count($this->parameters);
     }
--- a/intranet/libs/qrlib/vendor/symfony/http-foundation/Session/Session.php
+++ b/intranet/libs/qrlib/vendor/symfony/http-foundation/Session/Session.php
@@ -121,7 +121,7 @@
      *
      * @return \ArrayIterator An \ArrayIterator instance
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new \ArrayIterator($this->getAttributeBag()->all());
     }
@@ -131,7 +131,7 @@
      *
      * @return int
      */
-    public function count()
+    public function count(): int
     {
         return \count($this->getAttributeBag()->all());
     }
--- a/intranet/libs/qrlib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
+++ b/intranet/libs/qrlib/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php
@@ -131,7 +131,7 @@
      *
      * @return \ArrayIterator An \ArrayIterator instance
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new \ArrayIterator($this->attributes);
     }
@@ -141,7 +141,7 @@
      *
      * @return int The number of attributes
      */
-    public function count()
+    public function count(): int
     {
         return \count($this->attributes);
     }
--- a/intranet/libs/qrlib/vendor/symfony/property-access/PropertyPath.php
+++ b/intranet/libs/qrlib/vendor/symfony/property-access/PropertyPath.php
@@ -154,7 +154,7 @@
      *
      * @return PropertyPathIteratorInterface
      */
-    public function getIterator()
+    public function getIterator(): \Traversable
     {
         return new PropertyPathIterator($this);
     }
--- a/intranet/libs/qrlib/vendor/symfony/mime/RawMessage.php
+++ b/intranet/libs/qrlib/vendor/symfony/mime/RawMessage.php
@@ -16,7 +16,7 @@
 /**
  * @author Fabien Potencier <fabien@symfony.com>
  */
-class RawMessage implements \Serializable
+class RawMessage
 {
     private $message;
 
--- a/intranet/libs/qrlib/vendor/symfony/mime/Part/SMimePart.php
+++ b/intranet/libs/qrlib/vendor/symfony/mime/Part/SMimePart.php
@@ -18,6 +18,9 @@
  */
 class SMimePart extends AbstractPart
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_headers;
+
     private $body;
     private $type;
     private $subtype;
--- a/intranet/libs/qrlib/vendor/symfony/mime/Part/TextPart.php
+++ b/intranet/libs/qrlib/vendor/symfony/mime/Part/TextPart.php
@@ -23,6 +23,9 @@
  */
 class TextPart extends AbstractPart
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_headers;
+
     private static $encoders = [];
 
     private $body;
--- a/intranet/libs/qrlib/vendor/symfony/mime/Part/DataPart.php
+++ b/intranet/libs/qrlib/vendor/symfony/mime/Part/DataPart.php
@@ -20,6 +20,10 @@
  */
 class DataPart extends TextPart
 {
+    // Properties used by this legacy class, declared explicitly for PHP 8.2+.
+    public $_parent;
+    public $_headers;
+
     private static $mimeTypes;
 
     private $filename;
--- a/intranet/libs/qrlib/vendor/symfony/polyfill-intl-idn/bootstrap.php
+++ b/intranet/libs/qrlib/vendor/symfony/polyfill-intl-idn/bootstrap.php
@@ -49,11 +49,6 @@
     define('IDNA_ERROR_BIDI', 2048);
     define('IDNA_ERROR_CONTEXTJ', 4096);
 
-    if (PHP_VERSION_ID < 70400) {
-        function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
-        function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
-    } else {
         function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
         function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
-    }
 }
--- a/intranet/libs/qrlib/vendor/myclabs/php-enum/src/Enum.php
+++ b/intranet/libs/qrlib/vendor/myclabs/php-enum/src/Enum.php
@@ -232,7 +232,7 @@
      * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
      * @psalm-pure
      */
-    public function jsonSerialize()
+    public function jsonSerialize(): mixed
     {
         return $this->getValue();
     }
--- a/intranet/mailer/mailer.php
+++ b/intranet/mailer/mailer.php
@@ -28,6 +28,7 @@
  * @author  Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  * @author  Brent R. Matzelle (original founder)
  */
+#[\AllowDynamicProperties]
 class PHPMailer
 {
     const CHARSET_ISO88591 = 'iso-8859-1';
@@ -801,7 +802,7 @@
     private function mailPassthru($to, $subject, $body, $header, $params)
     {
         //Check overloading of mail function to avoid double-encoding
-        if (ini_get('mbstring.func_overload') & 1) {
+        if ('0' & 1) {
             $subject = $this->secureHeader($subject);
         } else {
             $subject = $this->encodeHeader($this->secureHeader($subject));
@@ -2668,13 +2669,21 @@
                 throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
             }
         } elseif ($this->sign_key_file) {
+            $fileHandle = null;
+            $signedHandle = null;
             try {
                 if (!defined('PKCS7_TEXT')) {
                     throw new Exception($this->lang('extension_missing') . 'openssl');
                 }
-                $file = fopen('php://temp', 'rb+');
-                $signed = fopen('php://temp', 'rb+');
-                fwrite($file, $body);
+                // OpenSSL requires filesystem paths, not PHP stream resources.
+                $fileHandle = tmpfile();
+                $signedHandle = tmpfile();
+                if ($fileHandle === false || $signedHandle === false) {
+                    throw new Exception($this->lang('signing') . 'Cannot create signing files.');
+                }
+                $file = stream_get_meta_data($fileHandle)['uri'];
+                $signed = stream_get_meta_data($signedHandle)['uri'];
+                fwrite($fileHandle, $body);
 
                 //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
                 if (empty($this->sign_extracerts_file)) {
@@ -2696,16 +2705,13 @@
                         $this->sign_extracerts_file
                     );
                 }
-                fclose($file);
                 if ($sign) {
                     $body = file_get_contents($signed);
-                    fclose($signed);
                     //The message returned by openssl contains both headers and body, so need to split them up
                     $parts = explode("\n\n", $body, 2);
                     $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
                     $body = $parts[1];
                 } else {
-                    fclose($signed);
                     throw new Exception($this->lang('signing') . openssl_error_string());
                 }
             } catch (Exception $exc) {
@@ -2713,6 +2719,9 @@
                 if ($this->exceptions) {
                     throw $exc;
                 }
+            } finally {
+                if (is_resource($fileHandle)) fclose($fileHandle);
+                if (is_resource($signedHandle)) fclose($signedHandle);
             }
         }
 
@@ -4328,11 +4337,11 @@
             $privKey = openssl_pkey_get_private($privKeyStr);
         }
         if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
-            openssl_pkey_free($privKey);
+            unset($privKey);
 
             return base64_encode($signature);
         }
-        openssl_pkey_free($privKey);
+        unset($privKey);
 
         return '';
     }
--- a/intranet/mailer2/mailer.php
+++ b/intranet/mailer2/mailer.php
@@ -28,6 +28,7 @@
  * @author  Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  * @author  Brent R. Matzelle (original founder)
  */
+#[\AllowDynamicProperties]
 class PHPMailer
 {
     const CHARSET_ISO88591 = 'iso-8859-1';
@@ -801,7 +802,7 @@
     private function mailPassthru($to, $subject, $body, $header, $params)
     {
         //Check overloading of mail function to avoid double-encoding
-        if (ini_get('mbstring.func_overload') & 1) {
+        if ('0' & 1) {
             $subject = $this->secureHeader($subject);
         } else {
             $subject = $this->encodeHeader($this->secureHeader($subject));
@@ -2668,13 +2669,21 @@
                 throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
             }
         } elseif ($this->sign_key_file) {
+            $fileHandle = null;
+            $signedHandle = null;
             try {
                 if (!defined('PKCS7_TEXT')) {
                     throw new Exception($this->lang('extension_missing') . 'openssl');
                 }
-                $file = fopen('php://temp', 'rb+');
-                $signed = fopen('php://temp', 'rb+');
-                fwrite($file, $body);
+                // OpenSSL requires filesystem paths, not PHP stream resources.
+                $fileHandle = tmpfile();
+                $signedHandle = tmpfile();
+                if ($fileHandle === false || $signedHandle === false) {
+                    throw new Exception($this->lang('signing') . 'Cannot create signing files.');
+                }
+                $file = stream_get_meta_data($fileHandle)['uri'];
+                $signed = stream_get_meta_data($signedHandle)['uri'];
+                fwrite($fileHandle, $body);
 
                 //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
                 if (empty($this->sign_extracerts_file)) {
@@ -2696,16 +2705,13 @@
                         $this->sign_extracerts_file
                     );
                 }
-                fclose($file);
                 if ($sign) {
                     $body = file_get_contents($signed);
-                    fclose($signed);
                     //The message returned by openssl contains both headers and body, so need to split them up
                     $parts = explode("\n\n", $body, 2);
                     $this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
                     $body = $parts[1];
                 } else {
-                    fclose($signed);
                     throw new Exception($this->lang('signing') . openssl_error_string());
                 }
             } catch (Exception $exc) {
@@ -2713,6 +2719,9 @@
                 if ($this->exceptions) {
                     throw $exc;
                 }
+            } finally {
+                if (is_resource($fileHandle)) fclose($fileHandle);
+                if (is_resource($signedHandle)) fclose($signedHandle);
             }
         }
 
@@ -4328,11 +4337,11 @@
             $privKey = openssl_pkey_get_private($privKeyStr);
         }
         if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
-            openssl_pkey_free($privKey);
+            unset($privKey);
 
             return base64_encode($signature);
         }
-        openssl_pkey_free($privKey);
+        unset($privKey);
 
         return '';
     }
--- a/intranet/phpqrcode/qrinput.php
+++ b/intranet/phpqrcode/qrinput.php
@@ -467,7 +467,7 @@
         }
         
         //----------------------------------------------------------------------
-        public function estimateBitsModeKanji($size)
+        public static function estimateBitsModeKanji($size)
         {
             return (int)(($size / 2) * 13);
         }
