Skip to content

Commit

Permalink
Bugfix Autoorientation
Browse files Browse the repository at this point in the history
  • Loading branch information
laraben authored Nov 23, 2021
1 parent 10bb072 commit b522499
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PDFMerger/PDFMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ protected function doMerge($orientation, $duplexSafe) {
for ($i = 1; $i <= $count; $i++) {
$template = $oFPDI->importPage($i);
$size = $oFPDI->getTemplateSize($template);
$autoOrientation = ($size['height'] > $size['width']) ? 'P' : 'L';
$autoOrientation = ($size[1] > $size[0]) ? 'P' : 'L';

$oFPDI->AddPage($autoOrientation, [$size['width'], $size['height']]);
$oFPDI->AddPage($autoOrientation, [$size[0], $size[1]]);
$oFPDI->useTemplate($template);
}
} else {
Expand All @@ -232,15 +232,15 @@ protected function doMerge($orientation, $duplexSafe) {
throw new \Exception("Could not load page '$page' in PDF '".$file['name']."'. Check that the page exists.");
}
$size = $oFPDI->getTemplateSize($template);
$autoOrientation = ($size['height'] > $size['width']) ? 'P' : 'L';
$autoOrientation = ($size[1] > $size[0]) ? 'P' : 'L';

$oFPDI->AddPage($autoOrientation, [$size['width'], $size['height']]);
$oFPDI->AddPage($autoOrientation, [$size[0], $size[1]]);
$oFPDI->useTemplate($template);
}
}

if ($duplexSafe && $oFPDI->page % 2) {
$oFPDI->AddPage($file['orientation'], [$size['width'], $size['height']]);
$oFPDI->AddPage($file['orientation'], [$size[0], $size[1]]);
}
});
}
Expand Down

0 comments on commit b522499

Please sign in to comment.