Public .NET API ReferenceL3 Persistence & IntegrationsStableAOT: Partial

EricksonLopez.Printing

High-performance, Native AOT-ready .NET printing ecosystem for ESC/POS thermal receipts and Zebra ZPL II industrial labels over TCP socket pooling, RS-232 serial, and SignalR cloud-to-edge bridge.

8 namespaces46 types232 membersGenerated from XML docs & assemblies · UTC 2026-12-01

Showing 46 of 46 types (232 members)

EricksonLopez.Printing#

14
interface

IPrintDocument

Assembly: EricksonLopez.Printing
public interface IPrintDocument

Defines a print document payload containing raw printer control sequences.

Members (7)

  • methodGetBytes
    byte[] GetBytes()

    Gets the raw binary commands to send to the printer.

    Returns: A byte array containing the raw printer commands.

  • methodGetMemory
    ReadOnlyMemory<byte> GetMemory()

    Gets the raw binary commands to send to the printer as a read-only memory region.

    Returns: A `ReadOnlyMemory<T>` wrapping the document bytes.

    Implementations should override this method to provide a true zero-copy view when backed by a pre-allocated buffer (e.g., `RawPrintDocument` returns `_bytes.AsMemory()`). The default implementation delegates to `GetBytes()` and therefore does not eliminate array allocation on its own.

  • methodWriteToAsync
    ValueTask WriteToAsync(Stream stream, CancellationToken cancellationToken = default)

    Writes the raw binary commands to the specified network or hardware stream.

    stream: Stream
    The destination stream to receive the raw command bytes.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous write operation.

  • propertyDocumentName
    string DocumentName { get; }

    Gets the human-readable name of the document or print job.

  • propertyIdempotencyKey
    string? IdempotencyKey { get; }

    Gets an optional unique idempotency key identifying this print job for deduplication across network and physical retries.

  • propertyIsEmpty
    bool IsEmpty { get; }

    Gets a value indicating whether this print document contains no printable data.

    Used to prevent zero-length submissions from consuming memory or network resources.

  • propertyIsIdempotent
    bool IsIdempotent { get; }

    Gets a value indicating whether this print document is safe to retry on transmission failure.

    When `false`, retries on transmission errors are forbidden to prevent duplicate physical printing.

interface

IPrinterClient

Assembly: EricksonLopez.Printing
public interface IPrinterClient

Defines a client driver capable of transmitting print documents to a physical or network printer.

Members (1)

  • methodPrintAsync
    Task<Result<bool>> PrintAsync(IPrintDocument document, CancellationToken cancellationToken = default)

    Transmits raw document commands asynchronously to the target printer.

    document: IPrintDocument
    The print document payload to transmit.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains a successful result if printed without transmission errors; otherwise, an error result detailing the failure.

    Exceptions: ArgumentNullException: `document` is `null`.

class

PooledTcpPrinterClient

Assembly: EricksonLopez.Printing
public sealed class PooledTcpPrinterClient : IPrinterClient, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IDisposable, IPrinterClient

Provides high-throughput network socket printing using a persistent TCP connection.

Remarks:

Access to the underlying socket is serialized using a `SemaphoreSlim` to prevent concurrent interleaved byte streams.

Members (6)

  • constructorPooledTcpPrinterClient
    public PooledTcpPrinterClient(TcpPrinterClientOptions options)

    Initializes a new instance of the `PooledTcpPrinterClient` class with the specified options.

    options: TcpPrinterClientOptions
    The connection and socket configuration options.

    Exceptions: ArgumentNullException: `options` is `null`

  • constructorPooledTcpPrinterClient
    public PooledTcpPrinterClient(TcpPrinterClientOptions options, ILogger<PooledTcpPrinterClient>? logger)

    Initializes a new instance of the `PooledTcpPrinterClient` class with the specified options and logger.

    options: TcpPrinterClientOptions
    The connection and socket configuration options.
    logger: ILogger<PooledTcpPrinterClient>?
    The optional logger for telemetry and diagnostics.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodDispose
    public void Dispose()

    Inherits documentation from base type or interface.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Inherits documentation from base type or interface.

  • methodPrintAsync
    public async Task<Result<bool>> PrintAsync(IPrintDocument document, CancellationToken cancellationToken = default)

    Transmits raw document commands asynchronously to the target printer.

    document: IPrintDocument
    The print document payload to transmit.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains a successful result if printed without transmission errors; otherwise, an error result detailing the failure.

    Exceptions: ArgumentNullException: `document` is `null`; ObjectDisposedException: Thrown when this client instance has already been disposed

  • methodWarmupAsync
    public async Task WarmupAsync(CancellationToken cancellationToken = default)

    Pre-establishes the persistent TCP connection to the printer endpoint during application startup or container readiness probes, eliminating first-print TCP handshake latency.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `Task` that completes when the connection has been established.

    Exceptions: ObjectDisposedException: This client has already been disposed; SocketException: The connection to the printer endpoint could not be established

class

PrintingErrorCodes

Assembly: EricksonLopez.Printing
public static class PrintingErrorCodes

Provides standard error code constants produced by the printing infrastructure.

Members (5)

  • fieldCanceled
    public const string Canceled

    Represents an error code indicating that a printer operation was canceled by the caller.

  • fieldInvalidOptions
    public const string InvalidOptions

    Represents an error code indicating that client options or parameters are invalid.

  • fieldSocketError
    public const string SocketError

    Represents an error code indicating a socket connection failure.

  • fieldTimeout
    public const string Timeout

    Represents an error code indicating that a printer operation timed out.

  • fieldTransmissionError
    public const string TransmissionError

    Represents an error code indicating a raw network socket transmission failure.

class

PrintingEventIds

Assembly: EricksonLopez.Printing
public static class PrintingEventIds

Provides pre-allocated logging event identifiers for structured telemetry.

Remarks:

Event ID ranges: - 1001–1003: TCP printer lifecycle events. - 1004–1006: Serial printer lifecycle events. - 1010–1011: Resilient retry decorator events.

Members (8)

  • fieldRetryAttempt
    public static readonly EventId RetryAttempt

    Represents the event identifier emitted on a resilient retry attempt.

  • fieldRetryExhausted
    public static readonly EventId RetryExhausted

    Represents the event identifier emitted when all retries have been exhausted.

  • fieldSerialPrintFailed
    public static readonly EventId SerialPrintFailed

    Represents the event identifier emitted when a serial print job fails.

  • fieldSerialPrintStarted
    public static readonly EventId SerialPrintStarted

    Represents the event identifier emitted when a serial print job begins.

  • fieldSerialPrintSuccess
    public static readonly EventId SerialPrintSuccess

    Represents the event identifier emitted when a serial print job succeeds.

  • fieldTcpPrintFailed
    public static readonly EventId TcpPrintFailed

    Represents the event identifier emitted when a TCP print job fails.

  • fieldTcpPrintStarted
    public static readonly EventId TcpPrintStarted

    Represents the event identifier emitted when a TCP print job begins.

  • fieldTcpPrintSuccess
    public static readonly EventId TcpPrintSuccess

    Represents the event identifier emitted when a TCP print job succeeds.

class

PrintingSerialServiceCollectionExtensions

Assembly: EricksonLopez.Printing.Serial
public static class PrintingSerialServiceCollectionExtensions

Provides extension methods for registering serial printing services in an `IServiceCollection`.

Members (2)

  • methodAddKeyedSerialPrinter
    public static IServiceCollection AddKeyedSerialPrinter(this IServiceCollection services, object? serviceKey, Action<SerialPrinterClientOptions> configure)

    Registers a keyed `SerialPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    serviceKey: object?
    The key used to identify this printer client registration.
    configure: Action<SerialPrinterClientOptions>
    The delegate used to configure `SerialPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services`, `serviceKey`, or `configure` is `null`

  • methodAddSerialPrinter
    public static IServiceCollection AddSerialPrinter(this IServiceCollection services, Action<SerialPrinterClientOptions> configure)

    Registers a `SerialPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    configure: Action<SerialPrinterClientOptions>
    The delegate used to configure `SerialPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

class

PrintingServiceCollectionExtensions

Assembly: EricksonLopez.Printing
public static class PrintingServiceCollectionExtensions

Provides extension methods for registering TCP printing services in an `IServiceCollection`.

Members (4)

  • methodAddKeyedPooledTcpPrinter
    public static IServiceCollection AddKeyedPooledTcpPrinter(this IServiceCollection services, object? serviceKey, Action<TcpPrinterClientOptions> configure)

    Registers a keyed persistent `PooledTcpPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    serviceKey: object?
    The key used to identify this printer client registration.
    configure: Action<TcpPrinterClientOptions>
    The delegate used to configure `TcpPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services`, `serviceKey`, or `configure` is `null`

  • methodAddKeyedTcpPrinter
    public static IServiceCollection AddKeyedTcpPrinter(this IServiceCollection services, object? serviceKey, Action<TcpPrinterClientOptions> configure)

    Registers a keyed `TcpPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    serviceKey: object?
    The key used to identify this printer client registration.
    configure: Action<TcpPrinterClientOptions>
    The delegate used to configure `TcpPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services`, `serviceKey`, or `configure` is `null`

  • methodAddPooledTcpPrinter
    public static IServiceCollection AddPooledTcpPrinter(this IServiceCollection services, Action<TcpPrinterClientOptions> configure)

    Registers a persistent `PooledTcpPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    configure: Action<TcpPrinterClientOptions>
    The delegate used to configure `TcpPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

  • methodAddTcpPrinter
    public static IServiceCollection AddTcpPrinter(this IServiceCollection services, Action<TcpPrinterClientOptions> configure)

    Registers a `TcpPrinterClient` as a `ServiceLifetime.Singleton` `IPrinterClient` in the service collection.

    services: this IServiceCollection
    The service collection to register the client into.
    configure: Action<TcpPrinterClientOptions>
    The delegate used to configure `TcpPrinterClientOptions`.

    Returns: The service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

class

RawPrintDocument

Assembly: EricksonLopez.Printing
public sealed class RawPrintDocument : IPrintDocument
Implements: IPrintDocument

Represents an in-memory print document backed by a raw byte array.

Members (8)

  • constructorRawPrintDocument
    public RawPrintDocument(byte[] bytes, string documentName = "", string? idempotencyKey = null, bool isIdempotent = false)

    Initializes a new instance of the `RawPrintDocument` class with the specified byte payload and metadata.

    bytes: byte[]
    The raw byte payload representing the print commands.
    documentName: string
    The human-readable name of the document.
    idempotencyKey: string?
    An optional unique identifier for job deduplication.
    isIdempotent: bool
    `true` if the document is safe to retransmit on failure; otherwise, `false`.

    Exceptions: ArgumentNullException: `bytes` or `documentName` is `null`

  • methodGetBytes
    public byte[] GetBytes()

    Gets the raw binary commands to send to the printer.

    Returns: A byte array containing the raw printer commands.

  • methodGetMemory
    public ReadOnlyMemory<byte> GetMemory()

    Gets the raw binary commands to send to the printer as a read-only memory region.

    Returns: A `ReadOnlyMemory<T>` wrapping the document bytes.

    Implementations should override this method to provide a true zero-copy view when backed by a pre-allocated buffer (e.g., `RawPrintDocument` returns `_bytes.AsMemory()`). The default implementation delegates to `GetBytes()` and therefore does not eliminate array allocation on its own.

  • methodWriteToAsync
    public ValueTask WriteToAsync(Stream stream, CancellationToken cancellationToken = default)

    Writes the raw binary commands to the specified network or hardware stream.

    stream: Stream
    The destination stream to receive the raw command bytes.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous write operation.

  • propertyDocumentName
    public string DocumentName { get; }

    Gets the human-readable name of the document or print job.

  • propertyIdempotencyKey
    public string? IdempotencyKey { get; }

    Gets an optional unique idempotency key identifying this print job for deduplication across network and physical retries.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether this print document contains no printable data.

    Used to prevent zero-length submissions from consuming memory or network resources.

  • propertyIsIdempotent
    public bool IsIdempotent { get; }

    Gets a value indicating whether this print document is safe to retry on transmission failure.

    When `false`, retries on transmission errors are forbidden to prevent duplicate physical printing.

class

ResilientPrinterClient

Assembly: EricksonLopez.Printing
public sealed class ResilientPrinterClient : IPrinterClient
Implements: IPrinterClient

Provides resilient retry and exponential backoff capabilities by decorating an underlying `IPrinterClient`.

Members (2)

  • constructorResilientPrinterClient
    public ResilientPrinterClient(IPrinterClient innerClient, ResilientPrinterOptions? options = null, ILogger<ResilientPrinterClient>? logger = null, TimeProvider? timeProvider = null)

    Initializes a new instance of the `ResilientPrinterClient` class with the specified client, options, logger, and time provider.

    innerClient: IPrinterClient
    The underlying printer client to decorate.
    options: ResilientPrinterOptions?
    The retry policy configuration options.
    logger: ILogger<ResilientPrinterClient>?
    The optional logger for telemetry and diagnostics.
    timeProvider: TimeProvider?
    The optional time provider used for backoff delays.

    Exceptions: ArgumentNullException: `innerClient` is `null`

  • methodPrintAsync
    public async Task<Result<bool>> PrintAsync(IPrintDocument document, CancellationToken cancellationToken = default)

    Transmits raw document commands asynchronously to the target printer.

    document: IPrintDocument
    The print document payload to transmit.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains a successful result if printed without transmission errors; otherwise, an error result detailing the failure.

    Exceptions: ArgumentNullException: `document` is `null`.

class

ResilientPrinterOptions

Assembly: EricksonLopez.Printing
public sealed class ResilientPrinterOptions

Specifies configuration options for resilient print operations and retry policies.

Members (5)

  • propertyBackoffMultiplier
    public double BackoffMultiplier { get; set; }

    Gets or sets the exponential backoff rate multiplier. Defaults to 2.0.

  • propertyInitialDelay
    public TimeSpan InitialDelay { get; set; }

    Gets or sets the initial backoff delay before the first retry attempt. Defaults to 200 milliseconds.

  • propertyMaxDelay
    public TimeSpan MaxDelay { get; set; }

    Gets or sets the maximum ceiling backoff delay between retry attempts. Defaults to 2 seconds.

  • propertyMaxRetries
    public int MaxRetries { get; set; }

    Gets or sets the maximum number of retry attempts for failed print jobs. Defaults to 3.

  • propertyRetryOnTransmissionError
    public bool RetryOnTransmissionError { get; set; }

    Gets or sets a value indicating whether to retry when a transmission error occurs after data transmission has begun.

    The default value is `false` to prevent duplicate physical printouts when partial data has reached the printer.

class

ResilientPrintingExtensions

Assembly: EricksonLopez.Printing
public static class ResilientPrintingExtensions

Provides extension methods for decorating printer clients with resilience and retry capabilities.

Members (1)

  • methodWithRetry
    public static IPrinterClient WithRetry(this IPrinterClient client, Action<ResilientPrinterOptions>? configure = null, ILogger<ResilientPrinterClient>? logger = null, TimeProvider? timeProvider = null)

    Wraps the printer client in a `ResilientPrinterClient` to automatically retry on transient failures.

    client: this IPrinterClient
    The underlying printer client to decorate.
    configure: Action<ResilientPrinterOptions>?
    The optional action to configure retry options.
    logger: ILogger<ResilientPrinterClient>?
    The optional logger for telemetry and diagnostics.
    timeProvider: TimeProvider?
    The optional time provider used for backoff delays.

    Returns: A decorated `IPrinterClient` with retry support.

    Exceptions: ArgumentNullException: `client` is `null`

class

SerialPrinterClientOptions

Assembly: EricksonLopez.Printing.Serial
public sealed class SerialPrinterClientOptions

Specifies configuration options for communicating with a POS receipt or label printer over a serial COM or RS-232 port.

Members (8)

  • propertyBaudRate
    public int BaudRate { get; set; }

    Gets or sets the serial baud rate. Typical values are 9600, 19200, 38400, or 115200. Default is 9600.

  • propertyDataBits
    public int DataBits { get; set; }

    Gets or sets the standard length of data bits per byte. Default is 8.

  • propertyHandshake
    public Handshake Handshake { get; set; }

    Gets or sets the handshaking protocol for serial port transmission. Default is `Handshake.None`.

  • propertyParity
    public Parity Parity { get; set; }

    Gets or sets the parity-checking protocol. Default is `Parity.None`.

  • propertyPortName
    public string PortName { get; set; }

    Gets or sets the serial port name (e.g. "COM1", "COM3", or "/dev/ttyUSB0"). Default is "COM1".

  • propertyReadTimeoutMs
    public int ReadTimeoutMs { get; set; }

    Gets or sets the read timeout in milliseconds. Default is 2000 ms.

  • propertyStopBits
    public StopBits StopBits { get; set; }

    Gets or sets the standard number of stop bits per byte. Default is `StopBits.One`.

  • propertyWriteTimeoutMs
    public int WriteTimeoutMs { get; set; }

    Gets or sets the write timeout in milliseconds. Default is 5000 ms.

class

TcpPrinterClient

Assembly: EricksonLopez.Printing
public sealed class TcpPrinterClient : IPrinterClient
Implements: IPrinterClient

Transmits raw byte streams to a network socket printer over a TCP connection.

Members (3)

  • constructorTcpPrinterClient
    public TcpPrinterClient(TcpPrinterClientOptions options)

    Initializes a new instance of the `TcpPrinterClient` class with the specified options.

    options: TcpPrinterClientOptions
    The connection and socket configuration options.

    Exceptions: ArgumentNullException: `options` is `null`

  • constructorTcpPrinterClient
    public TcpPrinterClient(TcpPrinterClientOptions options, ILogger<TcpPrinterClient>? logger)

    Initializes a new instance of the `TcpPrinterClient` class with the specified options and logger.

    options: TcpPrinterClientOptions
    The connection and socket configuration options.
    logger: ILogger<TcpPrinterClient>?
    The optional logger for telemetry and diagnostics.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodPrintAsync
    public async Task<Result<bool>> PrintAsync(IPrintDocument document, CancellationToken cancellationToken = default)

    Transmits raw document commands asynchronously to the target printer.

    document: IPrintDocument
    The print document payload to transmit.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains a successful result if printed without transmission errors; otherwise, an error result detailing the failure.

    Exceptions: ArgumentNullException: `document` is `null`

class

TcpPrinterClientOptions

Assembly: EricksonLopez.Printing
public sealed class TcpPrinterClientOptions

Specifies configuration options for connecting to a network printer over raw TCP sockets.

Members (5)

  • propertyHost
    public string Host { get; set; }

    Gets or sets the target printer IP address or hostname. Defaults to "127.0.0.1".

  • propertyLingerSeconds
    public int LingerSeconds { get; set; }

    Gets or sets the socket linger time in seconds to control socket closure behavior. Defaults to 0.

  • propertyNoDelay
    public bool NoDelay { get; set; }

    Gets or sets a value indicating whether to disable Nagle's algorithm (TCP_NODELAY) to minimize transmission latency. Defaults to `true`.

  • propertyPort
    public int Port { get; set; }

    Gets or sets the raw socket port number. Defaults to 9100.

  • propertyTimeoutMs
    public int TimeoutMs { get; set; }

    Gets or sets the socket connect and write timeout in milliseconds. Defaults to 5000 milliseconds.

EricksonLopez.Printing.EscPos#

4
enum

EscPosAlignment

Assembly: EricksonLopez.Printing.EscPos
public enum EscPosAlignment : byte

Specifies horizontal text and graphics alignment for ESC/POS commands.

Members (3)

  • fieldCenter
    Center = 1

    Centers content between margins.

  • fieldLeft
    Left = 0

    Aligns content to the left margin.

  • fieldRight
    Right = 2

    Aligns content to the right margin.

class

EscPosBuilder

Assembly: EricksonLopez.Printing.EscPos
public sealed class EscPosBuilder : IDisposable
Implements: IDisposable

Provides a fluent builder for composing Epson ESC/POS receipt printer command sequences.

Remarks:

Builder instances are not thread-safe and must not be shared across concurrent threads. Instances are designed for single-threaded sequential composition of a single print job. The output `IPrintDocument` produced by `Build` is immutable and thread-safe. Releases internal memory streams when disposed. Always use within a `using` block or explicitly call `Dispose`.

Members (23)

  • 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; ArgumentException: `data` is empty, consists only of white-space characters, or exceeds 255 bytes

  • 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`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; ArgumentException: `data` is empty, consists only of white-space characters, or exceeds 255 bytes

  • 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`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; ArgumentException: `data` does not contain 12 or 13 numeric digits, or contains an invalid check digit

  • methodBold
    public EscPosBuilder Bold(bool enable = true)

    Configures emphasized or bold text mode.

    enable: bool
    `true` to enable bold text; `false` to disable.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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.

    Returns: 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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 '-'.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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).

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • methodInitialize
    public EscPosBuilder Initialize()

    Resets printer hardware to its default initial state.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • methodOpenCashDrawer
    public EscPosBuilder OpenCashDrawer()

    Generates the electrical pulse to trigger a connected cash drawer.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; ArgumentNullException: `data` is `null`; ArgumentException: `data` encoded byte length exceeds 7089 bytes

  • 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; NotSupportedException: Safe mode is enabled

  • methodRaw
    public EscPosBuilder Raw(byte[] rawBytes)

    Appends raw binary printer command sequences directly to the buffer.

    rawBytes: byte[]
    The raw byte array to append.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed; ArgumentNullException: `rawBytes` is `null`; NotSupportedException: Safe mode is enabled

  • 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.

    Returns: 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.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • methodUnderline
    public EscPosBuilder Underline(EscPosUnderline underline = EscPosUnderline.SingleDot)

    Configures the underline text mode.

    underline: EscPosUnderline
    The underline style to apply.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ObjectDisposedException: This builder has already been disposed

  • 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`.

    Returns: The current builder instance for fluent chaining.

enum

EscPosQrErrorCorrection

Assembly: EricksonLopez.Printing.EscPos
public enum EscPosQrErrorCorrection : byte

Specifies the error correction level for ESC/POS two-dimensional QR codes.

Members (4)

  • fieldH
    H = 51

    Recovers approximately 30% of damaged or unreadable data.

  • fieldL
    L = 48

    Recovers approximately 7% of damaged or unreadable data.

  • fieldM
    M = 49

    Recovers approximately 15% of damaged or unreadable data.

  • fieldQ
    Q = 50

    Recovers approximately 25% of damaged or unreadable data.

enum

EscPosUnderline

Assembly: EricksonLopez.Printing.EscPos
public enum EscPosUnderline : byte

Specifies the underline mode for ESC/POS text output.

Members (3)

  • fieldDoubleDot
    DoubleDot = 2

    Enables double-dot thickness text underlining.

  • fieldNone
    None = 0

    Disables text underlining.

  • fieldSingleDot
    SingleDot = 1

    Enables single-dot thickness text underlining.

EricksonLopez.Printing.EscPos.Imaging#

3
enum

EscPosDitherAlgorithm

Assembly: EricksonLopez.Printing.EscPos.Imaging
public enum EscPosDitherAlgorithm

Specifies the dithering algorithm used to convert color or grayscale pixels into a 1-bit monochrome printer bitmap.

Members (2)

  • fieldFloydSteinberg
    FloydSteinberg = 1

    Applies Floyd-Steinberg error diffusion dithering, suitable for photographs and shaded continuous-tone images.

  • fieldThreshold
    Threshold = 0

    Applies direct luminance threshold comparison, suitable for line art, solid logos, and text.

class

EscPosImageBuilderExtensions

Assembly: EricksonLopez.Printing.EscPos.Imaging
public static class EscPosImageBuilderExtensions

Provides extension methods for appending graphic bitmap images to an `EscPosBuilder`.

Members (3)

  • methodImage
    public static EscPosBuilder Image(this EscPosBuilder builder, int width, int height, ReadOnlySpan<byte> pixelData, int bytesPerPixel = 3, EscPosDitherAlgorithm algorithm = EscPosDitherAlgorithm.FloydSteinberg, byte scale = 0, int maxAllowedDimension = MonochromeBitmapConverter.MaxDimension)

    Converts and appends raw pixel data to the ESC/POS receipt buffer.

    builder: this EscPosBuilder
    The ESC/POS builder instance.
    width: int
    The image width in pixels.
    height: int
    The image height in pixels.
    pixelData: ReadOnlySpan<byte>
    The raw pixel bytes in RGB, RGBA, or grayscale format.
    bytesPerPixel: int
    The number of bytes per pixel (1, 3, or 4). Defaults to 3.
    algorithm: EscPosDitherAlgorithm
    The dithering algorithm to apply. Defaults to `EscPosDitherAlgorithm.FloydSteinberg`.
    scale: byte
    The scale factor (0=normal, 1=double width, 2=double height, 3=quadruple). Defaults to 0.
    maxAllowedDimension: int
    The maximum allowable pixel dimension. Defaults to `MonochromeBitmapConverter.MaxDimension`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodImage
    public static EscPosBuilder Image(this EscPosBuilder builder, byte[] bmpBytes, EscPosDitherAlgorithm algorithm = EscPosDitherAlgorithm.FloydSteinberg, byte scale = 0, int maxAllowedDimension = MonochromeBitmapConverter.MaxDimension)

    Converts and appends an uncompressed BMP image (24-bit or 32-bit) to the ESC/POS receipt buffer.

    builder: this EscPosBuilder
    The ESC/POS builder instance.
    bmpBytes: byte[]
    The raw bytes of the BMP file.
    algorithm: EscPosDitherAlgorithm
    The dithering algorithm to apply. Defaults to `EscPosDitherAlgorithm.FloydSteinberg`.
    scale: byte
    The scale factor (0=normal, 1=double width, 2=double height, 3=quadruple). Defaults to 0.
    maxAllowedDimension: int
    The maximum allowable pixel dimension. Defaults to `MonochromeBitmapConverter.MaxDimension`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` or `bmpBytes` is `null`

  • methodRasterImage
    public static EscPosBuilder RasterImage(this EscPosBuilder builder, int width, int height, ReadOnlySpan<byte> packedRaster, byte scale = 0)

    Appends pre-packed 1-bit monochrome raster data to the ESC/POS receipt buffer.

    builder: this EscPosBuilder
    The ESC/POS builder instance.
    width: int
    The image width in pixels.
    height: int
    The image height in pixels.
    packedRaster: ReadOnlySpan<byte>
    The packed 1-bit raster data where 1 represents black and 0 represents white.
    scale: byte
    The scale factor (0=normal, 1=double width, 2=double height, 3=quadruple). Defaults to 0.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

class

MonochromeBitmapConverter

Assembly: EricksonLopez.Printing.EscPos.Imaging
public static class MonochromeBitmapConverter

Provides conversion and dithering algorithms to transform pixel buffers and BMP images into 1-bit monochrome ESC/POS raster bit data.

Members (4)

  • methodBuildEscPosRasterCommand
    public static byte[] BuildEscPosRasterCommand(int width, int height, ReadOnlySpan<byte> packedRaster, byte scale = 0)

    Creates an ESC/POS raster bit image command from packed monochrome raster data.

    width: int
    The image width in pixels.
    height: int
    The image height in pixels.
    packedRaster: ReadOnlySpan<byte>
    The packed 1-bit raster data.
    scale: byte
    The scaling factor mode (0 to 3). Defaults to 0.

    Returns: A byte array containing the complete ESC/POS raster graphics command.

    Exceptions: ArgumentOutOfRangeException: `scale` exceeds 3, `width` or `height` is non-positive, or dimensions exceed 65535; ArgumentException: `packedRaster` is smaller than the required packed byte size

  • methodConvertBmpToPacked1Bit
    public static (int Width, int Height, byte[] PackedRaster) ConvertBmpToPacked1Bit(ReadOnlySpan<byte> bmpBytes, EscPosDitherAlgorithm algorithm = EscPosDitherAlgorithm.FloydSteinberg, byte threshold = 128, int maxDimension = MaxDimension)

    Parses an uncompressed Windows Bitmap (BMP) file and converts it to packed 1-bit monochrome raster bytes.

    bmpBytes: ReadOnlySpan<byte>
    The raw bytes of the BMP file.
    algorithm: EscPosDitherAlgorithm
    The dithering algorithm to apply. Defaults to `EscPosDitherAlgorithm.FloydSteinberg`.
    threshold: byte
    The luminance threshold value between 0 and 255. Defaults to 128.
    maxDimension: int
    The maximum allowable pixel width or height. Defaults to `MaxDimension`.

    Returns: A tuple containing the image width, height, and packed 1-bit monochrome raster byte array.

    Supports 24-bit RGB and 32-bit RGBA BMP image formats. Exceptions: ArgumentException: `bmpBytes` is too small to contain a valid BMP header or lacks the 'BM' magic header; InvalidDataException: The BMP header contains invalid dimensions or offsets; NotSupportedException: The BMP bit depth is not 24-bit or 32-bit

  • methodConvertRgbToPacked1Bit
    public static byte[] ConvertRgbToPacked1Bit(int width, int height, ReadOnlySpan<byte> pixelData, int bytesPerPixel = 3, EscPosDitherAlgorithm algorithm = EscPosDitherAlgorithm.FloydSteinberg, byte threshold = 128, int maxDimension = MaxDimension)

    Converts raw RGB, RGBA, or grayscale pixel data into packed 1-bit monochrome raster bytes for thermal printers.

    width: int
    The image width in pixels.
    height: int
    The image height in pixels.
    pixelData: ReadOnlySpan<byte>
    The raw pixel bytes in RGB, RGBA, or grayscale format.
    bytesPerPixel: int
    The number of bytes per pixel (1, 3, or 4). Defaults to 3.
    algorithm: EscPosDitherAlgorithm
    The dithering algorithm to apply. Defaults to `EscPosDitherAlgorithm.FloydSteinberg`.
    threshold: byte
    The luminance threshold value between 0 and 255. Defaults to 128.
    maxDimension: int
    The maximum allowable pixel width or height. Defaults to `MaxDimension`.

    Returns: A byte array containing packed 1-bit monochrome raster data.

    In ESC/POS raster format, bit 1 represents a printed black dot and bit 0 represents white blank space. Exceptions: ArgumentOutOfRangeException: `width` or `height` is non-positive or exceeds `maxDimension`, or `bytesPerPixel` is not 1, 3, or 4; ArgumentException: `pixelData` length is smaller than the required buffer size

  • fieldMaxDimension
    public const int MaxDimension

    Defines the default maximum allowable image dimension in pixels to prevent memory exhaustion.

EricksonLopez.Printing.EscPos.Status#

3
record

EscPosPrinterStatus

Assembly: EricksonLopez.Printing.EscPos.Status
public sealed record EscPosPrinterStatus

Represents the parsed real-time hardware status of an ESC/POS printer.

Members (7)

  • propertyHasCutterError
    public bool HasCutterError { get; init; }

    Gets a value indicating whether an automatic paper cutter error has occurred.

  • propertyHasError
    public bool HasError { get; init; }

    Gets a value indicating whether an error condition is present on the printer.

  • propertyIsCoverOpen
    public bool IsCoverOpen { get; init; }

    Gets a value indicating whether the printer roll cover is open.

  • propertyIsDrawerOpen
    public bool IsDrawerOpen { get; init; }

    Gets a value indicating whether the connected cash drawer is open.

  • propertyIsOnline
    public bool IsOnline { get; init; }

    Gets a value indicating whether the printer is online and ready to accept print commands.

  • propertyIsPaperNearEnd
    public bool IsPaperNearEnd { get; init; }

    Gets a value indicating whether the paper roll is near its end.

  • propertyIsPaperOut
    public bool IsPaperOut { get; init; }

    Gets a value indicating whether paper has completely run out.

class

EscPosStatusCommands

Assembly: EricksonLopez.Printing.EscPos.Status
public static class EscPosStatusCommands

Provides predefined command bytecode sequences for real-time status queries.

Members (4)

  • propertyQueryErrorStatus
    public static ReadOnlyMemory<byte> QueryErrorStatus { get; }

    Gets the command bytes used to query printer hardware error conditions.

  • propertyQueryOfflineCause
    public static ReadOnlyMemory<byte> QueryOfflineCause { get; }

    Gets the command bytes used to query offline status causes such as cover open or paper out.

  • propertyQueryPaperSensor
    public static ReadOnlyMemory<byte> QueryPaperSensor { get; }

    Gets the command bytes used to query roll paper sensor levels.

  • propertyQueryPrinterStatus
    public static ReadOnlyMemory<byte> QueryPrinterStatus { get; }

    Gets the command bytes used to query general printer and cash drawer status.

class

EscPosStatusParser

Assembly: EricksonLopez.Printing.EscPos.Status
public static class EscPosStatusParser

Provides parsing methods for decoding single-byte responses from ESC/POS real-time status queries.

Remarks:

Usage pattern (serial port or raw TCP bidirectional stream): - Send `EscPosStatusCommands.QueryPrinterStatus`, `EscPosStatusCommands.QueryOfflineCause`, `EscPosStatusCommands.QueryErrorStatus`, and `EscPosStatusCommands.QueryPaperSensor` to the printer stream. - Read one byte response for each command (4 bytes total). - Pass the four bytes to `Parse` to obtain a unified `EscPosPrinterStatus` model. Alternatively, use the individual parse methods for targeted single-query scenarios.

Members (5)

  • methodParse
    public static EscPosPrinterStatus Parse(byte statusByte1, byte statusByte2, byte statusByte3, byte statusByte4)

    Combines four status query response bytes into a unified `EscPosPrinterStatus` domain model.

    statusByte1: byte
    The response byte from the printer status query.
    statusByte2: byte
    The response byte from the offline cause status query.
    statusByte3: byte
    The response byte from the error status query.
    statusByte4: byte
    The response byte from the paper sensor status query.

    Returns: A parsed `EscPosPrinterStatus` instance representing the combined printer state.

  • methodParseErrorStatusByte
    public static (bool HasCutterError, bool HasUnrecoverableError) ParseErrorStatusByte(byte response)

    Parses the single-byte response from an error status query.

    response: byte
    The response byte from the printer.

    Returns: A tuple indicating whether an autocutter error or unrecoverable error occurred.

  • methodParseOfflineCauseByte
    public static (bool IsCoverOpen, bool IsPaperOut, bool HasError) ParseOfflineCauseByte(byte response)

    Parses the single-byte response from an offline cause status query.

    response: byte
    The response byte from the printer.

    Returns: A tuple indicating whether the cover is open, a paper-out condition (paper has run out) is present, and whether an error flag is set.

  • methodParsePaperSensorByte
    public static (bool IsPaperNearEnd, bool IsPaperOut) ParsePaperSensorByte(byte response)

    Parses the single-byte response from a roll paper sensor status query.

    response: byte
    The response byte from the printer.

    Returns: A tuple indicating whether paper is near its end or completely exhausted.

  • methodParsePrinterStatusByte
    public static (bool IsDrawerOpen, bool IsOffline) ParsePrinterStatusByte(byte response)

    Parses the single-byte response from a real-time printer status query.

    response: byte
    The response byte from the printer.

    Returns: A tuple indicating whether the drawer is open and whether the printer is offline.

EricksonLopez.Printing.Serial#

1
class

SerialPrinterClient

Assembly: EricksonLopez.Printing.Serial
public sealed class SerialPrinterClient : IPrinterClient, IDisposable
Implements: IDisposable, IPrinterClient

Provides a printer client implementation that transmits raw byte streams to POS receipt and thermal printers over serial COM, RS-232, or virtual COM ports.

Members (4)

  • constructorSerialPrinterClient
    public SerialPrinterClient(SerialPrinterClientOptions options)

    Initializes a new instance of the `SerialPrinterClient` class with the specified options.

    options: SerialPrinterClientOptions
    The serial connection configuration options.

    Exceptions: ArgumentNullException: `options` is `null`

  • constructorSerialPrinterClient
    public SerialPrinterClient(SerialPrinterClientOptions options, ILogger<SerialPrinterClient>? logger)

    Initializes a new instance of the `SerialPrinterClient` class with the specified options and optional logger.

    options: SerialPrinterClientOptions
    The serial connection configuration options.
    logger: ILogger<SerialPrinterClient>?
    The optional logger for telemetry and diagnostics.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodDispose
    public void Dispose()

    Inherits documentation from base type or interface.

  • methodPrintAsync
    public async Task<Result<bool>> PrintAsync(IPrintDocument document, CancellationToken cancellationToken = default)

    Transmits raw document commands asynchronously to the target printer.

    document: IPrintDocument
    The print document payload to transmit.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains a successful result if printed without transmission errors; otherwise, an error result detailing the failure.

    Exceptions: ObjectDisposedException: The client has been disposed; ArgumentNullException: `document` is `null`

EricksonLopez.Printing.SignalR#

12
class

ClaimsTenantPrintScopeValidator

Assembly: EricksonLopez.Printing.SignalR
public sealed class ClaimsTenantPrintScopeValidator : ITenantPrintScopeValidator
Implements: ITenantPrintScopeValidator

Default claims-based implementation of `ITenantPrintScopeValidator` enforcing strict tenant, company, and branch isolation.

Members (4)

  • constructorClaimsTenantPrintScopeValidator
    public ClaimsTenantPrintScopeValidator(IOptions<PrinterHubOptions>? options = null)

    Initializes a new instance of the `ClaimsTenantPrintScopeValidator` class.

    options: IOptions<PrinterHubOptions>?
    Optional hub options configuring claim names and required permissions.
  • methodResolveCallerScope
    public Result<PrintAgentScope> ResolveCallerScope(ClaimsPrincipal? user, string printerId, string? branchId = null)

    Resolves and validates the caller's `PrintAgentScope` directly from their authenticated JWT claims.

    user: ClaimsPrincipal?
    The SignalR caller principal.
    printerId: string
    The target printer identifier.
    branchId: string?
    An optional explicit branch identifier when the caller token spans multiple branches within the company.

    Returns: The verified `PrintAgentScope` on success; otherwise, an unauthorized, forbidden, or validation error.

  • methodValidateCaller
    public Result<PrintAgentScope> ValidateCaller(ClaimsPrincipal? user, string tenantId, string companyId, string branchId, string printerId)

    Validates that `user` is authenticated and authorized for the explicitly requested tenant, company, branch, and printer identifiers.

    user: ClaimsPrincipal?
    The SignalR caller principal.
    tenantId: string
    The requested tenant identifier.
    companyId: string
    The requested company identifier.
    branchId: string
    The requested branch identifier.
    printerId: string
    The target printer identifier.

    Returns: The verified `PrintAgentScope` on success; otherwise, an unauthorized, forbidden, or validation error.

  • propertyDefault
    public static ClaimsTenantPrintScopeValidator Default { get; }

    Gets a shared default validator instance using default `PrinterHubOptions`.

class

HubPrinterDispatcher

Assembly: EricksonLopez.Printing.SignalR
public sealed class HubPrinterDispatcher : IHubPrinterDispatcher
Implements: IHubPrinterDispatcher

Dispatches print jobs to connected edge printer agents via strictly tenant-isolated SignalR groups.

Members (5)

  • constructorHubPrinterDispatcher
    public HubPrinterDispatcher(IHubContext<PrinterHub, IPrinterHubClient> hubContext, TimeProvider? timeProvider = null)

    Initializes a new instance of the `HubPrinterDispatcher` class with the specified hub context and optional time provider.

    hubContext: IHubContext<PrinterHub, IPrinterHubClient>
    The SignalR hub context.
    timeProvider: TimeProvider?
    The optional time provider used for timestamping.

    Exceptions: ArgumentNullException: `hubContext` is `null`.

  • constructorHubPrinterDispatcher
    public HubPrinterDispatcher(IHubContext<PrinterHub, IPrinterHubClient> hubContext, TimeProvider? timeProvider, ILogger<HubPrinterDispatcher>? logger)

    Initializes a new instance of the `HubPrinterDispatcher` class with the specified hub context, time provider, and logger.

    hubContext: IHubContext<PrinterHub, IPrinterHubClient>
    The SignalR hub context.
    timeProvider: TimeProvider?
    The optional time provider used for timestamping.
    logger: ILogger<HubPrinterDispatcher>?
    The optional logger for telemetry and diagnostics.

    Exceptions: ArgumentNullException: `hubContext` is `null`.

  • constructorHubPrinterDispatcher
    public HubPrinterDispatcher(IHubContext<PrinterHub, IPrinterHubClient> hubContext, TimeProvider? timeProvider, IOptions<PrinterHubOptions>? options, ILogger<HubPrinterDispatcher>? logger)

    Initializes a new instance of the `HubPrinterDispatcher` class with the specified hub context, time provider, options, and logger.

    hubContext: IHubContext<PrinterHub, IPrinterHubClient>
    The SignalR hub context.
    timeProvider: TimeProvider?
    The optional time provider used for timestamping.
    options: IOptions<PrinterHubOptions>?
    The optional hub configuration options.
    logger: ILogger<HubPrinterDispatcher>?
    The optional logger for telemetry and diagnostics.

    Exceptions: ArgumentNullException: `hubContext` is `null`.

  • methodDispatchAsync
    public Task<Result<bool>> DispatchAsync(ScopedPrintJobRequest request, CancellationToken cancellationToken = default)

    Dispatches a scoped print job request to all edge agents registered for the specified tenant, company, branch, and printer.

    request: ScopedPrintJobRequest
    The multi-tenant scoped print job request.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation containing `true` when dispatched; otherwise, a structured error.

    Exceptions: ArgumentNullException: `request` or `ScopedPrintJobRequest.Document` is `null`.; OperationCanceledException: The operation was canceled via `cancellationToken`.

  • methodDispatchAsync
    public async Task<Result<bool>> DispatchAsync(string tenantId, string companyId, string branchId, string printerName, IPrintDocument document, string? idempotencyKey = null, CancellationToken cancellationToken = default)

    Dispatches a print document to all edge agents registered for the specified tenant, company, branch, and printer.

    tenantId: string
    The owning tenant identifier.
    companyId: string
    The owning company identifier.
    branchId: string
    The owning branch identifier.
    printerName: string
    The target printer name or identifier.
    document: IPrintDocument
    The print document payload to transmit.
    idempotencyKey: string?
    An optional explicit idempotency key overriding `IPrintDocument.IdempotencyKey`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation containing `true` when dispatched; otherwise, a structured error.

    Exceptions: ArgumentNullException: `document` is `null`.; OperationCanceledException: The operation was canceled via `cancellationToken`.

interface

IHubPrinterDispatcher

Assembly: EricksonLopez.Printing.SignalR
public interface IHubPrinterDispatcher

Defines a contract for dispatching tenant-isolated print documents to edge printer agents connected via SignalR.

Members (2)

  • methodDispatchAsync
    Task<Result<bool>> DispatchAsync(ScopedPrintJobRequest request, CancellationToken cancellationToken = default)

    Dispatches a scoped print job request to all edge agents registered for the specified tenant, company, branch, and printer.

    request: ScopedPrintJobRequest
    The multi-tenant scoped print job request.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation containing `true` when dispatched; otherwise, a structured error.

    Exceptions: ArgumentNullException: `request` or `ScopedPrintJobRequest.Document` is `null`.; OperationCanceledException: The operation was canceled via `cancellationToken`.

  • methodDispatchAsync
    Task<Result<bool>> DispatchAsync(string tenantId, string companyId, string branchId, string printerName, IPrintDocument document, string? idempotencyKey = null, CancellationToken cancellationToken = default)

    Dispatches a print document to all edge agents registered for the specified tenant, company, branch, and printer.

    tenantId: string
    The owning tenant identifier.
    companyId: string
    The owning company identifier.
    branchId: string
    The owning branch identifier.
    printerName: string
    The target printer name or identifier.
    document: IPrintDocument
    The print document payload to transmit.
    idempotencyKey: string?
    An optional explicit idempotency key overriding `IPrintDocument.IdempotencyKey`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation containing `true` when dispatched; otherwise, a structured error.

    Exceptions: ArgumentNullException: `document` is `null`.; OperationCanceledException: The operation was canceled via `cancellationToken`.

interface

IPrinterHubClient

Assembly: EricksonLopez.Printing.SignalR
public interface IPrinterHubClient

Defines client-side operations invoked on printer agents connected via SignalR.

Members (1)

  • methodOnPrintJobReceived
    Task OnPrintJobReceived(PrintJobMessage job)

    Invoked when a print job is dispatched to the connected agent.

    job: PrintJobMessage
    The print job details and payload to be printed

    Returns: A task representing the asynchronous operation.

interface

ITenantPrintScopeValidator

Assembly: EricksonLopez.Printing.SignalR
public interface ITenantPrintScopeValidator

Validates that an authenticated SignalR hub caller is authorized to subscribe to a specific tenant, company, branch, and printer scope.

Members (2)

  • methodResolveCallerScope
    Result<PrintAgentScope> ResolveCallerScope(ClaimsPrincipal? user, string printerId, string? branchId = null)

    Resolves and validates the caller's `PrintAgentScope` directly from their authenticated JWT claims.

    user: ClaimsPrincipal?
    The SignalR caller principal.
    printerId: string
    The target printer identifier.
    branchId: string?
    An optional explicit branch identifier when the caller token spans multiple branches within the company.

    Returns: The verified `PrintAgentScope` on success; otherwise, an unauthorized, forbidden, or validation error.

  • methodValidateCaller
    Result<PrintAgentScope> ValidateCaller(ClaimsPrincipal? user, string tenantId, string companyId, string branchId, string printerId)

    Validates that `user` is authenticated and authorized for the explicitly requested tenant, company, branch, and printer identifiers.

    user: ClaimsPrincipal?
    The SignalR caller principal.
    tenantId: string
    The requested tenant identifier.
    companyId: string
    The requested company identifier.
    branchId: string
    The requested branch identifier.
    printerId: string
    The target printer identifier.

    Returns: The verified `PrintAgentScope` on success; otherwise, an unauthorized, forbidden, or validation error.

record

PrintAgentScope

Assembly: EricksonLopez.Printing.SignalR
public readonly record struct PrintAgentScope

Represents a validated multi-tenant hardware print routing scope bound to a tenant, company, branch, and printer identifier.

Members (7)

  • methodCreate
    public static Result<PrintAgentScope> Create(string? tenantId, string? companyId, string? branchId, string? printerId)

    Validates and constructs a `PrintAgentScope` ensuring all four routing dimensions are present and free of delimiter injection characters.

    tenantId: string?
    The owning tenant identifier.
    companyId: string?
    The owning company identifier.
    branchId: string?
    The owning branch identifier.
    printerId: string?
    The target printer identifier.

    Returns: A validated `PrintAgentScope` on success; otherwise, a validation error.

  • methodToGroupName
    public string ToGroupName()

    Formats the canonical tenant-isolated SignalR group key: `tenant:{TenantId}:company:{CompanyId}:branch:{BranchId}:printer:{PrinterId}`.

    Returns: The canonical SignalR group name.

    Exceptions: InvalidOperationException: Thrown when invoked on an uninitialized empty scope.

  • propertyBranchId
    public string BranchId { get; }

    Gets the normalized branch identifier.

  • propertyCompanyId
    public string CompanyId { get; }

    Gets the normalized company identifier.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether this scope is uninitialized.

  • propertyPrinterId
    public string PrinterId { get; }

    Gets the normalized uppercase printer identifier.

  • propertyTenantId
    public string TenantId { get; }

    Gets the normalized tenant identifier.

record

PrintJobMessage

Assembly: EricksonLopez.Printing.SignalR
public sealed record PrintJobMessage(string JobId, string TenantId, string CompanyId, string BranchId, string PrinterName, string DocumentName, string PayloadBase64, DateTimeOffset CreatedAt, string IdempotencyKey)

Represents a tenant-isolated print job message transmitted over SignalR containing the document payload, scope metadata, and idempotency key.

Members (10)

  • constructorPrintJobMessage
    public PrintJobMessage(string JobId, string TenantId, string CompanyId, string BranchId, string PrinterName, string DocumentName, string PayloadBase64, DateTimeOffset CreatedAt, string IdempotencyKey)

    Initializes a new instance of PrintJobMessage.

    JobId: string
    The unique identifier of the print job.
    TenantId: string
    The owning tenant identifier.
    CompanyId: string
    The owning company identifier.
    BranchId: string
    The owning branch identifier.
    PrinterName: string
    The target physical printer name or workstation identifier.
    DocumentName: string
    The name of the document being printed.
    PayloadBase64: string
    The raw printer commands encoded in Base64.
    CreatedAt: DateTimeOffset
    The timestamp when the job was dispatched.
    IdempotencyKey: string
    The deterministic idempotency key used by edge agents to deduplicate redeliveries.
  • propertyBranchId
    public string BranchId { get; init; }

    The owning branch identifier.

  • propertyCompanyId
    public string CompanyId { get; init; }

    The owning company identifier.

  • propertyCreatedAt
    public DateTimeOffset CreatedAt { get; init; }

    The timestamp when the job was dispatched.

  • propertyDocumentName
    public string DocumentName { get; init; }

    The name of the document being printed.

  • propertyIdempotencyKey
    public string IdempotencyKey { get; init; }

    The deterministic idempotency key used by edge agents to deduplicate redeliveries.

  • propertyJobId
    public string JobId { get; init; }

    The unique identifier of the print job.

  • propertyPayloadBase64
    public string PayloadBase64 { get; init; }

    The raw printer commands encoded in Base64.

  • propertyPrinterName
    public string PrinterName { get; init; }

    The target physical printer name or workstation identifier.

  • propertyTenantId
    public string TenantId { get; init; }

    The owning tenant identifier.

class

PrinterHub

Assembly: EricksonLopez.Printing.SignalR
public sealed class PrinterHub : Hub<IPrinterHubClient>
Inherits: Hub<IPrinterHubClient>

Provides an authenticated, multi-tenant isolated SignalR hub managing connections and group memberships for local hardware printer agents.

Members (11)

  • constructorPrinterHub
    public PrinterHub()

    Initializes a new instance of the `PrinterHub` class using the default `ClaimsTenantPrintScopeValidator`.

  • constructorPrinterHub
    public PrinterHub(ITenantPrintScopeValidator? scopeValidator)

    Initializes a new instance of the `PrinterHub` class with the specified scope validator.

    scopeValidator: ITenantPrintScopeValidator?
    The validator used to verify tenant, company, and branch isolation for callers.
  • methodGetPrinterGroupName
    public static string GetPrinterGroupName(string tenantId, string companyId, string branchId, string printerName)

    Formats the canonical multi-tenant SignalR printer group key: `tenant:{TenantId}:company:{CompanyId}:branch:{BranchId}:printer:{PrinterId}`.

    tenantId: string
    The owning tenant identifier.
    companyId: string
    The owning company identifier.
    branchId: string
    The owning branch identifier.
    printerName: string
    The target printer identifier.

    Returns: The normalized SignalR group name.

    Exceptions: ArgumentException: Any scope identifier is empty or contains illegal delimiter characters.

  • methodOnConnectedAsync
    public override async Task OnConnectedAsync()

    Inherits documentation from base type or interface.

  • methodOnDisconnectedAsync
    public override async Task OnDisconnectedAsync(Exception? exception)

    Inherits documentation from base type or interface.

    exception: Exception?
  • methodRegisterPrinter
    public async Task RegisterPrinter(string printerName, string? branchId = null)

    Enrolls the authenticated calling client connection into the tenant-isolated printer group resolved from the caller's claims.

    printerName: string
    The name or identifier of the printer to register.
    branchId: string?
    An optional explicit branch identifier validated against the caller's claims.

    Returns: A task representing the asynchronous operation.

    Exceptions: ArgumentException: `printerName` is `null` or whitespace.; HubException: The caller is unauthenticated or lacks valid tenant, company, or branch authorization.

  • methodRegisterPrinterAsync
    public Task RegisterPrinterAsync(string printerName, string? branchId = null)

    Enrolls the authenticated calling client connection into the tenant-isolated printer group asynchronously.

    printerName: string
    The name or identifier of the printer to register.
    branchId: string?
    An optional explicit branch identifier validated against the caller's claims.

    Returns: A task representing the asynchronous operation.

  • methodRegisterPrinterScoped
    public async Task RegisterPrinterScoped(string tenantId, string companyId, string branchId, string printerName)

    Enrolls the authenticated calling client connection into the explicitly specified tenant, company, branch, and printer group after verifying caller ownership.

    tenantId: string
    The owning tenant identifier.
    companyId: string
    The owning company identifier.
    branchId: string
    The owning branch identifier.
    printerName: string
    The target printer identifier.

    Returns: A task representing the asynchronous operation.

    Exceptions: ArgumentException: `printerName` is `null` or whitespace.; HubException: The caller is unauthenticated or attempts cross-tenant, cross-company, or cross-branch enrollment.

  • methodUnregisterPrinter
    public async Task UnregisterPrinter(string printerName, string? branchId = null)

    Removes the calling client connection from the tenant-isolated printer group resolved from the caller's claims.

    printerName: string
    The name or identifier of the printer to unregister.
    branchId: string?
    An optional explicit branch identifier validated against the caller's claims.

    Returns: A task representing the asynchronous operation.

    Exceptions: HubException: The caller is unauthenticated or lacks valid tenant, company, or branch authorization.

  • methodUnregisterPrinterAsync
    public Task UnregisterPrinterAsync(string printerName, string? branchId = null)

    Removes the calling client connection from the tenant-isolated printer group asynchronously.

    printerName: string
    The name or identifier of the printer to unregister.
    branchId: string?
    An optional explicit branch identifier validated against the caller's claims.

    Returns: A task representing the asynchronous operation.

  • methodUnregisterPrinterScoped
    public async Task UnregisterPrinterScoped(string tenantId, string companyId, string branchId, string printerName)

    Removes the calling client connection from the explicitly specified tenant, company, branch, and printer group after verifying caller ownership.

    tenantId: string
    The owning tenant identifier.
    companyId: string
    The owning company identifier.
    branchId: string
    The owning branch identifier.
    printerName: string
    The target printer identifier.

    Returns: A task representing the asynchronous operation.

    Exceptions: HubException: The caller is unauthenticated or attempts cross-tenant, cross-company, or cross-branch group modification.

class

PrinterHubOptions

Assembly: EricksonLopez.Printing.SignalR
public sealed class PrinterHubOptions

Configures security, claim extraction, and payload size limits for `PrinterHub` and `HubPrinterDispatcher`.

Members (6)

  • propertyBranchClaimTypes
    public IReadOnlyList<string> BranchClaimTypes { get; set; }

    Gets or sets the ordered claim types inspected to resolve the caller's branch identifier.

  • propertyCompanyClaimTypes
    public IReadOnlyList<string> CompanyClaimTypes { get; set; }

    Gets or sets the ordered claim types inspected to resolve the caller's company identifier.

  • propertyMaxPayloadBytes
    public int MaxPayloadBytes { get; set; }

    Gets or sets the maximum allowable raw print payload size in bytes. Defaults to 1 MiB (1,048,576 bytes).

  • propertyPermissionClaimType
    public string PermissionClaimType { get; set; }

    Gets or sets the claim type inspected when `RequiredPermissions` is non-empty.

  • propertyRequiredPermissions
    public IReadOnlySet<string> RequiredPermissions { get; set; }

    Gets or sets the optional set of permissions where at least one must be held by the caller to register a printer. When empty, claim-based tenant/company/branch isolation is enforced without requiring a specific permission claim.

  • propertyTenantClaimTypes
    public IReadOnlyList<string> TenantClaimTypes { get; set; }

    Gets or sets the ordered claim types inspected to resolve the caller's tenant identifier.

class

PrintingSignalRServiceCollectionExtensions

Assembly: EricksonLopez.Printing.SignalR
public static class PrintingSignalRServiceCollectionExtensions

Provides extension methods for registering tenant-isolated SignalR printing services in Microsoft Dependency Injection.

Members (1)

  • methodAddPrintingSignalR
    public static IServiceCollection AddPrintingSignalR(this IServiceCollection services, Action<PrinterHubOptions>? configure = null)

    Registers `ITenantPrintScopeValidator`, `IHubPrinterDispatcher`, and SignalR dependencies in the service collection.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<PrinterHubOptions>?
    An optional delegate to configure `PrinterHubOptions`.

    Returns: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`.

record

ScopedPrintJobRequest

Assembly: EricksonLopez.Printing.SignalR
public sealed record ScopedPrintJobRequest(string TenantId, string CompanyId, string BranchId, string PrinterId, IPrintDocument Document, string? IdempotencyKey)

Represents a multi-tenant scoped print job dispatch request targeting a specific tenant, company, branch, and printer.

Members (7)

  • constructorScopedPrintJobRequest
    public ScopedPrintJobRequest(string TenantId, string CompanyId, string BranchId, string PrinterId, IPrintDocument Document, string? IdempotencyKey = null)

    Initializes a new instance of ScopedPrintJobRequest.

    TenantId: string
    The owning tenant identifier.
    CompanyId: string
    The owning company identifier.
    BranchId: string
    The owning branch identifier.
    PrinterId: string
    The target physical printer identifier.
    Document: IPrintDocument
    The print document payload to transmit.
    IdempotencyKey: string?
    An optional explicit idempotency key overriding `IPrintDocument.IdempotencyKey`.
  • propertyBranchId
    public string BranchId { get; init; }

    The owning branch identifier.

  • propertyCompanyId
    public string CompanyId { get; init; }

    The owning company identifier.

  • propertyDocument
    public IPrintDocument Document { get; init; }

    The print document payload to transmit.

  • propertyIdempotencyKey
    public string? IdempotencyKey { get; init; }

    An optional explicit idempotency key overriding `IPrintDocument.IdempotencyKey`.

  • propertyPrinterId
    public string PrinterId { get; init; }

    The target physical printer identifier.

  • propertyTenantId
    public string TenantId { get; init; }

    The owning tenant identifier.

class

SignalRPrintingEventIds

Assembly: EricksonLopez.Printing.SignalR
public static class SignalRPrintingEventIds

Provides standardized `EventId` constants for structured telemetry in the SignalR printing bridge.

Remarks:

Event ID range 2001–2003 is reserved for SignalR dispatcher events to avoid collision with core transport Event IDs (1001–1011).

Members (3)

  • fieldDispatchFailed
    public static readonly EventId DispatchFailed

    Event ID emitted when a print job dispatch to an edge printer fails.

  • fieldDispatchStarted
    public static readonly EventId DispatchStarted

    Event ID emitted when a print job dispatch to an edge printer is initiated over SignalR.

  • fieldDispatchSuccess
    public static readonly EventId DispatchSuccess

    Event ID emitted when a print job is successfully acknowledged and dispatched to the edge client.

EricksonLopez.Printing.Zpl#

5
class

ZplBuilder

Assembly: EricksonLopez.Printing.Zpl
public sealed class ZplBuilder

Provides a fluent builder for compiling Zebra Programming Language (ZPL II) industrial labels.

Remarks:

This type is not thread-safe. Builder instances must not be shared across concurrent threads. The builder is designed for single-threaded sequential composition of one label per instance. The output `IPrintDocument` produced by `Build` is immutable and safe for concurrent use.

Members (14)

  • constructorZplBuilder
    public ZplBuilder(bool safeMode = false)

    Initializes a new instance of the `ZplBuilder` class and begins a new label format (`^XA`).

    safeMode: bool
    `true` to disallow raw command injection; otherwise, `false`.
  • methodBarcodeCode128
    public ZplBuilder BarcodeCode128(int x, int y, string data, int height = 60, bool showText = true, ZplOrientation orientation = ZplOrientation.Normal)

    Adds a Code 128 barcode at the specified coordinates (`^BC`).

    x: int
    The x-coordinate of the barcode in dots
    y: int
    The y-coordinate of the barcode in dots
    data: string
    The barcode data string
    height: int
    The barcode height in dots. Must be greater than zero.
    showText: bool
    `true` to print the human-readable interpretation line; otherwise, `false`.
    orientation: ZplOrientation
    The barcode orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentException: `data` is `null`, empty, whitespace, or contains ZPL command delimiters; ArgumentOutOfRangeException: `height` is less than or equal to zero

  • methodBarcodeCode39
    public ZplBuilder BarcodeCode39(int x, int y, string data, int height = 60, bool showText = true, ZplOrientation orientation = ZplOrientation.Normal)

    Adds a Code 39 barcode at the specified coordinates (`^B3`).

    x: int
    The x-coordinate of the barcode in dots
    y: int
    The y-coordinate of the barcode in dots
    data: string
    The barcode data string
    height: int
    The barcode height in dots. Must be greater than zero.
    showText: bool
    `true` to print the human-readable interpretation line; otherwise, `false`.
    orientation: ZplOrientation
    The barcode orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentException: `data` is `null`, empty, whitespace, or contains ZPL command delimiters; ArgumentOutOfRangeException: `height` is less than or equal to zero

  • methodBarcodeEan13
    public ZplBuilder BarcodeEan13(int x, int y, string data, int height = 60, bool showText = true, ZplOrientation orientation = ZplOrientation.Normal)

    Adds an EAN-13 barcode at the specified coordinates (`^BE`).

    x: int
    The x-coordinate of the barcode in dots
    y: int
    The y-coordinate of the barcode in dots
    data: string
    The barcode data string
    height: int
    The barcode height in dots. Must be greater than zero.
    showText: bool
    `true` to print the human-readable interpretation line; otherwise, `false`.
    orientation: ZplOrientation
    The barcode orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentException: `data` is `null`, empty, whitespace, or contains ZPL command delimiters; ArgumentOutOfRangeException: `height` is less than or equal to zero

  • methodBox
    public ZplBuilder Box(int x, int y, int width, int height, int borderThickness = 2)

    Draws a graphic box or line at the specified coordinates (`^GB`).

    x: int
    The x-coordinate of the box in dots
    y: int
    The y-coordinate of the box in dots
    width: int
    The box width in dots. Must be non-negative.
    height: int
    The box height in dots. Must be non-negative.
    borderThickness: int
    The border line thickness in dots. Default is 2. Must be non-negative.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentOutOfRangeException: `width`, `height`, or `borderThickness` is negative

  • methodBuild
    public IPrintDocument Build(string documentName = "", string? idempotencyKey = null)

    Compiles all configured ZPL commands into an immutable `IPrintDocument`.

    documentName: string
    The document name for telemetry and spool tracking. Default is "ZebraLabel".
    idempotencyKey: string?
    The optional unique idempotency tracking key

    Returns: An immutable `IPrintDocument` containing the complete ZPL II label stream.

  • methodCircle
    public ZplBuilder Circle(int x, int y, int diameter, int borderThickness = 2)

    Draws a graphic circle at the specified coordinates (`^GC`).

    x: int
    The x-coordinate of the circle center in dots
    y: int
    The y-coordinate of the circle center in dots
    diameter: int
    The circle diameter in dots. Must be non-negative.
    borderThickness: int
    The border line thickness in dots. Default is 2. Must be non-negative.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentOutOfRangeException: `diameter` or `borderThickness` is negative

  • methodDiagonalLine
    public ZplBuilder DiagonalLine(int x, int y, int width, int height, int borderThickness = 2, bool rightLeaning = false)

    Draws a graphic diagonal line at the specified coordinates (`^GD`).

    x: int
    The x-coordinate of the diagonal bounding box in dots
    y: int
    The y-coordinate of the diagonal bounding box in dots
    width: int
    The bounding box width in dots. Must be non-negative.
    height: int
    The bounding box height in dots. Must be non-negative.
    borderThickness: int
    The line thickness in dots. Default is 2. Must be non-negative.
    rightLeaning: bool
    `true` for a right-leaning diagonal (/); `false` for a left-leaning diagonal (\).

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentOutOfRangeException: `width`, `height`, or `borderThickness` is negative

  • methodEllipse
    public ZplBuilder Ellipse(int x, int y, int width, int height, int borderThickness = 2)

    Draws a graphic ellipse at the specified coordinates (`^GE`).

    x: int
    The x-coordinate of the ellipse in dots
    y: int
    The y-coordinate of the ellipse in dots
    width: int
    The ellipse width in dots. Must be non-negative.
    height: int
    The ellipse height in dots. Must be non-negative.
    borderThickness: int
    The border line thickness in dots. Default is 2. Must be non-negative.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentOutOfRangeException: `width`, `height`, or `borderThickness` is negative

  • methodLabelDimensions
    public ZplBuilder LabelDimensions(int width, int length)

    Configures the label print width (`^PW`) and label length (`^LL`) in dots.

    width: int
    The print width in dots. Must be greater than zero.
    length: int
    The label length in dots. Must be greater than zero.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentOutOfRangeException: `width` or `length` is less than or equal to zero

  • methodQrCode
    public ZplBuilder QrCode(int x, int y, string data, int magnification = 4, ZplOrientation orientation = ZplOrientation.Normal)

    Adds a two-dimensional QR code at the specified coordinates (`^BQ`).

    x: int
    The x-coordinate of the QR code in dots
    y: int
    The y-coordinate of the QR code in dots
    data: string
    The payload text or URL to encode in the QR code
    magnification: int
    The magnification factor between 1 and 10. Default is 4.
    orientation: ZplOrientation
    The QR code orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `data` is `null`

  • methodRaw
    public ZplBuilder Raw(string rawZpl)

    Appends raw ZPL command strings directly to the label buffer.

    rawZpl: string
    The raw ZPL commands to append

    Returns: The current builder instance for fluent chaining.

    Using this method allows raw injection of ZPL commands which can be used to reconfigure the physical printer. Untrusted input must never be passed to this method. Exceptions: NotSupportedException: The builder was initialized with safe mode enabled; ArgumentNullException: `rawZpl` is `null`

  • methodText
    public ZplBuilder Text(int x, int y, string text, int height = 30, int width = 30, char font = '', ZplOrientation orientation = ZplOrientation.Normal)

    Adds a text field at the specified coordinates using a character font identifier.

    x: int
    The x-coordinate of the text field in dots
    y: int
    The y-coordinate of the text field in dots
    text: string
    The text content to render
    height: int
    The character height in dots. Must be greater than zero.
    width: int
    The character width in dots. Must be greater than zero.
    font: char
    The ZPL font identifier character. Default is '0'. Valid values are '0' and 'A'–'H' per the ZPL II specification.
    orientation: ZplOrientation
    The text orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    This overload accepts any `char` value without validation. An invalid font character produces a syntactically well-formed but semantically incorrect ZPL label. Prefer the `Text(int, int, string, ZplFont, int, int, ZplOrientation)` overload which constrains the font to the `ZplFont` enumeration values. Exceptions: ArgumentNullException: `text` is `null`; ArgumentOutOfRangeException: `height` or `width` is less than or equal to zero

  • methodText
    public ZplBuilder Text(int x, int y, string text, ZplFont font, int height = 30, int width = 30, ZplOrientation orientation = ZplOrientation.Normal)

    Adds a text field at the specified coordinates using a strongly-typed `ZplFont`.

    x: int
    The x-coordinate of the text field in dots
    y: int
    The y-coordinate of the text field in dots
    text: string
    The text content to render
    font: ZplFont
    The strongly-typed ZPL font identifier
    height: int
    The character height in dots. Must be greater than zero.
    width: int
    The character width in dots. Must be greater than zero.
    orientation: ZplOrientation
    The text orientation. Default is `ZplOrientation.Normal`.

    Returns: The current builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `text` is `null`; ArgumentOutOfRangeException: `height` or `width` is less than or equal to zero

enum

ZplFont

Assembly: EricksonLopez.Printing.Zpl
public enum ZplFont

Specifies standard built-in Zebra alphanumeric font identifiers.

Members (9)

  • fieldFont0
    Font0 = ''

    Specifies the scalable smooth font 0 (`^A0`).

  • fieldFontA
    FontA = ''

    Specifies standard alphanumeric bitmap font A (`^AA`).

  • fieldFontB
    FontB = ''

    Specifies standard alphanumeric bitmap font B (`^AB`).

  • fieldFontC
    FontC = ''

    Specifies standard alphanumeric bitmap font C (`^AC`).

  • fieldFontD
    FontD = ''

    Specifies standard alphanumeric bitmap font D (`^AD`).

  • fieldFontE
    FontE = ''

    Specifies standard alphanumeric bitmap font E (`^AE`).

  • fieldFontF
    FontF = ''

    Specifies standard alphanumeric bitmap font F (`^AF`).

  • fieldFontG
    FontG = ''

    Specifies standard alphanumeric bitmap font G (`^AG`).

  • fieldFontH
    FontH = ''

    Specifies standard alphanumeric bitmap font H (`^AH`).

enum

ZplOrientation

Assembly: EricksonLopez.Printing.Zpl
public enum ZplOrientation

Specifies text or element orientation in ZPL II format.

Members (4)

  • fieldBottomUp270
    BottomUp270 = ''

    Specifies bottom-up orientation rotated 270 degrees clockwise.

  • fieldInverted180
    Inverted180 = ''

    Specifies inverted orientation rotated 180 degrees.

  • fieldNormal
    Normal = ''

    Specifies normal orientation without rotation (0 degrees).

  • fieldRotated90
    Rotated90 = ''

    Specifies orientation rotated 90 degrees clockwise.

class

ZplPrintDocument

Assembly: EricksonLopez.Printing.Zpl
public sealed class ZplPrintDocument : IPrintDocument
Implements: IPrintDocument

Represents a ZPL print document that streams UTF-8 encoded Zebra Programming Language commands directly to an output stream.

Members (6)

  • methodGetBytes
    public byte[] GetBytes()

    Gets the raw binary commands to send to the printer.

    Returns: A byte array containing the raw printer commands.

  • methodWriteToAsync
    public async ValueTask WriteToAsync(Stream stream, CancellationToken cancellationToken = default)

    Writes the raw binary commands to the specified network or hardware stream.

    stream: Stream
    The destination stream to receive the raw command bytes.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A `ValueTask` representing the asynchronous write operation.

    Exceptions: ArgumentNullException: `stream` is `null`

  • propertyDocumentName
    public string DocumentName { get; }

    Gets the human-readable name of the document or print job.

  • propertyIdempotencyKey
    public string? IdempotencyKey { get; }

    Gets an optional unique idempotency key identifying this print job for deduplication across network and physical retries.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether this print document contains no printable data.

    Used to prevent zero-length submissions from consuming memory or network resources.

  • propertyIsIdempotent
    public bool IsIdempotent { get; }

    Gets a value indicating whether this print document is safe to retry on transmission failure.

    When `false`, retries on transmission errors are forbidden to prevent duplicate physical printing.

class

ZplSanitizer

Assembly: EricksonLopez.Printing.Zpl
public static class ZplSanitizer

Provides zero-reflection, Native AOT-safe Zebra Programming Language (ZPL II) sanitization and control-injection prevention routines.

Members (4)

  • methodContainsHostCommandAttempt
    public static bool ContainsHostCommandAttempt(ReadOnlySpan<char> input)

    Inspects `input` for embedded ZPL host/format command injection attempts or raw ASCII control bytes (`NUL`, `ESC`).

    input: ReadOnlySpan<char>
    The character span to inspect.

    Returns: `true` if a ZPL command directive or binary control injection sequence is detected; otherwise, `false`.

  • methodEscapeForFieldHex
    public static string EscapeForFieldHex(ReadOnlySpan<char> input)

    Escapes untrusted text losslessly for embedding inside a ZPL `^FH_^FD...^FS` hexadecimal field block. Escapes `_`, `^`, `~`, `\`, and ASCII control characters (`0x00..0x1F`, `0x7F`) as `_XX` hex pairs.

    input: ReadOnlySpan<char>
    The untrusted character span to escape.

    Returns: The hex-escaped string safe for inclusion after `^FH_^FD`.

  • methodSanitizeBarcodeData
    public static string SanitizeBarcodeData(ReadOnlySpan<char> input, int maxLength = 128)

    Sanitizes barcode payload data by keeping only printable ASCII characters (`0x20..0x7E`) while stripping ZPL command delimiters (`^` and `~`).

    input: ReadOnlySpan<char>
    The candidate barcode value.
    maxLength: int
    The maximum allowable length. Must be greater than zero.

    Returns: A sanitized ASCII barcode payload string.

    Exceptions: ArgumentOutOfRangeException: `maxLength` is less than or equal to zero.

  • methodStripControlInjectionSequences
    public static string StripControlInjectionSequences(ReadOnlySpan<char> input, int maxLength = 512)

    Strips ZPL command-injection directives (such as `^XA`, `^XZ`, `~JR`, `~DY`, `~DG`, `^DF`), raw `^`/`~` command prefixes, and C0/C1 control characters from untrusted input.

    input: ReadOnlySpan<char>
    The untrusted text to sanitize.
    maxLength: int
    The maximum length of the returned sanitized string. Must be greater than zero.

    Returns: A sanitized plain-text string stripped of ZPL control-injection sequences.

    Exceptions: ArgumentOutOfRangeException: `maxLength` is less than or equal to zero.

EricksonLopez.Printing.Zpl.Imaging#

4
class

MonochromeBitmapConverter

Assembly: EricksonLopez.Printing.Zpl.Imaging
public static class MonochromeBitmapConverter

Provides utility methods for processing and converting pixel buffers and BMP images into 1-bit monochrome ZPL raster data.

Members (3)

  • methodConvertBmpToPacked1Bit
    public static (int Width, int Height, byte[] PackedRaster) ConvertBmpToPacked1Bit(ReadOnlySpan<byte> bmpBytes, ZplDitherAlgorithm algorithm = ZplDitherAlgorithm.FloydSteinberg, byte threshold = 128, int maxDimension = MaxDimension)

    Parses an uncompressed Windows Bitmap (BMP) file and converts it into packed 1-bit monochrome raster bytes.

    bmpBytes: ReadOnlySpan<byte>
    The raw bytes of the Windows Bitmap file
    algorithm: ZplDitherAlgorithm
    The dithering algorithm to apply. Default is `ZplDitherAlgorithm.FloydSteinberg`.
    threshold: byte
    The luminance cutoff threshold between 0 and 255. Default is 128.
    maxDimension: int
    The maximum allowable width or height in pixels. Default is `MaxDimension`.

    Returns: A tuple containing the parsed image width, height, and packed 1-bit monochrome raster byte array.

    Supports 24-bit RGB and 32-bit RGBA BMP formats. Image rows are processed sequentially using pooled buffers to avoid large object heap allocations. Exceptions: ArgumentException: `bmpBytes` is smaller than the 54-byte BMP header or lacks the 'BM' magic header; InvalidDataException: The BMP header contains invalid offsets, dimensions exceeding `maxDimension`, or truncated pixel data; NotSupportedException: The BMP bits per pixel is not 24 or 32

  • methodConvertRgbToPacked1Bit
    public static byte[] ConvertRgbToPacked1Bit(int width, int height, ReadOnlySpan<byte> pixelData, int bytesPerPixel = 3, ZplDitherAlgorithm algorithm = ZplDitherAlgorithm.FloydSteinberg, byte threshold = 128, int maxDimension = MaxDimension)

    Converts raw RGB, RGBA, or grayscale pixel data into packed 1-bit monochrome raster bytes for label printers.

    width: int
    The image width in pixels. Must be greater than zero and not exceed `maxDimension`.
    height: int
    The image height in pixels. Must be greater than zero and not exceed `maxDimension`.
    pixelData: ReadOnlySpan<byte>
    The raw pixel bytes
    bytesPerPixel: int
    The number of bytes per pixel: 1 for grayscale, 3 for RGB, or 4 for RGBA. Default is 3.
    algorithm: ZplDitherAlgorithm
    The dithering algorithm to apply. Default is `ZplDitherAlgorithm.FloydSteinberg`.
    threshold: byte
    The luminance cutoff threshold between 0 and 255. Default is 128.
    maxDimension: int
    The maximum allowable width or height in pixels. Default is `MaxDimension`.

    Returns: A byte array containing the packed 1-bit monochrome raster data.

    In ZPL II raster formatting, bit 1 represents a printed black dot and bit 0 represents white blank space. Exceptions: ArgumentOutOfRangeException: `width` or `height` is less than or equal to zero or exceeds `maxDimension`, or `bytesPerPixel` is not 1, 3, or 4; ArgumentException: `pixelData` length is smaller than the required size

  • fieldMaxDimension
    public const int MaxDimension

    Represents the default maximum allowable image dimension (width or height) in pixels to prevent denial-of-service via memory exhaustion.

enum

ZplDitherAlgorithm

Assembly: EricksonLopez.Printing.Zpl.Imaging
public enum ZplDitherAlgorithm

Specifies the dithering algorithm used to convert color or grayscale pixels into a 1-bit monochrome label bitmap.

Members (2)

  • fieldFloydSteinberg
    FloydSteinberg = 1

    Specifies Floyd-Steinberg error diffusion dithering, suitable for continuous-tone photos and shaded illustrations.

  • fieldThreshold
    Threshold = 0

    Specifies direct luminance threshold comparison, suitable for solid black and white logos, line art, and text.

class

ZplGraphicFieldConverter

Assembly: EricksonLopez.Printing.Zpl.Imaging
public static class ZplGraphicFieldConverter

Converts monochrome pixel buffers and bitmaps into Zebra ZPL II `^GF` (Graphic Field) hex command streams.

Members (1)

  • methodBuildGraphicFieldCommand
    public static string BuildGraphicFieldCommand(int x, int y, int width, int height, ReadOnlySpan<byte> packedRaster)

    Builds a ZPL II `^GF` command sequence from 1-bit packed monochrome raster data.

    x: int
    The horizontal origin coordinate in dots
    y: int
    The vertical origin coordinate in dots
    width: int
    The image width in dots. Must be greater than zero.
    height: int
    The image height in dots. Must be greater than zero.
    packedRaster: ReadOnlySpan<byte>
    The 1-bit packed raster data where 1 represents a black dot and 0 represents white

    Returns: A formatted ZPL string representing the graphic field command sequence.

    Exceptions: ArgumentOutOfRangeException: `width` or `height` is less than or equal to zero; ArgumentException: `packedRaster` length is smaller than the required byte count for the specified dimensions

class

ZplImageBuilderExtensions

Assembly: EricksonLopez.Printing.Zpl.Imaging
public static class ZplImageBuilderExtensions

Provides extension methods for appending graphical bitmap images and graphic fields to `ZplBuilder`.

Members (3)

  • methodGraphicField
    public static ZplBuilder GraphicField(this ZplBuilder builder, int x, int y, int width, int height, ReadOnlySpan<byte> packedRaster)

    Appends pre-packed 1-bit monochrome raster bytes as a ZPL II `^GF` Graphic Field.

    builder: this ZplBuilder
    The ZPL builder instance to append to
    x: int
    The horizontal origin coordinate in dots
    y: int
    The vertical origin coordinate in dots
    width: int
    The image width in dots
    height: int
    The image height in dots
    packedRaster: ReadOnlySpan<byte>
    The packed 1-bit raster data where 1 represents a black dot and 0 represents white

    Returns: The builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodImage
    public static ZplBuilder Image(this ZplBuilder builder, int x, int y, int width, int height, ReadOnlySpan<byte> pixelData, int bytesPerPixel = 3, ZplDitherAlgorithm algorithm = ZplDitherAlgorithm.FloydSteinberg, int maxAllowedDimension = MonochromeBitmapConverter.MaxDimension)

    Converts and appends raw pixel data as a ZPL II `^GF` Graphic Field.

    builder: this ZplBuilder
    The ZPL builder instance to append to
    x: int
    The horizontal origin coordinate in dots
    y: int
    The vertical origin coordinate in dots
    width: int
    The image width in pixels
    height: int
    The image height in pixels
    pixelData: ReadOnlySpan<byte>
    The raw pixel bytes in RGB, RGBA, or grayscale format
    bytesPerPixel: int
    The number of bytes per pixel: 1 for grayscale, 3 for RGB, or 4 for RGBA
    algorithm: ZplDitherAlgorithm
    The dithering algorithm to apply. Default is `ZplDitherAlgorithm.FloydSteinberg`.
    maxAllowedDimension: int
    The maximum allowable width or height in pixels

    Returns: The builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodImage
    public static ZplBuilder Image(this ZplBuilder builder, int x, int y, byte[] bmpBytes, ZplDitherAlgorithm algorithm = ZplDitherAlgorithm.FloydSteinberg, int maxAllowedDimension = MonochromeBitmapConverter.MaxDimension)

    Converts and appends an uncompressed BMP image as a ZPL II `^GF` Graphic Field.

    builder: this ZplBuilder
    The ZPL builder instance to append to
    x: int
    The horizontal origin coordinate in dots
    y: int
    The vertical origin coordinate in dots
    bmpBytes: byte[]
    The raw bytes of the BMP file
    algorithm: ZplDitherAlgorithm
    The dithering algorithm to apply. Default is `ZplDitherAlgorithm.FloydSteinberg`.
    maxAllowedDimension: int
    The maximum allowable width or height in pixels

    Returns: The builder instance for fluent chaining.

    Exceptions: ArgumentNullException: `builder` or `bmpBytes` is `null`

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.