Class: Device::Print
- Inherits:
-
Object
- Object
- Device::Print
- Defined in:
- lib/device/print.rb
Constant Summary collapse
- RET_OK =
0- ERR_PRN_BUSY =
Printer busy
-3701 # Printer busy
- ERR_PRN_PAPEROUT =
Out of paper
-3702 # Out of paper
- ERR_PRN_WRONG_PACKAGE =
The format of print data packet error
-3703 # The format of print data packet error
- ERR_PRN_OVERHEAT =
Printer over heating
-3704 # Printer over heating
- ERR_PRN_OUTOFMEMORY =
The print data is too large, and exceeds the buffer length.
-3705 # The print data is too large, and exceeds the buffer length.
- ERR_PRN_OVERVOLTAGE =
Voltage is too high.
-3706 # Voltage is too high.
- ERR_INVALID_PARAM =
Invalid parameter.
-1003 # Invalid parameter.
- ERR_DEV_NOT_EXIST =
Device does not exist.
-1004 # Device does not exist.
- ERR_DEV_BUSY =
Device is busy.
-1005 # Device is busy.
- ERR_FONT_NOT_EXIST =
Font does not exist.
-1008 # Font does not exist.
- DEFAULT_SINGLE_WIDTH =
12- DEFAULT_SINGLE_HEIGHT =
24- DEFAULT_MULTI_WIDTH =
24- DEFAULT_MULTI_HEIGHT =
24
Class Method Summary collapse
- .adapter ⇒ Object
-
.check ⇒ Object
Check printer status, useful for paper check.
-
.close ⇒ NilClass
Closes the printer.
-
.font=(path) ⇒ Object
Selects print font.
-
.level=(value) ⇒ NilClass
Sets printing gray level.
-
.open ⇒ Fixnum
Check printer status, useful for paper check.
-
.paper? ⇒ TrueClass, FalseClass
Check if printer has paper.
-
.paperfeed ⇒ NilClass
Feeds printing paper.
-
.print(string) ⇒ NilClass
Write text on print buffer.
-
.print_bmp(path) ⇒ NilClass
Print bmp file.
-
.puts(string) ⇒ NilClass
Write text on print buffer.
-
.reset ⇒ NilClass
Restore the printer default settings and clear the print buffer data.
-
.size(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ NilClass
Define size, in pixel, of printing.
-
.start(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ Fixnum
Initialize Printer device.
Class Method Details
.adapter ⇒ Object
21 22 23 |
# File 'lib/device/print.rb', line 21 def self.adapter Device.adapter::Print end |
.check ⇒ Object
Check printer status, useful for paper check.
172 173 174 |
# File 'lib/device/print.rb', line 172 def self.check self._check end |
.close ⇒ NilClass
Closes the printer.
72 73 74 |
# File 'lib/device/print.rb', line 72 def self.close self.adapter.close end |
.font=(path) ⇒ Object
Selects print font.
83 84 85 |
# File 'lib/device/print.rb', line 83 def self.font=(path) self.adapter.font = path end |
.level=(value) ⇒ NilClass
Sets printing gray level.
Level =0, reserved, Level =1, default level, normal print slip, Level =2, reserved, Level =3, two-layer thermal printing, Level =4, two-layer thermal printing, higher gray level than 3, The default level is 1. The illegal value does not change current settings.
100 101 102 |
# File 'lib/device/print.rb', line 100 def self.level=(value) self.adapter.level = value end |
.open ⇒ Fixnum
Check printer status, useful for paper check.
58 59 60 |
# File 'lib/device/print.rb', line 58 def self.open self.adapter.open end |
.paper? ⇒ TrueClass, FalseClass
Check if printer has paper
180 181 182 183 184 185 186 |
# File 'lib/device/print.rb', line 180 def self.paper? if self.check == ERR_PRN_PAPEROUT false else true end end |
.paperfeed ⇒ NilClass
Feeds printing paper.
127 128 129 |
# File 'lib/device/print.rb', line 127 def self.paperfeed self.adapter.feed end |
.print(string) ⇒ NilClass
Write text on print buffer.
136 137 138 |
# File 'lib/device/print.rb', line 136 def self.print(string) self.adapter.print(string) end |
.print_bmp(path) ⇒ NilClass
Print bmp file.
Details: Bitmap data is generated as monochromatic, bmp format. Printing bitmap size limit up to 384 pixels in width, spocket with 180 pixels and the height is unlimited. If the bitmap width is larger than the limit of the printer, then it will be sliced on the right side. If the data packet is too long, then this function will remove the LOGO message.
160 161 162 |
# File 'lib/device/print.rb', line 160 def self.print_bmp(path) self.adapter.print_bmp(path) end |
.puts(string) ⇒ NilClass
Write text on print buffer.
145 146 147 |
# File 'lib/device/print.rb', line 145 def self.puts(string) self.adapter.puts(string) end |
.reset ⇒ NilClass
Restore the printer default settings and clear the print buffer data.
65 66 67 |
# File 'lib/device/print.rb', line 65 def self.reset self.adapter.reset end |
.size(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ NilClass
Define size, in pixel, of printing
(For non-monospaced font, width of each character may not meet the settings).
The value ranges from 8 to 64.
117 118 119 120 121 122 |
# File 'lib/device/print.rb', line 117 def self.size(singlecode_width=DEFAULT_SINGLE_WIDTH, singlecode_height=DEFAULT_SINGLE_HEIGHT, multicode_width=DEFAULT_MULTI_WIDTH, multicode_height=DEFAULT_MULTI_HEIGHT) self.adapter.size(singlecode_width, singlecode_height, multicode_width, multicode_height) end |
.start(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ Fixnum
Initialize Printer device.
43 44 45 46 47 48 |
# File 'lib/device/print.rb', line 43 def self.start(singlecode_width=DEFAULT_SINGLE_WIDTH, singlecode_height=DEFAULT_SINGLE_HEIGHT, multicode_width=DEFAULT_MULTI_WIDTH, multicode_height=DEFAULT_MULTI_HEIGHT) self.adapter.start(singlecode_width, singlecode_height, multicode_width, multicode_height) end |