
ahmad_daffa
- May 13th, 13:52
<?php
//require('E:\AppServ\www\belajarpdf\fpdf.php');
require('fpdf/fpdf.php');
define('FPDF_FONTPATH','font/');
class PDF extends FPDF
{
//Current column
var $col=0;
//Ordinate of column start
var $y0;
//Page header
function Header()
{
//Page header
global $title;
$this->SetFont('Arial','',8);
$w=$this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
$this->SetLineWidth(1);
//$this->Cell($w,9,$title,1,1,'C',true);
$this->Ln(100);
//Save ordinate
$this->y0=$this->GetY();
}
//Page footer
function Footer()
{
//Page footer
$this->SetY(-15);
$this->SetFont('Arial','',8);
$this->SetTextColor(128);
//$this->Cell(80,10,$this->PageNo()+132,0,0,'R');
}
function SetCol($col)
{
//Set position at a given column
$this->col=$col;
$x=10+$col*65;
$this->SetLeftMargin($x);
$this->SetX($x);
}
function AcceptPageBreak()
{
//Method accepting or not automatic page break
if($this->col<10)
{
//Go to next column
$this->SetCol($this->col+1);
//Set ordinate to top
$this->SetY($this->y0);
//Keep on page
return false;
}
else
{
//Go back to first column
$this->SetCol(0);
//Page break
return true;
}
}
}
// Connect to the db.
//require_once ('./includes/dbconn.php');
mysql_connect("localhost","root","mysql");
mysql_select_db("wisuda");
$sql="select nama, gelar, tempat, tlbuku, nrp, alamatbuku, lulusbuku, predikatbuku, judulskripsibuku, jurusan, foto, nrptahun status from biomhs WHERE (status ='1' and jurusan = 'S1 Akuntansi') and (nrptahun > '0') ORDER BY nrptahun ASC LIMIT 5"; //ORDER BY `id` DESC LIMIT 100
$qry=mysql_query($sql) or die (mysql_error());
$pdf=new PDF('L','mm','A4');
$pdf->Open();
//$pdf->SetAutoPageBreak(false);
$pdf->AddPage();
$pdf->AliasNbPages();
$pdf->SetFont('Times','',8);
$pdf->SetY(4);
$pdf->SetX(4);
//$max=5;
//$i=0;
//$j=0;
//$no=0;
//$row_height = 6;
//$y_axis = $y_axis + $row_height;
while($row = mysql_fetch_array($qry))
{
if ($i == 5)
{
$pdf->SetAutoPageBreak(false);
$pdf->AddPage();
$pdf->AliasNbPages();
$pdf->SetY(4);
$pdf->SetX(4);
//$y_axis = $y_axis + $row_height;
//$i=0;
}
//function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
$kolom1 = 50;
$kolom2 = 25;
$kolom3 = 3;
$kolom4 = 90;
$tinggi1 = 8;
$tinggi2 = 2.7;
$tinggi3 = 1;
$tinggi4 = 8;
$pdf->Cell($kolom1,$tinggi1,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi1,' ',0,0,'C');
$pdf->Cell($kolom3,$tinggi1,' ',0,0,'C');
$pdf->SetFont('Times','B',9);
$pdf->Cell($kolom4,$tinggi1,$row['nama'].$row['gelar'],0,0,'C');
$pdf->Ln();
$pdf->SetFont('');
$pdf->SetFont('Times','',8);
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Tempat / Tgl. Lahir',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
$pdf->Cell($kolom4,$tinggi2,$row['tempat'].", ".$row['tlbuku'],0,0,'L');
$pdf->Ln();
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Nomor Pokok',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
$pdf->Cell($kolom4,$tinggi2,$row['nrp'],0,0,'L');
$pdf->Ln();
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Alamat',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
$pdf->Cell($kolom4,$tinggi2,$row['alamatbuku'],0,0,'L');
$pdf->Ln();
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Lulus Pada Tanggal',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
$pdf->Cell($kolom4,$tinggi2,$row['lulusbuku'], 0,0,'L');
$pdf->Ln();
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Predikat',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
$pdf->Cell($kolom4,$tinggi2,$row['predikatbuku'],0,0,'L');
$pdf->Ln();
$pdf->Cell($kolom1,$tinggi2,' ',0,0,'C');
$pdf->Cell($kolom2,$tinggi2,'Judul Skripsi / Ta',0,0,'L');
$pdf->Cell($kolom3,$tinggi2,':',0,0,'L');
//MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
$pdf->MultiCell($kolom4,$tinggi2,$row['judulskripsibuku'],0,'J');
//$pdf->MultiCell($kolom4,$tinggi2,$row['judulskripsi2'],1,'L');
//Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, boolean fill [, mixed link]]]]]]])
//$pdf->Cell($kolom4,$tinggi2,$row['judulskripsi'],1,1,'L');
$pdf->Cell($kolom1,$tinggi3,' ',0,0,'R');
$pdf->Cell($kolom2,$tinggi3,' ',0);
$pdf->Cell($kolom3,$tinggi3,'',0,0,'C');
$pdf->Cell($kolom4,$tinggi3,'_________________________________________________________________________________________________________',0,0,'R');
$pdf->Ln();
$i++;
if ($j == 5)
{
//$pdf->SetAutoPageBreak(false);
//$pdf->AddPage();
//$pdf->AliasNbPages();
//$pdf->SetY($y_axis_initial);
//$pdf->SetX(10);
//$y_axis = $y_axis + $row_height;
$j=0;
}
//$halaman = .$this->PageNo();
//for ($i = 1; $i <= $halaman; $i++)
//{
// for ($j = 1; $j <= 5; $j++)
// {
// $pdf->Cell(50,50,$j,0,0,'C');
// }
//}
//$foto = $row['nrp'];
$foto = $row['nrp'];
$foto= $foto. "" .".jpg";
$posisifotox = 30;
$posisifotoy = ($j*34.5)+ 10;
//$posisifotoy1 = 12; //(1*30)-10=10
//$posisifotoy2 = 50; //(2*30)-10=40
//$posisifotoy3 = 90; //3
//$posisifotoy4 = 110; //4
//$posisifotoy5 = 140; //5
$pdf->Image($foto,$posisifotox,$posisifotoy,25,25);
//masalahnya adalah $i*30 foto terus kebawah tidak restart ke atas lagi untuk halaman ke 2
//$pdf->Image($foto,$posisifotox,$posisifotoy1,30,30);
//$pdf->Image($foto,$posisifotox,$posisifotoy2,30,30);
//$pdf->Image($foto,$posisifotox,$posisifotoy3,30,30);
//$pdf->Image($foto,$posisifotox,$posisifotoy4,30,30);
//$pdf->Image($foto,$posisifotox,$posisifotoy5,30,30);
$j++;
}
//$pdf->MultiCell($kolom3,$tinggi2, "D test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 2);
$pdf->Output();
?>
Database:
-- phpMyAdmin SQL Dump
-- version 2.9.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 18, 2009 at 05:19 PM
-- Server version: 5.0.27
-- PHP Version: 5.2.1
--
-- Database: `wisuda`
--
-- --------------------------------------------------------
--
-- Table structure for table `biomhs`
--
CREATE TABLE `biomhs` (
`nrp` varchar(20) NOT NULL,
`nama` varchar(30) NOT NULL,
`alamat` varchar(50) NOT NULL,
`ipk` decimal(4,2) NOT NULL,
`tempat` varchar(20) NOT NULL,
`tl` date NOT NULL,
`p` char(1) NOT NULL,
`judulskripsi` text NOT NULL,
`lulus` text NOT NULL,
`tglinput` datetime NOT NULL,
`oleh` varchar(10) NOT NULL,
`status` tinyint(4) NOT NULL default '0',
`foto` varchar(30) NOT NULL,
`statusbar` tinyint(4) NOT NULL default '0',
`olehbar` varchar(10) NOT NULL,
`statusfoto` varchar(2) NOT NULL,
`gelar` varchar(10) NOT NULL,
`predikat` varchar(20) NOT NULL,
`jurusan` varchar(20) NOT NULL,
`judulskripsibuku` text NOT NULL,
`tlbuku` text NOT NULL,
`alamatbuku` text NOT NULL,
`lulusbuku` text NOT NULL,
`predikatbuku` text NOT NULL,
`nrptahun` text,
PRIMARY KEY (`nrp`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;