npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nuri-sunmi-qr-printer

v0.0.3

Published

Sunmi QR Code Scan & Printer

Downloads

1

Readme

nuri-sunmi-qr-printer

Sunmi QR Code Scan & Printer

Install

npm install nuri-sunmi-qr-printer
npx cap sync

Android Only Setting

This API requires the following permissions be added to your AndroidManifest.xml before the application tag:

<!-- To get access to the camera. -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- To get access to the flashlight. -->
<uses-permission android:name="android.permission.FLASHLIGHT"/>
AndroidManifest.xml

 <application
        android:name=".GlobalApplication" ">
        <activity
        </activity>
    </application>
//////////////////

import com.nuri.sunmi.qrprinter.SunmiQrPrinterPlugin;

public class GlobalApplication extends Application {

  String TAG = "GlobalApplication GlobalApplication";
  @Override
  public void onCreate() {
    super.onCreate();
    SunmiQrPrinterPlugin.Sunmi_Init(this);

    Log.v(TAG, "onCreate" );
  }

}

Usage


import { SunmiQrPrinter } from 'nuri-sunmi-qr-printer';


// QR Code Scan
  ngOnInit() {
    SunmiQrPrinter.addListener('Event_QRCodeData', (info: any) => {
        console.log('Event_QRCodeData : ', info.value);
    });
  }


	await SunmiQrPrinter.QR_Scan(data).then(res => {
      console.log('qrCode_data : ', res.value);
  });

// Sunmi Printer

  SunmiQrPrinter.Sunmi_GetIsConnnected()
    .then((result) => {
      console.log(" result.isConnnected : ", result.isConnnected);
    })
    .catch((err) => {
  });

  SunmiQrPrinter.Sunmi_GetPrinterStatus()
    .then((result) => {
      console.log(" result.isConnnected : ", result.printstats);


    })
    .catch((err) => {
  });

// QR Code ImgData ( Base64Image )  ====> this.qrCodeData
  getBase64StringFromDataURL(dataURL: string): string {

    dataURL = dataURL.replace('data:', '').replace(/^.+,/, '');

    return dataURL;
  }

  var qrCodeImgData = getBase64StringFromDataURL(....ImageData );

  var imageQrCode = {
    imgData: qrCodeImgData,
    nCanvasWidth: 384,
    nCanvasHeight: 200,
    nPosX: 0,
    nPosY: 0,
    nScaleWidth: 384,
    nScaleHeight: 200,
    nAlignment: 2,    // Center
  }
  SunmiQrPrinter.Sunmi_PrintBitmap(imageQrCode);

  // Left Aligin
  var text_round = {
    szFontName: "./assets/fonts/JetBrainsMono.ttf",
    msgText: round + '\n',
    fFontSize: 24,
    isBold: true,
    isUnderLine: false,
  }
  SunmiQrPrinter.Sunmi_PrintTextFont(text_round);
    //--------------------- Left Aligin

  // Right Aligin
  var text_Align = {
    nAlign: 2,
  }
  SunmiQrPrinter.Sunmi_SetAlign(text_Align);

  var text_TicketNo = {
    szFontName: "./assets/fonts/JetBrainsMono.ttf",
    msgText: TicketNo + '\n',
    fFontSize: 24,
    isBold: true,
    isUnderLine: false,
  }
  SunmiQrPrinter.Sunmi_PrintTextFont(text_TicketNo);
  //--------------------- Right Aligin


  var text_Msg = {
    msgText: '--------------------------------\n',
  }
  SunmiQrPrinter.Sunmi_PrintText(text_Msg);

  // Line Gap
  var text_Line = {
    nLine: 1,
  }
  SunmiQrPrinter.Sunmi_PrintLine(text_Line);


  SunmiQrPrinter.Sunmi_FeedPaper();

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>

| Param | Type | | ------------- | ------------------------------- | | options | { value: string; } |

Returns: Promise<{ value: string; }>


addListener('Event_QRCodeData', ...)

addListener(eventName: 'Event_QRCodeData', listenerFunc: any) => Promise<PluginListenerHandle> & PluginListenerHandle

| Param | Type | | ------------------ | ------------------------------- | | eventName | 'Event_QRCodeData' | | listenerFunc | any |

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


QR_Scan(...)

QR_Scan(options: { value: string; }) => Promise<{ value: string; }>

Sunmi Qr Scan

| Param | Type | | ------------- | ------------------------------- | | options | { value: string; } |

Returns: Promise<{ value: string; }>


Sunmi_GetPrinterStatus()

Sunmi_GetPrinterStatus() => Promise<{ printstats: string; }>

Current status of printer

Returns: Promise<{ printstats: string; }>


Sunmi_GetIsConnnected()

Sunmi_GetIsConnnected() => Promise<{ isConnnected: string; }>

Check if the printer is connected

Returns: Promise<{ isConnnected: string; }>


Sunmi_PrintBitmap(...)

Sunmi_PrintBitmap(options: QR_Image_Print) => Promise<{ value: string; }>

Print pictures and text in the specified orde After the picture is printed, the line feed output needs to be called, otherwise it will be saved in the cache In this example, the image will be printed because the print text content is added

| Param | Type | | ------------- | --------------------------------------------------------- | | options | QR_Image_Print |

Returns: Promise<{ value: string; }>


Sunmi_PrintText(...)

Sunmi_PrintText(options: Sunmi_PrintText) => Promise<{ value: string; }>

print text Set printer alignment ==> Sunmi_SetAlign 0 : Left, 1 : Center, 2 : Right

| Param | Type | | ------------- | ----------------------------------------------------------- | | options | Sunmi_PrintText |

Returns: Promise<{ value: string; }>


Sunmi_PrintTextFont(...)

Sunmi_PrintTextFont(options: Sunmi_PrintText_Font) => Promise<{ value: string; }>

print text You can put the custom font in the 'assets' directory and Specify the font name parameters Set printer alignment ==> Sunmi_SetAlign 0 : Left, 1 : Center, 2 : Right

| Param | Type | | ------------- | --------------------------------------------------------------------- | | options | Sunmi_PrintText_Font |

Returns: Promise<{ value: string; }>


Sunmi_PrintLine(...)

Sunmi_PrintLine(options: Sunmi_Print_Line) => Promise<{ value: string; }>

paper feed three lines Not disabled when line spacing is set to 0 max line 3

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | Sunmi_Print_Line |

Returns: Promise<{ value: string; }>


Sunmi_SetAlign(...)

Sunmi_SetAlign(options: Sunmi_Text_Align) => Promise<{ value: string; }>

Set printer alignment 0 : Left, 1 : Center, 2 : Right

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | Sunmi_Text_Align |

Returns: Promise<{ value: string; }>


Sunmi_FeedPaper()

Sunmi_FeedPaper() => Promise<{ value: string; }>

Due to the distance between the paper hatch and the print head, the paper needs to be fed out automatically But if the Api does not support it, it will be replaced by printing three lines

Returns: Promise<{ value: string; }>


Interfaces

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

QR_Image_Print

| Prop | Type | Description | | ------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | imgData | string | Image Data Base64String | | nCanvasWidth | number | Canvas Width size should be greater than or equal to the actual image size. ( CanvasWidth >= ImageWidth ) ( 캔버스 너비 크기는 실제 이미지 크기 이상이어야 합니다. (CanvasWidth >= ImageWidth ) ) | | nCanvasHeight | number | Canvas Height size should be greater than or equal to the actual image size. ( CanvasHeight >= ImageHeight ) ( 캔버스 높이 크기는 실제 이미지 크기보다 크거나 같아야 합니다. (CanvasHight >= ImageHeight ) ) | | nPosX | number | Canvas coordinates that allow you to print real images at the coordinates you want ( X (left) Point) 원하는 좌표로 실제 이미지를 출력할 수 있는 캔버스 좌표 | | nPosY | number | Canvas coordinates that allow you to print real images at the coordinates you want ( Y (top) Point) 원하는 좌표로 실제 이미지를 출력할 수 있는 캔버스 좌표 | | nScaleWidth | number | Zoom flag The Scale Width shall not exceed a maximum of 384px. ( 0 ~ 384px ) ( 스케일 폭은 최대 384px를 초과해서는 안 됩니다. ) If it is smaller than 384px, the canvas image size is reduced. ( 384px보다 작으면 캔버스 이미지 크기가 줄어듭니다. ) | | nScaleHeight | number | Zoom flag Scale height must be greater than 0px (resize desired) ( 스케일 높이는 0px보다 커야 합니다(원하는 크기 조정) ) | | nAlignment | number | Alignment of actual image output positions 0 : default ==> nPosX, nPosY Point mark 1 : Left Align 2 : Center Align 3 : Right Align |

Sunmi_PrintText

| Prop | Type | Description | | ------------- | ------------------- | -------------- | | msgText | string | Text to print. |

Sunmi_PrintText_Font

| Prop | Type | Description | | ----------------- | -------------------- | -------------------- | | szFontName | string | Font name definition | | msgText | string | Text to print. | | fFontSize | number | Font Size | | isBold | boolean | bold text | | isUnderLine | boolean | Underline text |

Sunmi_Print_Line

| Prop | Type | Description | | ----------- | ------------------- | ---------------------------------------------------------------------------- | | nLine | number | paper feed three lines Not disabled when line spacing is set to 0 max line 3 |

Sunmi_Text_Align

| Prop | Type | Description | | ------------ | ------------------- | ----------------------------------------------------- | | nAlign | number | Set printer alignment 0 : Left, 1 : Center, 2 : Right |