Merge pull request #28 from SilbinaryWolf/fix-windowscompat

fix(PDFTextExtractor): Added support for Windows, but only if 'binary_location' config is defined
This commit is contained in:
Daniel Hensby 2016-05-14 12:14:31 +01:00
commit 61750e33fc
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,