WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
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

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.

share|improve this answer
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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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