我正在使用fpdf生成Invoice,如示例FPDF - Invoice
中所示我在一张发票中有多个订单项。如果它超过了第1页,它必须通过保持表格格式保持原样自动转到下一页,这在此不会发生。
有人可以建议我吗?
这是我生成pdf的代码
$cols=array( "HSN/SAC" => 17,
"Description" => 45,
"Price" => 15,
"Qty" => 13,
"Disc%" => 10,
"Taxable Amt" => 20,
);
$pdf->addCols( $cols);
$cols=array( "HSN/SAC" => "L",
"Description" => "L",
"Price" => "L",
"Qty" => "L",
"Disc%" => "L",
"Taxable Amt" => "L",
);
$pdf->addLineFormat( $cols);
$pdf->addLineFormat($cols);
$y = 133;
$tamt1 =0;
$iamt =0;
$qty1 = 0;
while($row = mysqli_fetch_array($query))
{
$desc = $row['description'] ;
$total = $row['sub_total']+$row['tax_amount'];
$line = array( "HSN/SAC" => "".$row['hsn_sac']."",
"Description" => "".$row['name']." - ". html_entity_decode(strip_tags($desc)) ,
"Price" => "".$row['selling_price']."",
"Qty" => "".$row['quantity']."",
"Disc%" => "".$row['discount']."",
"Taxable Amt" => "".number_format(($row['total']),2)."",
);
$size = $pdf->addLine( $y, $line );
$y += $size + 10;
$total_amt += $row['total'];
$tax_amt += $row['tax_amount'];
$qty1 += $row['quantity'];
}
这是addCols
函数
function addCols( $tab )
{
global $colonnes;
$r1 = 9;
$r2 = $this->w - ($r1 * 1.9) ;
$y1 = 120;
$y2 = $this->h - 60 - $y1;
$this->SetXY( $r1, $y1 );
$this->Rect( $r1, $y1, $r2, $y2, "D");
$this->Line( $r1, $y1+6, $r1+$r2, $y1+7);
$colX = $r1;
$colonnes = $tab;
while ( list( $lib, $pos ) = each ($tab) )
{
$this->SetXY( $colX, $y1+2 );
$this->SetFont( "", "B", 7);
$this->Cell( $pos, 2, $lib, 0, 0, "C");
$colX += $pos;
$this->SetFont( "", "", 7);
$this->Line( $colX, $y1, $colX, $y1+$y2);
}
}