Writes Html-Code into the pdf at the current position

@param $strHtml

@throws \MpdfException
503488
public function writeHtml($strHtml, $strCss = '')
    {
        $strHtml = ($strCss ? '<style>' . $strCss . '</style>' : '') . $strHtml;

        $this->objPdf->WriteHTML(html_entity_decode($this->replaceInsertTags($strHtml)));
    }
801721
private function createRawDomDocument($html)
    {
        $domDocument = new \DOMDocument();
        $domDocument->strictErrorChecking = false;
        $domDocument->formatOutput = true;
        $libXmlState = \libxml_use_internal_errors(true);
        $domDocument->loadHTML($this->prepareHtmlForDomConversion($html));
        \libxml_clear_errors();
        \libxml_use_internal_errors($libXmlState);

        $this->domDocument = $domDocument;
    }
196239
public function appendChildFromHtmlString($html)
    {
        $dom = new \DOMDocument;
        $dom->loadHTML($html);

        $element = simplexml_import_dom($dom);
        $element = current($element->xPath('//body/*'));

        $this->appendChildNode($element);
    }
520876
protected function _write($str)
    {
        $file = $this->alias->resolve($this->_file);
        if (!is_file($file)) {
            $dir = dirname($file);
            /** @noinspection NotOptimalIfConditionsInspection */
            if (!is_dir($dir) && !@mkdir($dir, 0755, true) && !is_dir($dir)) {
                /** @noinspection ForgottenDebugOutputInspection */
                trigger_error("Unable to create $dir directory: " . error_get_last()['message'], E_USER_WARNING);
            }
        }

        //LOCK_EX flag fight with SWOOLE COROUTINE
        if (file_put_contents($file, $str, FILE_APPEND) === false) {
            /** @noinspection ForgottenDebugOutputInspection */
            trigger_error('Write log to file failed: ' . $file, E_USER_WARNING);
        }
    }
70586
public function write($str, $new_line = true)
    {
        fwrite($this->stream, $str.( true===$new_line ? PHP_EOL : '' ));
        fflush($this->stream);
    }
9605
function generateDemoHtml(done) {
			if (!o.htmlDemo) {
				done();
				return;
			}

			var context = prepareHtmlTemplateContext();

			// Generate HTML
			var demoTemplate = readTemplate(o.htmlDemoTemplate, 'demo', '.html');
			var demo = renderTemplate(demoTemplate, context);

			mkdirp(getDemoPath(), function(err) {
				if (err) {
					logger.log(err);
					return;
				}
				// Save file
				fs.writeFileSync(getDemoFilePath(), demo);
				done();
			});

		}
806449
public function write(PHPExcel $pPHPExcel = null)
    {
        if (!$pPHPExcel) {
            $pPHPExcel = $this->getParentWriter()->getPHPExcel();
        }

        $objWriter = null;
        if ($this->getParentWriter()->getUseDiskCaching()) {
            $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
        } else {
            $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
        }

        // XML header
        $objWriter->startDocument('1.0', 'UTF-8');

        // Meta
        $objWriter->startElement('office:document-meta');

        $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
        $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
        $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
        $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
        $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
        $objWriter->writeAttribute('office:version', '1.2');

        $objWriter->startElement('office:meta');

        $objWriter->writeElement('meta:initial-creator', $pPHPExcel->getProperties()->getCreator());
        $objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
        $objWriter->writeElement('meta:creation-date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
        $objWriter->writeElement('dc:date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
        $objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
        $objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
        $objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
        $keywords = explode(' ', $pPHPExcel->getProperties()->getKeywords());
        foreach ($keywords as $keyword) {
            $objWriter->writeElement('meta:keyword', $keyword);
        }

        //<meta:document-statistic meta:table-count="XXX" meta:cell-count="XXX" meta:object-count="XXX"/>
        $objWriter->startElement('meta:user-defined');
        $objWriter->writeAttribute('meta:name', 'Company');
        $objWriter->writeRaw($pPHPExcel->getProperties()->getCompany());
        $objWriter->endElement();
 
        $objWriter->startElement('meta:user-defined');
        $objWriter->writeAttribute('meta:name', 'category');
        $objWriter->writeRaw($pPHPExcel->getProperties()->getCategory());
        $objWriter->endElement();

        $objWriter->endElement();

        $objWriter->endElement();

        return $objWriter->getData();
    }
943451
public function generatePdf($strArticle, $objArticle)
	{
		if (!$GLOBALS['TL_CONFIG']['useDompdf']) {
			return;
		}

		// Add head section
		$strHtml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
		$strHtml .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
		$strHtml .= '<head>' . "\n";
		$strHtml .= '<title>' . $objArticle->title . '</title>' . "\n";
		$strHtml .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $GLOBALS['TL_CONFIG']['characterSet'] . '" />' . "\n";

		// Add stylesheets
		$objStylesheet = $this->Database->execute("SELECT * FROM tl_style_sheet");
		while ($objStylesheet->next()) {
			$arrMedia = deserialize($objStylesheet->media, true);
			if (in_array('print', $arrMedia)) {
				$objResult = $this->Database->prepare('SELECT * FROM tl_style WHERE pid=? && invisible!=?')->execute($objStylesheet->id, 1);
				if($objResult) {
					$strStyles = '';
					$arrStyles = $objResult->fetchAllAssoc();
					if(is_array($arrStyles) && !empty($arrStyles)) {
						foreach ($arrStyles as $s) {
							$Stylesheet = new \StyleSheets();
							$strStyles .= $Stylesheet->compileDefinition($s, false, array(), array(), true);
						}
					}
				}
			}
		}

		// URL decode image paths (see #6411)
		$strArticle = preg_replace_callback('@(src="[^"]+")@', function ($arg) {
			return rawurldecode($arg[0]);
		}, $strArticle);

		// Handle line breaks in preformatted text
		$strArticle = preg_replace_callback('@(<pre.*</pre>)@Us', function ($arg) {
			return str_replace("\n", '<br>', $arg[0]);
		}, $strArticle);

		// Convert the Euro symbol
		$strArticle = str_replace('€', '&#8364;', $strArticle);

		// Make sure there is no background
		$strHtml .= '<style type="text/css">' . "\n";
		$strHtml .= 'body { background:none; background-color:#ffffff; }' . "\n";
		if(isset($strStyles) && !empty($strStyles)) $strHtml .= $strStyles;
		$strHtml .= '</style>' . "\n";
		$strHtml .= '</head>' . "\n";
		$strHtml .= '<body>' . "\n";
		$strHtml .= $strArticle . "\n";
		$strHtml .= '</body>' . "\n";
		$strHtml .= '</html>';

		// Generate DOMPDF object
		$dompdf = new Dompdf();
		$dompdf->setPaper('A4', 'portrait');
		$dompdf->loadHtml($strHtml);
		$dompdf->render();

		$dompdf->stream(standardize(ampersand($objArticle->title, false)));

		// Stop script execution
		exit;
	}
1115064
protected function _write($templ = '', $base_path = '')
    {
        $output = trim($templ);

        if (empty($output)) {
            $output   = html::doctype('html5') . "\n" . $this->default_template;
            $is_empty = true;
        }

        // set default page title
        if (empty($this->pagetitle)) {
            $this->pagetitle = 'Roundcube Mail';
        }

        // declare page language
        if (!empty($_SESSION['language'])) {
            $lang = substr($_SESSION['language'], 0, 2);
            $output = preg_replace('/<html/', '<html lang="' . html::quote($lang) . '"', $output, 1);
            if (!headers_sent()) {
                header('Content-Language: ' . $lang);
            }
        }

        // replace specialchars in content
        $page_title  = html::quote($this->pagetitle);
        $page_header = '';
        $page_footer = '';

        // include meta tag with charset
        if (!empty($this->charset)) {
            if (!headers_sent()) {
                header('Content-Type: text/html; charset=' . $this->charset);
            }
            $page_header = '<meta http-equiv="content-type"';
            $page_header.= ' content="text/html; charset=';
            $page_header.= $this->charset . '" />'."\n";
        }

        // definition of the code to be placed in the document header and footer
        if (is_array($this->script_files['head'])) {
            foreach ($this->script_files['head'] as $file) {
                $page_header .= html::script($file);
            }
        }

        $head_script = $this->scripts['head_top'] . $this->scripts['head'];
        if (!empty($head_script)) {
            $page_header .= html::script(array(), $head_script);
        }

        if (!empty($this->header)) {
            $page_header .= $this->header;
        }

        // put docready commands into page footer
        if (!empty($this->scripts['docready'])) {
            $this->add_script('$(document).ready(function(){ ' . $this->scripts['docready'] . "\n});", 'foot');
        }

        if (is_array($this->script_files['foot'])) {
            foreach ($this->script_files['foot'] as $file) {
                $page_footer .= html::script($file);
            }
        }

        if (!empty($this->footer)) {
            $page_footer .= $this->footer . "\n";
        }

        if (!empty($this->scripts['foot'])) {
            $page_footer .= html::script(array(), $this->scripts['foot']);
        }

        // find page header
        if ($hpos = stripos($output, '</head>')) {
            $page_header .= "\n";
        }
        else {
            if (!is_numeric($hpos)) {
                $hpos = stripos($output, '<body');
            }
            if (!is_numeric($hpos) && ($hpos = stripos($output, '<html'))) {
                while ($output[$hpos] != '>') {
                    $hpos++;
                }
                $hpos++;
            }
            $page_header = "<head>\n<title>$page_title</title>\n$page_header\n</head>\n";
        }

        // add page hader
        if ($hpos) {
            $output = substr_replace($output, $page_header, $hpos, 0);
        }
        else {
            $output = $page_header . $output;
        }

        // add page footer
        if (($fpos = strripos($output, '</body>')) || ($fpos = strripos($output, '</html>'))) {
            $output = substr_replace($output, $page_footer."\n", $fpos, 0);
        }
        else {
            $output .= "\n".$page_footer;
        }

        // add css files in head, before scripts, for speed up with parallel downloads
        if (!empty($this->css_files) && !$is_empty
            && (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>')))
        ) {
            $css = '';
            foreach ($this->css_files as $file) {
                $css .= html::tag('link', array('rel' => 'stylesheet',
                    'type' => 'text/css', 'href' => $file, 'nl' => true));
            }
            $output = substr_replace($output, $css, $pos, 0);
        }

        $output = $this->parse_with_globals($this->fix_paths($output));

        if ($this->assets_path) {
            $output = $this->fix_assets_paths($output);
        }

        $output = $this->postrender($output);

        // trigger hook with final HTML content to be sent
        $hook = $this->app->plugins->exec_hook("send_page", array('content' => $output));
        if (!$hook['abort']) {
            if ($this->charset != RCUBE_CHARSET) {
                echo rcube_charset::convert($hook['content'], RCUBE_CHARSET, $this->charset);
            }
            else {
                echo $hook['content'];
            }
        }
    }
474337
public function render()
    {
        $stream = $this->_rtf->getWriter();

        if ($this instanceof PHPRtfLite_Table_Cell && $this->countElements() == 0) {
            $stream->write('{');
            $font = $this->getCellFont($this);
            if ($font) {
                $stream->write($font->getContent());
            }
            if ((!$this->isVerticalMerged() && !$this->isHorizontalMerged()) || $this->isVerticalMergedFirstInRange()) {
                $stream->write('{\~}');
            }
            $stream->write('}\intbl');
        }

        $lastKey = $this->countElements() - 1;

        foreach ($this->_elements as $key => $element) {
            if ($this instanceof PHPRtfLite_Table_Cell && !($element instanceof PHPRtfLite_Table)) {
                // table cell initialization
                $stream->write('\intbl\itap' . $this->getTable()->getNestDepth() . "\r\n");
                $stream->write($this->getCellAlignment());
            }

            if ($element instanceof PHPRtfLite_Element_Plain) {
                $element->render();
                continue;
            }

            $parFormat = null;
            if (!($element instanceof PHPRtfLite_Table)) {
                $parFormat = $element->getParFormat();
            }

            if ($parFormat) {
                $stream->write($this->_pard);
                if ($this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
                    $stream->write('{');
                }
                $stream->write($parFormat->getContent());
            }

            $font = $this->getCellFont($element);
            if ($font) {
                $stream->write($font->getContent());
            }

            $element->render();

            if ($this->needToAddParagraphEnd($key)) {
                $stream->write('\par ');
            }

            if ($font) {
                $stream->write($font->getClosingContent());
            }

            if ($parFormat && $this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
                $stream->write('}');
            }
        }
    }
195002
public static function write( $str, $color = null, $background = null ) 
	{
		if ( !is_null( $color ) ) 
		{
			$str = static::color( $str, $color, $background );
		}
		
		fwrite( STDOUT, $str );
	}
559546
public static function writeFile($strFilePath, $strContents)
    {
        $fileHandle = fopen($strFilePath, "w");
        if (!$fileHandle) {
            throw new \Exception("Cannot open file for writing: " . $strFilePath);
        }

        if (fwrite($fileHandle, $strContents, strlen($strContents)) === false) {
            throw new \Exception("Unable to write file: " . $strFilePath);
        }
        fclose($fileHandle);
    }
972833
public function prepare(): Mpdf
    {
        $this->pdf = $this->getPdf();

        // set the custom pdf template
        if (null !== $this->getTemplate() && file_exists($this->getTemplate())) {
            $this->pdf->SetImportUse();

            $pageCount = $this->pdf->SetSourceFile($this->getTemplate());
            $tplIdx = $this->pdf->ImportPage($pageCount);
            $this->pdf->UseTemplate($tplIdx);
            $this->pdf->UseTemplate($tplIdx);
        }

        $this->pdf->WriteHTML($this->html);

        $this->isPrepared = true;

        return $this->pdf;
    }
1286592
private function writeDocument(\DOMDocument $dom)
    {
        $dom->formatOutput = true;
        $this->write($dom->saveXML());
    }
728423
public function setHTML($html)
    {
        $node = $this->createDocumentFragment();
        $node->appendXML('<html xmlns="http://www.w3.org/1999/xhtml">'.$html.'</html>');
        $this->doc->appendChild($node);
    }
36520
function writeHTMLHeaders()
	{

		if ($this->mirrorMargins && ($this->page) % 2 == 0) {
			$OE = 'E';
		} else {
			$OE = 'O';
		}

		if ($OE === 'E') {
			$this->saveHTMLHeader[$this->page][$OE]['html'] = $this->HTMLHeaderE['html'];
		} else {
			$this->saveHTMLHeader[$this->page][$OE]['html'] = $this->HTMLHeader['html'];
		}

		if ($this->forcePortraitHeaders && $this->CurOrientation == 'L' && $this->CurOrientation != $this->DefOrientation) {
			$this->saveHTMLHeader[$this->page][$OE]['rotate'] = true;
			$this->saveHTMLHeader[$this->page][$OE]['ml'] = $this->tMargin;
			$this->saveHTMLHeader[$this->page][$OE]['mr'] = $this->bMargin;
			$this->saveHTMLHeader[$this->page][$OE]['mh'] = $this->margin_header;
			$this->saveHTMLHeader[$this->page][$OE]['mf'] = $this->margin_footer;
			$this->saveHTMLHeader[$this->page][$OE]['pw'] = $this->h;
			$this->saveHTMLHeader[$this->page][$OE]['ph'] = $this->w;
		} else {
			$this->saveHTMLHeader[$this->page][$OE]['ml'] = $this->lMargin;
			$this->saveHTMLHeader[$this->page][$OE]['mr'] = $this->rMargin;
			$this->saveHTMLHeader[$this->page][$OE]['mh'] = $this->margin_header;
			$this->saveHTMLHeader[$this->page][$OE]['mf'] = $this->margin_footer;
			$this->saveHTMLHeader[$this->page][$OE]['pw'] = $this->w;
			$this->saveHTMLHeader[$this->page][$OE]['ph'] = $this->h;
		}
	}
893735
public function appendPageCSS(string $str): PdfInterface
    {
        $this->setProperty('pageCSS', $str);
        $this->mpdf->WriteHTML($this->pageCSS, 1);

        return $this;
    }