1
我想設置中的所有頁面中的所有頁眉和頁腳與MPDF一個pdf休息,顯示頁眉和頁腳在每一頁是由長條桌
所以,我的代碼是這樣的:
<!DOCTYPE html>
<html>
<head>
<title>Data Category</title>
<style type="text/css">
.page{
padding-top:2.5cm;
padding-right:1.5cm;
padding-left:1cm;
padding-bottom:5cm;
}
table{
border-spacing:0;
border-collapse: collapse;
width:100%;
page-break-inside:auto;
}
table td, table th{
border: 1px solid black;
}
</style>
</head>
<body>
<div class="page">
<table border="0">
<thead>
<tr>
<th>No</th>
<th>Tanggal</th>
<th>Jam</th>
<th>No struk</th>
<th>Nama</th>
<th>Quantity</th>
<th>Nama Item</th>
<th>Harga Jual</th>
<th>Sub total</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach ($data as $key => $value) {
?>
<tr>
<td><?= $no++ ?></td>
<td><?= $value['date_format'] ?></td>
<td><?= $value['jam'] ?></td>
<td><?= $value['struk_no'] ?></td>
<td><?= $value['nama_karyawan'] ?></td>
<td><?= $value['jumlah_jual'] ?></td>
<td><?= $value['nama_item'] ?></td>
<td><?= $value['harga_jual'] ?></td>
<td><?= $value['subtotal'] ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
我已經讀過他們的文檔:mpdf docs。
但是,當我的表加載多個頁面,表打破了頭:
$detail = Yii::$app->db->createCommand($this->getSqlReportDetail($parseStart, $parseEnd))->queryAll();
$html = $this->renderPartial('_report_detail', ['data' => $detail]);
$mpdf = new \mPDF('c', 'A4', '', '', 0, 0, 0, 0, 0, 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->SetHTMLHeader(''
. '<div style="text-align: center; font-weight: bold;">'
. '<h1>Hair Deeper Salon</h1><br>'
. '<hr>'
. '</div>'
);
$mpdf->SetHTMLFooter('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;">
<tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE j-m-Y}</span></td>
<td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
<td width="33%" style="text-align: right; ">My document</td>
</tr>
</table>
');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;