DOMPDF 设置整个页面的字体?
我在 http://dompdf.github.com/ 使用 DOMPDF
我正在努力如何设置字体整个页面。在我制作的模板中,我在 CSS 中将字体设置为 Helvetica,但当它生成 PDF 时,它默认为 Times New Roman。 当我尝试时
<script type="text/php">{literal}if ( isset($pdf) ) {
$font = Font_Metrics::get_font("helvetica", "bold");
$pdf->page_text(72, 18, "TEST!", $font, 6, array(0,0,0));}
{/literal}</script>
它会打印测试!字体中的文字。但是如何才能将其应用到整个页面呢?
谢谢
Im using DOMPDF over at http://dompdf.github.com/
I am struggling how to set the font for the entire page. In the template I have made I have the font set to Helvetica in the CSS but when it generates the PDF it defaults to Times New Roman.
When I try
<script type="text/php">{literal}if ( isset($pdf) ) {
$font = Font_Metrics::get_font("helvetica", "bold");
$pdf->page_text(72, 18, "TEST!", $font, 6, array(0,0,0));}
{/literal}</script>
It prints the TEST! text in the font. However how do I get it to apply to the whole page?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
DOMPDF 使用 CSS,因此您需要像这样设置字体系列:
但请记住,您只能使用已安装的字体。要检查可以使用哪些字体,请查看字体目录:/dompdf/lib/fonts/
要安装更多字体,请按照以下指南操作:
http://code.google.com/p/dompdf/wiki/Installation#Font_Installation
DOMPDF works with CSS so you need to set the font family like so:
BUT remember that you can only use the font that have been installed. To check which fonts you can use have a look in the fonts directory: /dompdf/lib/fonts/
To install more font follow this guide:
http://code.google.com/p/dompdf/wiki/Installation#Font_Installation
DOMPDF 支持 CSS,因此您只需在 CSS 文件中定义字体并像平常在页面上一样加载它:
DOMPDF supports CSS, so you can just define the font in your CSS file and load it like you normally would on a page:
我也有同样的问题。不知何故,DomPDF 在 CSS 中的字体系列定义方面遇到了麻烦。我将内联样式应用于顶部 div 框来解决该问题。
希望这对仍在阅读该主题的任何人都有效。
I had the same problem. Somehow DomPDF has trouble with the font-family definition in the CSS. I applied inline style to the top div box to solve the problem.
Hope this works for anyone still reading this thread.
您需要将 font-family 定义添加到 CSS 中的每个元素:
You need to add the font-family definition to every element in your CSS: