How to generate copies in ESC / POS
This is not possible with ESC/POS. You have to send all data three times if you want three copies.
Python send escpos command to thermal printer character size issue
From reading the docs, it seems to me that you would have to use
b'\x1d' + b'\x21' + b'\x33'
to get 4 times magnification in height as well as width. The two '3' indicate the magnifications minus one. The first is width, the second is height.
So the problem seems to be that you split width and height into two bytes. They should be collected into one byte.
So, in total:
#ESC @ for initiate the printer
string = b'\x1b\x40'
#GS ! command in the doc corresponding to 4 times character height and width
string = string + b'\x1d' + b'\x21' + b'\x33'
string = string + bytes('hello world')
Or, in another way:
def initialize():
# Code for initialization of the printer.
return b'\x1b\x40'
def magnify(wm, hm):
# Code for magnification of characters.
# wm: Width magnification from 1 to 8. Normal width is 1, double is 2, etc.
# hm: Height magnification from 1 to 8. Normal height is 1, double is 2, etc.
return bytes([0x1d, 16*(wm-1) + (hm-1)])
def text(t, encoding="ascii"):
# Code for sending text.
return bytes(t, encoding)
string = initialize() + magnify(4, 4) + text('hello world')
Change code page with ESC/POS on Birch printer
I emailed Birch-POS support and they say the following:
Please suggest customer to use command
\x1F\x1B\x1F\xFF\x49
to set codepage to windows-1251.
Which matches the OPs wireshark comment, quoting:
Using wireshark I managed to get the following HEX dump when setting code page 73 using printer tool:
1f 1b 1f ff 49 ...
Unfortunately, JavaScript (specifically, UTF-8) does not like certain escape sequences over x7F
.
The working code should look like this:
var text = 'Привет мир';
// Use QZ's hex mode, which can workaround JavaScript not allowing certain hex values
var data = [
{
type: 'raw',
format: 'command'
flavor: 'hex',
data: 'x1Fx1Bx1FxFFx49', // Instruct Birch POS: Windows-1251
// data: 'x1Fx1Bx1FxFFx48', // Instruct Birch POS: Windows-1250
},
text + '\r\n'
];
// Tell Java to use a strict 8-bit encoding
var config = qz.configs.create('printer_name', { encoding: 'ISO-8859-1' });
qz.print(config, print_data).catch(function(e) {
console.error(e);
});
Related Topics
Angular Cli App Not Running When Deploying to Linux App Service
Is Wget or Similar Programs Always Available on Posix Systems
Rpm Installation Fails Due to Depencency /Bin/Sh Not Found
Trying to Launch an External Editor from Within a Go Program
How to Find Sample Source Files for Linux Device Drivers, Third Edition
How to Get Command History by Cursor Key in Linux Tclsh
How to Parse Http Headers Using Bash
How to Use File Protocol to Access a Directory on Local System
Sudo User Not Using Same Node Version
What Ncurses Frameworks Are Available for Bash
How to Set Default Arguments for "Ls" in Linux
Ld Does Not Link Opengl on Linux
Live Socket Monitoring with Netlink Inet_Diag