escpos 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -15
- data/lib/escpos/helpers.rb +23 -0
- data/lib/escpos/version.rb +1 -1
- data/lib/escpos.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c24bb0187f21839f9a1e104f73ec21f9ff0f79
|
4
|
+
data.tar.gz: 820003083f5e313efd6913abb1465ab62a9e1b63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74557d010bd475902bd3573603b5dee1388da8b93fbfda060fbb812ed1afd478015fb1cf1e3b5421d4c4fee636722cce23c142bfc6535ebea08c46e738deb59
|
7
|
+
data.tar.gz: e8a267a4224022385f80889711043e589fc065713fe66f65782fa87d40852779f679978c95186e03919cf33ce81f815b082cece0be5c69fd32b7526b1427f43e
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
|
|
26
26
|

|
27
27
|

|
28
28
|

|
29
|
+

|
29
30
|
|
30
31
|
## Usage
|
31
32
|
|
@@ -69,21 +70,26 @@ report = MyReport.new 'path/to/my_report.erb'
|
|
69
70
|
# @printer.to_escpos or @printer.to_base64 contains resulting ESC/POS data
|
70
71
|
```
|
71
72
|
|
72
|
-
## Available
|
73
|
-
|
74
|
-
- text
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
73
|
+
## Available helper methods
|
74
|
+
|
75
|
+
- **text**: Normal text formatting
|
76
|
+
- **encode**: Encode text for the printer
|
77
|
+
- **encoding, set_encoding, set_printer_encoding**: Set printer encoding
|
78
|
+
- **double_height**: Double height text
|
79
|
+
- **quad_text, big, title, header, double_width_double_height, double_height_double_width**: Double width & Double height text
|
80
|
+
- **double_width**: Double width text
|
81
|
+
- **underline, u**: Underlined text
|
82
|
+
- **underline2, u2**: Stronger underlined text
|
83
|
+
- **bold, b**: Bold text
|
84
|
+
- **left**: Align to left
|
85
|
+
- **right**: Align to right
|
86
|
+
- **center**: Align to center
|
87
|
+
- **invert, inverted**: Color inverted text
|
88
|
+
- **black, default_color, color_black, black_color**: Default Color (Usually black)
|
89
|
+
- **red, alt_color, alternative_color, color_red, red_color**: Alternative Color (Usually Red)
|
90
|
+
- **barcode**: Print barcode
|
91
|
+
- **partial_cut**: Partially cut the paper (may not be available on all devices)
|
92
|
+
- **cut**: Fully cut the paper (may not be available on all devices)
|
87
93
|
|
88
94
|
## Contributing
|
89
95
|
|
data/lib/escpos/helpers.rb
CHANGED
@@ -120,6 +120,29 @@ module Escpos
|
|
120
120
|
end
|
121
121
|
alias :invert :inverted
|
122
122
|
|
123
|
+
def black
|
124
|
+
[
|
125
|
+
Escpos.sequence(Escpos::TXT_COLOR_BLACK),
|
126
|
+
data,
|
127
|
+
Escpos.sequence(Escpos::TXT_COLOR_BLACK),
|
128
|
+
].join
|
129
|
+
end
|
130
|
+
alias :default_color :black
|
131
|
+
alias :black_color :black
|
132
|
+
alias :color_black :black
|
133
|
+
|
134
|
+
def red
|
135
|
+
[
|
136
|
+
Escpos.sequence(Escpos::TXT_COLOR_BLACK),
|
137
|
+
data,
|
138
|
+
Escpos.sequence(Escpos::TXT_COLOR_RED),
|
139
|
+
].join
|
140
|
+
end
|
141
|
+
alias :alt_color :red
|
142
|
+
alias :alternative_color :red
|
143
|
+
alias :red_color :red
|
144
|
+
alias :color_red :red
|
145
|
+
|
123
146
|
def barcode(data, opts = {})
|
124
147
|
text_position = opts.fetch(:text_position, Escpos::BARCODE_TXT_OFF)
|
125
148
|
unless [Escpos::BARCODE_TXT_OFF, Escpos::BARCODE_TXT_ABV, Escpos::BARCODE_TXT_BLW, Escpos::BARCODE_TXT_BTH].include?(text_position)
|
data/lib/escpos/version.rb
CHANGED
data/lib/escpos.rb
CHANGED
@@ -86,8 +86,10 @@ module Escpos
|
|
86
86
|
TXT_ALIGN_LT = [ 0x1b, 0x61, 0x00 ] # Left justification
|
87
87
|
TXT_ALIGN_CT = [ 0x1b, 0x61, 0x01 ] # Centering
|
88
88
|
TXT_ALIGN_RT = [ 0x1b, 0x61, 0x02 ] # Right justification
|
89
|
-
TXT_INVERT_ON = [ 0x1d, 0x42, 0x01 ] # Inverted
|
90
|
-
TXT_INVERT_OFF = [ 0x1d, 0x42, 0x00 ] # Inverted
|
89
|
+
TXT_INVERT_ON = [ 0x1d, 0x42, 0x01 ] # Inverted color text
|
90
|
+
TXT_INVERT_OFF = [ 0x1d, 0x42, 0x00 ] # Inverted color text
|
91
|
+
TXT_COLOR_BLACK = [ 0x1b, 0x72, 0x00 ] # Default Color
|
92
|
+
TXT_COLOR_RED = [ 0x1b, 0x72, 0x01 ] # Alternative Color (Usually Red)
|
91
93
|
|
92
94
|
# Barcodes
|
93
95
|
BARCODE_TXT_OFF = [ 0x1d, 0x48, 0x00 ] # HRI barcode chars OFF
|