-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
56 lines (52 loc) · 2.48 KB
/
index.html
File metadata and controls
56 lines (52 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bluetooth Print</title>
</head>
<body>
<h1>Bluetooth Print</h1>
<button id="connect">Connect and Print</button>
<p id="status"></p>
<p id="battery"></p>
<script
src="https://cdn.jsdelivr.net/npm/bluetooth-print-js@1.0/index.min.js"></script>
<script>
document.getElementById('connect').addEventListener('click', () => {
let printer = new PrintPlugin();
printer.connectToPrint({
onReady: async (print) => {
// Print Header
await print.writeText('SADIGIT', { align: 'center', bold: true, size: "double" })
await print.writeText('Jl. Kutamaya No.Ruko A, Kotakulon, Kec. Sumedang Sel., Kabupaten Sumedang, Jawa Barat 45311', { align: 'center' })
await print.writeText('0852-2299-9699', { align: 'center' })
await print.writeLineBreak()
await print.writeText('No.Transaksi: SDGT-ONL-0001', { align: 'center' })
await print.writeText('Kasir: Otongsuke', { align: 'center' })
await print.writeText('2024-10-23 10:20:18', { align: 'center' })
// Print Items
await print.writeDashLine()
for (let i = 0; i < 5; i++) {
await print.writeText('Item Sample-' + i, { align: 'left' })
await print.writeTextWith2Column('1 pcs x 10.000', '10.000')
}
await print.writeDashLine()
// Print Total
await print.writeTextWith2Column('Total :', '50.000')
await print.writeTextWith2Column('Bayar :', '100.000')
await print.writeTextWith2Column('Kembali :', '50.000')
await print.writeTextWith2Column('Metode :', 'Tunai')
// Print Footer
await print.writeLineBreak()
await print.writeText('Terimakasih sudah mencoba Follow IG @sadigit.id', { align: 'center' })
await print.writeLineBreak(3)
},
onFailed: (message) => {
console.log(message);
}
});
});
</script>
</body>
</html>