Hi Michael,
I can't do that cause I need TG to give me the HTML content. The first
thing i tried to do was to render the template "myself" but i got some
errors. For example, I was using something like {{tg.url('....')}} and
render_jinja2 fails because it didn't know what "tg" means. I guess
that road gets me to a place where I need "tmpl_context" and things
like that, so I would have to set up things the way TG already does.León On Sep 19, 4:10 am, Michael Pedersen <[email protected]> wrote: > Is there a reason you can't do something like this instead? > > class RootController(BaseController): > @expose('pdf', content_type='application/pdf') > def foo(self, *args, **kw): > return string_object_that_contains_pdf_file_contents > > It's the way I've done it elsewhere, and it works nicely. > > > > > > > > > > On Sun, Sep 18, 2011 at 3:54 AM, León Domingo <[email protected]> wrote: > > Hi, > > I've created a little function that makes use of wkhtmltopdf (http:// > > code.google.com/p/wkhtmltopdf/) to get PDF content from HTML content. > > > I would like to use some controllers to get a PDF version of the HTML > > content defined in the corresponding template. > > > @expose('foo.html') > > def foo(self, *args, **kwargs): > > return dict(....) > > > I've been making some experiments with a middleware class. > > > response.content_type = 'application/pdf' > > response.body = to_pdf(response.body) > > > return response(environ, start_response) > > > It works but I need something to know if I have to make the > > translation or not > > > if is_a_suitable_response: > > response.content_type = 'application/pdf' > > response.body = to_pdf(response.body) > > > return response(environ, start_response) > > > and I don't know how I can "mark" the response to do so. In the other > > hand, I don't know if this is the right way to do that. > > > Thanks a lot > > > León > > > -- > > You received this message because you are subscribed to the Google Groups > > "TurboGears" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/turbogears?hl=en. > > -- > Michael J. Pedersen > My IM IDs: Jabber/[email protected], AIM/pedermj022171 > Yahoo/pedermj2002, MSN/[email protected] > My Online Resume:http://www.icelus.org/ > Twitter: pedersentg -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

