1
votes

i wanted to show the font awesome icons in pdf view. I tried something like this.

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

it didn't work. So i googled and i found another question

i tried this link here

based on that i changed my code like this

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

(i changed only two fields ok). Also downloaded fontawesome file from github and copy fonts/fontawesome-webfont.ttf into your MPDF ttfonts/ directory. And In my MDPF config_fonts.php file, i added the lines mentioned in the link but it didn't work too.

1
Possible duplicate of How to use Font Awesome with MPDF?Finwe

1 Answers

4
votes

I had the same problem, follow all of the steps in the answer here How to use Font Awesome with MPDF? , the key thing for me was to add font-family:fontawesome; e.g.

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