duanjunao9348 2015-10-16 10:23
浏览 66
已采纳

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

I am storing my certificate theme in database as a html. my template fonts are weeding fornt. themes looks nice in browser out put . but when i tried to fetch from databse and disply in pdf the normal font output is coming . i am not getting where i am wrong .

code for storing template in databse :

 <?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());
}
?>

fetching template from databse and displaying in PDF.

here is my code :

$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 :

BROWSER OUTPUT

pdf output images : PDF out put

PLEASE HELP ME WHERE I AM WRONG . SORRY FOR MY BAD ENGLISH .

  • 写回答

1条回答 默认 最新

  • dsyrdwdbo47282676 2015-10-16 11:14
    关注

    You are using font in css. but you should use in mpdf.

    config_fonts.php // you should add in this page and
    

    then it will reflect. And add font files in your ttfonts directory.

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

    see this link for more information.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python