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 PDF Function > PHP PDF - Multiple Columns



Clound SSD Virtual Server

PHP PDF - Multiple Columns

PHP PDF - Multiple Columns การเขียน php กับ pdf กำหนดในส่วนของ Columns ในการแสดงผล และตัวอย่างนี้จะเป็นการเปิดไฟล์จาก txt มาเขียนลงบน PDF ด้วยครับ


FPDF Class



phpWritePDFMultiColumn.php

<html>
<head>
<title>ThaiCreate.Com PHP PDF</title>
</head>
<body>

<?php
require('fpdf.php');

class PDF extends FPDF
{
//Current column
var $col=0;
//Ordinate of column start
var $y0;

function Header()
{
	//Page header
	global $title;

	$this->SetFont('Arial','B',15);
	$w=$this->GetStringWidth($title)+6;
	$this->SetX((210-$w)/2);
	$this->SetDrawColor(0,80,180);
	$this->SetFillColor(230,230,0);
	$this->SetTextColor(220,50,50);
	$this->SetLineWidth(1);
	$this->Cell($w,9,$title,1,1,'C',true);
	$this->Ln(10);
	//Save ordinate
	$this->y0=$this->GetY();
}

function Footer()
{
	//Page footer
	$this->SetY(-15);
	$this->SetFont('Arial','I',8);
	$this->SetTextColor(128);
	$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}

function SetCol($col)
{
	//Set position at a given column
	$this->col=$col;
	$x=10+$col*65;
	$this->SetLeftMargin($x);
	$this->SetX($x);
}

function AcceptPageBreak()
{
	//Method accepting or not automatic page break
	if($this->col<2)
	{
		//Go to next column
		$this->SetCol($this->col+1);
		//Set ordinate to top
		$this->SetY($this->y0);
		//Keep on page
		return false;
	}
	else
	{
		//Go back to first column
		$this->SetCol(0);
		//Page break
		return true;
	}
}

function ChapterTitle($num,$label)
{
	//Title
	$this->SetFont('Arial','',12);
	$this->SetFillColor(200,220,255);
	$this->Cell(0,6,"Paragraph $num : $label",0,1,'L',true);
	$this->Ln(4);
	//Save ordinate
	$this->y0=$this->GetY();
}

function ChapterBody($file)
{
	//Read text file
	$f=fopen($file,'r');
	$txt=fread($f,filesize($file));
	fclose($f);
	//Font
	$this->SetFont('Times','',12);
	//Output text in a 6 cm width column
	$this->MultiCell(60,5,$txt);
	$this->Ln();
	//Mention
	$this->SetFont('','I');
	$this->Cell(0,5,'(end of excerpt)');
	//Go back to first column
	$this->SetCol(0);
}

function PrintChapter($num,$title,$file)
{
	//Add chapter
	$this->AddPage();
	$this->ChapterTitle($num,$title);
	$this->ChapterBody($file);
}
}


$pdf=new PDF();
$title='Welcome to www.ThaiCreate.Com Version 2009';
$pdf->SetTitle($title);
$pdf->SetAuthor('Jules Verne');
$pdf->PrintChapter(1,'ThaiCreate.Com Files 1','thaicreate1.txt');
$pdf->PrintChapter(2,'ThaiCreate.Com Files 2','thaicreate2.txt');

$pdf->Output("MyPDF/MyPDF.pdf","F");
?>

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









PHP & PDF

PHP & PDF


Reference : http://www.fpdf.org


   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2008-10-19 22:19:34 / 2017-03-15 10:41:47
  Download : Download  PHP PDF - Multiple Columns
 Sponsored Links / Related

 
PHP PDF
Rating :

 
PHP PDF - Header, footer, page break and image
Rating :

 
PHP PDF - Line breaks and colors
Rating :

 
PHP PDF - Insert Tables
Rating :

 
PHP PDF - Links and flowing text
Rating :

 
PHP PDF - MySQL Export to PDF
Rating :

 
PHP PDF - Export to PDF and Send Email Attachment
Rating :

 
PHP PDF - Thai Font Language
Rating :

 
PHP PDF - Header and Footer
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
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 อัตราราคา คลิกที่นี่