React guide

Silent print dari React.

Cetak PDF, receipt, atau label dari komponen React tanpa membuka dialog print browser.

Persiapan

  1. Install Mrjee Print Bridge.
  2. Salin token lokal yang dibuat otomatis dari Settings dan atur CORS allowlist.
  3. Buat mapping receipt-main.
  4. 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");
}

Test sekarang