psliwa / PdfBundle

This bundle integrates Symfony2 with PHPPdf library.
http://ohey.pl
MIT License
120 stars 45 forks source link

Not render pdf template #33

Open freenando opened 11 years ago

freenando commented 11 years ago

Hello, I need some help to generate a pdf with your bundle. I think installation was correctly and now I am trying to generate a pdf document like this:

//Controller in my bundle public function pdfAction($id_escuela, Request $request) { $format = $this->get('request')->get('_format'); return $this->render(sprintf('BackendAlumnosBundle:Default:pdfAlumnos.pdf.twig', $format)); }

//pdfAlumnos.pdf.twig


<pdf>
    <dynamic-page>
        Hello FER
    </dynamic-page>
</pdf>

But it shows in the browser as html page with this source code <pdf> <dynamic-page> Hello FER </dynamic-page> </pdf> What I am doing wrong? Why could be the template isn´t rendered?

Thanks for your work!

psliwa commented 11 years ago

Are you sure the format of the request (_format attribute) is pdf format? It looks like it isn't.

Magnanimity commented 11 years ago

I have the same issue. I am not getting a format in the request as I will always want to generate a pdf when calling this controller. Here is my code:

/**

pdf commented 11 years ago

Please use

code notation

so I don't get notified :wink:

psliwa commented 11 years ago

@Magnanimity : you should set default request format to "pdf" in your route definition.

..
@Route("/some", defaults={ "_format"="pdf" })
..
Dorwido commented 9 years ago

And how to set it outside of an controller?

Reason is I want to generate a invoice which isn't send to the browser, but instead sent as an email to the customer.