028 $pdf->Ln();
029 $pdf->Text(181,31,"dari Rumah Tahanan Negara Bangkalan",0);
030 $pdf->Ln();
031 $bln= date("F", mktime(0, "$bulan"));
032 $pdf->Text(181,37,"Dalam bulan $bln $tahun",0);
033
034 $y_axis_initial= 45;
035 $pdf->SetFont('Arial','',10);
036 $pdf->setFillColor(222,222,222);
037 $pdf->SetY($y_axis_initial);
038 $pdf->SetX(10);
039 //Header tabel halaman 1
040 $pdf->CELL(10,6,'NO',1,0,'C',1);
041 $pdf->Cell(40,6,'NAMA',1,0,'C',1);
042 $pdf->Cell(15,6,'GOL',1,0,'C',1);
043 $pdf->Cell(15,6,'P/W',1,0,'C',1);
044 $pdf->Cell(15,6,'UMUR',1,0,'C',1);
045 $pdf->Cell(37,6,'PUTUSAN DARI',1,0,'C',1);
046 $pdf->Cell(25,6,'PERKARA',1,0,'C',1);
047 $pdf->Cell(30,6,'ASAL PENYIDIK',1,0,'C',1);
048 $pdf->Cell(30,6,'TGL BEBAS',1,0,'C',1);
049 $pdf->Cell(40,6,'ALAMAT',1,0,'C',1);
050 $pdf->Cell(25,6,'KET PIDANA',1,0,'C',1);
051 $pdf->Ln();
052 $max=25;//max baris perhalaman
053 $i=0;
054 $no=0;
055 $row_height= 6;//tinggi tiap2 cell/baris
056 $y_axis= $y_axis+ $row_height;
057 $date= date("Y-m-d");
058
059 while($row= mysql_fetch_array($qry))
060 {
061 $no++;
062 $selisih= strtotime($date) -
strtotime($row[tgl_lahir]);
$now",0,0,'C');
107 $pdf->Ln();
108 $pdf->Cell(404,6,"Kepala Rutan Bangkalan",0,0,'C');
109 $pdf->Ln(30);
110 $pdf->SetFont('Arial','U',12);
111 $pdf->Cell(404,6,"BAMBANG HARYANTO,Bc.IP.SH.M.Hum",0,0,'C');
112 $pdf->Ln();
113 $pdf->SetFont('Arial','',12);
114 $pdf->Cell(404,6,"NIP. 19661018 1992 03 1001",0,0,'C');
115 $pdf->Ln();
116 $pdf->Output('Napi_bebas_'.date("F Y").'.pdf', 'I');
117 ?>
3. Html2PDF
Pertama kita buat file msf.php, file ini berisi halaman html yang akan kita konversi ke PDF.
Setau saya Html2PDF mendukung CSS sementara Html2FPDF tidak
01 <page style="font-size: 12pt">
02 <?
03 session_start();
04 mysql_connect('localhost','root','');
05 mysql_select_db('dbkapal');
06
$qry= mysql_query("select tugboat_name, cargo_id, barge_name, no_ship,
nama_rute, act_date, tot_cargo,voy from kapal a,rute b, bcr c, aktifitas
07
d where c.id_kapal = a.id_kapal and c.id_rute = b.id_rute and d.id_bcr =
c.id_bcr and attr ='complete_dish' order by barge_name ASC");
08
09 echo"<h3 align=center>Monthly Statemet of Fact</h3>
10 <table border=1 align=center>
11 <tr><td bgcolor='#999999'><strong>No</strong></td>
12 <td bgcolor='#999999'><strong>Tugboat Name</strong></td>
13 <td bgcolor='#999999'><strong>Barge Name</strong></td>
14 <td bgcolor='#999999'><strong>Cargo ID</strong></td>
15 <td bgcolor='#999999'><strong>No.Shipment</strong></td>
16 <td bgcolor='#999999'><strong>Voy</strong></td>
17 <td bgcolor='#999999'><strong>Port of Dish</strong></td>
18 <td bgcolor='#999999'><strong>Compl.Dish</strong></td>
19 <td bgcolor='#999999'><strong>Ttl Cgo(MT)</strong></td>
20 </tr>";
21
22 $no=1;
23 while($r= mysql_fetch_array($qry)){
24 echo"<tr>
25 <td>$no</td>
26 <td>$r[0]</td>
27 <td>$r[2]</td>
28 <td>$r[1]</td>
29 <td align='right'>$r[3]</td>
30 <td align='right'>$r[7]</td>
31 <td>".substr($r[4],0,16)."</td>
32 <td>".substr($r[5],0,16)."</td>
33 <td align='right'>".number_format($r[6])."</td>
34 </tr>";
35 $no++;
36 }
37 echo"</table>";
38 ?>
39 </page>
Nah, dari 3 contoh library di atas. Yang manakah yang paling anda suka?