我正在尝试使用TCPDF创建PDF文件。但是当我试图在HTML中插入内联CSS时,它显示了一个空白页面!下面是我的HTML的几行代码:
pdf->AddPage();
// set font
$pdf->SetFont('helvetica', 'B', 20);
$pdf->Write(0, 'Example of HTML Justification', '', 0, 'L', true, 0, false, false, 0);
// create some HTML content
$html = '
<div id="wrapper" style="width:900px;height:auto;margin:0 auto;">
<div id="header" style="width:900px;height:180px;border-bottom:2px solid #5a5a5a;">
<div id="img" style="width:174px;height:87px;position:relative;top:10px;left:350px;"><img src="Untitled Document_files/logoticket.png" /></div>
<div id="text" style="width:250px;position:relative;left:315px;top:20px;font-family:Arial, Helvetica, sans-serif;font-weight:bold;font-size:14px;">E-TICKET/RESERVATION VOUCHER</div>
<div id="text2" style="width:200px;position:relative;left:345px;top:40px;font-family:Arial, Helvetica, sans-serif;
font-weight:bold;font-size:12px;">Visit - www.bookings.7sisters.in</div>
</div>
<div id="mainContent">
<div id="icon" style="width:600px;
height:37px;
position:relative;
left:190px;
top:20px;">
<img src="Untitled D.....
等。
我将代码插入到TCPDF example 39中。但输出结果只有TCPDF徽标和一行"Example of HTML“。理由是什么呢?或者它不支持内联CSS?
发布于 2014-10-06 20:14:00
在我的例子中,服务器在双引号中添加了斜杠- tcpdf在没有警告的情况下忽略了style等属性。所以我用stripslashes函数删除了斜杠
发布于 2015-11-04 19:03:26
好吧,我找到了一个变通的方法:
<h1>Heading<small>Text(is smaller than heading.)</small></h1>
希望这对某些人有帮助。
发布于 2012-07-13 16:42:38
我使用了您提供的代码,并使用内联CSS将'Visit www.bookings.7sisters.in‘的颜色更改为红色。
请参阅我在https://www.box.com/s/520e9e1f4976802696ec上的示例输出
https://stackoverflow.com/questions/11395171
复制相似问题