-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove header from pdf file #19
Comments
If you are using render method for the html generation, you should change to renderView. |
put here how you response a pdf file |
|
You have those headers because you call it via Symfony2 Response. Is this a real problem that you have this header? Because this is standard header for HTTP responses (just sometimes "cache" is omitted). Or you want different? Then you can manipulate headers of response in Symfony2... Here is with simple $html = $this->render('MyMainBundle:CRM:pdf.html.twig', array(
'request' => $cr_request
));
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
echo $this->get('knp_snappy.pdf')->getOutputFromHtml($html); Closing this as this is not an issue. |
getContent() will keep you from grabbing the headers.
|
Or just use the renderView method instead of the render method as said by @galan83 $html = $this->renderView('pdf.html.twig', array(/* vars to pass to the twig template */) );
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="file.pdf"'
//inline = display in browser, attachment = download
)
); @stloyd you misunderstood the issue, the op meant that the headers were actually displayed as text in the pdf |
The last part of the previous solutions did not work for me, but this way it work for me.
|
Hey folks,
when I generate a pdf it always has this
HTTP/1.0 200 OK Cache-Control: no-cache Date: Sun, 20 Jan 2013 11:17:25 GMT
at the top. How can I avoid that?
The text was updated successfully, but these errors were encountered: