mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 11:06:00 +02:00
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:
parent
bde4cf4536
commit
75ffe7b56a
@ -89,7 +89,7 @@ FileTextCache_SSCache:
|
|||||||
|
|
||||||
PDFs require special handling, for example through the [XPDF](http://www.foolabs.com/xpdf/)
|
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
|
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
|
```yml
|
||||||
PDFTextExtractor:
|
PDFTextExtractor:
|
||||||
|
@ -71,6 +71,9 @@ class PDFTextExtractor extends FileTextExtractor
|
|||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
if (file_exists($path.'.exe')) {
|
||||||
|
return $path.'.exe';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not found
|
// Not found
|
||||||
@ -100,6 +103,10 @@ class PDFTextExtractor extends FileTextExtractor
|
|||||||
}
|
}
|
||||||
exec(sprintf('%s %s - 2>&1', $this->bin('pdftotext'), escapeshellarg($path)), $content, $err);
|
exec(sprintf('%s %s - 2>&1', $this->bin('pdftotext'), escapeshellarg($path)), $content, $err);
|
||||||
if ($err) {
|
if ($err) {
|
||||||
|
if (!is_array($err) && $err == 1) {
|
||||||
|
// For Windows compatibility
|
||||||
|
$err = $content;
|
||||||
|
}
|
||||||
throw new FileTextExtractor_Exception(sprintf(
|
throw new FileTextExtractor_Exception(sprintf(
|
||||||
'PDFTextExtractor->getContent() failed for %s: %s',
|
'PDFTextExtractor->getContent() failed for %s: %s',
|
||||||
$path,
|
$path,
|
||||||
|
Loading…
Reference in New Issue
Block a user