React guide
Silent print dari React.
Cetak PDF, receipt, atau label dari komponen React tanpa membuka dialog print browser.
Persiapan
- Install Mrjee Print Bridge.
- Salin token lokal yang dibuat otomatis dari Settings dan atur CORS allowlist.
- Buat mapping
receipt-main. - Panggil API lokal dari event handler React.
Contoh integrasi
async function printDocument(base64Pdf) {
const response = await fetch("http://localhost:9000/api/print", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_SECRET_TOKEN"
},
body: JSON.stringify({
logicalName: "receipt-main",
data: base64Pdf
})
});
if (!response.ok) throw new Error("Print failed");
}