我正在使用Barryvdh\DomPDF\在我的laravel项目中生成pdf文件,这是我的控制器:
<?php
// Our Controller
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// This is important to add here.
use Barryvdh\DomPDF\Facade as PDF;
class CustomerController extends Controller
{
public function printPDF()
{
// This $data array will be passed to our PDF blade
$data = [
'title' => 'First PDF for Medium',
'heading' => 'Hello from 99Points.info',
'content' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.'
];
$pdf = PDF::loadView('pdf_view', $data);
return $pdf->download('medium.pdf');
}
}如何在浏览器中预览我的pdf结果而不是下载?
谢谢
发布于 2020-02-24 23:32:22
将返回更改为包含文件和标头上的文件MIME类型的响应
$pdf = PDF::loadView('pdf_view', $data)->download('medium.pdf');
return response($pdf, 200)
->header('Content-Type', File::mimeType($pdf));https://stackoverflow.com/questions/60377727
复制相似问题