klemen1337 / node-thermal-printer Goto Github PK
View Code? Open in Web Editor NEWNode.js module for Epson, Star, Tanca, Drauma and Brother thermal printers command line printing.
License: MIT License
Node.js module for Epson, Star, Tanca, Drauma and Brother thermal printers command line printing.
License: MIT License
Hello,
I amtrying to connect to a Epson TM-20ii thermal printer through usbbut all i get is false when i run isPrinterConnected. Any solution that i could try to conenect to the printer? I have tryied changing the interfacein init but with no luck.
Thank you for your time
Can you make the "timeout" configureable in the NetPrint function?
I found myself getting too many Error: Socket Timeout error. 3 seconds might not be sufficient for network printers.
Thanks in advance
function NetPrint(host, port) { this.timeout = 3000;
....
Hi,
I have used this package and it is working good. I have some requirement in printing as below.
Hi there -
I'm new to thermal printers. The printer I'm trying to use is a Star TSP100IIILAN model (143 LAN). If I specify in the example.js options an interface of "tcp://10.0.1.15:9100", the net interface will successfully connect to the printer. The buffer is sent to the printer. Then there's a data event which returns "#�".
However, the printer does nothing.
I don't know if this is an issue with node-thermal-printer; I think I'm doing something wrong.
Perhaps this particular STAR printer model needs different commands sent to it than what are specified in this repo's lib/star.js?
Can you point me in the right direction? What do you think I'm doing wrong?
could this feature get added?
http://www.brother.com/product/dev/outline/index.htm
in more detail.. for this printer?
https://www.brother-usa.com/support/ModelInfo.aspx?R3ModelID=ptp700
and could we get it to load a pre existing template file?
would LOVE this feature to get added. and would be willing to pay to have it added. need this for a project im working on. would be willing to spend in 100's area for the feature.
Hai,
I used node thermal printer for access EPSON printer in my application.This npm is dependent on
fs npm
but when i execute printer, i got error like this fs.writeFile is not a function.
printer.init({ type: 'epson', interface: '\USB\VID_04B8&PID_0E15' }); console.log("print",printer); if(printer.isPrinterConnected){ console.log('isPrinterConnected'); } else{ console.log('not Connected'); } printer.cut(); try { printer.execute() } catch (error) { console.log("Print failed", error); }
I have a mobile application in iOS and Android and i want to manage printer via my mobile using react native technologies. so can we convert this module as react native module. if not so what are the reason if possible
printer.isPrinterConnected( function(isConnected){ console.log(isConnected); } );
always returns false, while printer is connected.
I have a problem.. i need to connect two thermal in the same computer.. do you have an example about it ?
Hello, I'm working on web app and now stuck on how to print on dot matrix printer. Does this library support dot matrix printer? I use Epson LX 310 for the printer.
Thanks!
I have printed the bill using USB printer. But when I turn off the printer, it's not return the "false" value for the printer.isPrinterConnected(). It is always prints the "Print done" on console.
var printer = require("node-thermal-printer");
printer.init({
type: "epson",
interface: "printer:RONGTA RP80 Printer"
});
printer.setTextDoubleWidth();
printer.bold(true);
printer.println("Hello World!");
printer.println("********");
printer.isPrinterConnected( function(isConnected){
console.log(isConnected);
if(isConnected){
printer.cut();
printer.execute(function(err){
if (err) {
console.error("Print failed", err);
} else {
console.log("Print done");
}
});
}else{
alert("printer is not connected/Off! Please check it!.");
}
});
What should be the interface name given in windows computer..?
Can someone please help me out thanx!!
Hello!
The console shows:
Printer connected: true
Print done
But nothing is printed.
Thank you very much.
Using Node.js 7.4.0.
if code128 only works on star and printBarcode only works on epson, it would be nice to have printBarcode documented like code128
hello, thank you for your project. do it support print via star bluetooth and zebra bluetooth?
thank you
I see that the config file has partial cut config but is not exposed via any functions in the module. How can I use the partial cut feature?
I am printing over WiFi.
If the printer is off, the callback is triggered two times. Here "printer is not connected! Please check it!." alert is showing two times.
Sometimes, Even In the printer ON condition, "printer is not connected! Please check it!." alert is showing after that printing has happening.(Print done alert).
Does it actual behavior or bug?
`printer.isPrinterConnected(function(isConnected){
console.log(isConnected);
if(isConnected){
printer.cut();
printer.execute(function(err){
if (err) {
alert("Print failed", err);
}else{
alert("Print done");
}
});
}else{
alert("printer is not connected! Please check it!.");
}
});`
Thanks.
Can you please provide help on printing of images in this printer? using the same API?
Other printing is working fine, but we need to print images. Please help.
Regards
Ali
I'm buying an Epson TM-T20 printer. Has anyone tested on it yet?
Thanks
when i want to print chinese, thr print result is messy code,how to solve this?thanks,i am new to nodejs.
I would like to try/catch to do one or the other but they're console.error, not actual errors so I can't.
Hi
I'm not able to print barcode using this library or project. I'm using Zebra TLP 2844 barcode printer.
how add interface printer queue in windows?
Hi, this works very well along with printer package for Windows, including QR and Barcode.
Tested on Epson TM-T82. However, am not able to find any doc on how to draw border for table.
Please help.
Thank you.
Hello!
TLDR; What's broken?
The table generator does not account for the extra line length when using Font B
More Info
When Font B
is used each line is an extra 15 characters wide and the line height remains the same. The problem is that the table generator does not account for the extra line length.
I'm using the Epson TM-T88V, so the 15 character difference might be different on other printers (maybe even less?)
From what it looks like, fixing this would require:
normal
resets font type)I wanted to get this tracked in an issue and will happily knock this out in a PR, but probably won't have time for several weeks though.
Problem
Uglify doesn't understand the ES6 syntax.
let i = "QRCODE_CELLSIZE_".concat(settings.cellSize.toString())
Explanation
I'm building a cross-platform desktop app using electron and react and I'm using npm package 'node-thermal-printer' for usb thermal printer. The printer code works fine in the places where react-scripts build doesn't involve like
But the build fails, when I add the same code in src/index.js where react-scripts build failed with error code ELIFECYCLE, errno 1
Issue Reference
facebook/create-react-app#2640
Expected Solution
The library needs to be compiled down to ES5 before publishing
Suggested Work Around
It's mandate for user to use babel for transpilation at their end.
when i use in MacOS, execute command "node example.js", Espon Printer is Connected my mac by use interface. the console print
"Not yet supported
false"
I'm trying to open the cash drawer however nothing is happening.
Code:
var printer = require("node-thermal-printer")
printer.init({
type: printer.printerTypes.STAR,
interface: 'printer:Star TSP100 Tear Bar (TSP113)',
characterSet: 'UTF8'
})
printer.alignCenter()
printer.isPrinterConnected( function(isConnected){ console.log(isConnected) } )
printer.println("Hello Mr. Santiago")
printer.code128("20101", {
height: 50,
text: 1
})
printer.cut()
printer.openCashDrawer()
printer.execute( function(err){ if(err) console.log(err) } )
Everything else seems to work though. The printer is a "Star TSP100 Tear Bar (TSP113)" is connected via USB to the computer and the cashdrawer is connected to the printer via phone-jack (I guess it is called).
You can add as feature connect via network?
not only by printing through usb
Hi,
i want to use this in a windows box. What should be the interface value for the printer connected to port USB001 ?
Thanks
Lucky
I have successfully printed texts and was able to confirm that most of the text options work but...
I noticed that I can't print anything else. I tried transferring an image onto my raspberry pi which is the computer utilizing the thermal printer, it was in PNG format. I then followed the examples and it just won't print out the image. It did move the thermal paper but nothing was printed.
When I tried printing out barcodes -- same result.. barcodes. I tried printing different formats.
I then moved onto the QR code hoping that would work but... no luck.
Hi guys,
Thanks for the package. It seems there is an update 1 month ago about node-png -> pgnjs, but no new version is pushed to npm.
Could you publish it?
Thanks
Hello, i get stocked in printer.execute()
this is my code
var printer = require("node-thermal-printer");
printer.init({
type: 'epson',
interface: '/dev/usb/lp0'
});
printer.println("Helloworld");
printer.execute(function(err){
console.log("enters");
if (err) {
console.error("Print failed", err);
} else {
console.log("Print done");
}
printer.clear();
});
The program dont execute the line "console.log("enters");"
Do you know of any way to be able to get data back from the printer? Specifically I'd like to check the sensors on whether the printer is out of paper.
It looks like there's not currently the ability to read from the printer, only send to it. Do you think reading in similar to the following might work? I'll try and see what I can figure out in the next few days.
http://stackoverflow.com/questions/2731624/how-to-get-status-from-pos-printer
printer.init({
type: 'star',
interface: 'tcp://192.168.1.10:9100',
characterSet: 'JAPANESE',
removeSpecialCharacters: false,
replaceSpecialCharacters: true,
extraSpecialCharacters:{'円':163}
})
printer.isPrinterConnected( function(isConnected){
console.log('Printer is connected: ', isConnected)
} )
printer.alignCenter()
printer.print("日本は素晴らしい")
printer.println("Test")
printer.println("Qrcode 128")
printer.code128("granpark")
printer.cut()
printer.execute(function (e) {
if (e)
{
console.log("Print Failed:", e)
}
else
{
console.log("Printed")
}
})
This is my code, I would love to know what are the interfaces and how we set one, because I believe I am missing something, However the console does print "Printer is connected: true" but still it isn't printing.
Hi,
I couldn't make my new Star printer print. here is the code:
printer.init({
type: printer.printerTypes.STAR, // 'star' or 'epson'
interface: "tcp://192.168.2.8:9100",
width: 48, // Number of characters in one line (default 48)
characterSet: 'SLOVENIA', // Character set default SLOVENIA
removeSpecialCharacters: false, // Removes special characters - default: false
replaceSpecialCharacters: true, // Replaces special characters listed in config files - default: true
// lineChar: "=", // Use custom character for drawing lines
ip: "localhost", // Ethernet printing IP
port: 9001 // Ethernet printing PORT
});
printer.alignCenter();
printer.println("Hello world");
printer.cut();
printer.execute(function (err) {
if (err) {
console.error("Print failed", err);
reject(err);
} else {
console.log("Print done");
return resolve(true);
}
});
It writes "Print Done" to to console but never prints actually. Is there anyone who faced the same problem?
Hello, please i have tried to import this module into an ember Js app using ember-browserify on a macOs laptop. The import but i got this issue when i tried to execute printer commands following the example provide on the README.
index.js:53 Uncaught TypeError: fs.writeFile is not a function
Please how can i resolve this?
Thank you.
I've had to manually add
specialCharacters: { "£": 35, "@": 64 }
to epsonConfig to enable these special characters. Can there not be a way to extend and support our own character set?
right now, if you try to println null, you get cannot read property length of null
. for me, I'd rather it just print an empty string.
Hi,
Thanks for this npm package. I run the node code using "sudo", but I received the following error.
( I have used "star" printer: TSP100III)
Any suggestions, please?
Output:
Printer is connected: true
Print Failed: { Error: connect ECONNREFUSED 192.168.1.157:9100
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '192.168.1.157',
port: 9100 }
I'm not able to print anything, using Zebra TLP 2844 printer.
Hi,
I'm facing a problem I can't solve. Each time I boot my Ubuntu Mate 18.04 systema, port for usb printer (Epson TM-T20II) changes,
currently it's
crw-rw---- 1 root lp 180, 1 may 8 12:15 lp1
but if I reboot, it can change to lp0 or lp2 or anything else [0-9]...
I have added a dev rule:
$ cat /etc/udev/rules.d/99-myprinters.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0e15", ATTRS{serial}=="544338593290260000", GROUP="lp", OWNER="username", MODE="0660", SYMLINK+="printer"
and symlink is created as follows
ls -l /dev/printer
lrwxrwxrwx 1 root root 15 may 8 12:15 /dev/printer -> bus/usb/001/005
if I do:
$ echo "test" >> /dev/usb/lp0
it prints ok, but
$ echo "test" >> /dev/printer
gives an error.
I'm thinking about creating a script in javascript to check all ports[0-9] and keep the one responding as there's only 1 printer in this system but I would like the OS to solve this issue as I think this can be solved as this.
Has someone faced this problem? Could it be solved disabling upnp in the BIOS?
Regards,
Hi all,
How can I use this module to print a html element?kindly help me to do that
P.S:
I am using Angular JS as front end I need to print a particular div
I'm trying to print two different PNGs and have so far tried printing them on two different STAR printers. And they end up printing, albeit with very visible vertical lines in them. Saving the png before the printing process of converting it to an image buffer for the star printer does not produce those lines, so I believe there might be an issue with the conversion to buffer data.
Any way of fixing this or anybody else who has encountered this?
I'm trying to connect to an Epson network printer however I'm getting the following error
PS D:\Development\test\print-test> node .\app.js
net.js:641
throw new TypeError('invalid data');
^TypeError: invalid data
at Socket.write (net.js:641:11)
at Object.module.exports.execute (D:\Development\test\print-test\node_modules\node-thermal-printer\node-thermal-printer.js:35:15)
at Object. (D:\Development\test\print-test\app.js:15:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
My JS
const printer = require("node-thermal-printer");
printer.init({
type: "epson",
characterSet: "UK",
interface: '/dev/usb/lp0',
ip: "192.168.100.252",
port: 9100
});
printer.isPrinterConnected(function(response){
console.log(response);
});
printer.execute();
Am I doing something wrong?
I want to print chinese but print out the Garbled.
English Is OK.
this is my code:
var printers = require("node-thermal-printer");
printers.init({
type: 'epson',
interface: 'printer:' + printer.getPrinters()[0].name,
characterSet:'CHINA'
});
printers.alignCenter();
printers.println(iconv.encode('--------测试打印----------','GBK'));
printers.println(iconv.encode('--------测试打印----------','UTF-8'));
printers.println('--------测试打印----------');
printers.println('hello');
printers.execute( function(err){
console.dir(err);
});
Can I have bigger size for the font?
I want the font size is bigger than quad area.
Thank you so much!!!
Would you add adafruit printer support?
Also image printing?
Much needed!
Hi,
I have the table with three columns like Column1, Column2, Column3.
If the text of column has more characters, it prints the last character of first line in first character of second line ie same character printed twice.
EXAMPLE:
Expected Output :
Chicken Fried Rice With Curry 1 100
Actual Output :
Chicken Fried Rice With C 1 100
Curry
In above, the "C" character printed twice.
If I change the line number 296 from "obj.text = obj.originalText.substring(cellWidth-1);" to "obj.text = obj.originalText.substring(cellWidth);" in tableCustom function of core.js file , it works as expected.
if(tooLong){ secondLineEnabled = true; //obj.text = obj.originalText.substring(cellWidth-1); obj.text = obj.originalText.substring(cellWidth); secondLine.push(obj); } else { obj.text = ""; secondLine.push(obj); }
Please comment on this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.