Do you know how to add a space or tab on fpdf? I used table and change cell function but still not working.
I want to add "keperluan" besides "jakarta" like in the picture below.
And here is the source code :
<?php
require('../fpdf17/fpdf.php');
require('../koneksi.php');
class PDF extends FPDF
{
function LoadDataFromSQL($sql)
{
$hasil=mysql_query($sql) or die(mysql_error());
$data = array();
while($rows=mysql_fetch_array($hasil)){
$data[] = $rows;
}
return $data;
}
// Colored table
function FancyTable($header, $data)
{
// Colors, line width and bold font
$this->SetFillColor(255,255,255);
$this->SetTextColor(0);
$this->SetDrawColor(0,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
// Header
$w = array(65,65,30,30);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],0,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
foreach($data as $row)
{
/* $this->Cell($w[0],6,'1. Uang Harian Pegawai','LR',0,'L',$fill);
$this->Cell($w[1],6,$row[uangharian],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[totaluangharian],'LR',0,'L',$fill);
$this->Cell($w[3],6,' ','LR',0,'C',$fill);
$this->Ln();
$this->Cell($w[0],6,'2. Uang Tunjangan PDLN','LR',0,'L',$fill);
$this->Cell($w[1],6,$row[tunjangan],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[totatunjangan],'LR',0,'L',$fill);
$this->Cell($w[3],6,' ','LR',0,'C',$fill);
$this->Ln();
$this->Cell($w[0],6,'3. Uang Taksi Bandara LN Pegawai','LR',0,'L',$fill);
$this->Cell($w[1],6,$row[taksiln],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[totaltaksiln],'LR',0,'L',$fill);
$this->Cell($w[3],6,' ','LR',0,'C',$fill);
$this->Ln();
$this->Cell($w[0],6,'','LR',0,'C',$fill);
$this->Cell($w[1],6,'Sub Total USD','LR',0,'R',$fill);
$this->Cell($w[2],6,$row[totalusd],'LR',0,'L',$fill);
$this->Cell($w[3],6,' ','LR',0,'C',$fill);
$this->Ln();
$this->Cell($w[0],6,'5. Uang Taksi Bandara DN','LR',0,'L',$fill);
$this->Cell($w[1],6,$row[taksidn],'LR',0,'L',$fill);
$this->Cell($w[2],6,'','LR',0,'C',$fill);
$this->Cell($w[3],6,$row[totaltaksidn],'LR',0,'L',$fill);
$this->Ln();
$this->Cell($w[0],6,'','LR',0,'L',$fill);
$this->Cell($w[1],6,'Sub Total Rupiah','LR',0,'R',$fill);
$this->Cell($w[2],6,'','LR',0,'C',$fill);
$this->Cell($w[3],6,$row[totalrupiah],'LR',0,'L',$fill);
$this->Ln();
$this->Cell($w[0],6,'4. Airport Tax Pegawai','LR',0,'L',$fill);
$this->Cell($w[1],6,$row[airporttax].' Rupiah','LR',0,'L',$fill);
$this->Cell($w[2],6,'','LR',0,'C',$fill);
$this->Cell($w[3],6,$row[airporttax].' Rupiah' ,'LR',0,'L',$fill);
$this->Ln();
$fill = !$fill; */
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
function FancyTables($headers, $data)
{
// Colors, line width and bold font
$this->SetFillColor(255,255,255);
$this->SetTextColor(0);
$this->SetDrawColor(255,255,255);
$this->SetLineWidth(.3);
$this->SetFont('','',11);
// Header
$w = array( 35,40,40,40, 35);
for($i=0;$i<count($headers);$i++)
$this->Cell($w[$i],7,$headers[$i],1,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(0,0,0);
$this->SetTextColor(0);
$this->SetFont('','',7);
// Data
$fill = false;
foreach($data as $row)
{
$this->Cell($w[0],6,'','LR',0,'C');
$this->Cell($w[1],6,' ','LR',0,'C');
$this->Cell($w[2],6,' ','LR',0,'C');
$this->Cell($w[3],6,' ','LR',0,'C');
$this->Cell($w[4],6,' ','LR',0,'C');
$this->Ln();
$this->Ln();
$this->Ln();
$this->Cell($w[0],6,'______________________','LR',0,'C',$fill);
$this->Cell($w[1],6,'_________________________','LR',0,'C',$fill);
$this->Cell($w[2],6,'_________________________','LR',0,'C',$fill);
$this->Cell($w[3],6,'_________________________','LR',0,'C',$fill);
$this->Cell($w[4],6,'______________________','LR',0,'C',$fill);
$this->Ln();
$this->Cell($w[0],6,$row['pegawai_EmployeeName'],'LR',0,'C',$fill);
$this->Cell($w[1],6,' ','LR',0,'C',$fill);
$this->Cell($w[2],6,' ','LR',0,'C',$fill);
$this->Cell($w[3],6,' ','LR',0,'C',$fill);
$this->Cell($w[4],6,' ','LR',0,'C',$fill);
$this->Ln();
$fill = !$fill;
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf = new PDF();
// Column headings
$pdf->addPage();
$pdf->setAutoPageBreak(true);
$pdf->setFont('Times','B',14);
$pdf->text(50,8,'FORMULIR PERMINTAAN KENDARAAN');
$pdf->setFont('Times','B',6);
$pdf->FancyTable($header,$data);
$pdf->Ln(50);
$headers = array('Pemohon,', 'KaDept. Pemohon,','KaBag Transport,', 'KaDept Transport,','Pool,');
$id=$_GET['id'];
$nip = $_GET['nip'];
$sql=mysql_query("SELECT * FROM formulir where RequestNumber = '$id' ") or die(mysql_error());
$data=mysql_fetch_array($sql);
$tanggalberangkat = $data['tglberangkat'];
$berangkat = date('d F Y', strtotime($tanggalberangkat));
$tanggalpulang = $data['tglpulang'];
$pulang = date('d F Y', strtotime($tanggalpulang));
$query3 = "SELECT * FROM formulir where RequestNumber = '$id'";
$rowSet3 = mysql_query($query3);
$row3 = mysql_fetch_array($rowSet3);
$pdf->setFont('Times','B',11);
$pdf->Cell(6,10,'Request Number',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,10,' : '.$data['RequestNumber'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,0.5,'Employee',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,0.5,' : '.$data['pegawai_EmployeeName'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,10,'NIK',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,10,' : '.$data['pegawai_EmployeeID'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,0.5,'Bagian',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,0.5,' : '.$data['jabatan'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,10,'Departemen',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,10,' : '.$data['Departemen'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,0.5,'Dipergunakan',0,0);
$pdf->setFont('Times','',11);
$pdf->Cell(6,0.5,' : '.$berangkat,0,0);
$pdf->Cell(6,0.5,' Pukul : '.$data['jamkeberangkatan'],0,1,'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,10,'Jenis Kendaraan',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,10,' : '.$data['tujuan'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,0.5,'Tujuan',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,0.5,' : '.$data['tujuan'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,10,'Keperluan',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,10,' : '.$data['keperluan'],0,1, 'L');
$pdf->setFont('Times','B',11);
$pdf->Cell(6,0.5,'Catatan',0,0,'L');
$pdf->setFont('Times','',11);
$pdf->Cell(6,0.5,' : '.$data['catatan'],0,1, 'L');
$query = "SELECT * FROM formulir where RequestNumber = '$id' ";
$data = $pdf->LoadDataFromSQL($query);
$pdf->Ln(20);
$pdf->SetFont('Times','',12);
$pdf->FancyTables($headers,$data);
$pdf->Output();
$pdf->Ln;
?>
Thank you so much for your help
Just change this line
to be like this
or you can add blank cell before break the line cell... remember
$pdf->cell($width,$height,0,1,'L')
1
mean break and go to the next line