DOMPDF的自定义字体 [英] Custom Fonts for DOMPDF
本文介绍了DOMPDF的自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用DOM PDF 0.6.0 Beta2.我想在PDF文件中使用自定义字体(字体:"Segeo打印","Lucida手写",夜空中的飞机").
I'm Using DOM PDF 0.6.0 Beta 2. I want to use custom fonts (Fonts: 'Segeo Print', 'Lucida Handwriting','Airplanes in the Night Sky') in PDF file.
我遵循了在我的PHP代码中安装和使用字体的指南,该指南在此处给出 http://code.google.com/p/dompdf/wiki/CPDFUnicode
I followed the guidelines to install and use fonts in my PHP Code, which is given here http://code.google.com/p/dompdf/wiki/CPDFUnicode
但是我无法在我的PDF中获得所需字体.您可以在这篇文章中找到我的代码.请让我知道如何解决此问题.
But I'm not able to get desire fonts in my PDF. You can find my code in this post. Please Let me know how I can resolve this issue.
<?php
require_once("dompdf_config.inc.php");
$html = "<html>
<head>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<style>
*{font-size:15px;}
div.ClJ{font: nightsky;}
</style>
</head>
<body>
<div class='ClJ'>This text is in DIV Element</div><br /><br />
</body>
</html>";
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$pdf = $dompdf->output();
$dompdf->stream("dompdf_out.pdf", array("Attachment" => false));
?>
推荐答案
- 转到您的DOMPDF文件夹
- 将您的字体以.ttf(TrueType字体)或.otf(OpenType字体)复制到DOMPDF的根目录中
- 打开命令行并运行
- go to your DOMPDF folder
- copy your font's as .ttf (TrueType Font) or .otf (OpenType Font) into the DOMPDF's root
- open your command line and run
php load_font.php your_fonts_name ./your-normal.ttf ./your-bold.ttf ./your-bold-italic.ttf
font-family: your_fonts_name;
这篇关于DOMPDF的自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文