oms-Editor/Theme/Api/editor-doc.tpl.php
Dennis Eichhorn a764d818fb
Some checks failed
Image optimization / general_image_workflow (push) Has been cancelled
CI / general_module_workflow_php (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled
fix version and bugs
2024-05-21 00:09:09 +02:00

42 lines
1021 B
PHP

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Media
* @copyright Dennis Eichhorn
* @license OMS License 2.2
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Editor\Models\NullEditorDoc;
use phpOMS\Utils\Parser\Markdown\Markdown;
/** @var \phpOMS\Views\View $this */
require_once $this->getData('defaultTemplates')
->findFile('.pdf.php')
->getAbsolutePath();
/** @var \Modules\Editor\Models\EditorDoc $doc */
$doc = $this->getData('doc') ?? new NullEditorDoc();
// Set up default pdf template
/** @phpstan-import-type DefaultPdf from ../../../../Admin/Install/Media/PdfDefaultTemplate/pdfTemplate.pdf.php */
$word = new DefaultWord();
$section = $word->createFirstPage();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, Markdown::parse($doc->plain));
$file = \tempnam(\sys_get_temp_dir(), 'oms_');
$word->save($file, 'Word2007');
$content = \file_get_contents($file);
if ($content !== false) {
echo $content;
}
\unlink($file);