Skip to content

Commit 6596b7b

Browse files
authored
Merge pull request #35 from builtwellstudio/feature/laravel-vapor-support
Feature/laravel vapor support
2 parents 54b5024 + 9f4c325 commit 6596b7b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,11 @@ Route::get('/', function (Codedge\Fpdf\Fpdf\Fpdf $fpdf) {
8989

9090
});
9191
```
92+
93+
## Use in Laravel Vapor
94+
95+
If you are wanting to use the [Laravel Vapor](https://vapor.laravel.com) platform to host your application, [a special/specific header](https://docs.vapor.build/1.0/projects/development.html#binary-responses) will need to be attached to each response that FPDF returns to your browser. To enable the use of this header, add the following environment variable to the Vapor environment file:
96+
97+
```dotenv
98+
FPDF_VAPOR_HEADERS=true
99+
```

src/Fpdf/Fpdf.php

+6
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,9 @@ function Output($dest='', $name='', $isUTF8=false)
10041004
header('Content-Disposition: inline; '.$this->_httpencode('filename',$name,$isUTF8));
10051005
header('Cache-Control: private, max-age=0, must-revalidate');
10061006
header('Pragma: public');
1007+
if (config('fpdf.useVaporHeaders')) {
1008+
header('X-Vapor-Base64-Encode: True');
1009+
}
10071010
}
10081011
echo $this->buffer;
10091012
break;
@@ -1014,6 +1017,9 @@ function Output($dest='', $name='', $isUTF8=false)
10141017
header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8));
10151018
header('Cache-Control: private, max-age=0, must-revalidate');
10161019
header('Pragma: public');
1020+
if (config('fpdf.useVaporHeaders')) {
1021+
header('X-Vapor-Base64-Encode: True');
1022+
}
10171023
echo $this->buffer;
10181024
break;
10191025
case 'F':

src/config/fpdf.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@
1111
|
1212
*/
1313

14-
'orientation' => 'P',
15-
'unit' => 'mm',
16-
'size' => 'A4',
14+
'orientation' => 'P',
15+
'unit' => 'mm',
16+
'size' => 'A4',
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| With Laravel Vapor hosting
21+
|--------------------------------------------------------------------------
22+
|
23+
| If the application is to be hosted in the Laravel Vapor hosting platform,
24+
| a special header needs to be attached to each download response.
25+
|
26+
*/
27+
'useVaporHeaders' => env('FPDF_VAPOR_HEADERS', false),
1728

1829
];

0 commit comments

Comments
 (0)