mPDF在CodeIgniter的页面方向不会做横向 [英] mPDF in CodeIgniter page orientation won't do landscape

查看:899
本文介绍了mPDF在CodeIgniter的页面方向不会做横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CodeIgniter中使用mPDF。

I'm using mPDF in CodeIgniter.

这里是我的lib(pdf.php)

here is my lib (pdf.php)

class pdf {
    function pdf()
    {
        $CI = & get_instance();
        log_message('Debug', 'mPDF class is loaded.');
    }

    function load($param=NULL)
    {
        include_once APPPATH.'/third_party/mpdf/mpdf.php';
        if ($params == NULL)
        {
            $param = '"en-GB-x","A4","","",10,10,10,10,6,3,"L"';
        }
        return new mPDF($param);
    }
}

这是我的控制器

$filename = 'qwerty';
//...
// As PDF creation takes a bit of memory, we're saving the created file in /downloads/reports/
$pdfFilePath = FCPATH."reports\\"   . $filename . ".pdf";
//$data['page_title'] = 'Hello world'; // pass data to the view
for($i=0;$i>=0;$i++)
{
    if(file_exists($pdfFilePath) == TRUE)
    {
        $pdfFilePath = FCPATH."reports\\"   . $filename . $i . ".pdf";
    } else {
        break 1;
    }
}
ini_set('memory_limit','32M');
$html = $this->load->view('certificate/certificate', $isi,TRUE); // render the view into HTML
$this->load->library('pdf');
$pdf = $this->pdf->load($param);
\$pdf = $this->pdf->load();
$pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822));
$pdf->WriteHTML($html);
$pdf->Output($pdfFilePath, 'F'); // save to file because we can

即使有配置( $ param ),结果仍然给我的肖像文件,因此,CSS里面是很搞笑。

even with that config ($param), the result still give me portrait file, thus, CSS inside is pretty messed up.

我应该怎么办?

推荐答案

我叫Rhonald Brito ,这是我第一次在这里,我有大约1年使用Codeigniter和MPDF,在这里我让你知道我的代码:

My name is Rhonald Brito, it is my first time here, I have about 1 year using Codeigniter and MPDF, here I let you know my code:

public function Make_PDF($view, $data, $file_name) {
    $html = $this->load->view($view, $data, true);
    $this->mpdf = new mPDF();
    $this->stylesheet = file_get_contents('css/style.css');
    $this->mpdf->AddPage('L', // L - landscape, P - portrait
            '', '', '', '',
            30, // margin_left
            30, // margin right
            30, // margin top
            30, // margin bottom
            18, // margin header
            12); // margin footer
    $this->mpdf->WriteHTML($html);
    //$this->mpdf->Output($file_name, 'D'); // download force
    $this->mpdf->Output($file_name, 'I'); // view in the explorer

    // for more information rhonalejandro@gmail.com
}

这篇关于mPDF在CodeIgniter的页面方向不会做横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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