forked from harf18/escpospi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
55 lines (44 loc) · 1.53 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
++++++++++++++
+ Esc/Pos Pi +
++++++++++++++
# Intro
The Esc/Pos Pi Java library provides printing to ESC/POS compatible Thermal printer from Raspberry Pi.
you can print :
- text (many styles and encoding)
- barcode
- QRCode
- Image
->>> Only Serial printers are compatible for now <<<-
It is largely based on python-escpos from Manuel F Martinez (https://github.com/python-escpos/python-escpos)
The code for image printing was written by Gustavo De Micheli (https://github.com/nMoncho)
---------
# Installation
This library uses Pi4J (wich uses WiringPi)
- Install WiringPi : http://wiringpi.com/download-and-install/
- Install Pi4J : http://pi4j.com/install.html
- Using Serial Port
* Permissions : Add yourself to the uucp group to use the port without sudo
$sudo usermod -a -G uucp pi
* Disabling the Serial Console preconfigured for system console (Systemd os like Raspbian Jessie)
$sudo sed -i.old 's/[^ ]*ttyAMA0[^ ]*//g' /boot/cmdline.txt
$sudo systemctl disable [email protected]
---------
# HardWare
To connect a serial printer you need a TTL to RS232 adapter ~$3-$10
---------
# Usage
Printer p = new Printer("serial");
try {
p.open("/dev/ttyAMA0", 9600);
p.setTextNormal();
p.printLn("Hello World");
p.barcode("1324354657687","EAN13",64,2,"","");
p.printQRCode("WHAT A NICE CODE");
p.lineBreak();
p.printImage("myPic.jpg");
} catch (BarcodeSizeError | ConnectionException | IOException | QRCodeException e) {
e.printStackTrace();
} finally {
p.cut();
p.close();
}