pdf.php 1.35 KB
<?php
require 'functions.php';
// memanggil library FPDF
require('fpdf.php');
// intance object dan memberikan pengaturan halaman PDF
$pdf = new FPDF('l', 'mm', 'A4');
// membuat halaman baru
$pdf->AddPage();
// setting jenis font yang akan digunakan
$pdf->SetFont('Arial', 'B', 16);
// mencetak string 
$pdf->Cell(270, 7, 'DAFTAR AKUN USER', 0, 1, 'C');
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(270, 7, 'DAFTAR AKUN APLIKASI E-Compliment', 0, 1, 'C');

// Memberikan space kebawah agar tidak terlalu rapat
$pdf->Cell(10, 7, '', 0, 1);

$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(20, 6, 'Nama', 1, 0);
$pdf->Cell(25, 6, 'Alamat', 1, 0);
$pdf->Cell(27, 6, 'NIK', 1, 0);
$pdf->Cell(35, 6, 'Jenis Kelamin', 1, 0);
$pdf->Cell(25, 6, 'Email', 1, 0);
$pdf->Cell(65, 6, 'Tempat Tanggal Lahir', 1, 0);
$pdf->Cell(25, 6, 'Pekerjaan', 1, 0);
$pdf->Cell(25, 6, 'Username', 1, 1);

$pdf->SetFont('Arial', '', 10);

$mahasiswa = mysqli_query($conn, "select * from user");
while ($row = mysqli_fetch_array($mahasiswa)) {
    $pdf->Cell(20, 6, $row['nama'], 1, 0);
    $pdf->Cell(25, 6, $row['alamat'], 1, 0);
    $pdf->Cell(27, 6, $row['nim'], 1, 0);
    $pdf->Cell(35, 6, $row['jenis'], 1, 0);
    $pdf->Cell(25, 6, $row['email'], 1, 0);
    $pdf->Cell(65, 6, $row['TTL'], 1, 0);
    $pdf->Cell(25, 6, $row['pekerjaan'], 1, 0);
    $pdf->Cell(25, 6, $row['username'], 1, 1);
}

$pdf->Output();