Skip to content

Commit

Permalink
Merge pull request #35 from builtwellstudio/feature/laravel-vapor-sup…
Browse files Browse the repository at this point in the history
…port

Feature/laravel vapor support
  • Loading branch information
codedge authored Sep 19, 2019
2 parents 54b5024 + 9f4c325 commit 6596b7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ Route::get('/', function (Codedge\Fpdf\Fpdf\Fpdf $fpdf) {

});
```

## Use in Laravel Vapor

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:

```dotenv
FPDF_VAPOR_HEADERS=true
```
6 changes: 6 additions & 0 deletions src/Fpdf/Fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,9 @@ function Output($dest='', $name='', $isUTF8=false)
header('Content-Disposition: inline; '.$this->_httpencode('filename',$name,$isUTF8));
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
if (config('fpdf.useVaporHeaders')) {
header('X-Vapor-Base64-Encode: True');
}
}
echo $this->buffer;
break;
Expand All @@ -1014,6 +1017,9 @@ function Output($dest='', $name='', $isUTF8=false)
header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8));
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
if (config('fpdf.useVaporHeaders')) {
header('X-Vapor-Base64-Encode: True');
}
echo $this->buffer;
break;
case 'F':
Expand Down
17 changes: 14 additions & 3 deletions src/config/fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@
|
*/

'orientation' => 'P',
'unit' => 'mm',
'size' => 'A4',
'orientation' => 'P',
'unit' => 'mm',
'size' => 'A4',

/*
|--------------------------------------------------------------------------
| With Laravel Vapor hosting
|--------------------------------------------------------------------------
|
| If the application is to be hosted in the Laravel Vapor hosting platform,
| a special header needs to be attached to each download response.
|
*/
'useVaporHeaders' => env('FPDF_VAPOR_HEADERS', false),

];

0 comments on commit 6596b7b

Please sign in to comment.