Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ผม ทำ pdf ให้ เป็นภาษาไทย ไม่ได้ ครับ ทำ ตาม กระทู้อื่นแล้วก้อไม่ได้อะครับ มี รูป + โค้ด



 

ผม ทำ pdf ให้ เป็นภาษาไทย ไม่ได้ ครับ ทำ ตาม กระทู้อื่นแล้วก้อไม่ได้อะครับ มี รูป + โค้ด

 



Topic : 100019



โพสกระทู้ ( 111 )
บทความ ( 0 )



สถานะออฟไลน์




รรร


Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP PDF</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>

<?php


require('../pdf/fpdf.php');

class PDF extends FPDF
{
//Load data
function conv($string) {
return iconv('UTF-8', 'TIS-620', $string);
}
function LoadData($file)
{
	//Read file lines
	$lines=file($file);
	$data=array();
	foreach($lines as $line)
		$data[]=explode(';',chop($line));
	return $data;
}

//Simple table
function BasicTable($header,$data)
{
	//Header
	$w=array(30,55,55,25,20,20);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C');
	$this->Ln();
	//Data
	foreach ($data as $eachResult) 
	{
		$this->Cell(30,6,$eachResult["x"],1);
		$this->Cell(55,6,$eachResult["x"],1);
		$this->Cell(55,6,$eachResult["x"],1);
		$this->Cell(25,6,$eachResult["x"],1,0,'C');
		$this->Cell(20,6,$eachResult["x"],1);
		$this->Cell(20,6,$eachResult["x"],1);
		$this->Ln();
	}
}

//Better table
function ImprovedTable($header,$data)
{
	//Column widths
	$w=array(20,55,55,25,25,25);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C');
	$this->Ln();
	//Data

	foreach ($data as $eachResult) 
	{
		$this->Cell(20,6,$eachResult["x"],1);
		$this->Cell(55,6,$eachResult["x"],1);
		$this->Cell(55,6,$eachResult["x"],1);
		$this->Cell(25,6,$eachResult["x"],1,0,'C');
		$this->Cell(25,6,$eachResult["x"],1);
		$this->Cell(25,6,$eachResult["x"],1);
		/*$this->Cell(25,6,number_format($eachResult["email"],2),1,0,'R');
		$this->Cell(25,6,number_format($eachResult["status_read"],2),1,0,'R');*/
		$this->Ln();
	}





	//Closure line
	$this->Cell(array_sum($w),0,'','T');
}

//Colored table
function FancyTable($header,$data)
{
	//Colors, line width and bold font
	$this->SetFillColor(255,0,0);
	$this->SetTextColor(255);
	$this->SetDrawColor(128,0,0);
	$this->SetLineWidth(.3);
	$this->SetFont('','B');
	//Header
	$w=array(10,55,55,25,25,25);
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
	$this->Ln();
	//Color and font restoration
	$this->SetFillColor(224,235,255);
	$this->SetTextColor(0);
	$this->SetFont('');
	//Data
	$fill=false;
	foreach($data as $row)
	{
		$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
		$this->Cell($w[1],6,$row[5],'LR',0,'L',$fill);
		$this->Cell($w[2],6,$row[3],'LR',0,'L',$fill);
		$this->Cell($w[3],6,$row[2],'LR',0,'C',$fill);
		$this->Cell($w[4],6,$row[4],'LR',0,'R',$fill);
		$this->Cell($w[5],6,$row[5],'LR',0,'R',$fill);
		/*$this->Cell($w[4],6,number_format($row[4]),'LR',0,'R',$fill);
		$this->Cell($w[5],6,number_format($row[5]),'LR',0,'R',$fill);*/
		$this->Ln();
		$fill=!$fill;
	}
	$this->Cell(array_sum($w),0,'','T');
}
}

$pdf=new PDF();
//Column titles
$header=array('ไอดี','subject','name','ip','email','status read');

//Data loading

//*** Load MySQL Data ***//
/*$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("woman_pj");
mysql_query("SET NAMES UTF8");*/
include("../../include/connect.inc.php");
$obj_db = new mysql_operator($obj_dbconfig->get_configdb());
$obj_db->opendb();

$strSQL = "SELECT * FROM tb_cns";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
	
	$result = mysql_fetch_array($objQuery);
	
	array_push($resultData,$result);
}
//************************//



$pdf->SetFont('Arial','',10);
//*** Table 3 ***//
$pdf->AddPage();
$pdf->Image('../pdf/head_02.jpg',50,10,100);
$pdf->Ln(40);
$pdf->FancyTable($header,$resultData);
$pdf->Output("../pdf/file/MyPDF.pdf","F");

?>

PDF Created Click <a href="../pdf/file/MyPDF.pdf">here</a> to Download
</body>
</html>



https://www.thaicreate.com/php/forum/091248.html
https://www.thaicreate.com/php/forum/040743.html
https://www.thaicreate.com/php/forum/047979.html

ดูแล้วทำ ตาม ก็ไม่ได้อะครับ เพราะ อะไร ครับ

ขอบคุณล่วงหน้า



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-09-04 13:51:48 By : nattaphong25332533 View : 680 Reply : 1
 

 

No. 1



โพสกระทู้ ( 455 )
บทความ ( 0 )



สถานะออฟไลน์


ตามความคิดผมนะ
1.ลองคิวรี จาก db มาโชว์ ก่อนว่ามัน แสดงเป็นไทน สมบูรณ์ไหม ถ้าไม่สมบูรณ์ ก็ mysql_query("SET NAMES UTF8"); ซะ (แล้วแต่คนว่าตอน insert เข้ารหัสแบบไหน)
2.ในเมื่อขั้นที่ 1 แสดงภาษาไทยได้แล้ว ลองแปลงเป็น pdf เลย ยังไม่ต้องเพิ่ม การ iconv อะไร มันแสดงภาษาไทยได้ไหม ถ้าไม่ได้ ลองดู font สิ มันสามารถแสดงภาษาไทยได้หรือไม่

ปล.ผิดพลาดขออภัย






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-09-04 14:14:05 By : yamcrocodile
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ผม ทำ pdf ให้ เป็นภาษาไทย ไม่ได้ ครับ ทำ ตาม กระทู้อื่นแล้วก้อไม่ได้อะครับ มี รูป + โค้ด
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่