SearchWP

This Documentation is for SearchWP Version 3

Adding PDF password support in Xpdf Integration

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:

<?php
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