composer require h4cc/wkhtmltopdf-amd64 0.12.x
composer require barryvdh/laravel-snappy
php artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider"
config/snappy.php が生成されます
binary を以下のように変更します。
'pdf' => [
'enabled' => true,
'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),
'timeout' => false,
'options' => [],
'env' => [],
],
web.php
Route::get('/hello', function () {
$pdf = \PDF::loadHTML('<h1>日本語の表示テストです</h1><style>h1{color:red;}</style>');
return $pdf->setOption('encoding', 'utf-8')->inline();
});
/hello でアクセスします。