TCPDF / FPDF - 分页问题
我正在尝试创建一个包含数据表的 PDF 文件。但是,当遇到分页符时,每次在断点级别将新的多单元格添加到页面时,它都会跳转到新页面。!?
我尝试对 TCPDF 执行完全相同的操作,但每次在分页点级别周围添加新单元格时,仍然会出现相同的分页问题...
示例:
http://www.online-økonomi.dk/_tst_fpdf.php
require_once '../class/download/fpdf/fpdf.php';
class File_PDF {
private $pdf;
private $col_product = 25;
private $col_unit = 12;
private $col_price = 20;
private $col_count = 14;
private $col_discount = 12;
private $col_vat = 12;
private $col_sum = 22;
private $width = 200;
private $line_height = 4.2;
private $margin_top = 30;
public function generate(){
$this->pdf = new FPDF();
$this->pdf->AddPage();
$this->pdf->SetDisplayMode('real');
$this->pdf->SetAutoPageBreak(true, 150);
if($this->products){
$i = 0;
$this->color_light();
foreach($this->products as $product){
$this->add_product($product, $i % 2 ? true:false);
$i++;
}
}
$this->pdf->Output();
}
private function add_product($product, $fill){
$this->txt();
$x = $this->width;
$y = $this->pdf->GetY();
$this->cell_sum($this->col_sum, $x, $y, $product['sum'] / 100, 'R', $fill);
$this->cell_vat($this->col_vat, $x, $y, $product['vat_percent'], 'R', $fill);
$this->cell_discount($this->col_discount, $x, $y, $product['discount_percent'] / 100, 'R', $fill);
$this->cell_count($this->col_count, $x, $y, $product['count'] / 100, 'R', $fill);
$this->cell_price($this->col_price, $x, $y, $product['price'] / 100, 'R', $fill);
$this->cell_unit($this->col_unit, $x, $y, $product['unit_name'], 'L', $fill);
$this->cell_name(0, $x, $y, $product['name'], 'L', $fill);
$this->cell_product($this->col_product, $x, $y, $product['product_id_'], 'L', $fill);
}
private function cell_sum($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_vat($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_discount($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_count($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_price($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_unit($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_name($width, &$x, $y, $str, $align, $fill=false){
$this->pdf->SetXY($this->col_product + 10, $y);
$this->pdf->MultiCell($x - $this->col_product - 10, $this->line_height, $str, 0, $align, $fill);
}
private function cell_product($width, &$x, $y, $str, $align, $fill=false){
$this->pdf->SetXY(10, $y);
$this->pdf->MultiCell($this->col_product, $this->line_height, $str, 0, $align, $fill);
}
private function cnstr_cell($width, &$x, $y, $str, $align='L', $fill=false){
$x -= $width;
$this->pdf->SetXY($x, $y);
$this->pdf->MultiCell($width, $this->line_height, $str, 0, $align, $fill);
}
private function color_light(){
$this->pdf->SetFillColor(200, 200, 200);
}
private function txt(){
$this->pdf->SetFont('Arial', '', 8.5);
}
private function txt_marked(){
$this->pdf->SetFont('Arial', 'B', 8.5);
}
private $products = array(
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
)
);
}
$PDF = new File_PDF();
$PDF->generate();
I'm trying to create a PDF file with a table of data.. But when a page break is met it jumps to a new page everytime a new multicell is added to the page at the break point level..!?
I have tried to do exactly the same with TCPDF, but still the same issue with a page break each time a new cell i added around the page break point level...
example:
http://www.online-økonomi.dk/_tst_fpdf.php
require_once '../class/download/fpdf/fpdf.php';
class File_PDF {
private $pdf;
private $col_product = 25;
private $col_unit = 12;
private $col_price = 20;
private $col_count = 14;
private $col_discount = 12;
private $col_vat = 12;
private $col_sum = 22;
private $width = 200;
private $line_height = 4.2;
private $margin_top = 30;
public function generate(){
$this->pdf = new FPDF();
$this->pdf->AddPage();
$this->pdf->SetDisplayMode('real');
$this->pdf->SetAutoPageBreak(true, 150);
if($this->products){
$i = 0;
$this->color_light();
foreach($this->products as $product){
$this->add_product($product, $i % 2 ? true:false);
$i++;
}
}
$this->pdf->Output();
}
private function add_product($product, $fill){
$this->txt();
$x = $this->width;
$y = $this->pdf->GetY();
$this->cell_sum($this->col_sum, $x, $y, $product['sum'] / 100, 'R', $fill);
$this->cell_vat($this->col_vat, $x, $y, $product['vat_percent'], 'R', $fill);
$this->cell_discount($this->col_discount, $x, $y, $product['discount_percent'] / 100, 'R', $fill);
$this->cell_count($this->col_count, $x, $y, $product['count'] / 100, 'R', $fill);
$this->cell_price($this->col_price, $x, $y, $product['price'] / 100, 'R', $fill);
$this->cell_unit($this->col_unit, $x, $y, $product['unit_name'], 'L', $fill);
$this->cell_name(0, $x, $y, $product['name'], 'L', $fill);
$this->cell_product($this->col_product, $x, $y, $product['product_id_'], 'L', $fill);
}
private function cell_sum($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_vat($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_discount($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_count($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_price($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_unit($width, &$x, $y, $str, $align, $fill=false){
$this->cnstr_cell($width, $x, $y, $str, $align, $fill);
}
private function cell_name($width, &$x, $y, $str, $align, $fill=false){
$this->pdf->SetXY($this->col_product + 10, $y);
$this->pdf->MultiCell($x - $this->col_product - 10, $this->line_height, $str, 0, $align, $fill);
}
private function cell_product($width, &$x, $y, $str, $align, $fill=false){
$this->pdf->SetXY(10, $y);
$this->pdf->MultiCell($this->col_product, $this->line_height, $str, 0, $align, $fill);
}
private function cnstr_cell($width, &$x, $y, $str, $align='L', $fill=false){
$x -= $width;
$this->pdf->SetXY($x, $y);
$this->pdf->MultiCell($width, $this->line_height, $str, 0, $align, $fill);
}
private function color_light(){
$this->pdf->SetFillColor(200, 200, 200);
}
private function txt(){
$this->pdf->SetFont('Arial', '', 8.5);
}
private function txt_marked(){
$this->pdf->SetFont('Arial', 'B', 8.5);
}
private $products = array(
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
),
array(
'product_id_' => 'ADS1550',
'name' => 'name',
'unit_name' => 'pcs',
'price' => 182450000,
'count' => 310000,
'discount_percent' => 19900,
'vat_percent' => 0,
'sum' => 1587057200
)
);
}
$PDF = new File_PDF();
$PDF->generate();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,在
Cell()
方法(在MultiCell()
中调用)中,如果当前 Y 位置 + 页面高度,FPDF 总是添加一个新页面。新单元格大于允许的页面高度。默认页面高度似乎是 297,使用
SetAutoPageBreak()
从中减去150
。因此,当Y
+cell_height
大于 147 时,在调用cnstr_cell()
时,您总是会得到一个新页面。为了防止这种情况,您需要自己调用
AddPage()
。在您的add_product()
方法中添加此检查:顺便说一句。我最近还必须生成动态 PDF,我最终使用了 wkhtmltopdf,它比所有 PHP 库。我建议看一下。
The problem is that in the
Cell()
method (which is called inMultiCell()
) FPDF allways adds a new page if the the current Y position + the height of the new cell is greater than the allowed page height.The default page height seems to be 297, with
SetAutoPageBreak()
you substract150
from it. So whenY
+cell_height
is graeter than 147 you allways get a new page when calling yourcnstr_cell()
.To prevent this you need to call
AddPage()
by yourself. Add this check in youradd_product()
method:Btw. I also had to generate a dynamic PDF recently, I ended up using wkhtmltopdf, it was way more easy to use and customize than all the PHP libraries. I suggest to take a look at it.