40                                        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> 
   43                                <body>$contentHtml</body> 
   53    private static function makeHtmlDocument($contentHtml, $styleHtml): string
 
   55        if (!is_string($contentHtml) || !strlen(trim($contentHtml))) {
 
   61        $dom = 
new DOMDocument(
"1.0", 
"utf-8");
 
   62        if (!@$dom->loadHTML($html)) {
 
   66        $invalid_elements = array();
 
   68        $script_elements = $dom->getElementsByTagName(
'script');
 
   69        foreach ($script_elements as $elm) {
 
   70            $invalid_elements[] = $elm;
 
   73        foreach ($invalid_elements as $elm) {
 
   74            $elm->parentNode->removeChild($elm);
 
   78        $domX = 
new DomXPath($dom);
 
   79        foreach ($domX->query(
"//*[contains(@class, 'noprint')]") as $node) {
 
   80            $node->parentNode->removeChild($node);
 
   83        $dom->encoding = 
'UTF-8';
 
   85        $img_src_map = array();
 
   86        foreach ($dom->getElementsByTagName(
'img') as $elm) {
 
   88            $uid = 
'img_src_' . uniqid();
 
   89            $src = $elm->getAttribute(
'src');
 
   91            $elm->setAttribute(
'src', $uid);
 
   93            $img_src_map[$uid] = $src;
 
   96        $cleaned_html = $dom->saveHTML();
 
   98        foreach ($img_src_map as $uid => $src) {
 
   99            $cleaned_html = str_replace($uid, $src, $cleaned_html);
 
  102        if (!$cleaned_html) {
 
  106        return $cleaned_html;
 
  118        if (!$pdf_factory->deliverPDFFromHTMLString(
 
  125            throw new \Exception(
'could not write PDF');
 
  132        $html = self::makeHtmlDocument($html, 
'<style>' . self::getCssContent() . 
'</style>');
 
  137    protected static function getTemplatePath($a_filename, $module_path = 
'Modules/Test/'): string
 
  140        include_once 
"Services/Style/System/classes/class.ilStyleDefinition.php";
 
  143            $fname = 
"./Customizing/global/skin/" .
 
  147        if ($fname == 
"" || !file_exists($fname)) {
 
  148            $fname = 
"./" . $module_path . 
"templates/default/" . basename($a_filename);
 
  155        $cssContent = file_get_contents(self::getTemplatePath(
'delos.css', 
''));
 
  156        $cssContent .= file_get_contents(self::getTemplatePath(
'test_pdf.css'));
 
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static preprocessHTML($html)
 
static getTemplatePath($a_filename, $module_path='Modules/Test/')
 
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
 
const PDF_OUTPUT_DOWNLOAD
 
static buildHtmlDocument($contentHtml, $styleHtml)