Hi all, Does anyone have any suggestions for generating a word doc from a linux rails application? We were using html and just naming it .doc, which works well until you need to embed images into the document. MHT looks promising but the only libraries aren''t free (not a deal breaker, but free is better). Thanks Simon
I''m working on something similar to this now. I''m writing my own libraries I will post back when I''m done. Will put it on rubyforge Sent from my iPhone On Apr 20, 2009, at 9:53 PM, "Simon Macneall" <macneall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > Does anyone have any suggestions for generating a word doc from a > linux rails application? We were using html and just naming it .doc, > which works well until you need to embed images into the document. > MHT looks promising but the only libraries aren''t free (not a deal > breaker, but free is better). > > Thanks > Simon > > >
Simon Macneall wrote:> Hi all, > > Does anyone have any suggestions for generating a word doc from a linux > rails application?Yes: don''t do it. Word documents have no place on the Web -- they don''t reliably preserve formatting and they don''t play nice with Web browsers. Generate a PDF file instead; prawn works well for this. [...]> Thanks > SimonBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
That''s a fabulous answer. I wouldn''t be asking if I could convince my customers that a PDF would do. They need to be able to edit the document after it is generated. -1 for helpfulness On Tue, 21 Apr 2009 11:38:01 +0800, Marnen Laibow-Koser <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Simon Macneall wrote: >> Hi all, >> >> Does anyone have any suggestions for generating a word doc from a linux >> rails application? > > Yes: don''t do it. Word documents have no place on the Web -- they don''t > reliably preserve formatting and they don''t play nice with Web browsers. > Generate a PDF file instead; prawn works well for this. > > [...] >> Thanks >> Simon > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
On Tue, Apr 21, 2009 at 5:58 AM, Simon Macneall <macneall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > That''s a fabulous answer. > I wouldn''t be asking if I could convince my customers that a PDF would do. They need to be able to edit the document after it is generated. > > -1 for helpfulness >Totally off the wall here but .docx files are XML so why not generate one in Word and then manipulate that from your app? Another crazy idea is to use OpenOffice, I think they have a Java interface that you might be able to hook into somehow. I have not done either of these, just throwing out some ideas. Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain
Well, to be fair, you didn''t specify that the file needed to be editable upon download so Simon''s solution is pretty reasonable. You might look into RTF. Some google searches seem to say that you can embed images into that format. On Apr 20, 2009, at 8:58 PM, Simon Macneall wrote:> > That''s a fabulous answer. > I wouldn''t be asking if I could convince my customers that a PDF > would do. They need to be able to edit the document after it is > generated. > > -1 for helpfulness > > > On Tue, 21 Apr 2009 11:38:01 +0800, Marnen Laibow-Koser <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > > wrote: > >> >> Simon Macneall wrote: >>> Hi all, >>> >>> Does anyone have any suggestions for generating a word doc from a >>> linux >>> rails application? >> >> Yes: don''t do it. Word documents have no place on the Web -- they >> don''t >> reliably preserve formatting and they don''t play nice with Web >> browsers. >> Generate a PDF file instead; prawn works well for this. >> >> [...] >>> Thanks >>> Simon >> >> Best, >> -- >> Marnen Laibow-Koser >> http://www.marnen.org >> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > >
Hi Andrew, Yeah, docx would work, however the customer only has word 2003, which doesn''t support that format. the options I have found so far are: mhtml - the only ruby lib is not free, and the format looks a bit painful to build yourself rtf - can''t see a ruby lib, but could build a servlet with java/itext html - can''t embed the image, but can make it a link back to the server (which is what we do with our old .net system), but is not ideal I use OpenOffice here, but the customer has word, and have you ever tried to convince a govt dept to change to open office? Not a quick/easy job :) Thanks Simon On Tue, 21 Apr 2009 12:06:53 +0800, Andrew Timberlake <andrew-642hCh26+Dt3UeSHeRwt+FaTQe2KTcn/@public.gmane.org> wrote:> > On Tue, Apr 21, 2009 at 5:58 AM, Simon Macneall <macneall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> That''s a fabulous answer. >> I wouldn''t be asking if I could convince my customers that a PDF would >> do. They need to be able to edit the document after it is generated. >> >> -1 for helpfulness >> > > Totally off the wall here but .docx files are XML so why not generate > one in Word and then manipulate that from your app? > > Another crazy idea is to use OpenOffice, I think they have a Java > interface that you might be able to hook into somehow. > > I have not done either of these, just throwing out some ideas. > > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain > > >
No I didn''t, and I probably snapped a bit more than I should have, but you continually see people answering questions with negatives like that, and it irks me. On Tue, 21 Apr 2009 12:07:37 +0800, Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org> wrote:> > Well, to be fair, you didn''t specify that the file needed to be > editable upon download so Simon''s solution is pretty reasonable. > > You might look into RTF. Some google searches seem to say that you > can embed images into that format. > > On Apr 20, 2009, at 8:58 PM, Simon Macneall wrote: > >> >> That''s a fabulous answer. >> I wouldn''t be asking if I could convince my customers that a PDF >> would do. They need to be able to edit the document after it is >> generated. >> >> -1 for helpfulness >> >> >> On Tue, 21 Apr 2009 11:38:01 +0800, Marnen Laibow-Koser >> <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org >> > wrote: >> >>> >>> Simon Macneall wrote: >>>> Hi all, >>>> >>>> Does anyone have any suggestions for generating a word doc from a >>>> linux >>>> rails application? >>> >>> Yes: don''t do it. Word documents have no place on the Web -- they >>> don''t >>> reliably preserve formatting and they don''t play nice with Web >>> browsers. >>> Generate a PDF file instead; prawn works well for this. >>> >>> [...] >>>> Thanks >>>> Simon >>> >>> Best, >>> -- >>> Marnen Laibow-Koser >>> http://www.marnen.org >>> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org >> >> > > > > >
Simon Macneall wrote:> No I didn''t, and I probably snapped a bit more than I should have, but > you continually see people answering questions with negatives like that, > and it irks me.You also continually see people asking how to solve a problem in a way they do not realize is suboptimal. Granted, that may not be the case here, but that wasn''t obvious from your original question. I would actually say that giving the client an HTML file might be the way to go here. It''s not well known, but MS Word does a beautiful job of importing HTML files (or did the last time I tried), including parsing <img> tags correctly. So your client should have no trouble editing the file with Word, or with just about anything else, and you won''t have to support a Web-unfriendly file format. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
The only problem with HTML is that I can''t find a way to embed the image (that works in Word), as opposed to having it link back to our server (which isn''t the desired outcome). On Tue, 21 Apr 2009 13:24:50 +0800, Marnen Laibow-Koser <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Simon Macneall wrote: >> No I didn''t, and I probably snapped a bit more than I should have, but >> you continually see people answering questions with negatives like that, >> and it irks me. > > You also continually see people asking how to solve a problem in a way > they do not realize is suboptimal. Granted, that may not be the case > here, but that wasn''t obvious from your original question. > > I would actually say that giving the client an HTML file might be the > way to go here. It''s not well known, but MS Word does a beautiful job > of importing HTML files (or did the last time I tried), including > parsing <img> tags correctly. So your client should have no trouble > editing the file with Word, or with just about anything else, and you > won''t have to support a Web-unfriendly file format. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
Steven, Cool, look forward to seeing the finished libraries. In the mean time, I managed to get the embedded images working in an html file. Using the example here: http://www.htmlcodetutorial.com/help/ftopic5309.html But for anyone following this, not the white space (ie empty lines) are important. Cheers Simon On Tue, 21 Apr 2009 10:03:18 +0800, Steven E <railsdeveloper623-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m working on something similar to this now. I''m writing my own > libraries I will post back when I''m done. Will put it on rubyforge > > Sent from my iPhone > > On Apr 20, 2009, at 9:53 PM, "Simon Macneall" <macneall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> >> Hi all, >> >> Does anyone have any suggestions for generating a word doc from a >> linux rails application? We were using html and just naming it .doc, >> which works well until you need to embed images into the document. >> MHT looks promising but the only libraries aren''t free (not a deal >> breaker, but free is better). >> >> Thanks >> Simon >> >> > > > >
Have you looked at http://poi.apache.org/. Its a java library but has wrappers for ruby. Hasham http://www.zenofruby.com On Apr 21, 6:53 am, "Simon Macneall" <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Does anyone have any suggestions for generating a word doc from a linux rails application? We were using html and just naming it .doc, which works well until you need to embed images into the document. MHT looks promising but the only libraries aren''t free (not a deal breaker, but free is better). > > Thanks > Simon
yeah, had a quick look, but it is an orphan project at the moment (at least the word module is). On Tue, 21 Apr 2009 17:28:12 +0800, Hasham <hasham2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Have you looked at http://poi.apache.org/. Its a java library but has > wrappers for ruby. > > Hasham > http://www.zenofruby.com > > On Apr 21, 6:53 am, "Simon Macneall" <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi all, >> >> Does anyone have any suggestions for generating a word doc from a linux >> rails application? We were using html and just naming it .doc, which >> works well until you need to embed images into the document. MHT looks >> promising but the only libraries aren''t free (not a deal breaker, but >> free is better). >> >> Thanks >> Simon > >
You can talk directly to the OpenOffice back-end, and have it generate an MSWord .doc file. On Apr 20, 11:27 pm, "Simon Macneall" <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Andrew, > > Yeah, docx would work, however the customer only has word 2003, which doesn''t support that format. > > the options I have found so far are: > mhtml - the only ruby lib is not free, and the format looks a bit painful to build yourself > rtf - can''t see a ruby lib, but could build a servlet with java/itext > html - can''t embed the image, but can make it a link back to the server (which is what we do with our old .net system), but is not ideal > > I use OpenOffice here, but the customer has word, and have you ever tried to convince a govt dept to change to open office? Not a quick/easy job :) > Thanks > Simon > > > > On Tue, 21 Apr 2009 12:06:53 +0800, Andrew Timberlake <and...@andrewtimberlake.com> wrote: > > > On Tue, Apr 21, 2009 at 5:58 AM, Simon Macneall <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > >> That''s a fabulous answer. > >> I wouldn''t be asking if I could convince my customers that a PDF would > >> do. They need to be able to edit the document after it is generated. > > >> -1 for helpfulness > > > Totally off the wall here but .docx files are XML so why not generate > > one in Word and then manipulate that from your app? > > > Another crazy idea is to use OpenOffice, I think they have a Java > > interface that you might be able to hook into somehow. > > > I have not done either of these, just throwing out some ideas. > > > Andrew Timberlake > >http://ramblingsonrails.com > >http://www.linkedin.com/in/andrewtimberlake > > > "I have never let my schooling interfere with my education" - Mark Twain- Hide quoted text - > > - Show quoted text -
There is an antique technique written up by Sam Neff at http://coldfusion.sys-con.com/node/41604 for ColdFusion. It works, and you don''t need to run Word on your server. You don''t have to use ColdFusion. In fact, you don''t need to run Windows. The source code is still available at http://gemsres.com/story/41604/zip.html Coldfusion is pretty easy to read, but if you get stuck, I''ll be glad to interpret. I won''t say it''s not a PITA, but it does work; I''ve used it. I think I did a version of it in VBA out of MS Access. I even embedded the graphics. Ron On Apr 21, 6:35 am, "Simon Macneall" <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yeah, had a quick look, but it is an orphan project at the moment (at least the word module is). > > On Tue, 21 Apr 2009 17:28:12 +0800, Hasham <hash...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Have you looked athttp://poi.apache.org/. Its a java library but has > > wrappers for ruby. > > > Hasham > >http://www.zenofruby.com > > > On Apr 21, 6:53 am, "Simon Macneall" <macne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi all, > > >> Does anyone have any suggestions for generating a word doc from a linux > >> rails application? We were using html and just naming it .doc, which > >> works well until you need to embed images into the document. MHT looks > >> promising but the only libraries aren''t free (not a deal breaker, but > >> free is better). > > >> Thanks > >> Simon
I didn''t think about that. I have html working fine now, but will keep this in mind for when the customer (as is almost guaranteed) asks for a more complex document. Cheers Simon On Tue, 21 Apr 2009 22:57:07 +0800, wjl_xyz <JohnCalyn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You can talk directly to the OpenOffice back-end, and have it generate > an MSWord .doc file. > >
Thanks, I ended up with something similar, using html and multipart mime Simon On Tue, 21 Apr 2009 22:58:18 +0800, paron <rphillips-9+Xt05h8050e0BZhvJFe1KxOck334EZe@public.gmane.org> wrote:> > There is an antique technique written up by Sam Neff at > http://coldfusion.sys-con.com/node/41604 for ColdFusion. It works, and > you don''t need to run Word on your server. You don''t have to use > ColdFusion. In fact, you don''t need to run Windows. The source code is > still available at http://gemsres.com/story/41604/zip.html > > Coldfusion is pretty easy to read, but if you get stuck, I''ll be glad > to interpret. > > I won''t say it''s not a PITA, but it does work; I''ve used it. I think I > did a version of it in VBA out of MS Access. I even embedded the > graphics. > > Ron
On Tue, Apr 21, 2009 at 1:35 AM, Simon Macneall <macneall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The only problem with HTML is that I can''t find a way to embed the image (that works in Word), as opposed to having it link back to our server (which isn''t the desired outcome).I am using this approach on a project with success. The only gotcha is that you have to use the full URL of the image, instead of just the path that Rails generates. Here''s a helper method I used: def image_url(img) request.protocol + request.host_with_port + image_path(img) end Hope that helps -- Brandon -------------------------------------------------------------------------------- Idea Foundry: training takes a Holiday http://ideafoundry.info – Refer a friend and get $100