Skip to content

Commit 20e17cb

Browse files
Merge pull request #7 from vluzrmos/master
Makes pdfinfo path configurable.
2 parents 9167cbb + 3923ded commit 20e17cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Howtomakeaturn/PDFInfo/PDFInfo.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class PDFInfo
2626
public $optimized;
2727
public $PDFVersion;
2828

29+
public static $bin;
30+
2931
public function __construct($file)
3032
{
3133
$this->file = $file;
@@ -35,9 +37,18 @@ public function __construct($file)
3537
$this->parseOutput();
3638
}
3739

40+
public function getBinary()
41+
{
42+
if (empty(static::$bin)) {
43+
static::$bin = getenv('PDFINFO_BIN') ?: 'pdfinfo';
44+
}
45+
46+
return static::$bin;
47+
}
48+
3849
private function loadOutput()
3950
{
40-
$cmd = "pdfinfo"; // Linux
51+
$cmd = escapeshellarg($this->getBinary()); // escapeshellarg to work with Windows paths with spaces.
4152

4253
$file = escapeshellarg($this->file);
4354
// Parse entire output

0 commit comments

Comments
 (0)