|
|
|
สอบถามการใช้ mpdf กับการ rotate page จากแนวตั้งเป็นแนวนอนค่ะ |
|
|
|
|
|
|
|
คือ เราต้องการสร้าง pdf แบบด้านล่างนี้น่ะค่ะ ตอนนี้ทำแบบปกติ (แนวตั้ง) ได้แล้ว เหลือการ rotate นี่แหละที่ติดปัญหา
ไม่รู้จะทำให้ header กับ footer rotate ไปด้วยยังไง รบกวนชี้แนะด้วยค่ะ >_>
ปล. อันนี้เราใช้ mpdf นะคะ ที่ต้อง rotate page ให้เป็นแนวนอนเพราะลูกค้าใช้ printer dot matrix ค่ะ
หากไม่ได้จริงๆ คงต้องเปลี่ยนไปใช้ fpdf
Code (PHP)
<?php
$html = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ใบรับสินค้า :: IN-1708-002</title>
<style>
@page {
margin-header: 4mm;
margin-footer: 4mm;
header: html_myHeader;
footer: html_myFooter;
}
/*@page rotated { size: landscape;}
table.rotated { page: rotated;page-break-before: right;}
table { rotate:90; }*/
/*.rotated { rotate: 90; page-break-before: right;}*/
body { margin:0 auto; padding:0; font-size:14pt; line-height:14pt; color:#000; }
.title { font-size:28pt; font-weight: bold;}
.docno { font-size:20pt; font-weight: bold;}
.time { font-size: 12pt; padding-top: 6pt;}
.form_data { padding: 2pt;}
.form_tbl td { padding:0pt 2pt;}
.tr_header td { border-top: 1pt solid #000; border-bottom: 1pt solid #000; border-collapse: collapse; padding:0pt 2pt; font-weight: bold;}
.tr_footer td { border-bottom: 1pt solid #000;}
.tr_total td { font-weight: bold; padding-top: 2pt; }
</style>
</head>
<body>
<htmlpageheader name="myHeader">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" class="title">ใบรับสินค้า</td>
<td align="right" valign="bottom" class="docno">IN-1708-002</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" class="form_data">
<tr>
<td align="left" valign="top" width="60">วันที่:</td>
<td align="left" valign="top" width="150">04/08/2017</td>
<td align="left" valign="top" width="40">สาขา:</td>
<td align="left" valign="top" width="100">รัตนา PD</td>
<td align="left" valign="top" width="70">เลขที่อ้างอิง:</td>
<td align="left" valign="top">sdd5</td>
</tr>
<tr>
<td align="left" valign="top">หมายเหตุ:</td>
<td align="left" valign="top" colspan="3">add 2</td>
<td align="left" valign="top">ชื่อผู้ผลิต:</td>
<td align="left" valign="top">ABC'id Co</td>
</tr>
</table>
</htmlpageheader>
<htmlpagefooter name="myFooter">
<table width="100%" border="0" cellpadding="0">
<tr>
<td align="left" valign="top">ผู้อนุมัติ</td>
<td align="left" valign="top" width="50"> </td>
<td align="left" valign="top">ผู้ส่ง</td>
<td align="left" valign="top" width="50"> </td>
<td align="left" valign="top">ผู้รับ</td>
</tr>
<tr>
<td align="left" valign="top">______________________</td>
<td align="left" valign="top"> </td>
<td align="left" valign="top">______________________</td>
<td align="left" valign="top"> </td>
<td align="left" valign="top">______________________</td>
</tr>
<tr>
<td align="right" valign="top" colspan="5" class="time">รัตนา PD 18/08/2017 11:37</td>
</tr>
</table>
</htmlpagefooter>
<table cellpadding="2" cellspacing="0" class="form_tbl rotated" width="100%">
<thead>
<tr class="tr_header">
<td align="center" valign="middle">ที่</td>
<td align="left" valign="middle" width="90">รหัส</td>
<td align="left" valign="middle" width="120">ชื่อสินค้า</td>
<td align="left" valign="middle" width="60">นน.มาตร</td>
<td align="right" valign="middle" width="60">จำนวน</td>
<td align="right" valign="middle" width="80">นน.รวม</td>
<td align="right" valign="middle" width="80">นน.จริง</td>
</tr>
</thead>
<tfoot>
<tr class="tr_footer">
<td align="center" valign="middle" height="1"></td>
<td align="left" valign="middle"></td>
<td align="left" valign="middle"></td>
<td align="left" valign="middle"></td>
<td align="right" valign="middle"></td>
<td align="right" valign="middle"></td>
<td align="right" valign="middle"></td>
</tr>
</tfoot>
<tbody>
<tr>
<td valign="top" align="center">1</td>
<td valign="top" align="left">K05</span></td>
<td valign="top" align="left">ค 1 บ</td>
<td valign="top" align="left">1 บ</td>
<td valign="top" align="right">10</td>
<td valign="top" align="right">152.00</td>
<td valign="top" align="right">152.50</td>
</tr>
<tr>
<td valign="top" align="center">2</td>
<td valign="top" align="left">K06</span></td>
<td valign="top" align="left">ค 2 บ</td>
<td valign="top" align="left">2 บ</td>
<td valign="top" align="right">10</td>
<td valign="top" align="right">304.00</td>
<td valign="top" align="right">304.20</td>
</tr>
<tr>
<td valign="top" align="center">3</td>
<td valign="top" align="left">K07</span></td>
<td valign="top" align="left">ค 3 บ</td>
<td valign="top" align="left">3 บ</td>
<td valign="top" align="right">10</td>
<td valign="top" align="right">456.00</td>
<td valign="top" align="right">456.26</td>
</tr>
<tr>
<td valign="top" align="center">4</td>
<td valign="top" align="left">M05</span></td>
<td valign="top" align="left">ม 1 บ</td>
<td valign="top" align="left">1 บ</td>
<td valign="top" align="right">15</td>
<td valign="top" align="right">228.00</td>
<td valign="top" align="right">228.45</td>
</tr>
<tr>
<td valign="top" align="center">5</td>
<td valign="top" align="left">M06</span></td>
<td valign="top" align="left">ม 2 บ</td>
<td valign="top" align="left">2 บ</td>
<td valign="top" align="right">15</td>
<td valign="top" align="right">456.00</td>
<td valign="top" align="right">456.20</td>
</tr>
<tr>
<td valign="top" align="center">6</td>
<td valign="top" align="left">M07</span></td>
<td valign="top" align="left">ม 3 บ</td>
<td valign="top" align="left">3 บ</td>
<td valign="top" align="right">15</td>
<td valign="top" align="right">684.00</td>
<td valign="top" align="right">683.98</td>
</tr>
<tr>
<td valign="top" align="center">7</td>
<td valign="top" align="left">M08</span></td>
<td valign="top" align="left">ม 4 บ</td>
<td valign="top" align="left">4 บ</td>
<td valign="top" align="right">5</td>
<td valign="top" align="right">304.00</td>
<td valign="top" align="right">304.00</td>
</tr>
</tbody>
</table>
<table cellpadding="2" cellspacing="0" class="form_tbl rotated" width="100%">
<tr class="tr_total">
<td valign="top" align="center"> </td>
<td valign="top" align="left" width="90"> </span></td>
<td valign="top" align="left" width="120"> </td>
<td valign="top" align="left" width="60">รวม</td>
<td valign="top" align="right" width="60">80</td>
<td valign="top" align="right" width="80">2,584.00</td>
<td valign="top" align="right" width="80">2,585.59</td>
</tr>
</table>
</body>
</html>
';
require_once('public/tool-mpdf60/mpdf.php');
$mpdf = new mPDF('th', 'A5', 0, 'angsa', 4, 4, 35, 30);
//$mpdf->forcePortraitHeaders = true;
$mpdf->AliasNbPages('[pagetotal]');
$mpdf->SetDisplayMode('fullpage');
//$mpdf->AddPage('L');
$mpdf->WriteHTML($html);
$mpdf->Output();
?>
Tag : PHP, HTML, CSS
|
|
|
|
|
|
Date :
2017-08-18 11:45:40 |
By :
KatMee |
View :
4115 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเพิ่ม '-L' ดูครับ
Code (PHP)
$mpdf = new mPDF('th', 'A5-L', 0, 'angsa', 4, 4, 35, 30);
|
|
|
|
|
Date :
2017-08-19 11:50:19 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|