I haven't actually done this, but there is a File API (http://api.drupal.org/?q=api/group/file/5) in Drupal for handling files. Off the top of my head, what you could do in hook_search() where $op == 'search' is use file_scan_directory() to get a list of all of the file names. This function also handles recursion, so it will also search subdirectories if you specify to do so.
As for reading content from the PDF, the only things I came across doing a quick Google search were the FPDI (http://www.hotscripts.com/Detailed/39165.html) and FPDF (http://www.fpdf.org/) PHP libraries.
Once you get your content (file names and doc content), my suggestion would be to use the Drupal indexer using hook_update_index(). That way, your searches would be much quicker than if you had to search all of your directories and files every time.
Steve
Jody Cleveland wrote:
How do I get drupal to search files though? And, will it search content of those files? Unfortunately, I haven't uploaded them through Drupal. I have multiple directories with thousands of pdf files as part of a local history digitization project.
- jody
On 12/31/07 11:45 AM, "Steve Edwards" killshot91@comcast.net wrote:
You would use hook_search() to specify the name of the new tab on the Search page, and then the query to search for the files. If the PDF files have been uploaded via Drupal, then there should be a record of them in the database and you could search there. Otherwise, you would have to add some code to iterate through the file directory, get the file names, and display them on the screen. Either way, hook_search() looks like it would work.
Steve
Jody Cleveland wrote:
Thanks!
Is there any way to code a search box to search a specific file directory on the site?
(I've got several directories of pdf files that I'd like to limit searches to.)
- jody
On 12/28/07 5:11 PM, "Bill Fitzgerald" bill@funnymonkey.com wrote:
Views would do this pretty well -- create a view that returns all nodes in a category, and expose the Search: Index filter.
Cheers,
Bill
Jody Cleveland wrote:
Hello,
Is there any way to code an html page to have a search box that defaults to search a specific category?
- jody