从php生成PDF报告

Ana*_*man 8 php pdf

我使用PHP代码查询数据库,结果将用于生成报告.

如果我希望以pdf格式生成报告,我该怎么办?

Sil*_*ght 12

如果您需要PDF文件中的UTF支持,请考虑tcpdf库.

从这里下载:http://www.tecnick.com/public/code/cp_dpage.php?beforepp_dp = tcpdf

在你的脚本中:

<?php
//include files
require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/config/lang/eng.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 

//add some content using class methods

//Close and output PDF document
$pdf->Output('filename.pdf', 'I');
?>
Run Code Online (Sandbox Code Playgroud)