ViewBlade
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style type="text/css" media="all">
.HVMC{font-family: "Herr Von Muellerhoff", cursive !important}
.MDHC{font-family: "Mr De Haviland", cursive !important;}
.ABC{font-family: "Alex Brush", cursive !important;}
.CCC{font-family: "Cedarville Cursive", cursive !important;}
.LBAC{font-family: "La Belle Aurore", cursive !important;}
.img-list {
background-size: contain;
background-position: center;
background-repeat: no-repeat;
position: relative;
width: 100%;
height: 1310px;
}
html,body
{
height: 100%;
margin: 0;
background-color:lightgray;
}
</style>
</head>
<div id="maindiv">
@foreach ($proposalfromTemplate as $proposal)
{!! $proposal->html !!}
@endforeach
<div>
</html>控制器
PDF::setOptions(['isRemoteEnabled' => TRUE, 'enable_javascript' => TRUE]);
$pdf = PDF::loadView('pdfview');
return $pdf->download($pid . '.pdf');当我返回View时,它工作得很好,但是当我返回$pdf->download()时,它不包括CSS,在Blade文件中,给定的数据是我从存储中获得的文本文件,所以我不能在上面添加CSS
谢谢
发布于 2020-04-06 19:45:40
在加载到DOMPDF之前,必须首先呈现HTML
public function generateXYZ()
{
PDF::setOptions(['isRemoteEnabled' => TRUE, 'enable_javascript' => TRUE]);
$dompdf = new Dompdf();
$html = view('your.view.path')->render();
$dompdf->loadHtml($html);
$dompdf->render();
return $pdf->download('card.pdf');
}https://stackoverflow.com/questions/61058871
复制相似问题