19 declare(strict_types=1);
    36                                         <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />    39                                 <body>$content_html</body>    51         if (!is_string($content_html) || !strlen(trim($content_html))) {
    58         if (!@$dom->loadHTML($html)) {
    62         $invalid_elements = [];
    64         $script_elements = $dom->getElementsByTagName(
'script');
    65         foreach ($script_elements as $elm) {
    66             $invalid_elements[] = $elm;
    69         foreach ($invalid_elements as $elm) {
    70             $elm->parentNode->removeChild($elm);
    74         $domX = 
new DomXPath($dom);
    75         foreach ($domX->query(
"//*[contains(@class, 'noprint')]") as $node) {
    76             $node->parentNode->removeChild($node);
    79         $dom->encoding = 
'UTF-8';
    81         $content_to_replace = $this->generateImageDataSrces($dom);
    83         $cleaned_html = $dom->saveHTML();
    89         if ($content_to_replace === null) {
    93         return str_replace(array_keys($content_to_replace), array_values($content_to_replace), $cleaned_html);
    96     private function generateImageDataSrces(
DOMDocument $dom): ?array
    98         $content_to_replace = null;
   100         $image_file_names = [];
   101         foreach ($dom->getElementsByTagName(
'img') as $elm) {
   103             $src = $elm->getAttribute(
'src');
   104             $original_content = $dom->saveHTML($elm);
   106             if (array_key_exists($src, $sources)) {
   107                 $replacement_content = preg_replace(
'/src=[^\s]*/', 
"src='{$sources[$src]}'", $original_content);
   108                 $content_to_replace[$original_content] = $replacement_content;
   112             if (stripos($src, ILIAS_HTTP_PATH) !== 
false   113                 && stripos($src, 
'assets') === 
false   114                 && file_exists($src)) {
   119                 $image_raw_content = file_get_contents($src);
   121                 file_put_contents($image_file_names[$src], $image_raw_content);
   122                 $image_content = base64_encode($image_raw_content);
   123                 $file_info = finfo_open(FILEINFO_MIME_TYPE);
   124                 $mime_type = finfo_file($file_info, $image_file_names[$src]);
   125                 $image_data = 
"data:{$mime_type};base64,{$image_content}";
   126                 $sources[$src] = $image_data;
   127                 $replacement_content = preg_replace(
'/src=[^\s]*/', 
"src='{$image_data}'", $original_content);
   128                 $content_to_replace[$original_content] = $replacement_content;
   134         foreach ($image_file_names as $image_file_name) {
   135             unlink($image_file_name);
   138         return $content_to_replace;
   152     private function getTemplatePath($a_filename, $module_path = 
'components/ILIAS/Test/'): string
   156             $fname = 
'./Customizing/skin/' .
   160         if ($fname == 
'' || !file_exists($fname)) {
   161             $fname = 
'./' . $module_path . 
'assets/css/' . basename($a_filename);
   168         $css_content = file_get_contents($this->
getTemplatePath(
'delos.css', 
''));
   169         $css_content .= 
' html, body { overflow: auto; } body { padding: 1rem; }';
 
makeHtmlDocument($content_html, $style_html)
 
generateHTML(string $content, string $filename)
 
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
 
getTemplatePath($a_filename, $module_path='components/ILIAS/Test/')
 
Class that handles PDF generation for test and assessment. 
 
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory. 
 
static signFile(string $path_to_file)
 
preprocessHTML(string $html)
 
buildHtmlDocument($content_html, $style_html)