<?php

namespace App\Service\Frontend;

use Dompdf\Dompdf;
use Dompdf\Options;

use Symfony\Component\HttpFoundation\RequestStack;

class ServiceReservation
{
    /**
     * @var DomPdf $domPdf
     */
    private $domPdf;

    /**
     * @return $this
     */
    public function __construct()
    {
        $this->domPdf = new DomPdf();
        $this->domPdf->setPaper('A4', 'portrait');

        $pdfOptions = new Options();
        $pdfOptions->set('defaultFont', 'Arial');
        $pdfOptions->setTempDir('temp');
        $pdfOptions->set(['IsHtml5ParserEnabled'=> true]);

        $this->domPdf->setOptions($pdfOptions);
    }
    

    public function generatePdfFile($html, $fileName = "details.pdf") {
        $this->domPdf->loadHtml($html);
        $this->domPdf->render();
        $this->domPdf->stream($fileName, [
            'Attachement' => true
        ]);
        return true;
    }

}

