无法在输出中获得预期的字体

时间:2015-10-16 10:23:35

标签: php html css fonts themes

我将证书主题作为html存储在数据库中。我的模板字体正在除草。主题在浏览器输出中看起来不错。但是当我试图从数据库中获取并在pdf中显示时,正常的字体输出即将到来。我没有得到我错的地方。

用于在数据库中存储模板的代码:

 <?php
ob_start();
?>
<head>
    <link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
    <style type="text/css">
        h1{
            font-family: 'weddingtext_btregular';
            font-weight:200;
            font-size:25px;
        }
        h2{
            font-family: 'weddingtext_btregular';
            font-weight:300;
            font-size:30px;
        }
        .span {
            font-family: cursive;
        }
        .span1 {
            padding-left:20%;
        }
        .span2 {
            padding-left:50%;
        }
    </style>
</head>
<?php
// normal output
echo '<img alt="Nimhans Logo" src="img/1.png" width="100%" ; />
      <h1>SL NO. <span class="span">##SLNO##</span></h1>
          <div class="body">
           <center><h1>Institute of National Importance</h1></center>
            <center><h1>Bengaluru - 560 029</h1></center>
              <br>
           <center><h1>Certifies that</h1></center>
           <br>
           <center><h2>##NAME##</h2></center>
           <br>
        <center><h1>has been dulg admitted to the Degreeof</h1>                  </center>

          <br>
           <center><h2>##COURSE##</h2></center>
        <br>
          <center><h1>in recognition of the fulfilment of requirements</h1></center>
          <center><h1>under the statutes of the institute</h1></center>
           <center><h1>##YEAR##</h1></center>
         <br>
           <center><h2>##CLASS##</h2></center>
            <br>
               <h1>##QRCODE## <span class="span1"> Biben under the seal of the Institute</span></h1>
             <br>
                <br>
            <h1>Date:29th November, 2015 <span class="span2"> Director/Dice Chancellor</span></h1>
             ';

// store buffer to variable and turn output buffering offer
$html = ob_get_clean();

echo $html;

include 'configaration/config.php';

$html = mysql_real_escape_string($html);

$dpt_name = "Nursing";
$qry = "INSERT INTO certificate (cert_data,department)
          VALUES ('$html','$dpt_name')";

if (!mysql_query($qry)) {

    die('Error: ' . mysql_error());
}
?>

从数据库中提取模板并以PDF格式显示。

这是我的代码:

$qry1 = "SELECT * FROM certificate WHERE department = '" . $dpt_name . "'";
$result1 = mysql_query($qry1);

if ($result1) {
    while ($row = mysql_fetch_array($result1)) {

        $template_data = $row["cert_data"];
    }
}
$template_data = str_replace('##NAME##', $std_name, $template_data);
$template_data = str_replace('##FROM##', $join_date, $template_data);
$template_data = str_replace('##NAME##', $std_name, $template_data);
$template_data = str_replace('##TO##', $to, $template_data);

ob_end_clean();

include 'MPDF57/mpdf.php';

$mpdf = error_reporting(E_STRICT);
$mpdf = new mPDF('win-1252', 'A4', '', '', 15, 10, 16, 10, 10, 10);
$mpdf->Bookmark('Start of the document');
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($template_data);
$mpdf->Output();

exit();

浏览器输出:

BROWSER OUTPUT

pdf输出图片: PDF out put

请帮助我错误的地方。对我不好的英语抱歉。

1 个答案:

答案 0 :(得分:0)

您正在使用css中的字体。但你应该在mpdf中使用。

config_fonts.php // you should add in this page and
然后它会反映出来。并在ttfonts目录中添加字体文件。

 $this->fontdata = array(
    "name of your font" => array(
        'T' => "Neutra_Display_Thin_Alt.ttf",// path to your font
     )
 ); 

有关详情,请参阅此link