xprinter-core-module
v0.2.0
Published
support sdk and printer
Maintainers
Readme
X-Printer TurboModule for React Native
This TurboModule provides a native interface for interacting with an x-printer in React Native applications.
Installation
Using npm
npm install xprinter-core-moduleUsing yarn
yarn add xprinter-core-moduleFor React Native versions < 0.60, link the native module:
react-native link xprinter-core-moduleFor React Native 0.60 and above, the module should be auto-linked.
Usage
Import the module in your JavaScript code:
import {
connectInternet,
disconnect,
printText,
sendData,
printText,
} from 'xprinter-core-module';Functions
connectInternet(ipAddress: string): Promise
Connects to the printer using the provided IP address.
Example:
try {
const result = await connectInternet('192.168.1.100');
console.log(result);
} catch (error) {
console.error('Connection failed:', error);
}disconnect(): Promise
Disconnects from the currently connected printer.
Example:
try {
const result = await disconnect();
console.log(result);
} catch (error) {
console.error('Disconnection failed:', error);
}sendData(data: string): Promise
Sends raw data to the printer.
Example:
try {
const result = await sendData('Raw printer data');
console.log(result);
} catch (error) {
console.error('Failed to send data:', error);
}printText(text: string, alignment: number, fontStyle: number, cutPaper: boolean, textSize: number): Promise
Prints text with specified formatting options.
Example:
try {
const result = await printText('Hello, Printer!', 1, 0, true, 12);
console.log(result);
} catch (error) {
console.error('Printing failed:', error);
}