|
日時: 2013/03/16 04:18
名前: lightbox
|
拡張子:
function text( $pdf, $x=0, &$y=0, $txt='', $w=1, $h=0 ) {
$a = $pdf->GetX();
$b = $pdf->GetY();
$hm = $pdf->getPageHeight( );
$dm = $pdf->getPageDimensions();
$tm = $dm['tm'];
$bm = $dm['bm'];
$txt = str_replace( "\r","", $txt );
$data = explode("\n", $txt );
if ( count( $data ) > 1 ) {
for( $i = 0; $i < count($data); $i++ ) {
if ( $i == 0 ) {
$pdf->SetXY( $x, $y );
}
else {
$y += $pdf->getLastH();
if ( $y >= ( $hm - $tm - $bm ) ) {
$pdf->AddPage();
$y = $tm;
}
$pdf->SetXY( $x, $y );
}
$pdf->Cell($w, $h, $data[$i], 0, 0, 'L');
}
}
else {
$pdf->SetXY( $x, $y );
$pdf->Cell($w, $h, $txt, 0, 0, 'L');
}
$y += $pdf->getLastH();
$pdf->SetXY($a,$b);
}
|