12
12
13
13
namespace Webklex \PDFMerger ;
14
14
15
- use fpdi \FPDI ;
15
+ use setasign \Fpdi \Fpdi as FPDI ;
16
+ use setasign \Fpdi \PdfParser \StreamReader ;
16
17
use Illuminate \Filesystem \Filesystem ;
17
18
use Illuminate \Support \Collection ;
18
19
@@ -213,15 +214,15 @@ protected function doMerge($orientation, $duplexSafe) {
213
214
214
215
$ this ->aFiles ->each (function ($ file ) use ($ oFPDI , $ orientation , $ duplexSafe ){
215
216
$ 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
+
217
219
if ($ file ['pages ' ] == 'all ' ) {
218
220
219
221
for ($ i = 1 ; $ i <= $ count ; $ i ++) {
220
222
$ template = $ oFPDI ->importPage ($ i );
221
223
$ size = $ oFPDI ->getTemplateSize ($ template );
222
- $ autoOrientation = ($ size ['h ' ] > $ size ['w ' ]) ? 'P ' : 'L ' ;
223
224
224
- $ oFPDI ->AddPage ($ autoOrientation , [$ size ['w ' ], $ size ['h ' ]]);
225
+ $ oFPDI ->AddPage ($ file [ ' orientation ' ] , [$ size ['width ' ], $ size ['height ' ]]);
225
226
$ oFPDI ->useTemplate ($ template );
226
227
}
227
228
} else {
@@ -230,15 +231,14 @@ protected function doMerge($orientation, $duplexSafe) {
230
231
throw new \Exception ("Could not load page ' $ page' in PDF ' " .$ file ['name ' ]."'. Check that the page exists. " );
231
232
}
232
233
$ size = $ oFPDI ->getTemplateSize ($ template );
233
- $ autoOrientation = ($ size ['h ' ] > $ size ['w ' ]) ? 'P ' : 'L ' ;
234
234
235
- $ oFPDI ->AddPage ($ autoOrientation , [$ size ['w ' ], $ size ['h ' ]]);
235
+ $ oFPDI ->AddPage ($ file [ ' orientation ' ] , [$ size ['width ' ], $ size ['height ' ]]);
236
236
$ oFPDI ->useTemplate ($ template );
237
237
}
238
238
}
239
239
240
240
if ($ duplexSafe && $ oFPDI ->page % 2 ) {
241
- $ oFPDI ->AddPage ($ file ['orientation ' ], [$ size ['w ' ], $ size ['h ' ]]);
241
+ $ oFPDI ->AddPage ($ file ['orientation ' ], [$ size ['width ' ], $ size ['height ' ]]);
242
242
}
243
243
});
244
244
}
0 commit comments