
bobtfish at bobtfish
Nov 9, 2011, 3:07 PM
Post #6 of 7
(288 views)
Permalink
|
|
Re: Should I create a new view for rendering a pdf in browser?
[In reply to]
|
|
On 9 Nov 2011, at 14:34, Steve wrote: > My question is fairly straightforward - If I want to render a pdf in > a browser, should I create a new Catalyst View? Yes. In a perfect world, you'd just say $c->stash( current_view => 'PDF' ) (and set a filename?) to make a pdf... > > The background on this is that we think that rather than rendering > an HTML version of these reports, and subsequently converting them > to pdf, just create the pdf on the fly and render it in the browser. > > Extra credit for recommendations on pdf tools for this type of > thing. We've looked at PDF::Create, PDF::API2, PDF::Reuse, and also > Prince (if we decide to convert from HTML). Depends how dirty you want to be :_) Doing something 'proper' with one of these (or also, take your XHTML, apply XSLT => docbook, then make a pdf?) totally works, and if you're prepared to put the effort in, you can make really nice documents.. But _if_ you can deal with something ugly but workable - then just subclass your HTML view, after process write $c->req->body out to a tempfile and run html2ps | ps2pdf on it! (Then read that back in and replace the body) This is really dirty (and kinda slow for big pages), but with a few appropriate options and some CSS to cut out the bits that shouldn't be in the pdf - it works well.. I use this technique for all of our invoices, as I don't really care how they look :) Cheers t0m _______________________________________________ List: Catalyst [at] lists Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst [at] lists/ Dev site: http://dev.catalyst.perl.org/
|