如何解决DOMPDF Symfony + Vuejs
我正在尝试使用 vuejs 和 symfony 下载文件。
现在我正在使用 dompdf。
这是我的代码:
$dompdf = new Dompdf();
$html = $this->renderView('invoices/report.html.twig',[
'protocol' => $protocol,'theme' => $theme,'audit' => [
'date' => '','updatedBy' => [
'name' => '',],'program' => $program,'customer' => $customer,'articles' => $articles,'invoices' => $invoices,]
);
$dompdf->loadHtml($html);
$dompdf->setPaper('A4','portrait');
$dompdf->render();
$response = new Response($dompdf->output());
// It will be called downloaded.pdf
return $response;
和 vuejs
.then((response) => response.text())
.then((data) => {
let blob = new Blob([data],{ type: 'application/pdf' })
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = 'test.pdf'
link.click()
});
我总是得到一个空白的 PDF
有人可以帮忙吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。