将php页面导出为pdf
我有一个php页面,其中包括表数据和一些漏斗图。我想将页面导出为带有页眉和页脚的pdf格式 有谁能告诉我如何使用javascript、jquery或任何其他形式导出它吗将php页面导出为pdf,php,javascript,jquery,pdf-generation,Php,Javascript,Jquery,Pdf Generation,我有一个php页面,其中包括表数据和一些漏斗图。我想将页面导出为带有页眉和页脚的pdf格式 有谁能告诉我如何使用javascript、jquery或任何其他形式导出它吗 感谢您使用FPDF,您可以从链接下载,有关更多信息,请参阅 之后,您可以按如下方式进行集成 <?php require_once('fpdf.php'); class PDF extends FPDF { function Header() { $query='your query';
感谢您使用FPDF,您可以从链接下载,有关更多信息,请参阅 之后,您可以按如下方式进行集成
<?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');
?>
尝试
mPdf
或fPdf
PHP库……您可以使用或导出pdf。由于您使用PHP生成页面,我认为最好的选择是使用TCPDF包。它具有强大的定制功能,配置起来更简单。感谢@Yadav,我发现它对我的需求非常有用。你能告诉我如何使用fpdf添加表格和图形吗?我有一个页面,其中有一些表格和漏斗图,一个接一个…让我知道如何在上面添加它code@mac你的图表是图像形式的吗?@你必须表手动,因为我已经根据我的需要和图像,让我给你的方式漏斗图是图像格式。。
$this->Image('image path',80,30,50);