我想为巴士代理商制作一张发票,左上角是他们的标志,右上角是他们的地址。然后在中间他们的信息名称,姓氏,destinatin,成本..等 然后在底部可能会有更多信息.. 构建它需要花费很多时间,但我想也许有一个已经制作好的脚本,所以如果有人知道我需要你的帮助,那么我将节省很多时间。
感谢您的时间和帮助。
答案 0 :(得分:0)
我使用FILE_PDF PHP库做了类似的事情。它以dates[]
或hours[]
的形式获取POST数据并用它填充表。这是我的一些代码,它不完美但它可能会给你一个开始
$tasks = array("dates","descriptions","hours","minutes");
foreach($tasks as $name)
{
$$name = explode("\n",$_POST[$name]);
}
for ($i=0;$i<count($descriptions);$i++)
{
$data[]=array("dates"=>$dates[$i],"descriptions"=>$descriptions[$i],"hours"=>$hours[$i],"minutes"=>$minutes[$i]);
}
$p = &File_PDF::factory('P','mm','A4');
$p->open();
$p->setMargins(25, 25);
$p->addPage('P');
$p->setFont('arial', '', 24);
$p->cell(0, 9, "Invoice", 0, 1, 'C');
$p->setFont('arial', '', 14);
$p->write(6,date("F j, Y"));
$p->newLine();
$p->write(6,"Invoice #DIM-09-10-001");
$p->newLine();
$p->write(6,"Invoice for X");
$p->newLine();
$p->newLine();
$p->setFont('arial', '', 12);
$p->write(10, 'Work performed @ hourly rate of $20.00');
$p->newLine();
$p->newLine();
$widths = array(23,90,15,25);
$header = array("Date","Task","","Time");
foreach($header as $num=>$col)
$p->Cell($widths[$num],7,$col,"B");
$p->newLine();
foreach($data as $row)
{
$i=0;
foreach($row as $name=>$col)
{
$p->Cell($widths[$i],10,$col,0);
$i++;
}
$p->newLine();
}
$table_footer = array(array("","Total Time",'8 hours @ $20/hour'),array("","Total Fees Due",'$160'));
$widths = array(80,35,40);
$borders = array(array(0,"T","T"));
foreach($table_footer as $rownum=>$row)
{
foreach($row as $num=>$col)
$p->Cell($widths[$num],10,$col,$borders[$rownum][$num]);
$p->newLine();
}
$p->write(10,"Please make check payable to ");
$p->setFontStyle("B");
$p->write(10,"David Mihal");
$p->newLine();
$p->newLine();
$p->setFontStyle("I");
$p->write(4,"All invoices are due and payable within 30 days. Thank you for your prompt attention to this invoice and for your continued business.");
$p->close();
$p->output('invoice.pdf',true);