Generates Pdf from html

@return string raw pdf data
342777
public function output()
    {
        $defaults = [
            'fontCache' => TMP,
            'tempDir' => TMP,
        ];
        $options = (array)$this->getConfig('options') + $defaults;

        $DomPDF = $this->_createInstance($options);
        $DomPDF->setPaper($this->_Pdf->pageSize(), $this->_Pdf->orientation());
        $DomPDF = $this->_render($this->_Pdf, $DomPDF);

        return $this->_output($DomPDF);
    }
1315443
private void generatePdf() {
        File pdfFile = new File(directory, filename + ".pdf");
        try (OutputStream os = new FileOutputStream(pdfFile)) {
            PdfRendererBuilder builder = new PdfRendererBuilder();
            builder.withHtmlContent(getHtmlForPDFConversion(), "file://" + pdfFile.getAbsolutePath()
                    .replaceAll(" ", "%20"));
            builder.toStream(os);
            builder.run();
        } catch (Exception e) {
            log.error(e);
        }
    }
437139
protected function _writeTexFile()
    {
        $output = $this->_Pdf->html();
        $file = sha1($output);
        $texFile = $this->getConfig('options.output-directory') . DS . $file;
        file_put_contents($texFile, $output);

        return $texFile;
    }
525550
public function generateRawData()
    {
        $rawData = ['id' => $this->getId()];
        $rawData['output_info'] = [];
        $rawData['output_info']['data'] = [];
        if ($this->getName()) {
            $rawData['name'] = $this->getName();
        }
        if ($this->getAppId()) {
            $rawData['app_id'] = $this->getAppId();
        }
        if ($this->getCreatedAt()) {
            $rawData['created_at'] = $this->getCreatedAt();
        }
        if ($this->getConcepts()) {
            $rawData['output_info']['data']['concepts'] = [];
            foreach ($this->getConcepts() as $concept) {
                $rawData['output_info']['data']['concepts'][] = $concept->generateRawData();
            }
        }
        if ($this->isConceptsMutuallyExclusive() || $this->isClosedEnvironment()) {
            $rawData['output_info']['output_config'] = $this->getOutputConfig();
        }
        if ($this->getModelVersion()) {
            $rawData['model_version'] = $this->getModelVersion()->generateRawData();
        }

        return $rawData;
    }
876895
public function generate()
    {
        // Add empty option (XHTML) if there are none
        if (empty($this->arrOptions)) {
            $this->arrOptions = array(
                array(
                    'value' => '',
                    'label' => '-'
                )
            );
        }

        $strClass = ('' !== $this->strClass ? ' class="' . $this->strClass . '"' : '');
        $strStyle = ('' !== $this->arrAttributes['style'] ? ' style="' . $this->arrAttributes['style'] . '"' : '');

        return $this->checkOptGroup($this->arrOptions, $strClass, $strStyle);
    }
981415
public function generateCode() {
        $content = "";
        foreach ($this->arrTemplates as $template) {
            if (!file_exists($template)) {
                //Template not found
                continue;
            }
            $content .= file_get_contents($template);
        }
        
        foreach ($this->attributes as $key => $val) {
            $content = str_replace($this->placeHolderStart.$key.$this->placeHolderEnd, $val, $content);
        }
        return $content;
    }
619088
public function generate()
	{
		$this->loadWebmasterTags();

		$title       = $this->getTitle();
		$description = $this->getDescription();
		$keywords    = $this->getKeywords();
		$metatags    = $this->metatags;

		$html = array();

		$html[] = "<title>$title</title>";
		$html[] = sprintf('<meta name="description" itemprop="description" content="%s" />%s', $description, PHP_EOL);

		if (!empty($keywords)) {
			$html[] = sprintf('<meta name="keywords" content="%s" />%s', $keywords, PHP_EOL);
		}

		foreach ($metatags as $key => $value):
			$name    = $value[0];
			$content = $value[1];
			$html[] = sprintf('<meta %s="%s" content="%s" />%s', $name, $key, $content, PHP_EOL);
		endforeach;

		return implode(PHP_EOL, $html);
	}
817451
public function generate()
	{
		if (!$this->mpdf) {
			$this->init();
		}
		// Better to avoid having mpdf set any headers as these can interfer with symfony responses
		$output = $this->mpdf->Output('', 'S');
		$time = microtime(true) - $this->start_time;
		$this->logger->debug("sasedev_mpdf: pdf generation took " . $time . " seconds");
		return $output;
	}
93298
public function generateRawData()
    {
        $rawData = ['id' => $this->getId()];
        $rawData['data'] = [];
        $rawData['data']['image'] = [];
        if ($this->getCreatedAt()) {
            $rawData['created_at'] = $this->getCreatedAt();
        }
        if ($this->getStatusDescription() || $this->getStatusCode()) {
            $rawData['status'] = $this->getStatus();
        }
        if ($this->getImage()) {
            $rawData['data']['image'][$this->getImageMethod()] = $this->getImage();
        }
        if ($this->getCrop()) {
            $rawData['data']['image']['crop'] = $this->getCrop();
        }
        if ($this->getConcepts()) {
            $rawData['data']['concepts'] = [];
            foreach ($this->getConcepts() as $concept) {
                $rawData['data']['concepts'][] = $concept->generateRawData();
            }
        }
        if ($this->getMetaData()) {
            $rawData['data']['metadata'] = $this->getMetaData();
        }

        return $rawData;
    }
407767
public function generateHTML() {
        //create blocktrail pub key QR codes if not already done
        if (!$this->blocktrailPubKeyQRs) {
            $this->processBlocktrailPubKeys();
        }
        $pubKeysHtml = "";
        foreach ($this->blocktrailPubKeyQRs as $pubKey) {
            $pubKeysHtml .= "<img src='{$pubKey['qr']}' />";
        }
        $totalPubKeys = count($this->blocktrailPubKeyQRs);

        $backupInfo = $this->prepareBackupInfo();
        $extraInfo = $this->prepareExtraInfo();

        $passwordEncryptedSecret = null;
        if (isset($this->backupInfo['encrypted_secret'])) {
            $passwordEncryptedSecret = $this->backupInfo['encrypted_secret'];
        }

        $html = self::renderTemplate(__DIR__ . "/../resources/templates/recovery_sheet.html.php", [
            'identifier' => $this->identifier,
            'totalPubKeys' => $totalPubKeys,
            'pubKeysHtml' => $pubKeysHtml,
            'backupInfo' => $backupInfo,
            'extraInfo' => $extraInfo,
            'passwordEncryptedSecret' => $passwordEncryptedSecret,
            'options' => $this->options,
        ]);

        return $html;
    }
353380
public static function generate ()
		{
			$data = random_bytes(16);

			$data[ 6 ] = chr(ord($data[ 6 ]) & 0x0f | 0x40); // set version to 0100
			$data[ 8 ] = chr(ord($data[ 8 ]) & 0x3f | 0x80); // set bits 6-7 to 10

			return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
		}
277204
public function getDataRowHTML()
    {
        $output = [];
        foreach ($this->columns as $name => $column) {

            // If multiple formatters are defined, use the first for the header cell

            if (!is_int($name)) {
                $field = $this->model->getElement($name);
            } else {
                $field = null;
            }

            if (!is_array($column)) {
                $column = [$column];
            }

            // we need to smartly wrap things up
            $cell = null;
            $cnt = count($column);
            $td_attr = [];
            foreach ($column as $c) {
                if (--$cnt) {
                    $html = $c->getDataCellTemplate($field);
                    $td_attr = $c->getTagAttributes('body', $td_attr);
                } else {
                    // Last formatter, ask it to give us whole rendering
                    $html = $c->getDataCellHTML($field, $td_attr);
                }

                if ($cell) {
                    if ($name) {
                        // if name is set, we can wrap things
                        $cell = str_replace('{$'.$name.'}', $cell, $html);
                    } else {
                        $cell = $cell.' '.$html;
                    }
                } else {
                    $cell = $html;
                }
            }

            $output[] = $cell;
        }

        return implode('', $output);
    }
856796
public function generateRawData()
    {
        $rawData = ['id' => $this->getId()];
        if ($this->getCreatedAt()) {
            $rawData['created_at'] = $this->getCreatedAt();
        }
        if ($this->getStatusDescription() || $this->getStatusCode()) {
            $rawData['status'] = $this->getStatus();
        }

        return $rawData;
    }
1208472
public function generate()
	{
		$returnVar = $this->executeCommand($output);

		if ($returnVar == 0)
		{
			$this->contents = $this->getPDFContents();
		}
		else
		{
			throw new PDFException($output);
		}

		$this->removeTmpFiles();

		return $this;
	}
1124061
protected function _render()
        {
            if (mb_strlen($this->_html, 'utf-8') === 0 && empty($this->_url))
                throw new Exception("HTML content or source URL not set.");

            if ($this->getUrl()) {
                $input = $this->getUrl();
            } else {
                File::put($this->getFilePath(), $this->getHtml());
                $input = $this->getFilePath();
            }

            $content = $this->_exec(repl('%input%', $input, $this->_getCommand()));

            if (strpos(i::lower($content['stderr']), 'error'))
                    throw new Exception("System error <pre>" . $content['stderr'] . "</pre>");

            if (mb_strlen($content['stdout'], 'utf-8') === 0)
                   throw new Exception("WKHTMLTOPDF didn't return any data.");

            if ((int)$content['return'] > 1)
                throw new Exception("Shell error, return code : " . (int)$content['return']);

            return $content['stdout'];
        }
1053750
public function generate()
	{
		if ($this->imageSubmit)
		{
			$objModel = \FilesModel::findByPk($this->singleSRC);

			if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path))
			{
				return sprintf('<button type="submit" id="ctrl_%s" class="submit btn %s" title="%s" alt="%s"%s>%s</button>',
					$this->strId,
					(($this->strClass != '') ? ' ' . $this->strClass : 'btn-default'),
					specialchars($this->slabel),
					specialchars($this->slabel),
					$this->getAttributes(),
					\Image::getHtml($objModel->path, $this->slabel)
				);
			}
		}

		$label = specialchars($this->slabel);

		if($this->bootstrap_addIcon) {
			$icon = Icons::generateIcon($this->bootstrap_icon);

			if($this->bootstrap_iconPosition == 'right') {
				$label = $label . ' ' . $icon;
			}
			else {
				$label = $icon  . ' ' . $label;
			}
		}

		// Return the regular button
		return sprintf('<button type="submit" id="ctrl_%s" class="submit btn %s"%s>%s</button>',
			$this->strId,
			(($this->strClass != '') ? $this->strClass : 'btn-default'),
			$this->getAttributes(),
			$label
		);
	}
949842
public function generate() {
		$output_path = $this->timestampedFileName( 'pdf' );
		$this->generateWithDocraptor( $this->pdfProfile, $this->generateHtml(), $output_path );
		delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
		return $output_path;
	}