From: Jeff Barczewski Date: 2006-11-17T05:02:14+09:00 Subject: Re: Rails view as PDF... suggestions? ------=_Part_25051_3551675.1163707330338 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 11/15/06, Kouhei Sutou wrote: > > Hi, > > 2006/11/16, J. B. Rainsberger : > > > I am about to do some research tomorrow, but if any of you has an > > obvious answer, then that would help. I am looking to build PDFs from > > Rails views, and I'd like some guidance on how to go about it. > > > I want to put placeholders, both text and images, onto a template and > > end up with a PDF. I'm pretty open about how that all happens, so feel > > free to make wild suggestions. The only important constraint I can think > > of is that layout (meaning spacing) matters, so relying on a browser > > rendering HTML is probably not an option. The template will be a kind of > > background on which the placeholders will be laid out, and I imagine > > it's the template that will be the tricky part. > > My suggestion is the following: > > 1. make a SVG for template with Illustrator, Inkscape and so on > 2. substitute placeholders in the SVG by ERB, Amrita and so on > 3. generate PDF from the substituted SVG. > (See [ruby-talk:225127]) > > You can also use MasterView to generate xml (for SVG or to use with XSL-FO). We don't have any special directives for this purpose but many of the standard ones would work nicely. In the java world we would use xsl-fo and an FO processor like Apache FOP to generate PDF's. A low tech way to do this would be to have ruby shell out and launch FOP to convert the XSL-FO formatted xml to PDF. I don't know if there are other C/C++ libraries (commercial or otherwise) that could do the same thing. Jeff Barczewski MasterView Template engine project founder http://masterview.org/ http://rubyforge.org/projects/masterview ------=_Part_25051_3551675.1163707330338--