开发者

Generate PDF with PHP

how generate PDF document with MYSQL query more than 15 fields with wrap text? I have generated PDF with fpdf option. but I have created only 8 fields with nowrap text. so any one please solve the solutions. thanks.

For example. I have created with nowrap text.

$pdf=new PDF();
$pdf->AddPage(开发者_StackOverflow);
$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();
}


There's a webservice called DocRaptor that uses Prince to generate pdf and xls from html. They offer a free plan as well as larger paid plans.


check this web link :- 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/

I hope it is useful for you :)


Have a look at the dompdf class. It generates the pdf from your html code so it's much easier and quicker to get the results you want. It's still a bit finicky with floats so you have to imagine your are in the 90's and do a table based design.


My advice is to print out the table in html, than convert in into pdf: is easier, faster, and more flexible: when you have the html documents, will be easy (for example) convert into a jpg, if you'll need to in the future.

If you can install software on your server, i raccomend you wkhtmltopdf.

You generate the html file, and wkhtmltopdf convert it to pdf, with full (webkit based) css support.

Else, i've found that html2ps doeas a great job, but is quite slower with large files.. css support is good, but no guarantee that it will support css3, for example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜