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