Skip to content

Commit 319612e

Browse files
committed
Small performance optimization
1 parent 465a490 commit 319612e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/PDFMerger/PDFMerger.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public function download(){
107107

108108
/**
109109
* Save the merged PDF content to the filesystem
110-
* @param mixed $filePath
111110
*
112111
* @return string
113112
*/
@@ -135,7 +134,15 @@ public function setFileName($fileName){
135134
return $this;
136135
}
137136

138-
public function addString($string, $fileName, $pages = 'all', $orientation = null){
137+
/**
138+
* Set the final filename
139+
* @param string $string
140+
* @param mixed $pages
141+
* @param mixed $orientation
142+
*
143+
* @return string
144+
*/
145+
public function addString($string, $pages = 'all', $orientation = null){
139146

140147
$filePath = storage_path('tmp/'.str_random(16).'.pdf');
141148
$this->oFilesystem->put($filePath, $string);
@@ -190,8 +197,8 @@ public function merge($orientation = 'P') {
190197

191198
$this->aFiles->each(function($file) use($oFPDI, $orientation){
192199
$file['orientation'] = !is_null($file['orientation'])?$orientation:$file['orientation'];
200+
$count = $oFPDI->setSourceFile($file['name']);
193201
if ($file['pages'] == 'all') {
194-
$count = $oFPDI->setSourceFile($file['name']);
195202

196203
for ($i = 1; $i <= $count; $i++) {
197204
$template = $oFPDI->importPage($i);

0 commit comments

Comments
 (0)