我需要生成一个pdf,名称放在特定位置的图像顶部。我编写了一个可用的HTML代码,但mpdf无法加载样式表,并且名称将打印在图像下方。
这是我的php代码:
<?php
$html = file_get_contents('index12.html');
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html,2);
$mpdf->Output();
index12.html
<!-- <link rel="stylesheet" href="style.css"> -->
<div class="image">
<img src="yugmak.jpg" alt="" />
<h2>Kung Fu Panda</h2>
</div>
的style.css
@font-face {
font-family: "Montez";
src: url("Montez.ttf");
}
.image {
position: relative;
width: 100%; /* for IE 6 */
}
h2 {
position: absolute;
font-family: "Montez";
font-size: 250px;
top: 2100px;
padding-left: 1050px;
width: 2000px;
}
任何使css在pdf中工作的方法都会很棒。