从 php 生成 PDF 报告 [英] Generate PDF report from php

查看:29
本文介绍了从 php 生成 PDF 报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using php code to query to a database and the results will be used to generate a report.

如果我想以pdf格式生成报告,我应该怎么做?

If I want the report to be generated in a pdf format how should I do it ?

推荐答案

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

If you need UTF support in your PDF file, consider tcpdf library.

从这里下载:http://www.tecnick.com/public/code/cp_dpage.php?aiocp_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');
?>

这篇关于从 php 生成 PDF 报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆