Skip to content

Commit ffdf268

Browse files
authored
Replace itbz (deprecated) with setasign (#14)
Replaced itbz with setasign. Also change the composer.json file
1 parent 688cecc commit ffdf268

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PDFMerger/PDFMerger.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
namespace Webklex\PDFMerger;
1414

15-
use fpdi\FPDI;
15+
use setasign\Fpdi\Fpdi as FPDI;
16+
use setasign\Fpdi\PdfParser\StreamReader;
1617
use Illuminate\Filesystem\Filesystem;
1718
use Illuminate\Support\Collection;
1819

@@ -213,15 +214,15 @@ protected function doMerge($orientation, $duplexSafe) {
213214

214215
$this->aFiles->each(function($file) use($oFPDI, $orientation, $duplexSafe){
215216
$file['orientation'] = is_null($file['orientation'])?$orientation:$file['orientation'];
216-
$count = $oFPDI->setSourceFile($file['name']);
217+
$count = $oFPDI->setSourceFile(StreamReader::createByString(file_get_contents($file['name'])));
218+
217219
if ($file['pages'] == 'all') {
218220

219221
for ($i = 1; $i <= $count; $i++) {
220222
$template = $oFPDI->importPage($i);
221223
$size = $oFPDI->getTemplateSize($template);
222-
$autoOrientation = ($size['h'] > $size['w']) ? 'P' : 'L';
223224

224-
$oFPDI->AddPage($autoOrientation, [$size['w'], $size['h']]);
225+
$oFPDI->AddPage($file['orientation'], [$size['width'], $size['height']]);
225226
$oFPDI->useTemplate($template);
226227
}
227228
} else {
@@ -230,15 +231,14 @@ protected function doMerge($orientation, $duplexSafe) {
230231
throw new \Exception("Could not load page '$page' in PDF '".$file['name']."'. Check that the page exists.");
231232
}
232233
$size = $oFPDI->getTemplateSize($template);
233-
$autoOrientation = ($size['h'] > $size['w']) ? 'P' : 'L';
234234

235-
$oFPDI->AddPage($autoOrientation, [$size['w'], $size['h']]);
235+
$oFPDI->AddPage($file['orientation'], [$size['width'], $size['height']]);
236236
$oFPDI->useTemplate($template);
237237
}
238238
}
239239

240240
if ($duplexSafe && $oFPDI->page % 2) {
241-
$oFPDI->AddPage($file['orientation'], [$size['w'], $size['h']]);
241+
$oFPDI->AddPage($file['orientation'], [$size['width'], $size['height']]);
242242
}
243243
});
244244
}

0 commit comments

Comments
 (0)