# PHP Script to search PDF files



## 37Seconds

Is there a PHP Script that can search through PDF files in a directory on the webserver using a keyword entered by a user of a website?


----------



## jaymanson

This may or may not be of some use to you:

You will no doubt be aware that you can add a Google search to your site. Click here to set it up! If you make sure your website is the only one under 'sites' and add *filetype: pdf* as a search refinement, that will do exactly what you are looking for.

Depending on what you need, this may not look professional enough for you, but it works all the same 

Jay


----------



## 37Seconds

Thanks for the idea Jay, but unforetunately it won't work for us. The site we plan on creating will be an intranet site behind a firewall for department to use, so the Google idea won't work.

The site will be used to search through department procedures that are in PDF format. I figured there would already be a php script that is able to do this that we could implement by creating a website on a server. Unforetunately, I have yet to be able to find one.

Any other ideas?


----------



## brendandonhu

You can convert the PDF document to plain text - take a look at the comments on http://php.net/pdf (there's a function called pdf2string()). You can also run the file through a library like pdftohtml or pdftotext.


----------



## jaymanson

Here's a possibility then 

Zoom Search Engine

It's free up to 50 page searching, and then not too much after that. Can't quickly see any free scripts that will search PDFs, but you might find one at Hotscripts. I'm more web designer than developer, so this is where I get a lot of my scripts from and then customise them to my needs


----------



## MMJ

Will it search filenames only or inside the actual file?

You can put the filenames in a db than have the search find them.


----------

