Untitled diff

Created Diff never expires
39 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
112 lines
18 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
91 lines
function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
function GetMultiCellHeight($w, $h, $txt, $border=null, $align='J') {
{
// Calculate MultiCell with automatic or explicit line breaks height
// Output text with automatic or explicit line breaks
// $border is un-used, but I kept it in the parameters to keep the call
// to this function consistent with MultiCell()
$cw = &$this->CurrentFont['cw'];
$cw = &$this->CurrentFont['cw'];
if($w==0)
if($w==0)
$w = $this->w-$this->rMargin-$this->x;
$w = $this->w-$this->rMargin-$this->x;
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
$s = str_replace("\r",'',$txt);
$s = str_replace("\r",'',$txt);
$nb = strlen($s);
$nb = strlen($s);
if($nb>0 && $s[$nb-1]=="\n")
if($nb>0 && $s[$nb-1]=="\n")
$nb--;
$nb--;
$b = 0;
if($border)
{
if($border==1)
{
$border = 'LTRB';
$b = 'LRT';
$b2 = 'LR';
}
else
{
$b2 = '';
if(strpos($border,'L')!==false)
$b2 .= 'L';
if(strpos($border,'R')!==false)
$b2 .= 'R';
$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
}
}
$sep = -1;
$sep = -1;
$i = 0;
$i = 0;
$j = 0;
$j = 0;
$l = 0;
$l = 0;
$ns = 0;
$ns = 0;
$nl = 1;
$height = 0;
while($i<$nb)
while($i<$nb)
{
{
// Get next character
// Get next character
$c = $s[$i];
$c = $s[$i];
if($c=="\n")
if($c=="\n")
{
{
// Explicit line break
// Explicit line break
if($this->ws>0)
if($this->ws>0)
{
{
$this->ws = 0;
$this->ws = 0;
$this->_out('0 Tw');
$this->_out('0 Tw');
}
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
//Increase Height
$height += $h;
$i++;
$i++;
$sep = -1;
$sep = -1;
$j = $i;
$j = $i;
$l = 0;
$l = 0;
$ns = 0;
$ns = 0;
$nl++;
if($border && $nl==2)
$b = $b2;
continue;
continue;
}
}
if($c==' ')
if($c==' ')
{
{
$sep = $i;
$sep = $i;
$ls = $l;
$ls = $l;
$ns++;
$ns++;
}
}
$l += $cw[$c];
$l += $cw[$c];
if($l>$wmax)
if($l>$wmax)
{
{
// Automatic line break
// Automatic line break
if($sep==-1)
if($sep==-1)
{
{
if($i==$j)
if($i==$j)
$i++;
$i++;
if($this->ws>0)
if($this->ws>0)
{
{
$this->ws = 0;
$this->ws = 0;
$this->_out('0 Tw');
$this->_out('0 Tw');
}
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
//Increase Height
$height += $h;
}
}
else
else
{
{
if($align=='J')
if($align=='J')
{
{
$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
}
}
$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
//Increase Height
$height += $h;
$i = $sep+1;
$i = $sep+1;
}
}
$sep = -1;
$sep = -1;
$j = $i;
$j = $i;
$l = 0;
$l = 0;
$ns = 0;
$ns = 0;
$nl++;
if($border && $nl==2)
$b = $b2;
}
}
else
else
$i++;
$i++;
}
}
// Last chunk
// Last chunk
if($this->ws>0)
if($this->ws>0)
{
{
$this->ws = 0;
$this->ws = 0;
$this->_out('0 Tw');
$this->_out('0 Tw');
}
}
if($border && strpos($border,'B')!==false)
//Increase Height
$b .= 'B';
$height += $h;
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
$this->x = $this->lMargin;
return $height;
}
}