From 75ffe7b56a895319b7a4a1e0c24fd2bc8033c9cd Mon Sep 17 00:00:00 2001 From: Jake Bentvelzen Date: Fri, 13 May 2016 15:07:33 +1000 Subject: [PATCH] fix(PDFTextExtractor): Added support for Windows, but only if 'binary_location' is defined. Updated documentation to inform the user of this. --- README.md | 2 +- code/extractors/PDFTextExtractor.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8514412..80e51af 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/code/extractors/PDFTextExtractor.php b/code/extractors/PDFTextExtractor.php index 0fdaf16..f832169 100644 --- a/code/extractors/PDFTextExtractor.php +++ b/code/extractors/PDFTextExtractor.php @@ -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,