fix(PDFTextExtractor): Added support for Windows, but only if 'binary_location' is defined. Updated documentation to inform the user of this.

This commit is contained in:
Jake Bentvelzen 2016-05-13 15:07:33 +10:00
parent bde4cf4536
commit 75ffe7b56a
2 changed files with 8 additions and 1 deletions

View File

@ -89,7 +89,7 @@ FileTextCache_SSCache:
PDFs require special handling, for example through the [XPDF](http://www.foolabs.com/xpdf/)
commandline utility. Follow their installation instructions, its presence will be automatically
detected. You can optionally set the binary path in `mysite/_config/config.yml`:
detected for *nix operating systems. You can optionally set the binary path (required for Windows) in `mysite/_config/config.yml`
```yml
PDFTextExtractor:

View File

@ -71,6 +71,9 @@ class PDFTextExtractor extends FileTextExtractor
if(file_exists($path)) {
return $path;
}
if (file_exists($path.'.exe')) {
return $path.'.exe';
}
}
// Not found
@ -100,6 +103,10 @@ class PDFTextExtractor extends FileTextExtractor
}
exec(sprintf('%s %s - 2>&1', $this->bin('pdftotext'), escapeshellarg($path)), $content, $err);
if ($err) {
if (!is_array($err) && $err == 1) {
// For Windows compatibility
$err = $content;
}
throw new FileTextExtractor_Exception(sprintf(
'PDFTextExtractor->getContent() failed for %s: %s',
$path,