如何在mpdf中添加多个css文件 [英] how to add multiple css file in mpdf

查看:910
本文介绍了如何在mpdf中添加多个css文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用mpdf将html页面转换为pdf格式.问题是我无法将多个CSS应用于pdf 文件..这是我的php

I am trying to convert my html page into pdf format using mpdf. problem is that i am unable to apply more than one css to pdf file.. here is my code of php

<?php
           $html =file_get_contents('mpdf/test.html');
            include("../mpdf.php");
            $mpdf=new mPDF(); 
           $mpdf->SetDisplayMode('fullpage','two');
            // LOAD a stylesheet 1
            $stylesheet = file_get_contents('assets/css/main.css');
            $mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text
          // LOAD a stylesheet 2
            $stylesheetextra = file_get_contents('assets/css/test.css');
            $mpdf->WriteHTML($stylesheetextra ,1);  // The parameter 1 tells that this is css/style only and no body/html/text
            $mpdf->WriteHTML($html,2);
          $mpdf->Output();

            exit;
            ?>

它给出的输出不是test.css附带的. main.css正确地应用于pdf文件,但test.css不适用于.please 帮我? 先谢谢你

Output it gives doesn't come with test.css . main.css is applying properly to pdf file but test.css doesn't applying.please help me? thanking you in advance

推荐答案

您只需将CSS内容存储在一个变量中即可,如下所示:

You can do it just storing the CSS content in one variable, like this:

$stylesheet  = '';
$stylesheet .= file_get_contents('css/bootstrap.min.css');
$stylesheet .= file_get_contents('css/style.css');
$stylesheet .= file_get_contents('css/impressao_ctr.css');

这篇关于如何在mpdf中添加多个css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆