如果页面为空,Mpdf 不应显示该页面
Mpdf should not display page if it's empty
我使用 Mpdf 创建了一个 3 页的 pdf 文档,第 1 页和第 3 页始终包含数据,而第 2 页则取决于它。如果其中的数据为空,我不想显示第二页
下面是代码结构
html = 'some html code to be printed on pdf'; //1st Page
$result[] = $html;
html2 = 'some html code to be printed on pdf'; //2nd Page (It might be empty)
$result[] = $html2;
// if($pdfdetails['Test'] != "")
// {
// $htmlnewpage = $html2;
// }else{
// $htmlnewpage = '';
// }
$result[] = $html2;
// In the second pdf, if the "if" condition is true then only the second page
has to be displayed or else 3rd page should display (next page),
but it isn't working for me.
html3 = 'some html code to be printed on pdf'; //3rd Page
$result[] = $html3;
$mpdf = new mPDF("en-GB-x", [336, 190], "", "",30,30,30,30,6,3);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$i=1;
$cnt = count($result);
foreach($result as $html){
$mpdf->AddPage("", [336, 190], "", "",10,10,10,4,1,0,'L');
$mpdf->WriteHTML($html,2);
if($i < $cnt) {
//$mpdf->AddPage('L');
}
$i++;
}
$mpdf->showImageErrors = true;
$mpdf->Output(test'.pdf', 'I');
我解决了
if($pdfdetails['Test'] != "")
{
$result[] = $html2;
}elseif($pdfdetails['Test'] == ""){
}
$result[] = $html3;
我使用 Mpdf 创建了一个 3 页的 pdf 文档,第 1 页和第 3 页始终包含数据,而第 2 页则取决于它。如果其中的数据为空,我不想显示第二页
下面是代码结构
html = 'some html code to be printed on pdf'; //1st Page
$result[] = $html;
html2 = 'some html code to be printed on pdf'; //2nd Page (It might be empty)
$result[] = $html2;
// if($pdfdetails['Test'] != "")
// {
// $htmlnewpage = $html2;
// }else{
// $htmlnewpage = '';
// }
$result[] = $html2;
// In the second pdf, if the "if" condition is true then only the second page
has to be displayed or else 3rd page should display (next page),
but it isn't working for me.
html3 = 'some html code to be printed on pdf'; //3rd Page
$result[] = $html3;
$mpdf = new mPDF("en-GB-x", [336, 190], "", "",30,30,30,30,6,3);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$i=1;
$cnt = count($result);
foreach($result as $html){
$mpdf->AddPage("", [336, 190], "", "",10,10,10,4,1,0,'L');
$mpdf->WriteHTML($html,2);
if($i < $cnt) {
//$mpdf->AddPage('L');
}
$i++;
}
$mpdf->showImageErrors = true;
$mpdf->Output(test'.pdf', 'I');
我解决了
if($pdfdetails['Test'] != "")
{
$result[] = $html2;
}elseif($pdfdetails['Test'] == ""){
}
$result[] = $html3;