2013-04-17 98 views
8

我有一個包含表格數據和下面幾個漏斗圖表的PHP頁面。 我要導出頁面頁眉和頁腳導出一個PHP頁面到PDF

到PDF

誰能告訴我如何使用JavaScript或jQuery的或以任何其他形式

謝謝

+1

嘗試'mPdf'或'fPdf' PHP庫... – Red

+0

當你正在使用PHP生成的頁面,我認爲最好的辦法是使用TCPDF包。它有如此強大的功能可以完成很多定製,而且更容易配置。 –

+0

你可以使用[DOMPDF](http://www.tcpdf.org/)或[TCPDF](https://github.com/dompdf/dompdf)進行pdf導出。 –

回答

9

使用FPDF你可以下載它導出從鏈接和更多信息,這裏的後,你可以整合如下http://fpdf.org

..

<?php 

require_once('fpdf.php'); 

class PDF extends FPDF 
{ 
    function Header() 
    { 
     $query='your query'; 
     $row=mysql_fetch_assoc($query); // data from database 


     $this->SetXY(50,60); 
     $this->Cell(45,6,'Name :',1,1,'R'); 
     $this->SetXY(95,60); 
     $this->Cell(80,6,$row['pdf_name'],1,1); 

     $this->SetXY(50,66); 
     $this->Cell(45,6,'Email Address :',1,1,'R'); 
     $this->SetXY(95,66); 
     $this->Cell(80,6,$row['pdf_email'],1,1); 

     $this->SetXY(50,72); 
     $this->Cell(45,6,'Question Paper Selected :',1,1,'R'); 
     $this->SetXY(95,72); 
     $this->Cell(80,6,$row['subject_sel'],1,1); 

     $this->SetXY(50,78); 
     $this->Cell(45,6,'Total Correct Answers :',1,1,'R'); 
     $this->SetXY(95,78); 
     $this->Cell(80,6,$row['right_answered'],1,1); 

     $this->SetXY(50,84); 
     $this->Cell(45,6,'Percentage :',1,1,'R'); 
     $this->SetXY(95,84); 
     $this->Cell(80,6,$row['percentage']."%",1,1); 

     $this->Ln(20); 
    } 
    function Footer() 
    { 
     $this->SetY(-15); 
     $this->SetFont('Arial','I',8); 
     $this->Cell(0,10,'abc according to you',0,0,'C'); 
    } 
} 
$pdf=new PDF('P','mm',array(297,210)); 
$pdf->Output($name.'.pdf','D'); 
?> 
您可以根據自己的需要進行編輯,它會以表格的形式顯示記錄並將其生成爲pdf。希望它對你有幫助。

更新:

圖像0​​

$this->Image('image path',80,30,50); 
+0

Thanks @Yadav我發現它對我的需求很有用 – Mac

+0

可以告訴我如何使用fpdf添加表格和圖表....我有一個表格和漏斗圖表的一個接一個的頁面...讓我知道如何我可以在上面的代碼中添加它 – Mac

+0

@mac以圖像形式做你的圖表嗎? –