From 1f29b2f1883e153e50c005363879c6fe11529e62 Mon Sep 17 00:00:00 2001 From: adrianrosian Date: Tue, 3 Sep 2013 09:38:47 +0300 Subject: [PATCH 1/2] Update Factory to add backwards compatibility support Added 2 versions for 1.x and 2.x versions of pdftk --- src/Shuble/Slurpy/Factory.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Shuble/Slurpy/Factory.php b/src/Shuble/Slurpy/Factory.php index 8b1319e..0cb7468 100644 --- a/src/Shuble/Slurpy/Factory.php +++ b/src/Shuble/Slurpy/Factory.php @@ -38,15 +38,23 @@ class Factory * @var string */ protected $binary; + + /** + * Version of pdftk, 1.x (1) or 2.x (2) + * + * @var integer + */ + protected $version; /** * Constructor * * @param string $binary */ - public function __construct($binary) + public function __construct($binary, $version = 2) { $this->binary = $binary; + $this->version = $version; } /** @@ -367,6 +375,8 @@ protected function getPageRange($handle, $input) */ protected function generateFileHandle($index) { + if (1 === $version) + return chr(65 + $index % 26); return chr(65 + floor($index/26) % 26) . chr(65 + $index % 26); } } From 3f98a9c0dec66af548bed0e8169c3e63016c4955 Mon Sep 17 00:00:00 2001 From: adrianrosian Date: Tue, 3 Sep 2013 09:50:51 +0300 Subject: [PATCH 2/2] Update Factory.php Fixed error in version comparison --- src/Shuble/Slurpy/Factory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shuble/Slurpy/Factory.php b/src/Shuble/Slurpy/Factory.php index 0cb7468..4ecf971 100644 --- a/src/Shuble/Slurpy/Factory.php +++ b/src/Shuble/Slurpy/Factory.php @@ -375,7 +375,7 @@ protected function getPageRange($handle, $input) */ protected function generateFileHandle($index) { - if (1 === $version) + if (1 === $this->version) return chr(65 + $index % 26); return chr(65 + floor($index/26) % 26) . chr(65 + $index % 26); }