【发布时间】:2019-05-27 16:08:27
【问题描述】:
我想在不保存的情况下附加使用 tcpdf 库生成的 pdf。 我可以附加生成的 pdf,但它已损坏。
我搜索了很多示例,但似乎都不起作用
这是我的代码:
public function index($id) {
$viaje = Viaje::find($id);
$users = User::orderBy('id', 'asc')->get();
// usersPdf is the view that includes the downloading content
$view = \View::make('usersPdf', ['viaje' => $viaje, 'users' => $users]);
$html_content = $view->render();
// Set title in the PDF
PDF::SetTitle("List of users");
PDF::AddPage();
PDF::writeHTML($html_content, true, false, true, false, '');
//PDF::Output('userlist.pdf');
$fileatt = PDF::Output($name='yourfilename.pdf', $dest='E');
$pdf = chunk_split($fileatt);
$contactopro = Contactoviajespro::find($id);
$data = [
'link' => 'http://',
'contacto' => $contactopro->name,
];
Mail::send('emails.notificacion', $data, function($msg) use($pdf) {
$msg->from('administracion@buendialogistica.com', 'Javier');
$msg->to('xavieeee@gmail.com')->subject('Notificación');
$msg->attachData($pdf, 'orden.pdf');
});
return redirect()->route('home')
->with(['message' => 'Email enviado correctamene']);
}
【问题讨论】: