php - 将css添加到pdf
问题描述
我需要生成一个 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>
样式.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中工作的方法都会很棒。
解决方案
推荐阅读
- java - Spring State Machine - 使用 StateMachineModelConfigurer 时定义 machineId
- android - 实现 MVVM LiveData RxJava Dagger Databinding 的正确结构?
- shell - 执行 shell 命令直到成功
- visual-studio - 如何在 C++ 中创建关于 MFC 或 MFC ActiveX 控件的 COM 对象?
- awk - 在找到包含模式的行后,我想使用 sed 或 awk 附加符合条件的多行
- postgresql - 如何在 postgresql 中创建函数以返回列值并更新表以及 x 锁定表?
- reactjs - 从 JSON 响应中获取 react js 中的数组数组
- influxdb - 在具有 HR 层次结构的用例上使用 influxdb
- asp.net-mvc - kendo ui mvc 编辑器“大于或等于”iTextSharp
- php - 我想知道是否有办法在android studio和使用mysql数据库的用户中显示当前登录的特定数据