TCPDF 中的 WriteHTML / 欧元符号无法正确显示
我已经阅读了所有其他线程并尝试了所有内容。这就是我所在的位置:
构造函数:
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
在执行 writeHTML 之前,我在缓冲区上运行 utf8_encode。
我已经尝试了确切的参考,粘贴原始字符,将构造函数更改为 UTF8 似乎在我的文档周围添加了带有重音符号的随机 A...
目前不确定。
我的另一个问题是使用 writeHTML 进行样式设置...我有表格,因为 TCPDF 的 writeHTML 函数似乎并不真正包含盒模型。例如,我有这样的代码:
<td valign="top" align="left" style="padding:0;">
<table width="193" cellpadding="0" cellspacing="0">
<tr><td style="text-align:left;" align="left" valign="top" width="193" style="width:193px;">
<?php
$imageCount = count($theImages);
for($i = 1; $i <= $imageCount; $i++)
{
$f = SITE_ROOT . '/i/properties/'. $p->id .'/l_'. $theImages[$i]['name'];
$u = '/i/properties/'. $p->id .'/l_'. $theImages[$i]['name'];
if(file_exists($f)) {
echo '<img src="'.$u.'" width="193" /></td></tr><tr><td>';
}
}
?></td></tr></table>
</td>
只是一个摘录,第一张图像与 eft 对齐,即使它都是 193?到目前为止,我已经花了一两天的时间在这上面,如果有人有任何替代方案来创建样式精美的属性数据表,与内容管理的 php 网站集成,请告诉我! :) 否则我的问题的任何答案都会很棒。
I've read all the other threads and tried everything. Here's where I'm at:
Constructor:
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
I'm running utf8_encode on the buffer before doing writeHTML.
I have tried € the exact reference, pasting the character raw, changing the constructor to UTF8 seems to add random A's with accents on around my document...
Not sure at this point.
My other question is styling using writeHTML... I have tables because TCPDF's writeHTML function doesn't really include the box model seemingly. For instance I have this code:
<td valign="top" align="left" style="padding:0;">
<table width="193" cellpadding="0" cellspacing="0">
<tr><td style="text-align:left;" align="left" valign="top" width="193" style="width:193px;">
<?php
$imageCount = count($theImages);
for($i = 1; $i <= $imageCount; $i++)
{
$f = SITE_ROOT . '/i/properties/'. $p->id .'/l_'. $theImages[$i]['name'];
$u = '/i/properties/'. $p->id .'/l_'. $theImages[$i]['name'];
if(file_exists($f)) {
echo '<img src="'.$u.'" width="193" /></td></tr><tr><td>';
}
}
?></td></tr></table>
</td>
Just an extract, and the first image is aligned to the eft, even though it's all 193? I have spent a fair day or two on this so far, and if anyone has any alternatives for creating nicely styled property data sheets, integrating with a content managed php site, please let me know! :) Otherwise any answers to my problems would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用编码
ISO-8859-1
创建 PDF,该编码的明显缺点是没有欧元符号。您可以ISO-8859-15
(与ISO-8859-1
兼容,但具有欧元符号)或
UTF-8
并确保所有文本都已正确编码为UTF-8
,然后再将其发送到 PDF 生成器You create your PDF using the encoding
ISO-8859-1
which has the distinct disadvantage of not having the Euro sign. You can eitherISO-8859-15
(which is compatible withISO-8859-1
but has the Euro sign)or
UTF-8
and make sure, all your text ist correctly encoded toUTF-8
before throwing it at the PDF generator