【发布时间】:2018-04-11 02:59:04
【问题描述】:
我过去曾尝试过 FPDF 和 TCPDF...我还检查了在无头模式下运行 chrome 以生成 PDF 的选项...我想知道是否有人对最好的方法有任何经验将这样的内容转换为 PDF。我问,因为它使用的 CSS 比我以前的 PDF 项目更复杂。有什么东西可以很好地转换以下内容吗?
编辑: 感谢指向 mPDF 的指针...我已经使用下面的代码成功生成了 PDF。 但是,CSS 的一部分应该包含一个小三角形,这使得该框看起来像一个对话气泡......因为不支持 BEFORE 和 AFTER,所以不会出现。
有人知道如何在不使用之前和之后的情况下复制下面的效果吗?我将其应用于<p> 标签。
<style>
.triangle-border1 {
position:relative;
padding:15px;
margin:1em 0 1em;
border:5px solid #F7827B;
color:#333;
background:#fff;
/* css3 */
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
.triangle-border1:before {
content:'';
position:absolute;
bottom:-20px; /* value = - border-top-width - border-bottom-width */
left:40px; /* controls horizontal position */
border-width:20px 20px 0;
border-style:solid;
border-color:#F7827B transparent;
/* reduce the damage in FF3.0 */
display:block;
width:0;
}
.triangle-border1:after {
content:'';
position:absolute;
bottom:-13px; /* value = - border-top-width - border-bottom-width */
left:47px; /* value = (:before left) + (:before border-left) - (:after border-left) */
border-width:13px 13px 0;
border-style:solid;
border-color:#fff transparent;
/* reduce the damage in FF3.0 */
display:block;
width:0;
}
</style>
但我无法使用之前和之后,因为我通过不支持它的 mPDF 输出到 PDF。
【问题讨论】:
-
我使用mPDF。它有很多功能。看一看。您也可以添加样式表,这样 CSS 就不必内联了