Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

React native thermal receipt printer

NotificationsYou must be signed in to change notification settings

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

 
 

Repository files navigation

npmnpm

ImplementAndroidIOS
Image & QR (URL & Base64)✔️✔️
Fix cut✔️✔️
Print With Column✔️✔️
NET Connect Timeout✔️✔️

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

Support

PrinterAndroidIOS
USBPrinter✔️
BLEPrinter✔️✔️
NetPrinter✔️✔️

billscreenshot

Installation

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

or

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

next step

# RN >= 0.60cd ios && pod install# RN < 0.60react-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[],columnAlignment:ColumnAlignment[],columnStyle?:string[],opts?:PrinterOptions)=>void;

Styling

import{COMMANDS,ColumnAlignment,}from"react-native-thermal-receipt-printer-image-qr";

See more here

Example

Print Columns Text

constBOLD_ON=COMMANDS.TEXT_FORMAT.TXT_BOLD_ON;constBOLD_OFF=COMMANDS.TEXT_FORMAT.TXT_BOLD_OFF;letorderList=[["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$"],];letcolumnAlignment=[ColumnAlignment.LEFT,ColumnAlignment.CENTER,ColumnAlignment.RIGHT,];letcolumnWidth=[46-(7+12),7,12];constheader=["Product list","Qty","Price"];Printer.printColumnsText(header,columnWidth,columnAlignment,[`${BOLD_ON}`,"","",]);for(letiinorderList){Printer.printColumnsText(orderList[i],columnWidth,columnAlignment,[`${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,// paddingX: 100});

See more here

Troubleshoot

  • When installingreact-native version >= 0.60, XCode shows this error:
duplicate symbols for architecture x86_64

That's because the .a library usesCocoaAsyncSocket 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 inios/AppDelegate.m

About

React native thermal receipt printer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java48.3%
  • TypeScript32.6%
  • Objective-C17.0%
  • Ruby1.1%
  • Other1.0%

[8]ページ先頭

©2009-2025 Movatter.jp