Introduction

SearchWP is a nice WordPress plugin which allows to extend WordPress search capabilities to various content format beyond just page text.
Here I am focusing on PDF indexing specifically. If you have any PDF files published and want them be indexed SearchWP-XPDF extension can be deployed.

Issue

Problem is that SearchWP developers decided to rely on deployment of direct code from FooLabs.  If it is not deployed as a drop-in, functionality would be disabled.
Drop-in option is not always possible and in fact unnecessary for this plugin to function.

In distros like CentOS  PHP XPDF support is available out of the box and can be enabled by installing poppler_utils.

Solution

    • Install SearchWP Xpdf extension as you would normally do
    • In WP Dashboard warning would appear – “SearchWP Xpdf Integration requires you to download and install Xpdf…”
    • SSH to your server
    • Install poppler_utils using yum# yum install poppler_utils
    • Refresh your WP Dashboard page. Warning would not go away because code specifically looking for physical location instead of verifying XPDF support by OS
    • Now we do some hacking:
      • in your WP installation, navigate to /plugins/searchwp-xpdf/ and open searchwp-xpdf.php for edit
      • Look for “// see if Xpdf exists”
      • Comment out what follows
        /*
        // see if Xpdf exists
        if ( $continue && file_exists( $this->xpdfPath ) ) {
        echo 'Xpdf (pdftotext) was found, continuing<br />';
        } elseif ( $continue ) {
        echo 'Xpdf (pdftotext) was not found, aborting<br />';
        $continue = false;
        }
        */
        
      • Next look for function admin_notice()
      • Comment out content of the function to suppress Admin notice
        function admin_notice() {
        /*
        ...
        <?php }
        */
        }
        
    • Refresh WP Dashboard
    • Warning would now go away
    • Run indexing, PDF files should now be indexed properly

Footnote

I did actually reach out to SearchWP team back in May 2017 and solution was acknowledged, but almost year later plugin still relies on custom drop-ins.

Enjoy.


0 Comments

Leave a Reply