# expo-esc-pos-utils

A powerful Expo module for ESC/POS printer utilities, supporting image printing and text formatting. This module provides easy-to-use utilities for working with thermal printers in React Native and Expo applications.

## Features

- Image printing support
- Text formatting
- Network printer support
- Base64 image conversion
- ESC/POS command utilities

## Installation

```bash
npm install expo-esc-pos-utils
# or
yarn add expo-esc-pos-utils
```

## Usage

```typescript
import ExpoEscPosUtils from 'expo-esc-pos-utils';
import { NetPrinter } from './net-printer';

// Example: Print an image
const printImage = async () => {
  const printer = new NetPrinter();
  try {
    // Connect to printer
    await printer.connect('192.168.1.100', 9100);
    await printer.initialize();

    // Convert and print image
    const base64Image = '...'; // Your base64 image string
    const intArray = await ExpoEscPosUtils.convertBase64ToGsV0Data(base64Image, 576);
    const uint8Array = new Uint8Array(intArray);
    await printer.printBitmap(uint8Array);
    printer.cut();
  } catch (error) {
    console.error('Printing error:', error);
  } finally {
    printer.disconnect();
  }
};
```

## API Reference

### `convertBase64ToGsV0Data(base64: string, width: number): Promise<number[]>`

Converts a base64 image to ESC/POS GS v0 command data.

- `base64`: Base64 encoded image string
- `width`: Width of the image in pixels
- Returns: Promise resolving to an array of numbers representing the ESC/POS command data

## Contributing

Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).

## License

MIT

# API documentation

- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/esc-pos-utils/)
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/esc-pos-utils/)

# Installation in managed Expo projects

For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects &mdash; it is likely to be included in an upcoming Expo SDK release.

# Installation in bare React Native projects

For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.

### Add the package to your npm dependencies

```
npm install expo-esc-pos-utils
```

### Configure for Android




### Configure for iOS

Run `npx pod-install` after installing the npm package.
