|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /home/queenjbs/www/test/tfpdf/example2/ |
Upload File : |
<?php
define('FPDF_FONTPATH','lib/font/');
require_once('lib/pdftable.inc.php');
class PDF extends PDFTable{
function PDF($orientation='P',$unit='mm',$format='A4'){
PDFTable::PDFTable($orientation,$unit,$format);
$this->AddFont('vni_times');
/*$this->AddFont('vni_times', 'B');
$this->AddFont('vni_times', 'I');
$this->AddFont('vni_times', 'BI');
$this->AddFont('vni_helve', 'B');*/
$this->SetAuthor('Pham Minh Dung');
$this->AliasNbPages();
}
function Header(){
parent::Header();
$this->setStyle('small');
$this->x = $this->left;
$this->y = $this->top-$this->getLineHeight()-0.5;
$user = getvar('UserName');
$time = date('d/m/Y');
$edit = getstr('EditBy');
$date = getstr('Updated');
$input = "Nhaäp bôûi [$edit] ngaøy $date";
$print = "In bôûi [$user] ngaøy $time";
$print = $edit? "$input. $print":$print;
$html = "
<table width=$this->width><tr>
<td nowrap>Coâng ty TNHH Quoác Daân - Chi nhaùnh TPHCM</td>
<td align=right nowrap>$print</td>
</tr></table>
";
$this->htmltable($html,0);
$this->hr();
$this->y = $this->top;
}
function Footer(){
$this->setStyle('small');
$this->x = $this->left;
$this->y = $this->bottom+0.5;
$version = getvar('Version');
$page = 'Trang '.$this->PageNo().'/{nb}';
$html = "
<table width=$this->width><tr>
<td nowrap>$version</td>
<td align=right nowrap>$page</td>
</tr></table>
";
$this->hr();
$this->htmltable($html,0);
}
/**
* @@desc Xuat ra chi thi cho phep download file
*/
function download($name){
$user = getvar('UserName');
$folder = "temp/$user/";
$name = $name.'_'.date('y-m-d_His').'.pdf';
$file = $folder.$name;
$this->Output($file,'F');
message("In thành công!<ul><li>Click chuột trái vào tên file để mở file trên cửa sổ mới.<li>Click chuột phải vào tên file và chọn <b>Save target as...</b> để lưu file.</ul><center><a href='get.php?f=$name' target=_blank>$name</a></center>");
}
/**
* @desc Thiet lap style dinh truoc
*/
function setStyle($style='normal'){
switch ($style){
case 'title':
$this->SetFont('vni_times','',19);
break;
case 'small':
$this->SetFont('vni_times','',8);
break;
case 'normal':
default:
$this->SetFont('vni_times','',12);
}
}
function text($w,$txt,$border=0,$align='J',$fill=0){
FPDF::MultiCell($w,$this->FontSizePt/2,$txt,$border,$align,$fill);
}
/**
* @desc Xuat ra dong chu xac dinh nguoi nhap du lieu tren form
*/
function makeSecurityString(){
/*$this->setStyle('small');
$this->x = $this->left;
$user = getvar('UserName');
$time = date('d/m/Y');
$edit = getstr('EditBy');
$date = getstr('Updated');
$input = "Nhaäp bôûi [$edit] ngaøy $date";
$print = "In bôûi [$user] ngaøy $time";
$print = $edit? "$input. $print":$print;
$version = getvar('Version');
$html = "
<table width=$this->width><tr>
<td nowrap>Coâng ty TNHH Quoác Daân</td>
<td align=center nowrap>$print</td>
<td align=right nowrap>$version</td>
</tr></table>
";
$this->hr();
$this->htmltable($html);*/
}
/**
* @desc Ve mot duong ngang toan chieu trang giay
*/
function hr(){
$this->Line($this->left,$this->y,$this->right,$this->y);
}
/**
* @desc Xuat ra phan ket thuc cua form va ve hinh chu nhat bao quanh form
*/
function formBox(){
$this->Ln(3);
$this->setStyle();
$table = "<table width=$this->width><tr>
<td align=center height=35 valign=top>Ngöôøi laäp bieåu
<td align=center valign=top>Keá toaùn tröôûng
<td align=center valign=top>Thuû tröôûng ñôn vò
</table>";
$this->htmltable($table);
}
/**
* @return array
* @desc Xac dinh kich thuoc cac cot tuong ung voi data
*/
function _getColumnSize($data, $size=array()){
if (is_array(current($data))){
foreach($data as $row){
foreach ($row as $i=>$txt){
$wtxt = $this->GetStringWidth($txt)+2;
if (!isset($size[$i]) || $size[$i] < $wtxt) $size[$i] = $wtxt;
}
}
}elseif (is_array($data)){
foreach ($data as $i=>$txt){
$wtxt = $this->GetStringWidth($txt)+2;
if (!isset($size[$i]) || $size[$i] < $wtxt) $size[$i] = $wtxt;
}
}
return $size;
}
}//end of class
?>