@param \Generated\Shared\Transfer\PdfTemplateTransfer $pdfTemplate

@return string
322964
public function render(PdfTemplateTransfer $pdfTemplate)
    {
        $loader = new Filesystem($this->config->getTwigTemplatePaths());
        $twig = new Twig_Environment($loader);
        $twig->setExtensions($this->extensions);

        $this->addFilters($twig);
        $this->addFunctions($twig);

        $path = $pdfTemplate->getPath();
        $parameter = $pdfTemplate->getParameter();

        if ($parameter === null) {
            $parameter = [];
        }

        return $twig->render($path, $parameter);
    }
246928
public function getFragmentFile($template, $content)
	{
        $tplCompiledFile = static::getCompiledPath() . '/fragment/' . ltrim($template, '/') . '.php';
        
        if (!$this->options['isCompiled'] || !file_exists($tplCompiledFile) ) {
            $tplCompiledPath = dirname($tplCompiledFile);
            if (!file_exists($tplCompiledPath)) {
                Dir::create($tplCompiledPath, 0755);
            }
            
            $content = $this->parse($content);
            $strlen = file_put_contents($tplCompiledFile, $content);
            chmod ($tplCompiledFile, 0755);
        }
        
        return $tplCompiledFile;
	}
1141947
public function createPdfDocument(TransferInterface $transfer, $containerName)
    {
        return $this->getFactory()
            ->createPdfDocumentManager()
            ->createDocument($transfer, $containerName);
    }
1371434
public function output(Request $request, $template, $output = self::OUTPUT_DOWNLOAD, $format = APIClient::FORMAT_PDF)
    {
        $name = $request->get('name');

        /**
         * Automatically triggers print action once the file is loaded
         */
        $params = [
            'print' => $output === self::OUTPUT_PRINT ? 1 : 0
        ];

        $data = $this->getData();

        try
        {
            /**
             * Set workspace identifier
             */
            \PDFGeneratorAPI::setWorkspace($this->userRepository->getWorkspaceIdentifier(Auth::user()));

            $result = \PDFGeneratorAPI::output($template, $data, $format, $name, $params);
        }
        catch(Exception $e)
        {
            return response()->json([
                'error' => $e->getMessage()
            ], $e->getCode());
        }

        $headers = [
            'Content-type' => $result->meta->{'content-type'},
            'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0, max-age=1',
            'Cache' => 'public',
            'Expires' => 'Sat, 26 Jul 1997 05:00:00 GMT',
            'Last-Modified' => gmdate('D, d M Y H:i:s').' GMT',
            'Content-Disposition' => 'inline; filename="'.$result->meta->name.'"'
        ];

        if ($output === self::OUTPUT_DOWNLOAD)
        {
            $headers['Content-Description'] = 'File Transfer';
            $headers['Content-Disposition'] = 'attachment; filename="'.$result->meta->name.'"';
            $headers['Content-Transfer-Encoding'] = 'binary';
        }

        return response(base64_decode($result->response), 200, $headers);
    }
799827
private function translate(string $template, array $parameters): string
    {
        $placeholders = array_map([$this, 'getPlaceholder'], array_keys($parameters));
        $replacements = array_map([$this, 'getTranslatedValue'], array_values($parameters));

        return str_replace($placeholders, $replacements, $template);
    }
448477
protected function convertToPdfTransfer(TransferInterface $transfer, $containerName)
    {
        $documentBuilder = $this->getConverter($containerName);

        $pdfTransfer = new PdfTransfer();
        $pdfTransfer = $documentBuilder->convertToPdfTransfer($transfer, $pdfTransfer);

        return $pdfTransfer;
    }
1281542
public function renderTemplate(Collection $collection)
    {
        $escapeHtmlAttribHelper = $this->getEscapeHtmlAttrHelper();
        $fieldsetHelper = $this->getFieldsetHelper();

        $templateMarkup = '';

        $elementOrFieldset = $collection->getTemplateElement();

        if ($elementOrFieldset instanceof PdfTextLineFieldSet) {
            $templateMarkup .= sprintf(
                $this->rowWrap,
                $this->getLineType(),
                $fieldsetHelper($elementOrFieldset, $this->shouldWrap()),
                ucfirst($this->getLineType())
            );
        }

        return sprintf(
            $this->getTemplateWrapper(),
            $this->getLineType(),
            $escapeHtmlAttribHelper($templateMarkup)
        );
    }
35225
protected function getTemplate($template, $className)
    {
        $this->template = $this->file->get($template);

        if ($this->needsScaffolding($template))
        {
            $this->template = $this->getScaffoldedModel($className);
        }

        return str_replace('{{className}}', $className, $this->template);
    }
691713
public function getCachedPdfPreview(string $pdfPath, array $options = [], string $fileExtension = 'jpg')
    {
        $pdfCache = $this;
        $imagePath = $this->cache->get($pdfPath, $fileExtension, function ($pdfPath, $cachePath, $cacheFileName) use ($pdfCache, $options) {
            return $pdfCache->generatePdfPreview($pdfPath, $cachePath.'/'.$cacheFileName, $options);
        });

        return $imagePath ? $imagePath : null;
    }
94810
protected function echos(string $template): string
	{
		// Closure that matches the "empty else" syntax

		$emptyElse = function($matches)
		{
			if(preg_match('/(.*)((\|\|)|(\s+or\s+))(.+)/', $matches) !== 0)
			{
				return preg_replace_callback('/(.*)((\|\|)|(\s+or\s+))(.+)/', function($matches)
				{
					return '(empty(' . trim($matches[1]) . ') ? ' . trim($matches[5]) . ' : ' . trim($matches[1]) . ')';
				}, $matches);
			}

			return $matches;
		};

		// Compiles echo tags

		return preg_replace_callback('/{{\s*(.*?)\s*}}/', function($matches) use ($emptyElse)
		{
			if(preg_match('/raw\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo %s; ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/preserve\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__, false); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/attribute\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeAttribute(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/js\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeJavascript(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/css\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeCSS(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/url\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeURL(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			else
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__); ?>', $emptyElse($matches[1]));
			}
		}, $template);
	}
635766
protected function recursiveRender($template)
    {
        $output = '';
        foreach ($template as $val) {
            if (is_array($val)) {
                $output .= $this->recursiveRender($val);
            } else {
                $output .= $val;
            }
        }

        return $output;
    }
1292625
protected function getTemplate($template)
    {
        $source = __DIR__.'/../../templates/'.$template;
        return file_exists($source) ? file_get_contents($source) : null;
    }
637886
private function getDomainRegex($template)
    {
        if (preg_match('#https?://(.*)#', $template, $matches)) {
            $template = $matches[1];
        }
        $parameters = [];
        if (strpos($template, '<') !== false) {
            $template = preg_replace_callback(
                '/<(?:\w+):?([^>]+)?>/u',
                function ($matches) use (&$parameters) {
                    $key = '#' . count($parameters) . '#';
                    $parameters[$key] = isset($matches[1]) ? $matches[1] : '\w+';
                    return $key;
                },
                $template
            );
        }
        $template = preg_quote($template);
        $template = strtr($template, $parameters);
        return '/^' . $template . '$/u';
    }
1267944
public function selectTemplate($template)
    {
        if (is_null($template)) {
            return 'default';
        }

        if (!array_key_exists($template, $this->templates)) {
            throw new RuntimeException("Template \"{$template}\" is not registered");
        }

        return $template;
    }
830065
public function transform(PdfContainer $pdfContainer)
    {
        $pdfConverterTransformer = new PdfConverterTransformer();

        return [
            'responseStatus' => $pdfContainer->getResponseStatus(),
            'sourceContainer' => $pdfConverterTransformer->transform($pdfContainer->getSourceContainer()),
            'url' => $pdfContainer->getUrl(),
        ];
    }
507701
protected function collectVerbatims(string $template): string
	{
		return preg_replace_callback('/{%\s*verbatim\s*%}(.*?){%\s*endverbatim\s*%}/is', function($matches)
		{
			$this->verbatims[] = $matches[1];

			return static::VERBATIM_PLACEHOLDER;
		}, $template);
	}
1109013
public function setMailTemplate(\KRS\MailBundle\Entity\MailTemplate $mailTemplate = null)
    {
        $this->mailTemplate = $mailTemplate;
    
        return $this;
    }