php生成pdf图片不显示不出来,php – FontAwesome图标不会在使用mPDF生成的PDF上显示...

我正在使用mPDF来生成工资单.但是,生成后,工资单中的图标不会显示.它只留下一个空白区域:

图标应显示在突出显示的位置上.

到目前为止,这就是我所做的:

我正在使用Yii2 PHP框架,这是我的动作控制器:

public function actionPdf($id)

{

$model = $this->findModel($id);

$earnings = EarningDetails::find()->where(['payslip_id' => $model->_id, 'status' => 1])->all();

$deductions = DeductionDetails::find()->where(['payslip_id' => $model->_id, 'status' => 1])->all();

$html = $this->render('view', [

'model' => $model,

'earnings' => $earnings,

'deductions' => $deductions,

]);

$mpdf = new mPDF('c','A5-L','0','',0,4,1,1,0,0);

$mpdf->allow_charset_conversion = true;

$mpdf->charset_in = 'windows-1252';

$mpdf->SetTopMargin(0);

$user_password = User::find()->where(['_id' => $model->user_id ])->one();

$password = $user_password->fname.$user_password->lname;

$mpdf->SetProtection(array(), $password, $password);

$mpdf->WriteHTML($html);

$mpdf->Output('Payslip.pdf', 'D');

exit;

}

我错过了什么吗?请告诉我.

解决方法:

除了编码问题,这可能是一些事情.首先,您需要将FontAwesome与MPDF安装集成.其次,您需要考虑如何在HTML中设置字形.

在mPDF中安装FontAwesome

从https://github.com/FortAwesome/Font-Awesome下载或克隆FontAwesome并将fonts / fontawesome-webfont.ttf复制到MPDF ttfonts /目录中.

在MDPF config_fonts.php文件中,将以下行添加到$this-> fontdata:

/* FontAwesome */

"fontawesome" => array(

'R' => "fontawesome-webfont.ttf"

),

在HTML中添加字形

您需要记住,CSS:在通常用于将FontAwesome字形添加到HTML的伪选择器之前在mPDF中不起作用.

坏:

…因为这个FontAwesome CSS规则在mPDF中不起作用:

.fa-smile-o:before {

content: "\f118";

}

好:

您可以通过在FontAwesome图标列表上单击来获取每个字形的unicode代码点,但Cheatsheet更方便.

标签:mpdf,php,pdf,icons

来源: https://codeday.me/bug/20191003/1849861.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值