|
 |
|
ทำรายงานกับ FPDF ดึงข้อมูลจากฐานข้อมูล ตัดขึ้นบรรทันใหม่ได้แล้ว แต่ตัดไม่เป็นคำ ต้องทำไงค่ะ รบกวนผู้รู้หน่อยค่ะ |
|
 |
|
|
 |
 |
|
จริงครับ การตัดคำและขึ้นบรรทัดใหม่ของ FPDF นั้นทำได้ค่อนข้างยาก เนื่องจากต้องกำหนด Cell ในการแสดงผลแบบเป๊ะๆ ตัวอย่าง
$this->Ln();
$this->Cell(100, 5, "http://google.co.th", 0, 0, 'L');
สังเกตุ : Ln() -> การขึ้นบรรทัดใหม่
Cell() -> กำหนดค่าในการแสดงผล
ซึ่งใช้ได้ดีหากข้อมูลที่นำมาแสดงมีความยาวแน่นอน แต่กรณีที่นำค่าจากฐานข้อมูลมาแสดง บางครั้งข้อมูลมีความยาวมากๆ และเราอยากให้มันขึ้นบรรทัดใหม่แบบอัตโนมัติ ดังนั้น ขอแนะนำให้ใช้ TCPDF ครับ ซึ่งเป็นตัวต่อยอดของ FPDF โดยสามารถแสดงผลในรูปของแท็ก HTML ได้ ตัวอย่าง
Code (PHP)
$content = '<table border="0" cellspacing="0" cellpadding="2">
<tr><td align="left" height="77">
ทั้งนี้ <b>ท่านควรเปลี่ยนรหัสผ่านอย่างสม่ำเสมอ อย่างน้อยปีละครั้ง (365 วัน/ครั้ง)</b> เพื่อป้องกันมิให้ผู้อื่นนำรหัส<br/>
ของท่านไปใช้งาน ซึ่งอาจก่อให้เกิดความเสียหายกับหน่วยงานและมหาวิทยาลัยฯ และเพื่อการป้องกันการกระทำความ<br/>
ผิดตาม<b>พระราชบัญญัติว่าด้วยการกระทำผิดเกี่ยวกับคอมพิวเตอร์ พ.ศ. 2550</b> มหาวิทยาลัยฯ ขอให้ท่านโปรดปฏิบัติ<br/> ตามข้อกำหนดใน<b>นโยบายการใช้งานสารสนเทศและความปลอดภัยของระบบ</b> อย่างเคร่งครัด
</td></tr>
<tr><td align="left" height="30">
จึงเรียนมาเพื่อทราบ และโปรดดำเนินการ
</td></tr>
</table>';
$content = stripslashes($content);
$content = AdjustHTML($content);
$this->writeHTML($content, true, 0, true, 0);
รายละเอียดการใช้งาน TCPDF สามารถหาได้จากเว็บ google ครับ
|
ประวัติการแก้ไข 2012-03-12 10:31:05 2012-03-13 11:50:46 2012-03-13 11:51:36
 |
 |
 |
 |
Date :
2012-03-12 10:27:53 |
By :
Mx0 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|