radfusion/app/Services/Export/Formats/PdfExport.php
2025-01-12 11:53:49 +06:00

44 lines
1.4 KiB
PHP

<?php
namespace app\Services\Export\Formats;
use App\Domain\Report\ExportFormat;
use App\Services\Report\ReportStorage;
final class PdfExport extends TemplatedDocExportBase
{
protected function handle(): string
{
$filename = $this->filename();
$pdf_path = ReportStorage::customFilepath($this->study, $filename);
if (ReportStorage::exists($this->study, $filename)) {
return $pdf_path;
}
$docx_path = ReportStorage::customFilepath($this->study, $this->filename('docx'));
$docx = $this->renderDocument();
$docx->createDocx(ReportStorage::abspath($docx_path));
$docx->transformDocument(ReportStorage::abspath($docx_path), ReportStorage::abspath($pdf_path));
return $pdf_path;
/*
$dompdf = new Dompdf\Dompdf;
$transform = new TransformDocAdvNative;
$transform->transformDocument('document.docx', 'document.pdf', ['dompdf' => $dompdf]);
$data = ['report' => $this->report, 'title' => 'PDF VIEW'];
Pdf::loadView('staff.reports.viewer.html-report', $data)
->setPaper('a4', 'landscape')
->setWarnings(false)
->setOption('defaultFont', 'Courier')
->save(ReportStorage::abspath($pdf_path));
*/
}
protected function getExtension(): string
{
return ExportFormat::Pdf->value;
}
}