escper 1.1.9 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +30 -15
  2. data/lib/escper/version.rb +1 -1
  3. metadata +1 -1
data/README.md CHANGED
@@ -11,9 +11,11 @@ Introduction
11
11
 
12
12
  Escper is a collection of essential tools that make printing of plain text and images to one or many serial thermal printers easy. Both USB and serial (RS232) printers are supported and detected automatically. Escper is useful for Ruby based Point of Sale systems that want to print receipts or tickets.
13
13
 
14
- While the actual printing is just writing a string to a device node inside of `/dev`, there is some preprocessing necessary. Thermal printers usually have a narrow character set, do not support UTF-8, only ASCII-8BIT. Escper makes it possible to just send UTF-8 text and it does all the conversion work under the covers. For special characters, Escper will map UTF-8 characters to the ASCII-8BIT codes that are actually supported by the currently set codepage on the printer (have a look at the user manual of your printer). The file `lib/escper/codepages.yml` is an example for matching UTF-8 codes to ASCII codes.
14
+ While the actual printing is just writing a string to a device node inside of `/dev`, there is some preprocessing necessary. Thermal printers usually have a narrow character set, do not support UTF-8, only ASCII-8BIT. Escper makes it possible to just conveniently pass an UTF-8 string to the printing method, and it does all the conversion work under the covers. For special characters, Escper will map UTF-8 characters to the ASCII-8BIT codes that are actually supported by the currently set codepage on the printer (have a look at the user manual of your printer). The file `lib/escper/codepages.yml` is an example for matching UTF-8 codes to ASCII codes of the standard codepage of the commonly available Espon and Metapace printers.
15
15
 
16
- Another tricky usecase is where text is mixed with images. Images are transformed into ESCPOS compatible printing data, which is supported by the majority of thermal printers. When mixing text and images, Escper will transform special UTF-8 characters according to the above mentioned codepages.yml file, but leave the image data unchanged.
16
+ Another tricky usecase is where text is mixed with images. Images are transformed into ESCPOS compatible printing data, which is supported by the majority of thermal printers. When mixing text and images in one print 'document', Escper will still transform special UTF-8 characters according to the above mentioned codepages.yml file, but leave the image data raw i.e. unchanged.
17
+
18
+ Escper only supports printers which support plain data copy to their device node living under `/dev`. Printers for which the Kernel does not create a device node that can be opened as a file or as a Serial Port are not supported. Escper does not care about the styling of the text with special printer commands; it is up to the user to pass those commands as part of the printing string. An exception are images; those are converted to ESCPOS code.
17
19
 
18
20
  Some Point of Sale systems, especially those for restaurants, have to send tickets to several printers at the same time (e.g. kitchen, bar, etc.). Escper makes this easy. Have a look at the usage examples below.
19
21
 
@@ -28,13 +30,11 @@ The source of the image can be a file:
28
30
 
29
31
  escpos_code = Escper::Img.new('/path/to/test.png', :file).to_s
30
32
 
31
- The source of the image can also be data which is uploaded from a HTML form:
33
+ The source of the image can also be data which is uploaded from a HTML form. Here, the variable `data` is a variable containing the image data of a multipart HTML form:
32
34
 
33
35
  escpos_code = Escper::Img.new(data.read, :blob).to_s
34
36
 
35
- "Data" is a variable containing the image data of a multipart HTML form.
36
-
37
- Alternatively, the source can be an ImageMagick canvas:
37
+ Alternatively, the image source can also be an ImageMagick canvas:
38
38
 
39
39
  canvas = Magick::Image.new(512, 128)
40
40
  gc = Magick::Draw.new
@@ -50,24 +50,25 @@ Alternatively, the source can be an ImageMagick canvas:
50
50
  gc.draw(canvas)
51
51
  escpos_code = Escper::Img.new(canvas,:obj).to_s
52
52
 
53
- For optimal visual results, when using a file or a blob, the image should previously be converted to an indexed, black and white 1-bit palette image. In Gimp, click on "Image -> Mode -> Indexed..." and select "Use black and white (1-bit) palette". For dithering, choose "Floyd-Steinberg (reduced color bleeding)". The image size depends on the resolution of the printer. The Escper gem contains a test image in `examples/escper.png`.
53
+ For optimal visual results, when using a file or a blob, the image should previously be converted to an indexed, black and white 1-bit palette image. In Gimp, click on "Image -> Mode -> Indexed..." and select "Use black and white (1-bit) palette". For dithering, choose "Floyd-Steinberg (reduced color bleeding)". The image size depends on the resolution of the printer.
54
54
 
55
55
  To send an image directly to a thermal receipt printer in just one line:
56
56
 
57
57
  File.open('/dev/usb/lp0','w') { |f| f.write Escper::Img.new('/path/to/image.png').to_s }
58
58
 
59
- Usecase: Print UTF-8 text to several serial printers at the same time
59
+
60
+ Usecase: Print UTF-8 text to several printers at the same time
60
61
  ------------
61
62
 
62
- First, create printer objects which are simply containers for data about the printer. If you develop your application in a framework like Rails, you also can use the models from this application instead of creating them from within Escper. The only requirements are that the objects respond to the methods `id`, `name`, `path`, `copies` and `codepage`.
63
+ First, create `VendorPrinter` objects which are simply containers for configuration data about the printer. If you develop your application in a framework like Rails, you also can use the models from the Rails application instead of creating them from within Escper. The only requirements are that the objects respond to the methods `id`, `name`, `path`, `copies`, `codepage` and `baudrate`.
63
64
 
64
65
  vp1 = Escper::VendorPrinter.new :id => 1, :name => 'Printer 1 USB', :path => '/dev/usb/lp0', :copies => 1
65
66
  vp2 = Escper::VendorPrinter.new :id => 2, :name => 'Printer 2 USB', :path => '/dev/usb/lp0', :copies => 1
66
67
  vp3 = Escper::VendorPrinter.new :id => 3, :name => 'Printer 3 RS232', :path => '/dev/ttyUSB0', :copies => 1
67
68
 
68
- `id` must be unique numbers which will be needed later during printing. `name` is an arbitrary string which is only used for logging. `path` is the path to a regular file or the device node of the thermal printer which usually lives under `/dev`. Device nodes can be of the type USB or serial (RS232). `copies` are the number of copies of pages that the printer should print. Optionally, you can pass in the key `codepage` which is a number that must correspond to one of the YAML keys in the file `codepages.yml`. By making the `codepage` a parameter of the printer model, it is possible to use several different printers from different manufacturers with different character sets at the same time.
69
+ `id` must be unique integers which will be needed later during printing. `name` is an arbitrary string which is only used for logging. `path` is the path to a regular file or the device node of the thermal printer which usually lives under `/dev`. Device nodes can be of the kinds USB or serial port (RS232). `copies` are the number of duplications of pages that the printer should print. Optionally, you can pass in the key `codepage` which is a number that must correspond to one of the YAML keys in the file `codepages.yml`. By making the `codepage` a parameter of the printer model, it is possible to use several different printers from different manufacturers with different character sets at the same time. `baudrate` is an optional integer to set the speed of the transmission (the default is 9600, this setting is only effective when using RS232 communication).
69
70
 
70
- Next, initialize the printing engine of Escper by passing it an array of the printer objects. It is also possible to pass it a single printer model instead of an array:
71
+ Next, initialize the printing engine of Escper by passing it an array of the VendorPrinter instances. It is also possible to pass a single VendorPrinter instance instead of an Array. As mentioned earlier, you also can pass instances or Arrays of instances of a class that is named differently (e.g. ActiveRecord queries), as longs as it responds to the afore mentioned attributes:
71
72
 
72
73
  print_engine = Escper::Printer.new 'local', [vp1, vp2, vp3]
73
74
 
@@ -116,7 +117,7 @@ Print text and image at the same time:
116
117
 
117
118
  print_engine.print 1, 'print text and image1 {::escper}image1{:/} and image 2 {::escper}image1{:/} to printer 1', raw_images
118
119
 
119
- Note that the magic tag `{::escper}image_key{:/}` will be replaced by Escper with the image that is stored in the hash `raw_images` with the key `image_key`.
120
+ Note that the magic tag `{::escper}image_key{:/}` will be replaced with the image that is stored in the hash `raw_images` with the key `image_key`.
120
121
 
121
122
  After printing is done, close the device nodes again:
122
123
 
@@ -126,7 +127,7 @@ After printing is done, close the device nodes again:
126
127
  Fallback mode
127
128
  ----------------------
128
129
 
129
- If a device node is busy or not writable, Escper will create fallback files instead and append the print data to that file. The fallback files will have the name of the printers and will be saved inside of `/tmp`, or, when you include Escper from Rails, in the `tmp` folder of the Rails app source.
130
+ If a device node is busy or not writable, Escper will create fallback files instead and append the print data to that file. The fallback files will have the name of the printers and will by default be saved in `/tmp`, or, when you include Escper from Rails, in the `tmp` folder of the Rails app source.
130
131
 
131
132
  Configuration
132
133
  ----------------------
@@ -139,9 +140,9 @@ You can configure Escper by calling in your project:
139
140
  config.safe_device_path = File.join('path', 'to', 'outputdir')
140
141
  end
141
142
 
142
- `codepage_file` specifies the path to `codepages.yml`. (for an explanation see above)
143
+ `codepage_file` specifies the path to `codepages.yml`. (for an explanation see above). If not specified, the file `codepages.yml` that is part of this gem distribution will be used.
143
144
 
144
- `use_safe_device_path` can be set to `true` when you are running Escper on a remote server and no actual writes to device nodes should occur. In this case, all print data will be stored in regular files in the path `safe_device_path` with safe file names, which can be further processed or submitted by other programs.
145
+ `use_safe_device_path` can be set to `true` when you are running Escper on a remote server and no actual writes to physical printers should occur. In this case, all print data will be stored in regular files in the path `safe_device_path` with safe/escaped file names, which can be further processed or served by other programs.
145
146
 
146
147
  Additional Features
147
148
  ----------------------
@@ -149,6 +150,20 @@ Additional Features
149
150
  For additional features, please study the source code.
150
151
 
151
152
 
153
+ Application
154
+ ----------------------
155
+
156
+ Escper is actively used in the production-quality Point of Sale products
157
+
158
+ [SALOR Retail](https://github.com/jasonknight/salor-retail)
159
+
160
+ and
161
+
162
+ [SALOR Hospitality](https://github.com/michaelfranzl/SalorHospitality)
163
+
164
+ and indirectly used by dozens of real stores daily, around the clock, around the world.
165
+
166
+
152
167
  Contact
153
168
  ----------------------
154
169
 
@@ -1,3 +1,3 @@
1
1
  module Escper
2
- VERSION = "1.1.9"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: