mPDF会显示字体真棒图标吗?

时间:2015-10-29 09:00:18

标签: yii2 font-awesome mpdf

我想在pdf视图中显示字体真棒图标。我试过这样的事情。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

<table class="table table-hover table-bordered">
            <thead>
              <tr>
                <th>#</th>  
                <th>Account</th>
                <th>Debit</th>
                <th>Credit</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>1</td>
                <td><?php echo $model->account; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->debit; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
              </tr>
              <tr>
                <td>2</td>
                <td><?php echo $model->against; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->debit; ?></td>
              </tr>
              <tr>
                <td colspan="2"></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
              </tr>
            </tbody>
        </table>

它没有用。所以我用谷歌搜索,我发现了另一个问题

i tried this link here

基于我改变了我的代码

<table class="table table-hover table-bordered">
            <thead>
              <tr>
                <th>#</th>  
                <th>Account</th>
                <th>Debit</th>
                <th>Credit</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>1</td>
                <td><?php echo $model->account; ?></td>
                <td><i class="fa"> &#xf156;</i> <?php echo $model->debit; ?></td>
                <td><i class="fa"> &#xf156;</i> <?php echo $model->credit; ?></td>
              </tr>
              <tr>
                <td>2</td>
                <td><?php echo $model->against; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->debit; ?></td>
              </tr>
              <tr>
                <td colspan="2"></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
                <td><i class="fa fa-inr"></i> <?php echo $model->credit; ?></td>
              </tr>
            </tbody>
        </table>

(我只改变了两个字段)。还从github下载了fontawesome文件,并将fonts fonts / fontawesome-webfont.ttf复制到您的MPDF ttfonts /目录中。 在我的MDPF config_fonts.php文件中,我添加了链接中提到的行,但它也没有用。

1 个答案:

答案 0 :(得分:2)

我有同样的问题,按照这里答案中的所有步骤How to use Font Awesome with MPDF?,对我来说关键是添加font-family:fontawesome;例如

<i style="font-family:fontawesome;" class="fa">&#xf118;</i>