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 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥15 this signal is connected to multiple drivers怎么解决
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus