# PDF text search in rails

**URL:** <https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351>\
**Category:** Rails\
**Created:** [June 3, 2008, 7:26am UTC](https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351 "2008-06-03T07:26:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [June 3, 2008, 7:26am UTC](https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351/1 "2008-06-03T07:26:17Z")

</div>

is there any plugin which could search in PDF documents. For example,  
user should be able to search for keywords in the PDF contents.

---

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [June 3, 2008, 2:42pm UTC](https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351/2 "2008-06-03T14:42:17Z")

</div>

Good morning -

On 3-Jun-08, at 1:25 AM, ripan wrote:

> is there any plugin which could search in PDF documents. For example,  
> user should be able to search for keywords in the PDF contents.

Someone submitted a patch for acts\_as\_solr to index documents - read  
the google group for this project

J

---

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [June 3, 2008, 2:47pm UTC](https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351/3 "2008-06-03T14:47:40Z")

</div>

> is there any plugin which could search in PDF documents.

Maybe you can try this: [http://raa.ruby-lang.org/project/rpdf2txt/](http://raa.ruby-lang.org/project/rpdf2txt/)  
or JRoR and one of the many Java PDF libraries. I’m not aware of a  
Rails plugin.

---

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [June 3, 2008, 3:26pm UTC](https://www.ruby-forum.com/t/pdf-text-search-in-rails/139351/4 "2008-06-03T15:26:48Z")

</div>

> Someone submitted a patch for acts\_as\_solr to index documents - read  
> the google group for this project

I didn’t think solr would do this, since it provides index and query  
but not parsing of rich formats. However, there seems to be a patch  
that extracts text (but not metadata) from rich documents into solr:  
[UpdateRichDocuments - Solr - Apache Software Foundation](http://wiki.apache.org/solr/UpdateRichDocuments). The solr committers  
are reluctant to use that patch, though, and would rather build a  
bridge from Tika ([Apache Tika – Apache Tika](http://incubator.apache.org/tika/)) to solr, even if  
that is further down the road.

I did find the patch to acts\_as\_solr here:  
[http://www.nabble.com/Rich-Document-support-for-solr-ruby-and-acts\_as\_solr-p17161561.html](http://www.nabble.com/Rich-Document-support-for-solr-ruby-and-acts_as_solr-p17161561.html)  
But since this patch relies on the uncommitted solr patch, I wouldn’t  
rely on this being viable for the long-term.

A less tenuous solution may be to extract the text from a PDF via some  
other library (perhaps rpdf2txt or PDFbox), and indexing it using the  
standard acts\_as\_solr.

- Mark.
