无法在横向 mPDF 中创建字符串 PDF 法律页面 v7.X

Can't Create String PDF Legal page in Landscape mPDF v7.X

无法在横向 mPDF 中创建字符串 PDF 法律页面 v7.X

省略旧版本说这个例子:

$mpdf=new mPDF('utf-8', 'A4-L');

$mpdf=new mPDF('','', 0, '', 15, 15, 16, 16, 9, 9, 'L');

新版本7.X

$myMpdf = new Mpdf([
    'mode' => 'utf-8',
    'format' => 'A4-L',
    'orientation' => 'L'
]

我正在尝试这个构造:

function GenPDF2List($P) {
        try {
            $FNAME=$P['FNAME']; #filename.pdf
            $FSIZE=$P['FSIZE']; #Legal
            $FVIEW=$P['FVIEW']; #L
            $mpdf = new \Mpdf\Mpdf([ 
                'mode' => 'utf-8', 
                'format' => $FSIZE, 
                'orientation' => $FVIEW, 
                'margin_left'=> 5, 
                'margin_right'=> 5, 
                'margin_top'=> 5, 
                'margin_bottom'=> 5, 
                'margin_header'=> 5, 
                'margin_footer'=> 5 
            ]);
            $mpdf->SetAuthor($P['AUTOR']);
            $mpdf->SetTitle($P['TITTLE']);
            $mpdf->WriteHTML($P['CONT']);
            $P['DOC'] = $mpdf->Output($FNAME,\Mpdf\Output\Destination::STRING_RETURN);
            return $P;
        } catch (\Mpdf\MpdfException $e) {
            echo $e;
        }
    }

不要工作我明白了:

example

我没有收到任何错误、警告或 ETc... 使用另一个 html 代码进行测试...

function GenPDF2List($P) {
            try {
                $FNAME=$P['FNAME']; #filename.pdf
                $FSIZE=$P['FSIZE']; #Legal
                $FVIEW=$P['FVIEW']; #L
                $mpdf = new \Mpdf\Mpdf([ 
                    'mode' => 'utf-8', 
                    'format' => $FSIZE, 
                    'orientation' => $FVIEW, 
                    'margin_left'=> 5, 
                    'margin_right'=> 5, 
                    'margin_top'=> 5, 
                    'margin_bottom'=> 5, 
                    'margin_header'=> 5, 
                    'margin_footer'=> 5 
                ]);
                $mpdf->SetAuthor($P['AUTOR']);
                $mpdf->SetTitle($P['TITTLE']);
                $mpdf->WriteHTML('<h1>hello world</h1>');
                $P['DOC'] = $mpdf->Output($FNAME,\Mpdf\Output\Destination::STRING_RETURN);
                return $P;
            } catch (\Mpdf\MpdfException $e) {
                echo $e;
            }
        }

Example 2

HTML Chrome 中的 PDF 查看器:

$info        = '<object data="data:application/pdf;base64,' . 
                base64_encode($P['DOC']) 
                . '" type="application/pdf" height="600px" width="100%"></object>';

方向参数目前对我的设置无效。 不知道是error/bug还是什么

我用以下方法解决这个问题:

function GenPDF2List($P) {
            try {
                $FNAME=$P['FNAME']; #filename.pdf
                $FSIZE=$P['FSIZE']; #Legal
                $FVIEW=$P['FVIEW']; #L
                $mpdf = new \Mpdf\Mpdf([ 
                    'mode' => 'utf-8', 
                    'format' => $FSIZE, 
                    'orientation' => $FVIEW, 
                    'margin_left'=> 5, 
                    'margin_right'=> 5, 
                    'margin_top'=> 5, 
                    'margin_bottom'=> 5, 
                    'margin_header'=> 5, 
                    'margin_footer'=> 5 
                ]);
                $mpdf->AddPage('L');
                $mpdf->SetAuthor($P['AUTOR']);
                $mpdf->SetTitle($P['TITTLE']);
                $mpdf->WriteHTML('<h1>hello world</h1>');
                $P['DOC'] = $mpdf->Output($FNAME,\Mpdf\Output\Destination::STRING_RETURN);
                return $P;
            } catch (\Mpdf\MpdfException $e) {
                echo $e;
            }
        }