@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function register() |
| 26 | 26 | { |
| 27 | - $this->app->singleton('PdfFusion', function ($app) { |
|
| 27 | + $this->app->singleton('PdfFusion', function($app) { |
|
| 28 | 28 | $PdfFusion = new PdfFusion($app['files']); |
| 29 | 29 | return $PdfFusion; |
| 30 | 30 | }); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Construct and initialize a new instance |
| 42 | 42 | * @param Filesystem $Filesystem |
| 43 | 43 | */ |
| 44 | - public function __construct(Filesystem $filesystem){ |
|
| 44 | + public function __construct(Filesystem $filesystem) { |
|
| 45 | 45 | $this->filesystem = $filesystem; |
| 46 | 46 | $this->createDirectoryForTemporaryFiles(); |
| 47 | 47 | $this->fpdi = new Fpdi(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return self |
| 65 | 65 | */ |
| 66 | - public function init(){ |
|
| 66 | + public function init() { |
|
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string |
| 73 | 73 | */ |
| 74 | - public function inline(){ |
|
| 74 | + public function inline() { |
|
| 75 | 75 | return $this->fpdi->Output($this->fileName, 'I'); |
| 76 | 76 | } |
| 77 | 77 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public function download(){ |
|
| 82 | + public function download() { |
|
| 83 | 83 | return $this->fpdi->Output($this->fileName, 'D'); |
| 84 | 84 | } |
| 85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - public function save($filePath = null){ |
|
| 90 | + public function save($filePath = null) { |
|
| 91 | 91 | return $this->filesystem->put($filePath ? $filePath : $this->fileName, $this->string()); |
| 92 | 92 | } |
| 93 | 93 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return string |
| 97 | 97 | */ |
| 98 | - public function string(){ |
|
| 98 | + public function string() { |
|
| 99 | 99 | return $this->fpdi->Output($this->fileName, 'S'); |
| 100 | 100 | } |
| 101 | 101 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public function setFileName($fileName){ |
|
| 107 | + public function setFileName($fileName) { |
|
| 108 | 108 | $this->fileName = $fileName; |
| 109 | 109 | return $this; |
| 110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | - public function addPDFString($string, $pages = 'all', $orientation = null){ |
|
| 119 | + public function addPDFString($string, $pages = 'all', $orientation = null) { |
|
| 120 | 120 | $filePath = storage_path('tmp/'.\Str::random(16).'.pdf'); |
| 121 | 121 | $this->filesystem->put($filePath, $string); |
| 122 | 122 | $this->tmpFiles->push($filePath); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @throws \Exception if there are now PDFs to merge |
| 158 | 158 | */ |
| 159 | - public function duplexMerge($orientation = 'P'){ |
|
| 159 | + public function duplexMerge($orientation = 'P') { |
|
| 160 | 160 | $this->merge($orientation, true); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | $fpdi = $this->fpdi; |
| 168 | 168 | $files = $this->files; |
| 169 | - foreach($files as $index => $file){ |
|
| 169 | + foreach ($files as $index => $file) { |
|
| 170 | 170 | $file['orientation'] = is_null($file['orientation']) ? $orientation : $file['orientation']; |
| 171 | 171 | $count = $fpdi->setSourceFile($file['name']); |
| 172 | - if($file['pages'] == 'all') { |
|
| 172 | + if ($file['pages'] == 'all') { |
|
| 173 | 173 | $pages = $count; |
| 174 | 174 | for ($i = 1; $i <= $count; $i++) { |
| 175 | 175 | $template = $fpdi->importPage($i); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $fpdi->AddPage($file['orientation'], [$size['width'], $size['height']]); |
| 178 | 178 | $fpdi->useTemplate($template); |
| 179 | 179 | } |
| 180 | - }else { |
|
| 180 | + } else { |
|
| 181 | 181 | $pages = count($file['pages']); |
| 182 | 182 | foreach ($file['pages'] as $page) { |
| 183 | 183 | if (!$template = $fpdi->importPage($page)) { |
@@ -200,17 +200,17 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return string |
| 202 | 202 | */ |
| 203 | - protected function convertPDFVersion($filePath){ |
|
| 203 | + protected function convertPDFVersion($filePath) { |
|
| 204 | 204 | $pdf = fopen($filePath, "r"); |
| 205 | 205 | $first_line = fgets($pdf); |
| 206 | 206 | fclose($pdf); |
| 207 | 207 | //extract version number |
| 208 | 208 | preg_match_all('!\d+!', $first_line, $matches); |
| 209 | 209 | $pdfversion = implode('.', $matches[0]); |
| 210 | - if($pdfversion > "1.4"){ |
|
| 211 | - $newFilePath = storage_path('tmp/' . \Str::random(16) . '.pdf'); |
|
| 210 | + if ($pdfversion > "1.4") { |
|
| 211 | + $newFilePath = storage_path('tmp/'.\Str::random(16).'.pdf'); |
|
| 212 | 212 | //execute shell script that converts PDF to correct version and saves it to tmp folder |
| 213 | - shell_exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'. $newFilePath . '" "' . $filePath . '"'); |
|
| 213 | + shell_exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'.$newFilePath.'" "'.$filePath.'"'); |
|
| 214 | 214 | $this->tmpFiles->push($newFilePath); |
| 215 | 215 | $filePath = $newFilePath; |
| 216 | 216 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | protected function createDirectoryForTemporaryFiles(): void |
| 227 | 227 | { |
| 228 | - if (! $this->filesystem->isDirectory(storage_path('tmp'))) { |
|
| 228 | + if (!$this->filesystem->isDirectory(storage_path('tmp'))) { |
|
| 229 | 229 | $this->filesystem->makeDirectory(storage_path('tmp')); |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | $fpdi->AddPage($file['orientation'], [$size['width'], $size['height']]); |
| 178 | 178 | $fpdi->useTemplate($template); |
| 179 | 179 | } |
| 180 | - }else { |
|
| 180 | + } else { |
|
| 181 | 181 | $pages = count($file['pages']); |
| 182 | 182 | foreach ($file['pages'] as $page) { |
| 183 | 183 | if (!$template = $fpdi->importPage($page)) { |