# MS Word files and PDFs

**URL:** <https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551>\
**Category:** Ruby\
**Created:** [April 23, 2006, 1:49am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551 "2006-04-23T01:49:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [April 23, 2006, 1:49am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/1 "2006-04-23T01:49:06Z")

</div>

Hello,

I’m fairly new to the Ruby scene.  
Is there any library that can read MS Word (.doc) files and extract the  
pure  
text…what about libs for PDF files?

Thanks folks,

M.

---

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [April 23, 2006, 2:35am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/2 "2006-04-23T02:35:21Z")

</div>

You could use the win32ole library and read them yourself via OLE.

---

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [April 23, 2006, 2:44am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/3 "2006-04-23T02:44:28Z")

</div>

On Sun, 23 Apr 2006, Mateo Barraza wrote:

> I’m fairly new to the Ruby scene.  
> Is there any library that can read MS Word (.doc) files and extract the pure  
> text…what about libs for PDF files?

Hi,

There’s not a MS Word library that I know of that will easily allow you  
to extract the pure text, but the OLE suggestion is a good idea. Another  
method would be to save as WordprocessingML (XML) (if you have Word  
2003) and use  
either REXML or libxml-ruby (two Ruby XML libraries) to parse it (or  
XSLT). If you’ve got XML, the  
interesting nodes (if you really only want text) are the ‘w:t’ ones.

HTH,  
Keith

---

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [April 23, 2006, 3:23am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/4 "2006-04-23T03:23:58Z")

</div>

Thanks for your responses; I also found that the POI java project was  
extended to support ruby:  
[http://jakarta.apache.org/poi/poi-ruby.html](http://jakarta.apache.org/poi/poi-ruby.html)  
Although, I think the win32ole solution is the best for simply  
reading the content of the docs…

M

---

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [February 8, 2008, 8:18am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/5 "2008-02-08T08:18:19Z")

</div>

Keith S. wrote:

> You could use the win32ole library and read them yourself via OLE.

Hi,

could you provide code snippet

---

<div class="post-metadata">

**Author:** ![Mateo\_Barraza](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Mateo\_Barraza](https://www.ruby-forum.com/u/Mateo_Barraza)\
**Post date:** [February 8, 2008, 9:15am UTC](https://www.ruby-forum.com/t/ms-word-files-and-pdfs/58551/6 "2008-02-08T09:15:06Z")

</div>

On Feb 8, 2008 8:18 AM, Rajesh S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Keith S. wrote:  
> I have found this most useful:  
> [http://rubyonwindows.blogspot.com/](http://rubyonwindows.blogspot.com/)  
> what you want should be hidden in there  
> [Ruby on Windows: word](http://rubyonwindows.blogspot.com/search/label/word)

A most valuable read anyway.

Cheers  
Robert

–  
[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

Whereof one cannot speak, thereof one must be silent.  
Ludwig Wittgenstein
