Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "fpdf.php";
- //require "fpdfMultiCell.php";
- require "../../config.php";
- class PDF extends FPDF
- {
- /*
- function LoadDataFromSQL($sql)
- {
- $hasil = mysqli_query($konek,$sql)or die(mysqli_error($konek));
- $data = array();
- while($rows=mysqli_fetch_array($hasil)){
- $data[] = $rows;
- }
- return $data;
- }
- */
- // Colored table
- function FancyTable($header, $data)
- {
- // Colors, line width and bold font
- $this->SetFillColor(77,65,240);
- $this->SetTextColor(255);
- $this->SetDrawColor(128,0,0);
- $this->SetLineWidth(.3);
- $this->SetFont('','B');
- /* $w adalah variabel lebar dari kolom data
- dalam kasus ini, kolom no lebarnya 20, propinsi 100
- dan upah 60 */
- $w = array( 70, 50, 30, 50);
- for($i=0;$i<count($header);$i++)
- $this->Cell($w[$i],7,$header[$i],1,0,'C',true);
- $this->Ln();
- // tentukan warna background and fontnya
- $this->SetFillColor(224,235,255);
- $this->SetTextColor(0);
- $this->SetFont('');
- // Data
- $fill = false;
- foreach($data as $row)
- {
- $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
- $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
- $this->Cell($w[2],6,$row[2],'LR',0,'R',$fill);
- $this->Cell($w[3],6,$row[3],'LR',0,'R',$fill);
- $this->Ln();
- $fill = !$fill;
- }
- // Closing line
- $this->Cell(array_sum($w),0,'','T');
- }
- const DPI = 96;
- const MM_IN_INCH = 25.4;
- const A4_HEIGHT = 297;
- const A4_WIDTH = 210;
- // tweak these values (in pixels)
- const MAX_WIDTH = 400;
- const MAX_HEIGHT = 250;
- function pixelsToMM($val) {
- return $val * self::MM_IN_INCH / self::DPI;
- }
- function resizeToFit($imgFilename) {
- list($width, $height) = getimagesize($imgFilename);
- $widthScale = self::MAX_WIDTH / $width;
- $heightScale = self::MAX_HEIGHT / $height;
- $scale = min($widthScale, $heightScale);
- return array(
- round($this->pixelsToMM($scale * $width)),
- round($this->pixelsToMM($scale * $height))
- );
- }
- function centreImage($img) {
- list($width, $height) = $this->resizeToFit($img);
- // you will probably want to swap the width/height
- // around depending on the page's orientation
- $this->Image(
- /*$img, (self::A4_HEIGHT - $width) / 2,
- (self::A4_WIDTH - $height) / 2,*/
- $img,
- 10,
- 20,
- $width,
- $height
- );
- }
- // Page footer
- function Footer()
- {
- // Position at 1.5 cm from bottom
- $this->SetY(-15);
- $this->SetTextColor(0,0,0);
- // Arial italic 8
- $this->SetFont('Arial','I',8);
- // Page number
- $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
- }
- }
- $href = $_REQUEST['profile_id'];
- $pdf = new PDF();
- // header tabel
- $header = array('No Reg', 'Nama', 'Jenis Kriminal', 'foto');
- // buat query SQLmu disini
- //$query="select no_reg, nama, jenis_kriminal from bio_tr";
- $query = 'select *
- from
- bio_tr btr
- inner join
- bio_pl bpl
- inner join
- pasal psl
- inner join
- foto ft
- on
- btr.id_tr = ft.id_pemilik
- and
- btr.id_tr = psl.id_tersangka
- and
- btr.id_tr = bpl.pelapor_tr
- and
- btr.id_tr = '.$href.'
- order by
- ft.created
- desc
- limit 1';
- //$data = $pdf->LoadDataFromSQL($query);
- $hasil = mysqli_query($konek,$query)or die(mysqli_error($konek));
- $row = mysqli_fetch_array($hasil);
- /*
- $data = array();
- while($rows = mysqli_fetch_array($hasil)){
- $data[] = $rows;
- }
- */
- $pdf->AliasNbPages();
- $pdf->AddPage();
- //HEADER
- $pdf->SetFont('Arial','B', 15);
- $pdf->SetFillColor(48,126,204);
- $pdf->SetTextColor(255,255,255);
- $pdf->SetDrawColor(164,165,166);
- $pdf->SetLineWidth(.3);
- $pdf->Cell(190,10,'DATA IDENTITAS',0,1,'C',true);
- $pdf->Ln();
- //END HEADER
- $pdf->centreImage('../dataInsert/'.$row['dir_foto'].'');
- //tentukan ukuran dan jenis form
- $pdf->SetFont('Arial','',11);
- $pdf->SetTextColor(0);
- $pdf->setX(100);
- $pdf->Cell(40,5,'Nama',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.$row['nama'].'',1,0,'L');
- $pdf->Ln();
- $pdf->setX(100);
- $pdf->Cell(40,5,'No Induk Registrasi',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.substr($row['no_reg'],0,-10).'',1,0,'L');
- $pdf->Ln();
- $pdf->setX(100);
- $pdf->Cell(40,5,'Tanggal Lahir',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.$row['tgl_lahir'].'',1,0,'L');
- $pdf->Ln();
- $pdf->setX(100);
- $pdf->Cell(40,5,'Alamat',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.$row['alamat'].'',1,0,'L');
- $pdf->Ln();
- $pdf->setX(100);
- $pdf->Cell(40,5,'Jenis Kelamin',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.$row['kelamin'].'',1,0,'L');
- $pdf->Ln();
- $pdf->setX(100);
- $pdf->Cell(40,5,'Warga Negara',1,0,'L');
- $pdf->Cell(6,5,' : ',1,0,'L');
- $pdf->Cell(50,5,''.$row['wn'].'',1,0,'L');
- //$pdf->FancyTable($header,$data);
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment