Expand description
§tauri-plugin-thermoprint
Tauri v2 plugin for thermal receipt printing via serial ports.
§Setup
Rust side (src-tauri/src/main.rs):
ⓘ
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_thermoprint::init())
.run(tauri::generate_context!())
.expect("error running app");
}JavaScript side:
import { invoke } from '@tauri-apps/api/core';
// List available serial ports
const ports = await invoke('plugin:thermoprint|list_ports');
// Print ESC/POS bytes to a serial port
await invoke('plugin:thermoprint|print_serial', {
port: '/dev/ttyUSB0',
baudRate: 9600,
data: Array.from(receiptBytes),
});
// Render a JSON template and print in one call
await invoke('plugin:thermoprint|print_template', {
port: '/dev/ttyUSB0',
baudRate: 9600,
template: JSON.stringify({ width: "80mm", elements: [...] }),
});Structs§
- Port
Info - Information about an available serial port.
Functions§
- init
- Initialise the thermoprint plugin.