|
 |
|
ติดปัญหากับ FPDF ในการตั้ง $pdf->SetXY('',''); ค่ะ |
|
 |
|
|
 |
 |
|
ติดปัญหากับ FPDF ในการตั้ง $pdf->SetXY('',''); ค่ะ
ปัญหาคือ อยากจะตั้งตารางให้เกือบชิดกระดาษซ้ายประมาณ 5 มิล แต่พอลอง for($i=1;$i<20;$i++) แล้ว แถวคอลัมน์มันไม่ตรงกันค่ะ

Code (PHP)
<!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>Untitled Document</title>
</head>
<body>
<?php
require('fpdf.php');
define('FPDF_FONTPATH','font/');
$pdf=new FPDF();
$pdf->DefOrientation="L"; // แนวนอน
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',14);
$pdf->SetXY(5,10);
$pdf->Cell(15,14,iconv("UTF-8","TIS-620","ลำดับ"),1,0,'C');
$pdf->Cell(30,14,iconv("UTF-8","TIS-620","เขตการขาย"),1,0,'C');
$pdf->Cell(40,14,iconv("UTF-8","TIS-620","ชื่อร้านค้า"),1,0,'C');
$pdf->Cell(30,14,iconv("UTF-8","TIS-620","จังหวัด"),1,0,'C');
$pdf->Cell(100,7,iconv("UTF-8","TIS-620","ประจำปี"),1,0,'C');
$pdf->Cell(40,14,iconv("UTF-8","TIS-620","หมายเหตุ"),1,0,'C');
$pdf->Ln(7);
$pdf->SetXY(120,17);
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2550"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2551"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2552"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2553"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2554"),1,0,'C');
$pdf->Ln();
$pdf->SetXY(5,24); ///ตรงนี้
for($i=1;$i<20;$i++)
{
$pdf->Cell(15,7,$i,1,0,'C');
$pdf->Cell(30,7,iconv("UTF-8","TIS-620","เขตการขาย $i"),1,0,'C');
$pdf->Cell(40,7,iconv("UTF-8","TIS-620",".co.th"),1,0,'C');
$pdf->Cell(30,7,iconv("UTF-8","TIS-620","กรุงเทพ"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","1000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2,000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","3000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","400"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","1000"),1,0,'C');
$pdf->Cell(40,7,"",1,0,'C'); // หมายเหตุ
$pdf->Ln();
}
$pdf->Output("MyPDF/MyPDF.pdf","F");
?>
PDF Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>
Tag : PHP, CakePHP, Report Others

|
ประวัติการแก้ไข 2014-02-05 10:08:25 2014-02-05 10:09:43 2014-02-05 10:26:13 2014-02-05 10:27:06
|
 |
 |
 |
 |
Date :
2014-02-05 10:06:59 |
By :
loomoo |
View :
2702 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง SETX ของแต่ละรอบ/แถวดูครับ
Code (PHP)
$pdf->SetXY(5,24); ///ตรงนี้
for($i=1;$i<20;$i++)
{
$pdf->SetX(5);
$pdf->Cell(15,7,$i,1,0,'C');
$pdf->Cell(30,7,iconv("UTF-8","TIS-620","เขตการขาย $i"),1,0,'C');
$pdf->Cell(40,7,iconv("UTF-8","TIS-620",".co.th"),1,0,'C');
$pdf->Cell(30,7,iconv("UTF-8","TIS-620","กรุงเทพ"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","1000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","2,000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","3000"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","400"),1,0,'C');
$pdf->Cell(20,7,iconv("UTF-8","TIS-620","1000"),1,0,'C');
$pdf->Cell(40,7,"",1,0,'C'); // หมายเหตุ
$pdf->Ln();
}
|
 |
 |
 |
 |
Date :
2014-02-05 10:52:30 |
By :
Krungsri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณมากค่ะ 
|
 |
 |
 |
 |
Date :
2014-02-05 11:34:14 |
By :
loomoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|