From 89c33c0d5a48c5fa9cbbf8a29f1c1692ad414308 Mon Sep 17 00:00:00 2001 From: Duidev Software House Date: Thu, 11 Sep 2025 13:44:59 +0700 Subject: [PATCH] Update --- htdocs/resources/views/pendaftaran.blade.php | 38 +++++--------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/htdocs/resources/views/pendaftaran.blade.php b/htdocs/resources/views/pendaftaran.blade.php index e56cd3c9..e9b92b8a 100644 --- a/htdocs/resources/views/pendaftaran.blade.php +++ b/htdocs/resources/views/pendaftaran.blade.php @@ -888,13 +888,10 @@ }; } function jQueryOpenBarCode(item, nofoto) { - // Pastikan library sudah termuat if (typeof window.jspdf === 'undefined' || typeof JsBarcode === 'undefined') { alert('Kesalahan: Library jsPDF atau JsBarcode belum dimuat.'); return; } - - // 1. Parsing data (sama seperti sebelumnya) const itemParts = item.split('<>'); const asalpasien = itemParts[0]?.trim() || "xx"; const kd_spesimen = itemParts[1]?.trim() || "xx"; @@ -906,15 +903,12 @@ if (nama.length > 12) { nama = nama.substring(0, 12) + "."; } - // 2. Inisialisasi dokumen PDF const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'landscape', unit: 'mm', format: [50, 35] }); - - // 3. Pengaturan Teks dan Posisi const leftMargin = 2; const contentWidth = 50 - (leftMargin * 2); let yPosition = 4; @@ -924,34 +918,24 @@ doc.text(`${kd_spesimen} / ${asalpasien}`, leftMargin, yPosition, { maxWidth: contentWidth, }); - yPosition += 4; // Geser posisi Y ke bawah untuk barcode - - // 4. Generate Barcode dan tambahkan ke PDF (BAGIAN YANG DIUBAH) + yPosition += 4; try { const canvas = document.createElement('canvas'); JsBarcode(canvas, nofoto, { format: "CODE128", - displayValue: false, // DIUBAH: Tidak menampilkan teks bawaan + displayValue: false, height: 40, width: 1.5, - margin: 5 // Beri sedikit margin agar tidak terpotong + margin: 5 }); const barcodeDataUrl = canvas.toDataURL('image/png'); - const barcodeHeight = 10; // Tinggi gambar barcode di PDF (dalam mm) - - // Tambahkan gambar barcode ke PDF + const barcodeHeight = 10; doc.addImage(barcodeDataUrl, 'PNG', leftMargin, yPosition, contentWidth, barcodeHeight); - - // Pindahkan posisi Y ke bawah gambar barcode yPosition += barcodeHeight + 3; - - // DITAMBAHKAN: Tulis teks nofoto secara manual di bawah barcode - doc.setFont('helvetica', 'bold'); // Set font biasa (tidak bold) - doc.setFontSize(8); // Atur ukuran font agar jelas - const centerX = 50 / 2; // Titik tengah horizontal halaman - doc.text(nofoto, centerX, yPosition, { align: 'center' }); // Teks dibuat rata tengah - - // Pindahkan posisi Y untuk baris selanjutnya + doc.setFont('helvetica', 'bold'); + doc.setFontSize(8); + const centerX = 50 / 2; + doc.text(nofoto, centerX, yPosition, { align: 'center' }); yPosition += 4; } catch (e) { @@ -959,9 +943,7 @@ doc.text("Error Barcode", leftMargin, yPosition); yPosition += 12; } - - // 5. Menambahkan sisa teks - doc.setFont('helvetica', 'bold'); // Kembalikan font menjadi bold + doc.setFont('helvetica', 'bold'); doc.setFontSize(6.5); doc.text(`${noregister} / ${nama} / ${tgllahir}`, leftMargin, yPosition, { maxWidth: contentWidth, @@ -970,8 +952,6 @@ doc.text(`${reques} ( ${daftartgl} )`, leftMargin, yPosition, { maxWidth: contentWidth, }); - - // 6. Tampilkan PDF di tab baru doc.output('dataurlnewwindow'); } $(window).on('load', function () {