Adding PDF password support in Xpdf Integration

Last updated December 18, 2018 « Knowledge Base

Note: this applies only to Xpdf Integration

Xpdf Integration offloads the PDF parsing process away from PHP to the command line. This is good for a number of reasons. Parsing PDFs is a very expensive process in PHP, and there are other limitations like the inability to parse password protected PDFs.

Xpdf does support parsing of password protected (read: not encrypted) PDFs using the searchwp_xpdf_command filter. This filter allows you to directly manipulate the command being executed to fire Xpdf, and since Xpdf supports an option to include a password, you can go ahead and to that like so:

function my_searchwp_xpdf_command( $cmd, $filename ) {
return $cmd . ' -upw password';
add_filter( 'searchwp_xpdf_command', 'searchwp_xpdf_command', 10, 2 );
view raw functions.php hosted with ❤ by GitHub
Fix Search on Your Site. No Coding Required!

Now you can utilize all of the content that's gone unrecognized by native WordPress search instantly with SearchWP

Get SearchWP