Uhm, I would suggest you to setup a after_render hook and decide if the render result must be converted to a PDF or not. In the case it doesn't have to be converted you can leave it go as HTML, otherwise you can call wkhtmltopdf
On Sun, Sep 18, 2011 at 9: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. > > -- 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.

