The ecspos package is designed to facilitate interactions with printers that support the ESC/POS protocol, providing a streamlined API for common printing tasks including text printing, alignment, and image processing.
go get github.com/dataismo/ecsposA struct that encapsulates the communication with an ESC/POS printer.
printer: Anio.Writerthat represents the output stream to the printer.content: A slice of byte slices, each representing a command or data to send to the printer.imageWidth: An integer specifying the width to use when printing images.
Creates a new Ecspos instance.
- Parameters:
printer: The output destination for print commands, typically an open file handle to a printer device.
- Returns: A pointer to an initialized
Ecsposinstance with default settings.
Sets the width for image printing operations. This can be useful for adjusting how images are scaled before being printed.
- Parameters:
w: The width in pixels.
- Returns: The
*Ecsposinstance to support method chaining.
Configures the printer to align subsequent text centrally.
- Returns: The
*Ecsposinstance for chaining.
Sets text alignment to the left, which is the default state for most printers.
- Returns: The
*Ecsposinstance.
Adjusts text alignment to the right.
Enables bold font style for printed text.
- Returns: The
*Ecsposinstance.
Resets the font style to normal (non-bold).
- Returns: The
*Ecsposinstance.
Appends the provided text to the queue of content to be printed, followed by a newline character.
- Parameters:
txt: The text string to print.
- Returns: The
*Ecsposinstance.