Skip to content
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

Not render pdf template #33

Open
freenando opened this issue Feb 20, 2013 · 5 comments
Open

Not render pdf template #33

freenando opened this issue Feb 20, 2013 · 5 comments

Comments

@freenando
Copy link

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
Copy link
Owner

psliwa commented Feb 20, 2013

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

@Magnanimity
Copy link

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()
    */
    public function generatePdfAction()
    {
    return $this->render(sprintf('MyFreelancerPortfolioBundle:Main:demopdf.%s.twig', 'pdf'), array(
    'content' => '

    Testing PDF

    ',
    ));
    }

@pdf
Copy link

pdf commented Oct 11, 2013

Please use

code notation

so I don't get notified 😉

@psliwa
Copy link
Owner

psliwa commented Oct 11, 2013

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

..
@Route("/some", defaults={ "_format"="pdf" })
..

@Dorwido
Copy link

Dorwido commented Jun 30, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants