0

如何使用 MYSQL 查询超过 15 个字段和换行文本生成 PDF 文档?我已经使用 fpdf 选项生成了 PDF。但我只创建了 8 个没有换行文本的字段。所以请任何人解决解决方案。谢谢。

例如。我用 nowrap 文本创建。

$pdf=new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(4,126,167);
$pdf->Cell(10,10,'Worksheet Report');
$pdf->Ln();

//Column titles
$header=array('Client','Team In Charge','Staff In Charge','Priority','Master Activity','Sub Activity','Last Reports Sent','Job in Hand','Team Incharge Notes','External Due Date','Befree Due Date','Status');
$pdf->SetFont('Arial','B',6);
$pdf->FancyTable($header);

$pdf->SetFont('Arial','',5);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetLineWidth(.2);
$sql=$_SESSION['query'];
$result = mysql_query($sql);
while($row = @mysql_fetch_array($result)){
$pdf->Cell(15,10,htmlspecialchars($row["lp_wrk_CompanyName"]),1,0,'T',true);
$pdf->Cell(17,10,$commonUses->getFirstLastName($row["wrk_TeamInCharge"]),1,0,'T',true);
$pdf->Cell(17,10,$commonUses->getFirstLastName($row["wrk_StaffInCharge"]),1,0,'T',true);
$pdf->Cell(12,10,htmlspecialchars($row["lp_wrk_priority"]),1,0,'T',true);
$pdf->Cell(17,10,htmlspecialchars($row["lp_wrk_MasCode"]).($row["lp_wrk_MasCode"]!=""? "-":"").htmlspecialchars($row["lp_wrk_MasterActivity"]),1,0,'T',true);
$pdf->Cell(15,10,htmlspecialchars($row["lp_wrk_SubCode"]).($row["lp_wrk_SubCode"]!=""? "-":"").htmlspecialchars($row["lp_wrk_SubActivity"]),1,0,'T',true);
$pdf->Cell(19,10,htmlspecialchars($row["wrk_Details"]),1,0,'T',true);
$pdf->Cell(18,10,htmlspecialchars($row["wrk_Notes"]),1,0,'T',true);
$pdf->Cell(19,10,htmlspecialchars($row["wrk_TeamInChargeNotes"]),1,0,'T',true);
$pdf->Cell(18,10,$commonUses->showGridDateFormat($row["wrk_DueDate"]),1,0,'T',true);
$pdf->Cell(18,10,$commonUses->showGridDateFormat($row["wrk_InternalDueDate"]),1,0,'T',true);

$pdf->Cell(15,10,htmlspecialchars($row["lp_wrk_Status"]),1,0,'T',true);
$pdf->Ln();
}
4

4 回答 4

3

有一个名为DocRaptor的网络服务,它使用 Prince 从 html 生成 pdf 和 xls。他们提供免费计划以及更大的付费计划。

于 2010-11-06T00:08:01.033 回答
0

检查此网络链接:- http://qualitypoint.blogspot.com/2010/07/resolved-wrap-text-issue-in-fpdf-table.html http://blog.themeforest.net/tutorials/how-to -create-pdf-files-with-php/

我希望它对你有用:)

于 2010-11-02T09:21:04.240 回答
0

我的建议是用 html 打印表格,而不是转换为 pdf:更容易、更快、更灵活:当您拥有 html 文档时,如果您需要,将很容易(例如)转换为 jpg到未来。

如果你可以在你的服务器上安装软件,我推荐你wkhtmltopdf

您生成 html 文件,然后 wkhtmltopdf 将其转换为 pdf,并具有完整的(基于 webkit 的)css 支持。

否则,我发现html2ps做得很好,但处理大文件时速度很慢。. css 支持很好,但不能保证它会支持 css3,例如。

于 2010-11-06T00:12:59.220 回答
0

看看dompdf类。它从您的 html 代码生成 pdf,因此可以更轻松快捷地获得所需的结果。花车仍然有点挑剔,所以你必须想象你在 90 年代并做一个基于桌子的设计。

于 2010-11-02T12:07:10.953 回答