Last active
November 7, 2018 07:42
-
-
Save ger86/2133bc76a0579a0d7ff449c022d40516 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DownloadSpecificationsController extends Controller { | |
/** | |
* @Route("/generate-pdf", name="app_generate_pdf") | |
*/ | |
public function downloadSpecifications() { | |
$html = $this->renderView('download-specifications/pdf.html.twig'); | |
$filename = sprintf('specifications-%s.pdf', date('Y-m-d-hh-ss')); | |
return new Response( | |
$this->get('knp_snappy.pdf')->getOutputFromHtml($html), | |
200, | |
[ | |
'Content-Type' => 'application/pdf', | |
'Content-Disposition' => sprintf('attachment; filename="%s"', $filename), | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment