如何在mPDF中使用引导程序? [英] How to use bootstrap in mPDF?

查看:55
本文介绍了如何在mPDF中使用引导程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用mpdf从html生成我的pdf.到目前为止,使用我当前传入的html,我能够生成包含页眉和页脚的一页pdf.但是,如果有一页以上,则我的页脚会一直到第二页的底部.有没有一种方法可以为每个页面添加页眉和页脚?

I am currently using mpdf to generate my pdfs from html. So far with my current html that I am passing in, I am able to generate a one page pdf with a header and footer. However, if there is more than one page, my footer goes all the way to the bottom of the second page. Is there a way to add a header and footer for each page?

我已经尝试过$ pdf-> setHTMLHeader了,但是它似乎并没有把我的css文件带进去,并且它留下了x应该在我的徽标位置.我怎样才能做到这一点?我曾尝试在各个地方搜索,但似乎找不到解决方法.

I have tried $pdf->setHTMLHeader but it doesn't seem to take my css files in and it leaves an x where my logo is supposed to be. How can I do this? I have tried searching in various places but I can't seem to find a solution.

这是我的代码

public function generate_pdf($account_id,$transaction_id,$html){
        $document_folder = $_SERVER['DOCUMENT_ROOT']."/".DOCUMENT_FOLDER."/".PAYMENT_RECEIPTS."/".date("Y");
        $extension = ".pdf";
        if(!is_dir($document_folder)){
            mkdir($document_folder, 0777,true);
        }
        $file_name = md5($transaction_id.$account_id);
        $this->load->library('m_pdf');
        $pdf = $this->m_pdf->load();
        $header = $this->load->view('pdfs/header','',true);
        $footer = $this->load->view('pdfs/footer','',true);
        $pdf->setHTMLHeader($header);
        $pdf->setHTMLFooter($footer);
        $pdf->AddPage('', // L - landscape, P - portrait 
            '', '', '', '',
            5, // margin_left
            5, // margin right
           60, // margin top
           30, // margin bottom
            0, // margin header
            0
        ); // margin footer
        $pdf->WriteHTML(base64_decode($html));
        $pdf->Output($document_folder."/".$file_name.$extension, "F");
        $result = array(
            'file_name'=>$file_name,
            'file_location'=>$document_folder."/".$file_name.$extension,
            'file_link'=>DOCUMENT_LOCATION."/".DOCUMENT_FOLDER."/".PAYMENT_RECEIPTS."/".date("Y")."/".$file_name.$extension
        );
        return $result;
        exit;

    }

还有,有没有办法知道PDF的输出是否成功?当前$ pdf->输出仅返回"

Also, is there a way to know if the output of the PDF was successful? Currently $pdf->Output only returns ""

谢谢

推荐答案

mPDF不完全支持Bootstrap样式.一种选择是其他选择,例如基于无头铬的 wkhtmltopdf .

mPDF does not support Bootstrap styles entirely. An option would be some alternative such as headless-chrome based wkhtmltopdf.

一位mpdf的人告诉我,bootstrap不支持mpdf内的即用型功能,您必须使用一些自定义样式. Github链接

one of the mpdf guy told that bootstrap not supported out-of-the-box inside mpdf and you have to use some custom style. Github link

希望这将有助于解决您的问题.

Hope this will help to solve your problem.

这篇关于如何在mPDF中使用引导程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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