63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
require('fpdf.php');
|
|
|
|
// Konversi cm ke mm (1 cm = 10 mm)
|
|
$lebar = 45; // 4.5 cm = 45 mm
|
|
$tinggi = 100; // Sesuaikan tinggi sesuai kebutuhan
|
|
$margin = 2; // Margin 2 mm
|
|
|
|
// Buat instance FPDF dengan orientasi potret
|
|
$pdf = new FPDF('P', 'mm', array($lebar, $tinggi));
|
|
$pdf->SetMargins($margin, $margin, $margin);
|
|
$pdf->AddPage();
|
|
|
|
// Set font
|
|
$pdf->SetFont('Helvetica', 'B', 8);
|
|
$pdf->Cell(0, 4, 'Struk Pembayaran', 0, 1, 'C');
|
|
$pdf->Ln(2);
|
|
|
|
// Tambahkan teks contoh
|
|
$pdf->SetFont('Helvetica', '', 7);
|
|
$pdf->Cell(0, 4, 'Tanggal : ' . date('d-m-Y H:i:s'), 0, 1, 'L');
|
|
$pdf->Cell(0, 4, 'Bulan : ' . date('M-Y'), 0, 1, 'L');
|
|
$pdf->Ln(2);
|
|
|
|
// Garis pemisah
|
|
$pdf->Cell(0, 0, str_repeat('-', 48), 0, 1, 'L');
|
|
$pdf->Ln(2);
|
|
|
|
// Contoh item
|
|
$items = [
|
|
['Nama', ':', 'Akhtar Biantara D'],
|
|
['No. Id', ':', '202576676623'],
|
|
['Server', ':', 'CC-NET'],
|
|
['Penagih', ':', 'Teknisi'],
|
|
['Pelunas', ':', 'Admin Finance'],
|
|
['Keterangan', ':', "Rek. PT, No 0812787682\nAlamat: Jl. Merdeka No.10, Jakarta"],
|
|
];
|
|
|
|
foreach ($items as $item) {
|
|
$ket = $item[0];
|
|
$spc = $item[1];
|
|
$itm = $item[2];
|
|
|
|
if ($ket == 'Keterangan') {
|
|
$pdf->Cell(15, 4, $ket, 0, 0, 'L');
|
|
$pdf->Cell(2, 4, $spc, 0, 1, 'L');
|
|
$pdf->MultiCell(0, 4, $itm, 0, 'R');
|
|
} else {
|
|
$pdf->Cell(15, 4, $ket, 0, 0, 'L');
|
|
$pdf->Cell(2, 4, $spc, 0, 0, 'L');
|
|
$pdf->Cell(0, 4, $itm, 0, 1, 'R');
|
|
}
|
|
}
|
|
|
|
$pdf->Ln(2);
|
|
$pdf->Cell(0, 1, str_repeat('-', 48), 0, 1, 'L');
|
|
$pdf->Cell(0, 1, str_repeat('-', 48), 0, 1, 'L');
|
|
$pdf->Ln(2);
|
|
|
|
// Output PDF
|
|
$pdf->Output('I', 'struk.pdf');
|