Friday, March 25, 2016

Cara Export Data PHP Menjadi File PDF

Cara Export Data PHP Menjadi File PDF
Juragan codingmerubah data web menjadi PDF di PHP dengan library FPDF
Halo bro kali ini juragan coding akan memberikan tutorial cara eksport data di PHP menjadi sebuah file
pdf yang bias download, konsep ini sangat cocok untuk loe yang akan membuat website seperti
penerimaan siswa baru dengan codeignitr atau aplikasi CRUD yang kompleks dengan PHP, untuk
membuat file pdf disini gw menggunakan library FPDF jadi di tutorial kali gw akan ngejelasin dari mulai
cara install sampai tahap pembuatan langsung saja di simak
Pertama download fpdf di bawah ini
Setelah di download include kan ke file php loe
Untuk melihat hasilnya silahkan copy script di bawah ini
Cara Export Data PHP Menjadi File PDF


<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'www.juragancoding.com');
$pdf->Output();
?>

Nah jika loe masih bingung bias di coba scipt di bawah ini


<?php
require('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','',9);
// Move to the right
$this->Cell(48);
// Title
$this->Cell(10,-2,'YAYASAN PEMBINA LEMBAGA PENDIDIKAN DASAR DAN MENENGAH
PGRI',0,'C');
// Line break
$this->Ln(4);
// Arial bold 15
$this->SetFont('Arial','',9);
// Move to the right
$this->Cell(58);
// Title
$this->Cell(10,-2,'(YPLP DIKDASMEN PGRI) KABUPATEN BANDUNG BARAT',0,'C');
// Line break
$this->Ln(5);
// Arial bold 15
$this->SetFont('Arial','B',14);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(10,-2,'SMK PGRI LEMBANG',0,'C');
// Line break
$this->Ln(5);
// Arial bold 15
$this->SetFont('Arial','',9);
// Move to the right
$this->Cell(40);
// Title
$this->Cell(10,-2,'Terakreditasi B (SK-BAN- S/M PROPINSI JAWA BARAT NO.
02.00/694/BP-SM/X/2011)',0,'C');
// Line break
$this->Ln(4);
// Arial bold 15
$this->SetFont('Arial','',8);
// Move to the right
$this->Cell(30);
// Title
$this->Cell(10,-2,'Jl.Barulaksana No.65 Kec. Lembang Kabupaten Bandung
Barat | Tlp : (021) 8767655 www.smkpgrilembang.sch.id',0,'C');
$this->Ln(4);
$this->cell(190,0.2,'','0','1','C',true);
$this->Ln(5);
$this->SetFont('Times','',12);
$this->Cell(10,-2,'Nama : M Candra Hamdani',0,'C');
$this->SetFont('Times','',12);
$this->Cell(130);
$this->Cell(10,-2,'Program Studi : TKJ',0,'C');
$this->Ln(5);
$this->SetFont('Times','',12);
$this->Cell(10,-2,'Kelas : Xi Semester 2',0,'C');
$this->SetFont('Times','',12);
$this->Cell(130);
$this->Cell(10,-2,'Ranking : 1',0,'C');
// Line break
$this->Ln(6);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'www.smkpgrilembang.sch.id',0,0,'C');
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->Cell(0,10,'Mohon maaf masih dalam perbaikan');
$pdf->Output();
?>

Artikel Terkait