2

I have a blog with reasonable number of pdf files. How can I make wordpress look into pdf files when I search it?

Thanks

4
  • You probably can't. Wordpress is made to manage content, not documents. – ashes999 Oct 2 '11 at 23:02
  • Well you could, you would just have to create a plugin that uses some other tool to do it. – Devin Humbert Oct 3 '11 at 0:37
  • I didn't expect this kind of advice to be honest :) – user3047 Oct 3 '11 at 20:40
  • I experienced the same problem a few months ago, I came to know about its solutions in form of plugin which is "Full text Search". It supports PDF's Docx and many other formats. I think its link is "fulltextsearch.org". – Marcus Jul 7 '18 at 11:20
1

The built in WordPress search doesn't index PDF file contents, however Google does, there's a good tutorial on DevPress on replacing WordPress search with Google Custom Search.

1
  • I didn't know Google would index your pdfs too. That's risky if you have some confidential pdfs. – AlxVallejo Jan 31 '12 at 21:39
1

You could use the open-source utility, xpdf, to convert the pdf file into a plan text file and search through it like any other text file. Incorporating into WordPress is another thing to worry about though.

I used it on my Mac to extract data from my company's quarterly financial statements. You could install under Mac OS X, if you've got MacPorts installed.

port install xpdf

You would then need to use the utility xpdf-pdftotext to convert the pdf file to a plain text file.

You could simply store the result in PHP as a variable

$file_name = '/usr/local/src/file1.pdf';

// On Mac the utility is called xpdf-pdftotext, and pdftotext on Linux I believe

if (file_exists($file_name)) {
    $file_contents = shell_exec("/opt/local/bin/xpdf-pdftotext $filename - 2>&1");

    echo $file_contents;
}

If you'd like to install xpdf from source, its available on their website, which offers both Linux and Windows versions.

Check out the xpdf man pages to get an idea of the utility, they've got different tools for different applications. Here's the man page for the pdftotext utility.

Best of luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.