# How to index PDF

**URL:** <https://www.ruby-forum.com/t/how-to-index-pdf/145564>\
**Category:** Ferret\
**Created:** [August 11, 2008, 5:01pm UTC](https://www.ruby-forum.com/t/how-to-index-pdf/145564 "2008-08-11T17:01:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![slum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@slum](https://www.ruby-forum.com/u/slum)\
**Post date:** [August 11, 2008, 5:01pm UTC](https://www.ruby-forum.com/t/how-to-index-pdf/145564/1 "2008-08-11T17:01:26Z")

</div>

Hello,

I’m actually trying to index PDF without success.  
Anyone could explain how does it works ?

Thank you.

---

<div class="post-metadata">

**Author:** ![slum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@slum](https://www.ruby-forum.com/u/slum)\
**Post date:** [August 12, 2008, 5:54am UTC](https://www.ruby-forum.com/t/how-to-index-pdf/145564/2 "2008-08-12T05:54:16Z")

</div>

SÃ©bastien Mizrahi wrote:

> Hello,
> 
> I’m actually trying to index PDF without success.  
> Anyone could explain how does it works ?
> 
> Thank you.

You must parse the PDF into pure text using some libs

---

<div class="post-metadata">

**Author:** ![slum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@slum](https://www.ruby-forum.com/u/slum)\
**Post date:** [August 12, 2008, 8:49am UTC](https://www.ruby-forum.com/t/how-to-index-pdf/145564/3 "2008-08-12T08:49:58Z")

</div>

Nathan Li wrote:

> SÃ©bastien Mizrahi wrote:
> 
> > Hello,
> > 
> > I’m actually trying to index PDF without success.  
> > Anyone could explain how does it works ?
> > 
> > Thank you.
> 
> You must parse the PDF into pure text using some libs

Thank you for your quick answer 🙂  
Do you have the name of the lib I should use, and an small tutorial ?

---

<div class="post-metadata">

**Author:** ![slum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@slum](https://www.ruby-forum.com/u/slum)\
**Post date:** [September 26, 2008, 1:56pm UTC](https://www.ruby-forum.com/t/how-to-index-pdf/145564/4 "2008-09-26T13:56:21Z")

</div>

SÃ©bastien Mizrahi wrote:

> Nathan Li wrote:
> 
> > SÃ©bastien Mizrahi wrote:
> > 
> > > Hello,
> > > 
> > > I’m actually trying to index PDF without success.  
> > > Anyone could explain how does it works ?
> > > 
> > > Thank you.
> > 
> > You must parse the PDF into pure text using some libs
> 
> Thank you for your quick answer 🙂  
> Do you have the name of the lib I should use, and an small tutorial ?

i use the command line tool “pdftotext” for this which i put into  
lib/bin inside my app.

add a method to your model and add id to your indexed fields

e.g.

def text  
path = ‘path/to/your/file.pdf’  
text = `#{RAILS_ROOT}/lib/bin/pdftotext -q \"#{path}\" -`  
end

ralf
