|
 |
|
ข้อความที่ Query ออกมาสร้าง PDF มันยาว ขึ้นบรรทัดใหม่ยังไง.. |
|
 |
|
|
 |
 |
|
ผม Query ข้อมูลจาก ฐานข้อมูล MySQL มาสร้างเป็นตาราง
และข้อความที่ออกมามันมีความยาวมากครับ มันก็เลยเกินหน้า เกินตาราง ไม่ยอมขึ้นบรรทัดใหม่ไห้
จะแก้ไขยังไงครับ ปวดหัวแล้วววว...
มีคนบอกว่าใช้ MultiCell ผมไม่เข้าใจว่าใช้ยังไง รบกวนชี้แนะอีกรอบให้แจ้งใจด้วยครับ..
ถ้าจะดีแก้โค้ดให้ผมเลยจะเป็นพระคุณอย่างสูง งง งวยยยยยยยยยยยยยยยยยยย
<?
require_once('dbconn.php');
$query = "select * from project";
$query = $query." where project_id = '255204027' ";
$rsmem=mysql_db_query($db,$query);
$num=mysql_num_rows($rsmem);
$row = mysql_fetch_assoc($rsmem);
?>
<?
require('thaipdfclass.php');
$pdf=new ThaiPDF();
$pdf->SetThaiFont();
$pdf->AddPage();
$pdf->Image('logo_regis.jpg',90,10);
$pdf->SetFont('CordiaNew','B',20);
$pdf->SetTextColor(0,0,0);
$pdf->Ln(40);
$pdf->Cell(0,7,'ใบสมัครขอรับทุนเพื่อการศึกษาค้นคว้าด้วยตนเองสำหรับนิสิตคณะวิทยาศาสตร์',0,1,'C');
$pdf->Ln(10);
$pdf->SetFont('CordiaNew','B',16);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(0,7,'ข้อมูลโครงการ',1,0,'L');
$pdf->Ln(7);
$pdf->SetFont('CordiaNew','',15);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(50,7,'รหัสโครงการ : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[project_id],1,1,'L');
$pdf->Cell(50,7,'ชื่อโครงงานภาษาไทย : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[project_name_th],1,1,'L');
$pdf->Cell(50,7,'ชื่อโครงงานภาษาอังกฤษ : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[project_name_en],1,1,'L');
$pdf->Cell(50,7,'ชื่อโครงงานภาษาอังกฤษ : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[project_name_en],1,1,'L');
$pdf->Cell(50,7,'อาจารย์ที่ปรึกษาโครงงาน : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[teacher_id],1,1,'L');
$pdf->Cell(50,7,'สถานที่ติดต่อได้สะดวก : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[address],1,1,'L');
$pdf->Cell(50,7,'โทรศัพท์ติดต่อ : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[telephone],1,1,'L');
$pdf->Cell(50,7,'Email : ',1,0,'R');
$pdf->Cell(140,7,' '.$row[contact_email],1,1,'L');
$pdf->Ln(10);
$pdf->SetFont('CordiaNew','B',16);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(0,7,'ข้อมูลผู้จัดทำ',1,0,'L');
$pdf->Ln(8);
$pdf->SetFont('CordiaNew','',15);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(20,7,'1.',1,0,'R');
$pdf->Cell(150,7,' '.$row[project_name_th],1,1,'L');
$pdf->Cell(20,7,'2.',1,0,'R');
$pdf->Cell(150,7,' '.$row[project_name_th],1,1,'L');
$pdf->Cell(20,7,'3.',1,0,'R');
$pdf->Cell(150,7,' '.$row[project_name_th],1,1,'L');
$pdf->Ln(30);
$pdf->Cell(0,7,' ลงชื่อ.............................................................หัวหน้าโครงการ',0,1);
$pdf->Cell(0,7,' (.............................................................)',0,1);
$pdf->Cell(0,7,' ลงชื่อ.............................................................ที่ปรึกษาโครงการ',0,1);
$pdf->Cell(0,7,' (.............................................................)',0,1);
$pdf->Cell(0,7,' วันที่........... เดือน.....................................ปี..............',0,1);
$pdf->Output();
?> Code (PHP)
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-04-02 06:54:46 |
By :
maccit |
View :
5471 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
MultiCell ใช้ประมาณนี้ครับ
Code (PHP)
<?php
$pdf->MultiCell(0,5,"ข้อมูล",0,'L');
//ค่าในฟังก์ชัน
// ค่าแรกคือ ความกว้างของข้อมูล ถ้าเป็น 0 จะแสดงจนสุดขอบด้านขวาของหน้า
// ค่าที่ 2 (ในที่นี้คือ เลข 5) คือระยะห่างระหว่างบรรทัด
// ค่าที่ 3 คือข้อมูลที่จะแสดงผล
// ค่าที่ 4 คือ กำหนดว่าจะแสดงกรอบหรือไม่ ถ้าเป็น 1 คือแสดง -- ถ้าเป็น 2 คือไม่แสดง
// ค่าที่ 5 คือกำหนดตำแหน่งครับ มี L = จัดชิดซ้าย // C = จัดกึ่งกลาง // R = จัดชิดขวา // J= จัดแบบกระจายเต็มบรรทัด
?>
|
 |
 |
 |
 |
Date :
2009-04-04 16:38:22 |
By :
a|r|m|p|s |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองใช้ multiCell ดูแล้วก็ยังไม่ได้ครับ คือมันตัดคำให้จริง แต่พอเซลถัดไป หมายถึงคอลัมน์ถัดไปของแถวเดิม
มันจะตัดขึ้นบรรทัดใหม่ไปด้วยครับ จะแก้ไขยังไงดีครับ
|
 |
 |
 |
 |
Date :
2011-10-09 14:51:23 |
By :
alessandro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประสบปัญหานี้เหมือนกันค่ะ เราใช้วิธีลักไก่
โดยคำนวณระยะห่างระหว่างจุด Y ของขอบบนกับขอบล่างของ Multicell
แล้วใช้วิธีprint เฉพาะขอบ ซ้ำอีกที แต่ไม่ค่อยแนะนำวิธีนี้ เพราะมันจะมีปัญหากับข้อมูลที่เกิน 1 หน้ากระดาษ
|
 |
 |
 |
 |
Date :
2011-12-27 17:12:23 |
By :
KatMee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|