TX Sheet Control

BarcodeDrawingOptions Class

Class
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server from the private NuGet feed or the supplied NuGet folder
Assembly
TXTextControl.TXSheetControl.Api.dll
Install
dotnet add package TXTextControl.TXSheetControl.Server .NET 10 and later.
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll
Inherits
  1. BarcodeOptions
  2. BarcodeDrawingOptions

Floating barcode settings, inheriting BarcodeOptions and using ordinary drawing placement.

Syntax

public sealed class BarcodeDrawingOptions : BarcodeOptions
{
    public DrawingAnchor? Anchor { get; init; }
    public ObjectSize? Size { get; init; }
    public string? Name { get; init; }
    public string? AltText { get; init; }
    public double? Rotation { get; init; }
}

Remarks

See Barcodes and QR Codes for a complete .NET example, source validation, mail merge and file compatibility.

  • Constructor — Creates settings.

  • Anchor — Anchor cell and optional CSS-pixel offsets. Defaults to A1.

  • Size — Width and height in unscaled CSS pixels. Defaults to 160×160 for QR or 280×100 for linear codes.

  • Name — Drawing name; defaults to Barcode.

  • AltText — Accessibility description for the drawing.

  • Rotation — Clockwise rotation in degrees.

Constructor

public BarcodeDrawingOptions()

Creates an instance with the property defaults shown in this reference. Settings are validated when applied to the owning document; result objects obtained from document operations are detached snapshots.

Examples

Create and save a label workbook with the configured barcode settings.

using TXTextControl.TXSheetControl.Server;

static async Task<byte[]> CreateFloatingLabelAsync(ServerSheetControl control)
{
    var sheet = await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("001042");
    var options = new BarcodeDrawingOptions {
        Symbology = "code128", Source = "A1", Anchor = new DrawingAnchor("D4", 8, 8),
        Size = new ObjectSize(240, 100), Name = "Invoice barcode", AltText = "Invoice identifier", Rotation = 0
    };
    var drawing = await sheet.Drawings.AddBarcodeAsync(options);
    var snapshot = await drawing.GetBarcodeAsync();
    await drawing.UpdateBarcodeAsync(new BarcodeOptions { Symbology = "code128", Source = "A1", ShowText = false });
    return await control.SaveAsync(StreamType.SpreadsheetML);
}