diff --git a/src/FdfWriter.php b/src/FdfWriter.php index 9b28665..fe2f6c0 100644 --- a/src/FdfWriter.php +++ b/src/FdfWriter.php @@ -85,7 +85,11 @@ public function save(string $filename): int|bool public static function escapePdfString(?string $string): string { // Create UTF-16BE string encode as ASCII hex - $utf16Value = mb_convert_encoding($string ?? '', 'UTF-16BE', 'UTF-8'); + $string ??= ''; + $utf16Value = mb_convert_encoding($string, 'UTF-16BE', 'UTF-8'); + if (false === $utf16Value) { + return $string; + } return strtr($utf16Value, ['(' => '\(', ')' => '\)', '\\' => '\\\\']); }