Comments (16)
Here's how to send ESC/POS commands and few links which is MUST read
- ESC/POS commands list
- For standard text link 1 or alternate mirror
- For image link 2, should convert to javascript version
example: prints text and feeds 10 lines and cuts the paper. (tested on Epson TM-T88V thermal printer and working)
String.prototype.toBytes = function() {
var arr = []
for (var i=0; i < this.length; i++) {
arr.push(this[i].charCodeAt(0))
}
return arr;
}
var printData = "hello world ESC/POS".toBytes().concat([0x01B, 0x64, 10, 0x1d, 0x56, 0x00]);
printer.printDirect({
data: new Buffer(printData)
, printer:'TM_T88V_S_A_192_168_1_152'
, type: 'RAW'
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
}
, error:function(err){console.log(err);}
});
Note: 0x1d, 0x56, 0x00
is the esc/pos cut command
from node-printer.
Sorry, i tried eveything above, none of it working....
I'm using POS 58 Thermal Printer. I can printer is working, but when i try to send an print command from nodejs use nore-printer. If i set type is TEXT The Printer just print a blank line, any else type, printer says nothing. This is my entire code
var printer = require("printer");
String.prototype.toBytes = function (){
var arr = [];
for (var i = 0; i < this.length; i++) {
arr.push(this[i].charCodeAt(0))
}
return arr;
};
var printData = "hello world ESC/POS".toBytes().concat([0x01B, 0x64, 3]);
printer.printDirect({
data: new Buffer(printData)
, printer: 'POS58 10.0.0.6'
, type: 'RAW'
, success: function (jobID){
console.log("sent to printer with ID: " + jobID);
}
, error: function (err){
console.log(err);
}
});
from node-printer.
I think you could use RAW
type to send direct to printer. examples/print_raw.js
. Let me know if this works. Otherwise you have to find the appropiate type format name.
from node-printer.
OK, I have tried but no way... will search hoe the hell this should work.
best,
from node-printer.
Yes! Thanks pushpak. I've looking for this for some time now!
link1 is really useful.
no need to print images now. but I keep that link in mind!
from node-printer.
Thanks @pushpak for your input. Closing this issue.
from node-printer.
Hey @jcerdan, link 1 from @pushpak 's comment doesn't seem to be working anymore. Can anyone provide me with an updated link?
I'm trying to print to a thermal printer with Node.js and suffering some roadblocks.
from node-printer.
Hi @afaqurk.
It works fine for me. If you can't see it install npm module node-escpos as it's a file describing commands for printer to cut, align, etc...
This is the module https://github.com/StadiumRunner/node-escpos
The file is located in lib/commands.js
best,
from node-printer.
Sorry, I meant the second link. Specifically, this one.
from node-printer.
@afaqurk check my updated comment with alternate mirror link
from node-printer.
Thank you!
from node-printer.
Be care full, Nodejs chars are în UTF8 format. You have to transform imto ASCII I suppose.
from node-printer.
How suppose can i do that? I'm new on nodejs. I'm trying to build a app with NWJS. Thanks
from node-printer.
I tried this
new Buffer(printData, 'ascii')
Still nothing.
from node-printer.
Hey, i found out. I used
new Uint8Array(printData).buffer
It's working now. Thanks :)
from node-printer.
Hey , Sangd8 , can you please show me full code for this if it's working for you ?
i have same problem now , and i used Uint8Array(printData).buffer but it shows error to me
Argument 0 must be a string or Buffer
from node-printer.
Related Issues (20)
- Docs unclear - do I need Python on target server, or just on dev machine? Other related questions...
- npm install - The module was compiled against a different Node.js version HOT 3
- Unable to install from NPM HOT 11
- Version NodeJS and Electron HOT 1
- npm published package 0.4.0 doesn't include the fix in #292 HOT 1
- invalid ELF header
- printer.js MODULE_NOT_FOUND after compiling project with pkg HOT 1
- jobs doesnt get filled if printer is a shared printer
- How to get response from device? Not job status HOT 1
- can i delete the Build folder?
- Print PDF from URL HOT 3
- Files spooling but never printing
- Cannot find module './node_printer_darwin_x64.node' HOT 3
- Can't print the Image manipulated by Sharp library & converted into base64 & then after buffer! its prints special characters on Images! HOT 2
- Error: StartDocPrinterW error: code: 1804, message: The specified datatype is invalid. HOT 1
- Error: StartDocPrinterW error: code: 1905, message: ...
- alternative to image printing in windows
- Is it possible to use this on an MacBook M2 ( arm64 )? HOT 1
- Cannot find module './node_printer_win32_x64.node'
- Cant install npm install printer. HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-printer.