entityManager->getRepository(Reception::class)->find($id); if (!$reception instanceof Reception) { throw new NotFoundHttpException('Reception not found.'); } $options = new Options(); $options->set('isRemoteEnabled', true); $dompdf = new Dompdf($options); $html = $this->twig->render('reception_voucher.html.twig', [ 'reception' => $reception, ]); $dompdf->loadHtml($html); $dompdf->setPaper('A4'); $dompdf->render(); $filename = sprintf('bon-reception-%d.pdf', $reception->getId()); return new Response($dompdf->output(), Response::HTTP_OK, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="'.$filename.'"', ]); } }