Source from fpdf.org
pdfClass.php
require('class/fpdf/fpdf.php');
require('class/fpdi/fpdi.php');
class PDF extends FPDI
{
function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $maxline=0)
{
//Output text with automatic or explicit line breaks, maximum of $maxlines
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r", '', $txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$b=0;
if($border)
{
if($border==1)
{
$border='LTRB';
$b='LRT';
$b2='LR';
}
else
{
$b2='';
if(is_int(strpos($border, 'L')))
$b2.='L';
if(is_int(strpos($border, 'R')))
$b2.='R';
$b=is_int(strpos($border, 'T')) ? $b2.'T' : $b2;
}
}
$sep=-1;
$i=0;
$j=0;
$l=0;
$ns=0;
$nl=1;
while($i<$nb)
{
//Get next character
$c=$s[$i];
if($c=="\n")
{
//Explicit line break
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
$i++;
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border and $nl==2)
$b=$b2;
if ( $maxline && $nl > $maxline )
return substr($s, $i);
continue;
}
if($c==' ')
{
$sep=$i;
$ls=$l;
$ns++;
}
$l+=$cw[$c];
if($l>$wmax)
{
//Automatic line break
if($sep==-1)
{
if($i==$j)
$i++;
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
}
else
{
if($align=='J')
{
$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
$this->_out(sprintf('%.3f Tw', $this->ws*$this->k));
}
$this->Cell($w, $h, substr($s, $j, $sep-$j), $b, 2, $align, $fill);
$i=$sep+1;
}
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border and $nl==2)
$b=$b2;
if ( $maxline && $nl > $maxline )
return substr($s, $i);
}
else
$i++;
}
//Last chunk
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
if($border and is_int(strpos($border, 'B')))
$b.='B';
$this->Cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill);
$this->x=$this->lMargin;
return '';
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','',8);
$this->Cell(0,10,'N I G H T P A I N T I N G . C O M . A U - Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
drawPDF.php
include "__pdfClass.php";
$pdf = new PDF();
$pageLimitRow = 230; //페이지당 길이 제한
/* example
$pdf->AddFont('rlight','L','Rajdhani-Light.php');
$pdf->AddFont('rlight','','Rajdhani-Regular.php');
$pdf->AddFont('rlight','B','Rajdhani-Medium.php');
$pdf->AddFont('rlight','XB','Rajdhani-Bold.php');
*/
$pdf->SetMargins(0,0,0);
$pdf->AddPage();
$pdf->AliasNbPages();
$rightY = 50;
$pdf->SetTextColor(60,177,232);
$pdf->SetFont('rlight','XB',20);
$pdf->SetXY(76, $rightY); $pdf->Cell(127, 1, "TEXT", 0, 0, 'L');