src/Service/MpdfService.php line 43

  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the guesthouse administration package.
  5.  *
  6.  * (c) Alexander Elchlepp <info@fewohbee.de>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace App\Service;
  12. use Symfony\Component\HttpFoundation\RequestStack;
  13. class MpdfService
  14. {
  15.     private $requestStack;
  16.     public function __construct(RequestStack $requestStack)
  17.     {
  18.         $this->requestStack $requestStack;
  19.     }
  20.     // put your code here
  21.     public function getMpdf()
  22.     {
  23.         $locale $this->requestStack->getCurrentRequest()->getLocale();
  24.         $config = [
  25.             'mode' => $locale,
  26.             'format' => 'A4',
  27.             'orientation' => 'P',
  28.             'margin_left' => 25,
  29.             'margin_right' => 20,
  30.             'margin_top' => 20,
  31.             'margin_bottom' => 20,
  32.             'margin_header' => 9,
  33.             'margin_footer' => 9,
  34.         ];
  35.         return new \Mpdf\Mpdf($config);
  36.     }
  37. }