PDA

View Full Version : PDF Indexing Workaround on Shared Hosting


dekortage
02-07-2007, 11:17 AM
I recently installed PHPdig for a client who has a shared hosting account with CheapCheap.biz. With only a shared account, there is no access to PDF converters on the server, and no way to install them. However, he still had a handful of PDFs that he wanted to include in search results. My workaround was this:

1. Open the PDFs and export the text to a plain-text file. If the PDF was called "newsletter-2006.pdf", then I named the text file "newsletter-2006_pdf.txt" in the exact same directory.

2. Index the text files with PHPdig (using direct URLs).

3. Add the following PHP code to PHPdig's /libs/search_function.php, around line 520, just before the line that begins "$table_results[$n] = ...":

$url = str_replace("_pdf.txt",".pdf",$url);


And there you go. This way, PHPdig has indexed the text of the PDF, but will return search links to the actual PDF file. It's not an ideal solution, but it works in a pinch.