Fix problem with PDF and the empty page due a wrong page break

This commit is contained in:
Dany De Bontridder 2016-01-25 23:50:14 +01:00
parent 0c1e780b5d
commit 41989ff6fa
4 changed files with 46 additions and 40 deletions

View file

@ -54,10 +54,10 @@ class Print_Ledger_Detail_Item extends PDFLand
$this->Ln(20);
$high=6;
$this->SetFont('DejaVu', '', 6);
$this->LongLine(20, $high, _('Date'),0, 'L', false);
$this->Cell(20, $high, _('Date'),0, 'L', false);
$this->Cell(20, $high, _('Numéro interne'), 0, 0, 'L', false);
$this->LongLine(50, $high, _('Code'),0,'L',false);
$this->LongLine(80, $high, _('Libellé'),0,'L',false);
$this->Cell(50, $high, _('Code'),0,'L',false);
$this->Cell(80, $high, _('Libellé'),0,'L',false);
$this->Cell(20, $high, _('Tot HTVA'), 0, 0, 'R', false);
$this->Cell(20, $high, _('Tot TVA NP'), 0, 0, 'R', false);
$this->Cell(20, $high, "", 0, 0, 'R', false);
@ -144,7 +144,7 @@ class Print_Ledger_Detail_Item extends PDFLand
$this->write_cell(20,$high,'Code TVA');
$this->write_cell(20,$high,'TVA',0,0,'R');
$this->write_cell(20,$high,'TVAC',0,0,'R');
$this->Ln(6);
$this->line_new(6);
$this->show_col=false;
}
}
@ -161,7 +161,7 @@ class Print_Ledger_Detail_Item extends PDFLand
$this->write_cell(20,$high,nbm($row['vat']),0,0,'R');
$sum=bcadd($row['price'],$row['vat']);
$this->write_cell(20,$high,nbm($sum),0,0,'R');
$this->Ln(6);
$this->line_new(6);
}
}

View file

@ -38,7 +38,7 @@ class Print_Ledger_Misc extends PDF
//Title
$this->Cell(0,10,$this->dossier, 'B', 0, 'C');
//Line break
$this->line_new(20);
$this->Ln(20);
$this->SetFont('DejaVu', 'B', 7);
$this->Cell(30,6,'Piece');
$this->Cell(10,6,'Date');
@ -56,10 +56,10 @@ class Print_Ledger_Misc extends PDF
//Arial italic 8
$this->SetFont('Arial', 'I', 8);
//Page number
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->Cell(0,6,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->Ln(3);
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
$this->Cell(0,6,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
}
/**
*@brief print the pdf
@ -77,6 +77,7 @@ class Print_Ledger_Misc extends PDF
for ( $i=0;$i<count($a_jrn);$i++)
{
$row=$a_jrn[$i];
$this->LongLine(30,5,$row['jr_pj_number']);
$this->write_cell(10,5, smaller_date($row['date']));
$this->write_cell(20,5,$row['jr_internal']);

View file

@ -77,9 +77,9 @@ class Print_Ledger_Simple extends PDF
//Arial bold 12
$this->SetFont('DejaVu', 'B', 12);
//Title
$this->write_cell(0,10,$this->dossier, 'B', 0, 'C');
$this->Cell(0,10,$this->dossier, 'B', 0, 'C');
//Line break
$this->line_new(20);
$this->Ln(20);
$this->SetFont('DejaVu', 'B', 8);
/* column header */
//----------------------------------------------------------------------
@ -90,46 +90,46 @@ class Print_Ledger_Simple extends PDF
$tmp1=$line_tva['tva_id'];
$this->rap_tva[$tmp1]=(isset($this->rap_tva[$tmp1]))?$this->rap_tva[$tmp1]:0;
}
$this->write_cell(15,6,'Pièce');
$this->write_cell(10,6,'Date');
$this->write_cell(13,6,'ref');
$this->Cell(15,6,'Pièce');
$this->Cell(10,6,'Date');
$this->Cell(13,6,'ref');
if ( $this->jrn_type=='ACH')
$this->write_cell(40,6,'Client');
$this->Cell(40,6,'Client');
else
$this->write_cell(40,6,'Fournisseur');
$this->Cell(40,6,'Fournisseur');
$flag_tva=(count($this->a_Tva) > 4)?true:false;
if ( !$flag_tva ) $this->write_cell(65,6,'Description');
if ( !$flag_tva ) $this->Cell(65,6,'Description');
$this->write_cell(15,6,'HTVA',0,0,'R');
$this->Cell(15,6,'HTVA',0,0,'R');
if ( $this->jrn_type=='ACH')
{
$this->write_cell(15,6,'Priv/DNA',0,0,'R');
$this->write_cell(15,6,'TVA ND',0,0,'R');
$this->Cell(15,6,'Priv/DNA',0,0,'R');
$this->Cell(15,6,'TVA ND',0,0,'R');
}
$this->write_cell(15,6,'TVA NP',0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
$this->Cell(15,6,'TVA NP',0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
foreach($this->a_Tva as $line_tva)
{
$this->write_cell(15,6,$line_tva['tva_label'],0,0,'R');
$this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
}
$this->write_cell(15,6,'TVAC',0,0,'R');
$this->line_new(5);
$this->Cell(15,6,'TVAC',0,0,'R');
$this->Ln(5);
$this->SetFont('DejaVu','',6);
// page Header
$this->write_cell(143,6,'report',0,0,'R');
$this->write_cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
$this->Cell(143,6,'report',0,0,'R');
$this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
if ( $this->jrn_type != 'VEN')
{
$this->write_cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
$this->write_cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
$this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
$this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
}
$this->write_cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
$this->Cell(15,6,nbm($this->rap_tva_np),0,0,'R'); /* Tva ND */
foreach($this->rap_tva as $line_tva)
$this->write_cell(15,6,nbm($line_tva),0,0,'R');
$this->write_cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
$this->Cell(15,6,nbm($line_tva),0,0,'R');
$this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
$this->line_new(6);
$this->Ln(6);
//total page
$this->tp_htva=0.0;
$this->tp_tvac=0.0;

View file

@ -157,16 +157,21 @@ class PDF extends TFPDF
* nombre de lignes que le texte prendrait. Ensuite il faut
* faire un saut de page (renvoit true) si dépasse
*/
$sizetext=$this->GetStringWidth($this->cells[$i]->text);
// if text bigger than column width then check
$y=$this->GetY();
$nb_row=$this->count_nb_row($this->cells[$i]->text, $this->cells[$i]->width);
$height=$this->cells[$i]->height*$nb_row;
$sizetext=$this->GetStringWidth($this->cells[$i]->text);
// If the text is bigger than a sheet of paper then return false
if ($height >= $this->h) return false;
if ( $y + $height > ($this->h - $this->bMargin-20))
if ( $y + $height > ($this->h - $this->bMargin ))
return true;
}
}
return false;
@ -197,7 +202,7 @@ class PDF extends TFPDF
$a->align,
$a->fill
);
$x_m=$x_m+$this->cells[$i]->width;
$x_m=$x_m+$a->width;
$tmp=$this->GetY()-$y_m;
if ( $tmp > $this->bigger) $this->bigger=$tmp;
$this->SetXY($x_m,$y_m);
@ -349,7 +354,7 @@ class PDFLand extends PDF
//Title
$this->Cell(0,10,$this->dossier, 'B', 0, 'C');
//Line break
$this->line_new(20);
$this->Ln(20);
}
function Footer()
{
@ -359,7 +364,7 @@ class PDFLand extends PDF
$this->SetFont('DejaVuCond', 'I', 8);
//Page number
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
$this->line_new(3);
$this->Ln(3);
// Created by NOALYSS
$this->Cell(0,8,'Created by NOALYSS, online on http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
@ -394,7 +399,7 @@ class PDFBalance_simple extends PDF
$this->to);
$this->Cell(0,7,$titre,1,0,'C');
$this->line_new();
$this->Ln();
$this->SetFont('DejaVu','',6);
$this->Cell(20,7,'id','B');
$this->Cell(90,7,'Poste Comptable','B');
@ -402,7 +407,7 @@ class PDFBalance_simple extends PDF
$this->Cell(20,7,'Crédit','B',0,'L');
$this->Cell(20,7,'Solde','B',0,'L');
$this->Cell(20,7,'D/C','B',0,'L');
$this->line_new();
$this->Ln();
}
}