
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
react-native-thermal-printer-image-drawer
Advanced tools
$ npm install react-native-go-green-thermal-printer --save
$ react-native link react-native-go-green-thermal-printerlibReact-Core.a, ExternalAccessory.frameworknode_modules âžś react-native-go-green-thermal-printer âžś ios and drag and drop BRPtouchPrinterKitW.framework onto Frameworks in the project navigator$(SRCROOT)/../node_modules/react-native-go-green-thermal-printer/ios with recursive option.Libraries âžś Add Files to [your project's name]node_modules âžś react-native-go-green-thermal-printer and add RNGoGreenThermalPrinter.xcodeprojlibRNGoGreenThermalPrinter.a to your project's Build Phases âžś Link Binary With LibrariesCmd+R)<Main method to call is
rejecter:(RCTPromiseRejectBlock)reject)
On the JS side you need
import { NativeEventEmitter, NativeModules } from 'react-native';
const ThermalPrinter = NativeModules.RNGoGreenThermalPrinter;
const printContent = [];
// each command in array follows structure [<command name>, <command param 0>, <command param 1>, ... <command param n>]
// Check Epson docs for reference
printContent.push(['addText', 'Hello\n']);
printContent.push(['addCut', 0]); //cut paper
// Printing image
printContent.push = [['addImage', img, 0, 0, 500, 300, 1, 0, 0, 1.0, 2 ]]
// in sequence: - (int) addImage:(UIImage *)data x:(long)x y:(long)y
// width:(long)width height:(long)height color:(int)color
// mode:(int)mode halftone:(int)halftone
// brightness:(double)brightness compress:(int)compress;
ThermalPrinter.thermalPrintToIp('TCP:192.168.0.222', printContent, 5000) //timeout in ms, note has to be long enough to print
// Alternate method to print following Zebra syntax, automatically put image starting at 0,0
ThermalPrinter.printImage(img, 300, 300, 'TCP:192.168.0.222', 5000);
Printer supports to main modes of printing, direct thermal and thermal transfer. Thermal transfer uses a ink ribbon to transfer ink to the label. We would generally use direct thermal.
It's best if you handle out of ribbon errors now so that if we switch no code changes are needed, since when it is set in direct thermal mode, out of ribbon will always be false anyway.
The bridge expects base64 encoded PNG, the PNG can be color or greyscale.
A test base64 PNG file test-base64-png.txt is located in the root of this repo for testing.
The package has been configured to expect a 508 x 300 px PNG. For best results generate the PNG in these dimensions.
The label is 2.5" x 1.5" at 203dpi, vertical dot high is slightly shorter for better printing.
Any errors caught will return the error object which contains the error code within, you can check ZebraErrorCode.h to convert the code to a human readable error, or rely on the string error description.
const ZebraPrinter = NativeModules.RNGoGreenZebraPrinter;
export async function zebraPrint() {
const testImg = '<some base64 PNG>';
try {
// Prints PNG to printer
// ZebraPrinter.printImage(<PNG img data>, '<ip address>', <port number>, <timeout in ms>)
// returns printer status *before* sending print instructions
let result = await ZebraPrinter.printImage(testImg, '192.168.0.20', 9100, 2000);
// Gets current printer status
// ZebraPrinter.printerStatusAddressWithString('<ip address>', <port number>, <timeout in ms>)
let result = await ZebraPrinter.printerStatusAddressWithString('192.168.0.20', 9100, 2000);
// Result contains printer status
result = {
detail: {
isHeadCold: false,
isHeadOpen: false, // open when changing/loading labels
isHeadTooHot: false,
isPaperOut: false,
isPartialFormatInProgress: false, // awaiting terminating instruction to be sent
isPaused: false, // when pause key is pressed on printer
isReadyToPrint: true,
isReceiveBufferFull: false,
isRibbonOut: false,
labelLengthInDots: 316, // in height/feed direction
labelsRemainingInBatch: 0,
numberOfFormatsInReceiveBuffer: 0, // how many labels are buffered to print
printMode: 2
},
success: true
}
} catch (e) {
// handle error e
// error codes in the error object can be mapped via ZebraErrorCode.h
// [ <success>, <string description of error>, <error object> ]
}
}
FAQs
## Getting started
The npm package react-native-thermal-printer-image-drawer receives a total of 7 weekly downloads. As such, react-native-thermal-printer-image-drawer popularity was classified as not popular.
We found that react-native-thermal-printer-image-drawer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.