Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse word documents with ruby?

Does anyone know of a library that I can use on OS X/Linux to parse Word files and output the content as HTML?

I've had a look at win32ole but as far as I can see it's for Windows only, although I could be wrong.

Any suggestions?

like image 458
Jim Neath Avatar asked Dec 17 '08 20:12

Jim Neath


1 Answers

The Word document format (ignoring docx for the moment) is terrible and was constantly changing. IMHO that is why there are so few (read: zero) Ruby libraries out there to parse them.

What I recommend doing is using JRuby and some of the established Java libraries for reading the doc format. Google should help you out there: http://schmidt.devlib.org/java/libraries-word.html.

There is a Java project for reading MIcrosoft file formats, POI (http://poi.apache.org/) and they do have Ruby bindings (http://poi.apache.org/poi-ruby.html) but I'm not sure how up-to-date those are. On their site it says the Ruby bindings are for 1.8.2...

like image 149
Chris Lloyd Avatar answered Sep 30 '22 01:09

Chris Lloyd