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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_searchwp_xpdf_command( $cmd, $filename ) { | |
return $cmd . ' -upw password'; | |
} | |
add_filter( 'searchwp_xpdf_command', 'searchwp_xpdf_command', 10, 2 ); |