【问题标题】:pdf invoice from php来自php的pdf发票
【发布时间】:2011-05-14 18:37:02
【问题描述】:

我想为巴士公司开一张发票,他们的标志在左上角,他们的地址在右上角。然后在中间他们的信息名称,姓氏,destinatin,成本..等。 然后在底部可能有更多信息.. 构建它需要很多时间,但我想也许某个地方已经为此制作了脚本,所以如果有人知道,我需要你的帮助,然后我会抽出很多时间。

感谢您的时间和帮助。

【问题讨论】:

标签: php pdf pdf-generation


【解决方案1】:

我使用 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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-20
    • 2022-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多