@@ -195,7 +195,7 @@ public function addPDF($filePath, $pages = 'all', $orientation = null) {
195
195
*
196
196
* @throws \Exception if there are now PDFs to merge
197
197
*/
198
- public function merge ($ orientation = ' P ' ) {
198
+ public function merge ($ orientation = null ) {
199
199
$ this ->doMerge ($ orientation , false );
200
200
}
201
201
@@ -228,18 +228,20 @@ protected function doMerge($orientation, $duplexSafe) {
228
228
for ($ i = 1 ; $ i <= $ count ; $ i ++) {
229
229
$ template = $ oFPDI ->importPage ($ i );
230
230
$ size = $ oFPDI ->getTemplateSize ($ template );
231
+ $ autoOrientation = isset ($ file ['orientation ' ]) ? $ file ['orientation ' ] : $ size ['orientation ' ];
231
232
232
- $ oFPDI ->AddPage ($ file [ ' orientation ' ] , [$ size ['width ' ], $ size ['height ' ]]);
233
+ $ oFPDI ->AddPage ($ autoOrientation , [$ size ['width ' ], $ size ['height ' ]]);
233
234
$ oFPDI ->useTemplate ($ template );
234
235
}
235
236
} else {
236
237
foreach ($ file ['pages ' ] as $ page ) {
237
238
if (!$ template = $ oFPDI ->importPage ($ page )) {
238
- throw new \Exception ("Could not load page ' $ page' in PDF ' " . $ file ['name ' ]. "'. Check that the page exists. " );
239
+ throw new \Exception ("Could not load page ' $ page' in PDF ' " . $ file ['name ' ] . "'. Check that the page exists. " );
239
240
}
240
241
$ size = $ oFPDI ->getTemplateSize ($ template );
242
+ $ autoOrientation = isset ($ file ['orientation ' ]) ? $ file ['orientation ' ] : $ size ['orientation ' ];
241
243
242
- $ oFPDI ->AddPage ($ file [ ' orientation ' ] , [$ size ['width ' ], $ size ['height ' ]]);
244
+ $ oFPDI ->AddPage ($ autoOrientation , [$ size ['width ' ], $ size ['height ' ]]);
243
245
$ oFPDI ->useTemplate ($ template );
244
246
}
245
247
}
0 commit comments