constructorEscPosBuilder
public EscPosBuilder(Encoding? encoding = null, bool safeMode = true)
Initializes a new instance of the `EscPosBuilder` class with the specified encoding and safety mode.
- encoding: Encoding?
- The character encoding to use for text commands. Defaults to UTF-8.
- safeMode: bool
- `true` to sanitize control characters in text; otherwise, `false`.
methodAlign
public EscPosBuilder Align(EscPosAlignment alignment)
Sets the horizontal text and graphics alignment.
- alignment: EscPosAlignment
- The alignment mode to apply.
Retorna: The current builder instance for fluent chaining.
methodBarcodeCode128
public EscPosBuilder BarcodeCode128(string data, int height = 64, bool showHri = true)
Appends a one-dimensional Code 128 barcode.
- data: string
- The barcode alphanumeric data.
- height: int
- The barcode height in dots. Defaults to 64.
- showHri: bool
- `true` to print Human Readable Interpretation (HRI) text below the barcode; otherwise, `false`.
Retorna: The current builder instance for fluent chaining.
methodBarcodeCode39
public EscPosBuilder BarcodeCode39(string data, int height = 64, int width = 2, bool showHri = true)
Appends a one-dimensional Code 39 barcode.
- data: string
- The barcode alphanumeric data.
- height: int
- The barcode height in dots. Defaults to 64.
- width: int
- The barcode module width (2 to 6). Defaults to 2.
- showHri: bool
- `true` to print Human Readable Interpretation (HRI) text below the barcode; otherwise, `false`.
Retorna: The current builder instance for fluent chaining.
methodBarcodeEan13
public EscPosBuilder BarcodeEan13(string data, int height = 64, int width = 2, bool showHri = true)
Appends a one-dimensional EAN-13 barcode.
- data: string
- The 12 or 13 numeric digits. If 12 digits are provided, the check digit is computed automatically.
- height: int
- The barcode height in dots. Defaults to 64.
- width: int
- The barcode module width (2 to 6). Defaults to 2.
- showHri: bool
- `true` to print Human Readable Interpretation (HRI) text below the barcode; otherwise, `false`.
Retorna: The current builder instance for fluent chaining.
methodBold
public EscPosBuilder Bold(bool enable = true)
Configures emphasized or bold text mode.
- enable: bool
- `true` to enable bold text; `false` to disable.
Retorna: The current builder instance for fluent chaining.
methodBuild
public IPrintDocument Build(string documentName = "", string? idempotencyKey = null)
Compiles all commands into an immutable `IPrintDocument`.
- documentName: string
- The document name. Defaults to "Receipt".
- idempotencyKey: string?
- An optional unique idempotency tracking key.
Retorna: A compiled immutable `IPrintDocument`.
methodCut
public EscPosBuilder Cut(bool partial = false)
Cuts the receipt paper.
- partial: bool
- `true` to perform a partial cut leaving a connecting tab; `false` for a full cut.
Retorna: The current builder instance for fluent chaining.
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodDivider
public EscPosBuilder Divider(int width = 42, char character = '')
Appends a full-width divider line using the specified character. If `width` is less than or equal to zero, returns the current instance immediately without writing.
- width: int
- The total line width in characters. Defaults to 42. If less than or equal to zero, no divider or newline is appended.
- character: char
- The divider character to repeat. Defaults to '-'.
Retorna: The current builder instance for fluent chaining.
methodDoubleSize
public EscPosBuilder DoubleSize(bool doubleWidth = true, bool doubleHeight = true)
Configures double-width and double-height font magnification.
- doubleWidth: bool
- `true` to enable double-width characters; otherwise, `false`.
- doubleHeight: bool
- `true` to enable double-height characters; otherwise, `false`.
Retorna: The current builder instance for fluent chaining.
methodFeed
public EscPosBuilder Feed(int lines = 1)
Feeds paper by the specified number of lines.
- lines: int
- The number of lines to feed. Defaults to 1.
Retorna: The current builder instance for fluent chaining.
methodFontSize
public EscPosBuilder FontSize(int widthMultiplier = 1, int heightMultiplier = 1)
Sets character font scale multipliers from 1 to 8 times normal width and height.
- widthMultiplier: int
- The horizontal scaling multiplier (1 to 8).
- heightMultiplier: int
- The vertical scaling multiplier (1 to 8).
Retorna: The current builder instance for fluent chaining.
methodInitialize
public EscPosBuilder Initialize()
Resets printer hardware to its default initial state.
Retorna: The current builder instance for fluent chaining.
methodLine
public EscPosBuilder Line(string text = "")
Appends a line of text followed by a line feed.
- text: string
- The string content to append before the line feed. Defaults to empty string.
Retorna: The current builder instance for fluent chaining.
methodOpenCashDrawer
public EscPosBuilder OpenCashDrawer()
Generates the electrical pulse to trigger a connected cash drawer.
Retorna: The current builder instance for fluent chaining.
methodQrCode
public EscPosBuilder QrCode(string data, int moduleSize = 6, EscPosQrErrorCorrection errorCorrection = EscPosQrErrorCorrection.M)
Generates a standard ESC/POS two-dimensional QR code.
- data: string
- The text or URL content for the QR code.
- moduleSize: int
- The QR module pixel size (1 to 16). Defaults to 6.
- errorCorrection: EscPosQrErrorCorrection
- The error correction level. Defaults to `EscPosQrErrorCorrection.M`.
Retorna: The current builder instance for fluent chaining.
methodRaw
public EscPosBuilder Raw(ReadOnlySpan<byte> rawBytes)
Appends raw binary printer command sequences directly to the buffer.
- rawBytes: ReadOnlySpan<byte>
- The raw byte span to append.
Retorna: The current builder instance for fluent chaining.
methodRaw
public EscPosBuilder Raw(byte[] rawBytes)
Appends raw binary printer command sequences directly to the buffer.
- rawBytes: byte[]
- The raw byte array to append.
Retorna: The current builder instance for fluent chaining.
methodTableRow
public EscPosBuilder TableRow(string left, string right, int totalWidth = 42, char fillChar = '')
Appends a two-column row with left- and right-aligned text separated by a filler character.
- left: string
- The left column text.
- right: string
- The right column text.
- totalWidth: int
- The total line width in characters. Defaults to 42.
- fillChar: char
- The filler character between left and right columns. Defaults to space.
Retorna: The current builder instance for fluent chaining.
methodText
public EscPosBuilder Text(string text)
Appends text to the print buffer without appending a line feed.
- text: string
- The string content to append.
Retorna: The current builder instance for fluent chaining.
methodUnderline
public EscPosBuilder Underline(EscPosUnderline underline = EscPosUnderline.SingleDot)
Configures the underline text mode.
- underline: EscPosUnderline
- The underline style to apply.
Retorna: The current builder instance for fluent chaining.
methodUnderline
public EscPosBuilder Underline(bool enable, bool doubleThickness = false)
Configures the underline text mode with optional double thickness.
- enable: bool
- `true` to enable underline; `false` to disable.
- doubleThickness: bool
- `true` to use double-dot thickness; otherwise, `false`.
Retorna: The current builder instance for fluent chaining.