Socket
Socket
Sign inDemoInstall

react-native-thermal-receipt-printer-image-qr

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-thermal-receipt-printer-image-qr

Fork of react-native-thermal-receipt-printer. A React Native Library to support USB/BLE/Net printer


Version published
Weekly downloads
319
decreased by-33.68%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-thermal-receipt-printer-image-qr

npm npm

  • I fork this for my quickly project, this is not the official project.
  • Fork of react-native-thermal-receipt-printer and add implement :
ImplementAndroidIOS
Image & QR:heavy_check_mark::exclamation:
Fix cut:heavy_check_mark::heavy_check_mark:
Print With Column:heavy_check_mark::heavy_check_mark:
NET Connect Timeout:heavy_check_mark::heavy_check_mark:

:grey_exclamation:Print Image & QR with bluetooth in IOS just implement not tested yet

bill screenshot

Installation

npm i react-native-thermal-receipt-printer-image-qr
npm i react-native-ping

or

yarn add react-native-thermal-receipt-printer-image-qr
yarn add react-native-ping

next step

# RN >= 0.60
cd ios && pod install

# RN < 0.60
react-native link react-native-thermal-receipt-printer-image-qr

API Reference

    init: () => Promise;
    getDeviceList: () => Promise;
    /**
     * `timeout`
     * @default 4000ms
     */
    connectPrinter: (host: string, port: number, timeout?: number | undefined) => Promise;
    closeConn: () => Promise;
    /**
     * Print text
     */
    printText: (text: string, opts?: {}) => void;
    /**
     * Print text & end the bill & cut
     */
    printBill: (text: string, opts?: PrinterOptions) => void;
    /**
     * print with image url
     */
    printImage: (imgUrl: string, opts?: PrinterImageOptions) => void;
    /**
     * Base 64 string
     */
    printImageBase64: (Base64: string, opts?: PrinterImageOptions) => void;
    /**
     * Only android print with encoder
     */
    printRaw: (text: string) => void;
    /**
     * print column
     * 80mm => 46 character
     * 58mm => 30 character
     */
    printColumnsText: (texts: string[], columnWidth: number[], columnAliment: ColumnAliment[], columnStyle?: string[], opts?: PrinterOptions) => void;

Styling

import {
  COMMANDS
} from 'react-native-thermal-receipt-printer-image-qr';

See more here

Example

Print Columns Text

const BOLD_ON = COMMANDS.TEXT_FORMAT.TXT_BOLD_ON;
const BOLD_OFF = COMMANDS.TEXT_FORMAT.TXT_BOLD_OFF;
let orderList = [
  ["1. Skirt Palas Labuh Muslimah Fashion", "x2", "500$"],
  ["2. BLOUSE ROPOL VIRAL MUSLIMAH FASHION", "x4222", "500$"],
  ["3. Women Crew Neck Button Down Ruffle Collar Loose Blouse", "x1", "30000000000000$"],
  ["4. Retro Buttons Up Full Sleeve Loose", "x10", "200$"],
  ["5. Retro Buttons Up", "x10", "200$"],
];
let columnAliment = [ColumnAliment.LEFT, ColumnAliment.CENTER, ColumnAliment.RIGHT];
let columnWidth = [46 - (7 + 12), 7, 12]
const header = ['Product list', 'Qty', 'Price']
Printer.printColumnsText(header, columnWidth, columnAliment, [`${BOLD_ON}`, '', '']);
for (let i in orderList) {
  Printer.printColumnsText(orderList[i], columnWidth, columnAliment, [`${BOLD_OFF}`, '', '']);
}
Printer.printBill(`${CENTER}Thank you\n`);

Print image

Printer.printImage('https://media-cdn.tripadvisor.com/media/photo-m/1280/1b/3a/bd/b5/the-food-bill.jpg', {
imageWidth: 575,
// imageHeight: 1000,
// only ios
// paddingX: 100
})

See more here

Troubleshoot

  • when install in react-native version >= 0.60, xcode show this error
duplicate symbols for architecture x86_64

that because the .a library uses CocoaAsyncSocket library and Flipper uses it too

Podfile

...
  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # add_flipper_pods!
  # post_install do |installer|
  #   flipper_post_install(installer)
  # end
...

and comment out code related to Flipper in ios/AppDelegate.m

Support

PrinterAndroidIOS
USBPrinter:heavy_check_mark:
BLEPrinter:heavy_check_mark::heavy_check_mark:
NetPrinter:heavy_check_mark::heavy_check_mark:

Keywords

FAQs

Package last updated on 17 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc