This is pretty much exactly what's done on one of the apps I maintain.
We have a zipped template, which we use together with ruby to generate
(in the same manner as any html template) an .odt open office
document. We then have Star Office (which is pretty much open office)
running on another server which is used to convert the .odt file to
both pdf and doc formats.

This is very unreliable, it breaks often, and is complicated enough
that it essentially runs via 'black magic'. While the answers others
have given to 'not ever do this' aren't terribly helpful considering
it's a requirement for you, I have to say, yes it can be done in this
manner, but you should be warned it's a real world of hurt. If this
wasn't a feature already implemented before my time, I would be doing
everything in my power to avoid having to do so.

On Sep 30, 4:26 am, Peter De Berdt <peter.de.be...@pandora.be> wrote:
> On 29 Sep 2009, at 16:47, Marnen Laibow-Koser wrote:
>
> >> And to put it quite simple: the old Word format is a closed format  
> >> and
> >> there is no rubygem available for reading or writing Word files on
> >> Linux since no one has gone through the effort of reverse engineering
> >> it (and there are more than enough alternative solutions available
> >> such as RTF and HTML).
>
> > I believe you may be incorrect on the reverse-engineering part.  
> > Plenty
> > of other software reads and writes old MS Word files -- which means  
> > that
> > *someone* figured out the spec...
>
> It's done through OLE and you need a Windows server for it. Plenty of  
> examples for that.
>
> You could also try the OpenOffice conversion route, but the number of  
> hoops and the amount of work you're getting yourself into is going to  
> be so staggering I wouldn't want to be in your place.
>
> Basically, you would have to go through these steps:
>         • Create an ODT template manually with placeholders, like [%value-to-
> replace%]
>         • When instantiating the template with real data in Ruby, unzip the  
> template ODT (it's a zipped XML), and run against the XML the textual  
> replace of the placeholders with the actual values.
>         • Zip the ODT back
>         • Run the conversion ODT -> DOC via OpenOffice command line interface.
>
> Best regards
>
> Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to