Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dotnetdreamer/capacitor-niimbot-printer

A plugin that connects to Niimbot printers via the NiimBlue web UI with some tweaks
https://github.com/dotnetdreamer/capacitor-niimbot-printer

angular b1 capacitor ionic-framework mobile-app niimblue niimbot typescript webview-app

Last synced: about 2 months ago
JSON representation

A plugin that connects to Niimbot printers via the NiimBlue web UI with some tweaks

Awesome Lists containing this project

README

        

# Niimbot printer plugin
A capacitor plugin that connects to Niimbot printers via [NiimBlue](https://github.com/MultiMote/niimblue) web ui

## How it works ?
This plugin essentially uses [NiimBlue](https://github.com/MultiMote/niimblue) to connect to NIIMBOT printers. The plugin provides an easy way to load and automate niimblue in webview via simple API.

## Having Issues ?
If you are facing issue related to NiimBlue, please go to the official repository and file it there. Issues related to the plugin itself can be created in this repsoitory

## Install

### Install Bluetooth ble plugin
Install `https://github.com/capacitor-community/bluetooth-le`

### Local version (Local Machine)
To use and install this plugin locally (instead of npm), follow:
1. `git clone https://github.com/dotnetdreamer/capacitor-niimbot-printer.git`
2. `npm i path_to_just_cloned_repo (e.g C:\Git\z_others\capacitor-niimbot-printer)`
3. Go to `this_plugin_path -> android -> gradle.properties` and uncomment `localPluginPath` property. Now change the value to your app root location (where you will use this plugin). The path must ends with '/' character
4. (Optional) This plugin has pre-compiled version of Niimlue web app inside `android/src/niimblue` folder. You can replace it with your own version of Niimblue web app by following compilation instructions [here](https://github.com/MultiMote/niimblue)

### Release version (NPM)
```bash
npm install capacitor-niimbot-printer
npx cap sync
```

> [!Important]
> Make sure that `your_app/android/app/src/main/assets/public/assets/niimblue` has all the required files copied by the plugin during build time. You can look specifically for index.html and other js, fonts files.
If you are running your app via livereload i.e `ionic capacitor run android --livereload --external` then make sure to copy `your_app/android/app/src/main/assets/public/assets/niimblue` folder into `your_app/src/assets` folder

## How navigation between your app & Niimblue web app works ?
When you use this plugin, your app can call print API method then your user will be redirected to Niimblue web ui which means your main ui is no longer active. Inside Niimblue web ui, user has two choices i.e Press floating close (fab) button or use back button or gestures. Only then Niimblue web ui will be destroyed and your will get active.

## API

* [`print(...)`](#print)
* [Interfaces](#interfaces)

### print(...)

```typescript
print(options: INiimbotPrintOptions) => Promise
```

Print a document using the Niimbot printer. Internally, this will open the Niimblue web app to print the document

| Param | Type | Description |
| ------------- | --------------------------------------------------------------------- | --------------------------------------------- |
| **`options`** | INiimbotPrintOptions | The options to use when printing the document |

**Returns:** Promise<any>

--------------------

### Interfaces

#### INiimbotPrintOptions

| Prop | Type | Description |
| ----------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **`debug`** | boolean | Whether to show console logs or not Default: true |
| **`redirectUri`** | string | After closing the Niimblue web app, the user will be redirected to this URL. This is your app's URL Default: 'index.html' |
| **`preview`** | boolean | Should show the the print preview dialog on load or not. Setting it to true will show the print preview dialog immediately Default: false |
| **`displayFab`** | boolean | Whether to show the close floating button or not. Setting it to false will hide the close button Default: true |
| **`toast`** | { enabled?: boolean; message?: string; } | An optional message to show as a toast when navigating back from the NiimBlue web ui to the app |

| Method | Signature |
| --------------- | -------------------------------------------------------------------------- |
| **addListener** | (eventName: 'done', listenerFunc: () => void) => Promise<void> |