Documentation ¶
Index ¶
- Constants
- type BarCode
- type Density
- type ErrorStatus
- type Font
- type HRIPosition
- type Justification
- type OfflineStatus
- type PaperSensorStatus
- type PrintModeMask
- type Printer
- func (p Printer) Beep(n, t int) error
- func (p Printer) CR() error
- func (p Printer) Close() error
- func (p Printer) Cut() error
- func (p Printer) CutFeed(n int) error
- func (p Printer) Feed(n int) error
- func (p Printer) FeedLines(n int) error
- func (p Printer) HT() error
- func (p Printer) Initialize() error
- func (p Printer) Justify(j Justification) error
- func (p Printer) LF() error
- func (p Printer) Morse(message string) error
- func (p Printer) MorsePrint(message string) error
- func (p Printer) Print(a ...any) error
- func (p Printer) PrintBarCode(barcodeType BarCode, data string) error
- func (p Printer) PrintImage24(img image.Image, density Density) error
- func (p Printer) PrintImage8(img image.Image, density Density) error
- func (p Printer) Printf(format string, a ...any) error
- func (p Printer) Println(a ...any) error
- func (p Printer) Read(b []byte) (int, error)
- func (p Printer) ResetBarCodeHeight() error
- func (p Printer) ResetLineSpacing() error
- func (p Printer) SelectPrintMode(modes ...PrintModeMask) error
- func (p Printer) SetBarCodeHeight(n int) error
- func (p Printer) SetBold(b bool) error
- func (p Printer) SetCharacterSize(width, height int) error
- func (p Printer) SetFont(f Font) error
- func (p Printer) SetHRIPosition(hp HRIPosition) error
- func (p Printer) SetHT(positions ...int) error
- func (p Printer) SetLineSpacing(n int) error
- func (p Printer) SetReversePrinting(b bool) error
- func (p Printer) SetRotate90(b bool) error
- func (p Printer) SetTabs(width int) error
- func (p Printer) SetUpsideDown(upsidedown bool) error
- func (p Printer) TransmitErrorStatus() (ErrorStatus, error)
- func (p Printer) TransmitOfflineStatus() (OfflineStatus, error)
- func (p Printer) TransmitPaperSensorStatus() (PaperSensorStatus, error)
- func (p Printer) TransmitPrinterStatus() (PrinterStatus, error)
- func (p Printer) Write(b []byte) (int, error)
- type PrinterStatus
Constants ¶
const ( // Default ip and port for hoin printers DefaultHoinIP = "192.168.1.23:9100" HT = 0x09 LF = 0x0A CR = 0x0D GS = 0x1D ESC = 0x1B DLE = 0x10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorStatus ¶
type ErrorStatus struct {
AutoCutter, UnRecoverable, AutoRecoverable bool
}
type HRIPosition ¶
type HRIPosition int
const ( HRINone HRIPosition = iota HRIAbove HRIBelow HRIBoth )
type Justification ¶
type Justification int
const ( LeftJustify Justification = iota CenterJustify RightJustify )
type OfflineStatus ¶
type OfflineStatus struct {
CoverOpen, FeedButton, PrintingStopped, ErrorOccured bool
}
type PaperSensorStatus ¶
type PaperSensorStatus struct {
NearEnd, RollEnd bool
}
type PrintModeMask ¶
type PrintModeMask int
const ( // bit 0: Font selection, 0: Font A (normal), 1: Font B (thin) ThinFont PrintModeMask = 1 << 0 // bit 1 and 2 are unused // bit 3: Bold, 0: Off, 1: On Bold PrintModeMask = 1 << 3 // bit 4: Double height, 0: Off, 1: On DoubleHeight PrintModeMask = 1 << 4 // bit 5: Double width, 0: Off, 1 DoubleWidth PrintModeMask = 1 << 5 // bit 6 unused // bit 7: Underline, 0: Off, 1: On Underline PrintModeMask = 1 << 7 )
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
func NewIpPrinter ¶
func NewPrinter ¶
func NewPrinter(dst io.ReadWriteCloser) Printer
func (Printer) Beep ¶
Beep makes a beep sound n times for t duration
Duration is dependent on the model. For the HOP-E802 each duration is around 100ms
func (Printer) HT ¶
HT moves the print position to the next horizontal tab position
By default HT will do nothing if SetHT is not called with tab positions
func (Printer) Initialize ¶
func (Printer) Justify ¶
func (p Printer) Justify(j Justification) error
Justify sets the alignment to n
func (Printer) MorsePrint ¶
MorsePrint beeps out the morse message but also prints it to the paper
func (Printer) PrintBarCode ¶
PrintBarCode prints the bar code passed in with data.
The size ranges are as follows in (Type: min, max):
BcUPCA: 11, 12 BcUPCE: 6, 7 BcJAN13: 12, 13 BcJAN8: 7, 8 BcCODE39: 0, 14 BcITF: 0, 22 BcCODABAR: 2, 19 BcCODE93: 1, 17 BcCODE123: 0, 65
For the accepted data values:
BcUPCA, BcUPCE, BcJAN13, BcJAN8, BcITF all only accept [0123456789] BcCODE39, BcCODE93, BcCODE123 can accept [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.*$/+% ] BcCODABAR: The first and last character of the CODABAR code bar has to be one of [ABCD] and the rest of the characters in between can be one of [0123456789-$:/.+]
Note on the CODE123 length:
...the docs say it's between 2 and 255 but the printer does not have that limit. On one hand it can go down to 0 character, but also I could not find the limit for max characters. At 15 characters it went off the page with a HOP-E802 printer and at 34 characters it starts printing the HRI weird. At 66 0s repeating it seems to break and stop printing, and the same at 65 As repeating. Long story short...I think they didn't finish programming the checks on CODE123
func (Printer) PrintImage24 ¶
PrintImage24 prints an image in the 24-bit row format. In this format each row is 24 dots tall.
This works the same as PrintImage8() with the only difference being the DPI of the printed image. SingleDensity is 90dpi while DoubleDensity is 180dpi. Vertical DPI is always 180dpi for 24-bit image data.
func (Printer) PrintImage8 ¶
PrintImage8 prints an image in the 8-bit row format. In this format each row is 8 dots tall.
The density selects the horizontal DPI of the image. SingleDensity is 90dpi while DoubleDensity is 180dpi. Vertical DPI is always 60dpi for 8-bit image data.
No black and white conversion is performed on the provided image. The image should be converted before calling this function.
func (Printer) ResetBarCodeHeight ¶
ResetBarCodeHeight sets the bar code height to 162
func (Printer) ResetLineSpacing ¶
ResetLineSpacing sets the spacing to the default which is 1/6-inch lines (approx. 4.23mm)
func (Printer) SelectPrintMode ¶
func (p Printer) SelectPrintMode(modes ...PrintModeMask) error
SelectPrintMode sets the print mode for the printer. The modes are as follows and are provided as variadic arguments:
- ThinFont: Font selection, 0: Font A (normal), 1: Font B (thin)
- Bold: Emphasized mode, 0: Off, 1: On (Emphasized mode just prints the text bold, hence the flag is named 'bold')
- DoubleHeight: Double height, 0: Off (normal), 1: On (double height font)
- DoubleWidth: Double width, 0: Off (normal), 1: On (double width font)
- Underline: Underline, 0: Off (normal), 1: On (underlined font)
func (Printer) SetBarCodeHeight ¶
SetBarCodeHeight sets the bar code height in n dots
func (Printer) SetCharacterSize ¶
SetCharacterSize sets both the width and height of text characters. The values for height and width must be between 0 and 7, inclusively.
While the printer may accept all valid values, it may not print text correctly.
func (Printer) SetHRIPosition ¶
func (p Printer) SetHRIPosition(hp HRIPosition) error
SetHRIPosition sets the printing position of the HRI characters in relation to the barcode
func (Printer) SetHT ¶
SetHT sets the horizontal tab positions
This command cancels previous SetHT commands Multiple positions can be set for tabbing A max of 32 positions can be set Calling SetHT with no argments resets the tab positions
func (Printer) SetLineSpacing ¶
SetLineSpacing sets the line spacing to n * v/h motion units in inches
func (Printer) SetReversePrinting ¶
SetReversePrinting sets the white/black printing mode
If b is true then it will print black text on white background If b is false then it will print white text on black background
func (Printer) SetRotate90 ¶
SetRotate90 turns on 90 clockwise rotation mode for the text
When text is double-width or double-height the text will be mirrored
func (Printer) SetTabs ¶
SetTabs will set up to 32 tab positions at the given width intervals. If the tab value exceeds 256, fewer than 32 positions will be set.
func (Printer) SetUpsideDown ¶
SetUpsideDown will either set or clear printing text upside-down. This setting does not affect images or barcodes.
func (Printer) TransmitErrorStatus ¶
func (p Printer) TransmitErrorStatus() (ErrorStatus, error)
func (Printer) TransmitOfflineStatus ¶
func (p Printer) TransmitOfflineStatus() (OfflineStatus, error)
func (Printer) TransmitPaperSensorStatus ¶
func (p Printer) TransmitPaperSensorStatus() (PaperSensorStatus, error)
func (Printer) TransmitPrinterStatus ¶
func (p Printer) TransmitPrinterStatus() (PrinterStatus, error)
type PrinterStatus ¶
type PrinterStatus struct {
DrawerOpen bool
}