我从这里得到:https://github.com/barryvdh/laravel-dompdf https://github.com/barryvdh/laravel-dompdf
我的控制器是这样的:
public function listdata()
{
$pdf=PDF::loadView('print_tests.test_pdf');
$pdf->setPaper('L', 'landscape');
return $pdf->stream('test_pdf.pdf');
}
我的看法是这样的:
<script type="text/php">
if ( isset($pdf) ) {
$x = 72;
$y = 18;
$text = "{PAGE_NUM} of {PAGE_COUNT}";
$font = $fontMetrics->get_font("Arial", "bold");
$size = 6;
$color = array(0,0,0);
$word_space = 0.0; // default
$char_space = 0.0; // default
$angle = 0.0; // default
$pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
}
</script>
我用这个:
"barryvdh/laravel-dompdf": "^0.7.0",
执行后,字体不是Arial,页面不显示。
我该如何解决?
try in Laravel 5.5 以上.
1.首先下载您要添加(或设置)的字体.ttf
扩大
2.像这样存储在laravel存储文件夹中storage/fonts/yourfont.ttf
3.使用CSS@字体脸你的刀刃里有规则..
4.例如创建sample.blade.php
像这样的文件
<html>
<head>
<meta http-equiv="Content-Type" content="charset=utf-8" />
<style type="text/css">
@font-face {
font-family: 'yourfont'; //you can set your custom name also here..
src: url({{ storage_path('fonts/yourfont.ttf') }}) format('truetype');
font-weight: 400; // use the matching font-weight here ( 100, 200, 300, 400, etc).
font-style: normal; // use the matching font-style here
}
body{
font-family: "yourfont", //set your font name u can set custom font name also which u set in @font-face css rule
</style>
</head>
<body>
Check your font is working or not...
</body>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)