Glyphicon / FontAwesome not showing in mPDF HTML export

China☆狼群 提交于 2019-12-08 11:25:48

问题


I am using mPDF and when exporting HTML content to pdf, all contents are showing perfectly. But glyphicons are not showing. So I add font awesome style code in /application/third_party/mpdf/config_fonts.php as follows

"fontawesome" => array(  
    'R' => "fontawesome-webfont.ttf"  
 ),

And changed the code in view page

<i class="fa fa-phone"></i> 

to

<span style="font-family: fontawesome;">&#xf095;</span>  

After doing that I got fontawesome inside pdf. Is there any way to use

<i class="fa fa-phone"></i>   

to generate icon inside pdf?


回答1:


You are mixing together Font Awesome and Glyphicons, which are different projects.

Anyway, both use ::before CSS pseudoclass to display element content with the actual icon and this pseudoclass is not supported in mPDF.

That means there is no way to display those icons without pre-processing the HTML (adding content to i with fa class) or inserting characters directly as you have shown in your example.

<span style="font-family: fontawesome;">&#xf095;</span>  


来源:https://stackoverflow.com/questions/49549328/glyphicon-fontawesome-not-showing-in-mpdf-html-export

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!