diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php
index f2ac0a3e2f8c..38ad2fe8cee9 100644
--- a/CRM/Utils/PDF/Utils.php
+++ b/CRM/Utils/PDF/Utils.php
@@ -95,21 +95,20 @@ public static function html2pdf($text, $fileName = 'civicrm.pdf', $output = FALS
\n";
// Strip ,
, and tags from each page
+
$htmlElementstoStrip = [
- '@]*?>.*?@siu',
- '@@siu',
- '@@siu',
- '@@siu',
- '@]*?>@siu',
- '@@siu',
- '@]*?>@siu',
+ ']*?>.*?',
+ '',
+ '',
+ '',
+ ']*?>',
+ '',
+ ']*?>',
];
- $htmlElementsInstead = ['', '', '', '', '', ''];
foreach ($pages as & $page) {
- $page = preg_replace($htmlElementstoStrip,
- $htmlElementsInstead,
- $page
- );
+ foreach ($htmlElementstoStrip as $pattern) {
+ $page = mb_eregi_replace($pattern, '', $page);
+ }
}
// Glue the pages together
$html .= implode("\n\n", $pages);