tauri-plugin-thermal-printer 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -13
- package/dist-js/index.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ pub fn generate_document(&mut self, print_job: &PrintJobRequest) -> Result<Vec<u
|
|
|
90
90
|
#### 4. **OS Integration** (`src/desktop_printers/` and `android/`)
|
|
91
91
|
- **Linux/macOS**: Uses CUPS system (`lpstat`, `lp` commands)
|
|
92
92
|
- **Windows**: Uses WinAPI (Windows API) to directly access system printers via functions such as EnumPrintersW for listing printers, OpenPrinterW for opening printer handles, and WritePrinter for sending raw data
|
|
93
|
-
- **Android**: Kotlin plugin with Bluetooth SPP and
|
|
93
|
+
- **Android**: Kotlin plugin with Bluetooth SPP, USB, and Network (TCP/IP) printer discovery and printing
|
|
94
94
|
|
|
95
95
|
### Workflow
|
|
96
96
|
|
|
@@ -106,8 +106,8 @@ pub fn generate_document(&mut self, print_job: &PrintJobRequest) -> Result<Vec<u
|
|
|
106
106
|
|
|
107
107
|
1. **Frontend** sends `PrintJobRequest` with sections and configuration
|
|
108
108
|
2. **Rust** generates ESC/POS binary data using the same `ProcessPrint` pipeline
|
|
109
|
-
3. **Kotlin plugin** receives the binary data and the printer MAC
|
|
110
|
-
4. **Bluetooth SPP**
|
|
109
|
+
3. **Kotlin plugin** receives the binary data and the printer identifier (MAC, USB VID:PID, or IP:PORT)
|
|
110
|
+
4. Connection is established via **Bluetooth SPP**, **USB Bulk Transfer**, or **TCP Socket**
|
|
111
111
|
5. **Thermal Printer** interprets ESC/POS commands and prints
|
|
112
112
|
|
|
113
113
|
#### Print Structure Example:
|
|
@@ -150,18 +150,18 @@ The plugin translates all sections into **ESC/POS** (Escape Sequence for Point o
|
|
|
150
150
|
- ✅ **Linux**: Fully functional (CUPS)
|
|
151
151
|
- ✅ **macOS**: Fully functional (CUPS)
|
|
152
152
|
- ✅ **Windows**: Fully functional (WinAPI)
|
|
153
|
-
- ✅ **Android**: Bluetooth and
|
|
153
|
+
- ✅ **Android**: Bluetooth, USB, and Network printer discovery and printing
|
|
154
154
|
- ❌ **iOS**: Not implemented
|
|
155
155
|
|
|
156
156
|
### Supported Connections
|
|
157
157
|
|
|
158
158
|
| Connection | Linux | macOS | Windows | Android |
|
|
159
159
|
| ---------- | ----- | ----- | ------- | ------- |
|
|
160
|
-
| USB | ✅ | ✅ | ✅ | ✅
|
|
161
|
-
| Network | ✅ | ✅ | ✅ |
|
|
160
|
+
| USB | ✅ | ✅ | ✅ | ✅ |
|
|
161
|
+
| Network | ✅ | ✅ | ✅ | ✅ |
|
|
162
162
|
| Bluetooth | ❌ | ❌ | ❌ | ✅ |
|
|
163
163
|
|
|
164
|
-
> **Android note**: The `printer` field in `PrintJobRequest` must be the
|
|
164
|
+
> **Android note**: The `printer` field in `PrintJobRequest` must be the printer identifier returned by `list_thermal_printers`. For Bluetooth, it's the MAC address (e.g. `"AA:BB:CC:DD:EE:FF"`). For USB, it's `"VID:xxxx/PID:yyyy"`. For Network, it's `"IP:PORT"` (e.g. `"192.168.1.100:9100"`). Required permissions (Bluetooth, USB, Internet) are handled automatically at runtime.
|
|
165
165
|
|
|
166
166
|
## Installation
|
|
167
167
|
|
|
@@ -391,12 +391,14 @@ Returns `Promise<void>`. Resolves when printing completes successfully. **Throws
|
|
|
391
391
|
| `printer` | string | ✅ Yes | Printer name |
|
|
392
392
|
| `paper_size` | PaperSize | ❌ No | Paper size (default: `"Mm80"`) — see [Paper Sizes](#paper-sizes) |
|
|
393
393
|
| `options` | PrinterOptions | ❌ No | Configuration options |
|
|
394
|
-
| `options.cut_paper` | boolean | ❌ No | Cut
|
|
395
|
-
| `options.beep` | boolean | ❌ No | Beep
|
|
396
|
-
| `options.open_cash_drawer` | boolean | ❌ No |
|
|
394
|
+
| `options.cut_paper` | boolean | ❌ No | Append a tail `Cut` section equivalent to `{ "Cut": { "mode": "partial", "feed": 0 } }` (default: `true`) |
|
|
395
|
+
| `options.beep` | boolean | ❌ No | Append a tail `Beep` section equivalent to `{ "Beep": { "times": 1, "duration": 3 } }` (default: `false`) |
|
|
396
|
+
| `options.open_cash_drawer` | boolean | ❌ No | Append a tail `Drawer` section equivalent to `{ "Drawer": { "pin": 2, "pulse_time": 100 } }` (default: `false`) |
|
|
397
397
|
| `options.code_page` | CodePage | ✅ Yes | Required ESC/POS page selection plus host-side encoding strategy — see [CodePage](#codepage) |
|
|
398
398
|
| `sections` | array | ✅ Yes | Array of sections to print (see [Section Types](#section-types)) |
|
|
399
399
|
|
|
400
|
+
`options.cut_paper`, `options.beep`, and `options.open_cash_drawer` are tail-action shorthands. They append sections at the end of the document in this fixed order: `Beep` → `Cut` → `Drawer`. They do **not** disable or replace manually declared sections, so if you specify both, both actions are emitted.
|
|
401
|
+
|
|
400
402
|
#### Paper Sizes
|
|
401
403
|
|
|
402
404
|
| Value | Paper width | Chars/line | Typical use |
|
|
@@ -1144,7 +1146,7 @@ await print_thermal_printer(job);
|
|
|
1144
1146
|
|
|
1145
1147
|
This section contains practical examples for different use cases. Each example demonstrates how to structure print jobs for various business scenarios.
|
|
1146
1148
|
|
|
1147
|
-
> **NOTE:**
|
|
1149
|
+
> **NOTE:** With default options, a tail `Cut` section is appended automatically as `{ "Cut": { "mode": "partial", "feed": 0 } }`. Add your own `Cut` section when you need an extra cut or different parameters.
|
|
1148
1150
|
|
|
1149
1151
|
### 🛒 Long Receipt (Supermarket - 80mm)
|
|
1150
1152
|
|
|
@@ -1625,5 +1627,6 @@ const paymentReceipt: PrintJobRequest = {
|
|
|
1625
1627
|
- No need to manually reset styles
|
|
1626
1628
|
|
|
1627
1629
|
#### Paper Cutting
|
|
1628
|
-
- **Automatic**:
|
|
1629
|
-
- **Manual
|
|
1630
|
+
- **Automatic**: `options.cut_paper = true` appends a tail `Cut` section with `mode: "partial"` and `feed: 0`
|
|
1631
|
+
- **Manual**: Add a `Cut` section anywhere in `sections` to issue explicit cut commands
|
|
1632
|
+
- **Combined**: Automatic and manual cuts are both emitted when both are present
|
package/dist-js/index.d.ts
CHANGED
|
@@ -93,8 +93,11 @@ export declare const CUT_MODE: {
|
|
|
93
93
|
readonly PARTIAL: CutMode;
|
|
94
94
|
};
|
|
95
95
|
export interface PrinterOptions {
|
|
96
|
+
/** Append a tail `Cut` section with mode `"partial"` and feed `0`. */
|
|
96
97
|
cut_paper: boolean;
|
|
98
|
+
/** Append a tail `Beep` section with times `1` and duration `3`. */
|
|
97
99
|
beep: boolean;
|
|
100
|
+
/** Append a tail `Drawer` section with pin `2` and pulse time `100`. */
|
|
98
101
|
open_cash_drawer: boolean;
|
|
99
102
|
/** Required ESC/POS page plus host-side encoding strategy. */
|
|
100
103
|
code_page: CodePage;
|