天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php FPDF類庫應用實現代碼

復制代碼 代碼如下:
<?php
require('chinese.php');
class PDF extends PDF_Chinese
{
function Header() //設置頁眉
{
$this->SetFont('GB','',10);
$this->Write(10,'XX公司產品名錄');
$this->Ln(20); //換行
}
function Footer() //設置頁腳
{
$this->SetY(-15);
$this->SetFont('GB','',10);
$this->Cell(0,10,'第'.$this->PageNo().'頁');
}
}

$conn = mysql_connect("localhost", "root", ""); //連接數據庫

mysql_select_db("product", $conn); //執行SQL
$query_rs_prod = "SELECT * FROM product ORDER BY prod_id";
$rs_prod = mysql_query($query_rs_prod, $conn) or die(mysql_error());
$row_rs_prod = mysql_fetch_assoc($rs_prod);
$totalRows_rs_prod = mysql_num_rows($rs_prod);

$pdf=new PDF(); //創建新的FPDF對象
$pdf->AddGBFont(); //設置中文字體
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁

$pdf->SetFont('GB','',10); //設置字體樣式

$header=array('產品編號','產品名稱','產品類型','產品單價'); //設置表頭
$width=array(20,80,40,20); //設置每列寬度

for($i=0;$i<count($header);$i++) //循環輸出表頭
$pdf->Cell($width[$i],6,$header[$i],1);
$pdf->Ln();

do //循環輸出表體
{
$pdf->Cell($width[0],6,$row_rs_prod['prod_id'],1);
$pdf->Cell($width[1],6,$row_rs_prod['prod_name'],1);
$pdf->Cell($width[2],6,$row_rs_prod['prod_type'],1);
$pdf->Cell($width[3],6,$row_rs_prod['prod_price'],1);
$pdf->Ln();
} while ($row_rs_prod = mysql_fetch_assoc($rs_prod));

$pdf->Output("product.pdf", true); //下載PDF文件
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件
$pdf=new FPDF('P', 'mm', 'A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁
$pdf->SetFont('Courier','I',20); //設置字體樣式
$pdf->Cell(0,0,'Hello World!'); //增加一個單元格
$pdf->Output(); //輸出PDF到瀏覽器
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件
$pdf=new FPDF('P', 'mm', 'A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁
$pdf->SetFont('Courier','I',20); //設置字體樣式
$pdf->Image('sight.jpg',20,20,0,0); //增加一張圖片,文件名為sight.jpg
$pdf->Output(); //輸出PDF到瀏覽器
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件
$pdf=new FPDF(‘P', ‘mm', ‘A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁
$pdf->SetFont('Courier','I',20); //設置字體樣式
$pdf->Cell(60,10,'Hello World!',1); //增加一個單元格 邊框為1
$pdf->Output(); //輸出PDF到瀏覽器
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件
$pdf=new FPDF('P', 'mm', 'A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁

$pdf->SetFont('Arial','',14); //設置字體樣式

$header=array('Name','Age','Sex','Salary'); //設置表頭
$data=array(); //設置表體
$data[0] = array('Simon','24','Male','5,000.00');
$data[1] = array('Elaine','25','Female','6,000.00');
$data[2] = array('Susan','25','Female','7,000.00');
$data[3] = array('David','26','Male','8,000.00');

$width=array(40,40,40,40); //設置每列寬度

for($i=0;$i<count($header);$i++) //循環輸出表頭
$pdf->Cell($width[$i],6,$header[$i],1);
$pdf->Ln();

foreach($data as $row) //循環輸出表體
{
$pdf->Cell($width[0],6,$row[0],1);
$pdf->Cell($width[1],6,$row[1],1);
$pdf->Cell($width[2],6,$row[2],1);
$pdf->Cell($width[3],6,$row[3],1);
$pdf->Ln();
}

$pdf->Output(); //輸出PDF到瀏覽器
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件
$pdf=new FPDF('P', 'mm', 'A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁
$pdf->SetFont('Courier','I',20); //設置字體樣式
$pdf->Cell(0,0,'你好,FPDF'); //增加一個單元格并輸出中文
$pdf->Output(); //輸出PDF到瀏覽器
?>

復制代碼 代碼如下:
<?php
require('chinese.php');
class PDF extends PDF_Chinese
{
function Header() //設定頁眉
{
$this->SetFont('GB','',10);
$this->Write(10,'FPDF中文測試');
$this->Ln(20);
}

function Footer() //設定頁腳
{
$this->SetY(-15);
$this->SetFont('GB','',10);
$this->Cell(0,10,'第'.$this->PageNo().'頁');
}
}

$pdf=new PDF(); //創建PDF文檔
$pdf->AddGBFont();
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('GB','I',20);
$pdf->Cell(0,10,'你好,FPDF'); //輸出一段中文
$pdf->Output();
?>

復制代碼 代碼如下:
<?php
$conn = mysql_connect("localhost", "root", ""); //連接數據庫
$colname_rs_article = $_GET['id']; //獲取參數id

mysql_select_db("cms", $conn); //執行SQL
$query_rs_article = sprintf("SELECT * FROM articles WHERE article_id = %s", $colname_rs_article);
$rs_article = mysql_query($query_rs_article, $conn) or die(mysql_error());
$row_rs_article = mysql_fetch_assoc($rs_article);
$totalRows_rs_article = mysql_num_rows($rs_article);

function conv($Text) //對返回文本進行處理
{
$Text=htmlspecialchars($Text); //轉換HTML關鍵字符
$Text=nl2br($Text); //轉換換行符
return $Text;
}
?>
<p align="center"><B><?php echo $row_rs_article['title']; ?></B></p>
<p align="center"><font size=2><?php echo $row_rs_article['author']; ?> | <a href="showpdf.php?id=<?php echo $row_rs_article['article_id']; ?>">下載PDF文檔</a></font></p>
<HR>
<p><?php echo conv($row_rs_article['content']); ?></p>

復制代碼 代碼如下:
<?php
require('chinese.php');
class PDF extends PDF_Chinese
{
function Header() //設置頁眉
{
$this->SetFont('GB','',10);
$this->Write(10,'文章系統 - XX網站');
$this->Ln(20); //換行
}
function Footer() //設置頁腳
{
$this->SetY(-15);
$this->SetFont('GB','',10);
$this->Cell(0,10,'第'.$this->PageNo().'頁');
}
}
//主程序開始
$conn = mysql_connect("localhost", "root", ""); //連接數據庫
$colname_rs_article = $_GET['id']; //獲取參數id

mysql_select_db("cms", $conn); //執行SQL
$query_rs_article = sprintf("SELECT * FROM articles WHERE article_id = %s", $colname_rs_article);
$rs_article = mysql_query($query_rs_article, $conn) or die(mysql_error());
$row_rs_article = mysql_fetch_assoc($rs_article);
$totalRows_rs_article = mysql_num_rows($rs_article);
//開始創建PDF文檔
$pdf=new PDF();
$pdf->AddGBFont();
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('GB','B',20);
$pdf->Cell(0,10,$row_rs_article['title']); //輸出文章標題
$pdf->Ln(); //換行
$pdf->SetFont('GB','',10);
$pdf->Cell(0,10,$row_rs_article['author']); //輸出文章作者
$pdf->Ln();
$pdf->SetFont('GB','',12);
$content = $row_rs_article['content'];
while($content != "") //循環逐頁將文章內容寫入PDF
{
$length = strlen($content); //獲取文章長度
$output = substr($content, 0, 1024); //獲取本頁輸出內容,每1024個字符為1頁
$pdf->Cell(0,10,$output); //輸出文章內容
$content = substr($content, 1024, $length); //獲取剩余未輸出內容
$pdf->AddPage(); //換頁
}
$pdf->Output($row_rs_article['title'].".pdf", true); //輸出PDF文件,文件名為文章標題
?>

復制代碼 代碼如下:
<?php
define('FPDF_FONTPATH','font/'); //定義font文件夾所在路徑
require_once('fpdf/fpdf.php'); //包含fpdf類庫文件

class PDF extends FPDF
{
function Header() //設置頁眉
{
$this->SetFont('Arial','B',15); //設置頁眉字體
$this->Cell(80); //移動單元格
$this->Cell(30,10,'Title'); //寫入頁眉文字
$this->Ln(20); //換行
}

function Footer() //設置頁腳
{
$this->SetY(-15); //設置頁腳所在位置
$this->SetFont('Arial','I',8); //設置頁腳字體
$this->Cell(0,10,'Page - '.$this->PageNo()); //輸出當前頁碼作為頁腳內容
}
}

$pdf=new PDF('P', 'mm', 'A4'); //創建新的FPDF對象,豎向放紙,單位為毫米,紙張大小A4
$pdf->Open(); //開始創建PDF
$pdf->AddPage(); //增加一頁
$pdf->SetFont('Courier','I',20); //設置字體樣式
$pdf->Cell(0,0,'Hello World!'); //增加一個單元格
$pdf->Output(); //輸出PDF到瀏覽器
?>

php技術php FPDF類庫應用實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 精品国产中文字幕在线视频 | 无码专区久久综合久综合字幕 | 国产精品麻豆a在线播放 | 光溜溜的美女直播软件 | 欧美手机在线 | 九色PORNY蝌蚪视频首页 | 久久久这里有精品999 | 99久久久久精品国产免费麻豆 | 黄色a三级免费看 | 大学生宿舍飞机china free | 亚洲午夜福利未满十八勿进 | 国产精品一区二区欧美视频 | 亚洲中文无码亚洲人在线观看- | 国产成人拍精品免费视频爱情岛 | 黄色免费网址在线观看 | 色偷偷亚洲天堂 | 香蕉久久一区二区三区啪啪 | 国产又粗又猛又爽又黄的免费视频 | 麻豆精品传媒一二三区 | 亚洲日韩欧美国产中文在线 | 亚洲精品视频在线观看免费 | 真实国产精品视频国产网 | 男女牲交大战免费播放 | 熟妇久久无码人妻AV蜜桃 | 狠狠色狠狠色综合日日2019 | 久久夜色撩人精品国产 | 边做边爱免费视频 | 色多多污网站在线观看 | 欧美日韩精品一区二区三区高清视频 | ai换脸在线全集观看 | 旧里番6080在线观看 | 在线播放日韩欧美亚洲日本 | 色WWW永久免费视频首页 | 3d在线看小舞被躁视频 | 成人免费一区二区无码视频 | 精品久久久久中文字幕加勒比东京热 | 亚洲日韩欧美国产专区 | 花蝴蝶在线直播观看 | 久久免费精品国产72精品剧情 | www.av日韩| 狠狠国产欧美在线视频 |