Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.6.22
|
Leadtools.Barcode Namespace : IBarcodeWriteOptions Interface |
public interface IBarcodeWriteOptions : IBarcodeOptions
'Declaration
Public Interface IBarcodeWriteOptions Inherits IBarcodeOptions
'Usage
Dim instance As IBarcodeWriteOptions
public interface IBarcodeWriteOptions : IBarcodeOptions
function Leadtools.Barcode.IBarcodeWriteOptions() IBarcodeOptions
public interface class IBarcodeWriteOptions : public IBarcodeOptions
Note: In LEADTOOLS for .NET, the equivalent to this interface is the BarcodeWriteOptions class.
The BarcodeWriter class contains the BarcodeWriter.WriteBarcode method which is used to write a barcode to an image. You must create an instance of BarcodeWriter, fill its members with the barcode properties and pass it to this method.
The IBarcodeWriteOptions interface and the classes that implements it are used to control the options used when writing a barcode using LEADTOOLS. You can set the options in two ways:
The BarcodeWriter class contains default options for each barcode symbology (or group of common symbologies). These options can be retrieved using the BarcodeWriter.GetDefaultOptions method passing the symbology of interest. You can then change members of the returned IBarcodeWriteOptions (or after casting it to the appropriate implementing class).
You can also create an instance of one of the derived IBarcodeWriteOptions classes and use it directly in the BarcodeWriter.WriteBarcode method which accepts the options as an input parameter.
The BarcodeWriteOptions contains the following members and features:
Member | Description |
---|---|
BarcodeWriteOptions.ForeColor |
Controls the barcode foreground color (color of the bars or symbols) to use when writing a barcode to an image. |
BarcodeWriteOptions.BackColor |
Controls the barcode background color (color of the spaces) to use when writing a barcode to an image. |
IBarcodeWriteOptions is an interface and cannot be created directly, instead create one of these classes that implements it:
Write options class | Descriptions |
---|---|
OneDBarcodeWriteOptions |
Standard 1D linear barcode options. Used when writing any of the following symbologies: EAN13, EAN8, UPCA, UPCE, Code3Of9, Code128, CodeInterleaved2Of5, Codabar, UCCEAN128, Code93, EANEXT5, EANEXT2, MSI, Code11, CodeStandard2Of5, GS1Databar, GS1DatabarLimited or GS1DatabarExpanded |
GS1DatabarStackedBarcodeWriteOptions |
GS1 DataBar Stacked barcode options. Used when writing GS1DatabarStacked or GS1DatabarExpandedStacked symbologies |
FourStateBarcodeWriteOptions |
4-State barcode options. Used when writing AustralianPost4State, RoyalMail4State or USPS4State symbologies |
PostNetPlanetBarcodeWriteOptions |
POSTNET/Planet barcode options. Used when writing PostNet or Planet symbologies |
PatchCodeBarcodeWriteOptions |
Patch code barcode options. Used when writing PatchCode symbology. |
DatamatrixBarcodeWriteOptions |
Datamatrix barcode options. Used when writing Datamatrix symbology. |
MicroPDF417BarcodeWriteOptions |
Micro PDF417 barcode options. Used when writing MicroPDF417 symbology. |
PDF417BarcodeWriteOptions |
PDF417 barcode options. Used when writing PDF417 symbology. |
QRBarcodeWriteOptions |
QR barcode options. Used when writing QR symbology. |
This example sets the "Use X Module" option of all supported symbologies to be "true" and then creates TIFF files of all the supported barcodes.
using Leadtools; using Leadtools.Codecs; using Leadtools.Barcode; using Leadtools.ImageProcessing; public async Task BarcodeWriteOptions_Example() { int resolution = 300; // Create a Barcode engine BarcodeEngine engine = new BarcodeEngine(); // Get the Barcode writer BarcodeWriter writer = engine.Writer; // All 1D options have the UseXModule set to false by default, we need to set it to true // so we can calculate the default size. We will change the default options so we can // pass null to CalculateBarcodeDataBounds and WriteBarcode below // For all Standard 1D OneDBarcodeWriteOptions oneDWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions; oneDWriteOptions.UseXModule = true; // All GS1 Databar Stacked GS1DatabarStackedBarcodeWriteOptions gs1DatabarStackedWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.GS1DatabarStacked) as GS1DatabarStackedBarcodeWriteOptions; gs1DatabarStackedWriteOptions.UseXModule = true; // Patch Code PatchCodeBarcodeWriteOptions patchCodeWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PatchCode) as PatchCodeBarcodeWriteOptions; patchCodeWriteOptions.UseXModule = true; // All PostNet/Planet PostNetPlanetBarcodeWriteOptions postNetPlanetWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PostNet) as PostNetPlanetBarcodeWriteOptions; postNetPlanetWriteOptions.UseXModule = true; // We will use this object to save files using(RasterCodecs codecs = new RasterCodecs()) { // Get all the available write symbologies BarcodeSymbology[] symbologies = writer.GetAvailableSymbologies(); foreach(BarcodeSymbology symbology in symbologies) { Debug.WriteLine("Processing {0}", symbology); // Create the default data for this symbology BarcodeData data = BarcodeData.CreateDefaultBarcodeData(symbology); // Calculate its size with default options writer.CalculateBarcodeDataBounds(LeadRectHelper.Empty, resolution, resolution, data, null); // Create an image to write the data to LeadRect pixels = data.Bounds; using(RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColorHelper.FromKnownColor(RasterKnownColor.White))) { // Write the barcode with default options writer.WriteBarcode(image, data, null); // Save it string outFileName = symbology.ToString() + ".tif"; StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(outFileName); await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Tif, 1); } } } }
IBarcodeWriteOptions Members
Leadtools.Barcode Namespace
OneDBarcodeWriteOptions Class
GS1DatabarStackedBarcodeWriteOptions Class
FourStateBarcodeWriteOptions Class
PostNetPlanetBarcodeWriteOptions Class
PatchCodeBarcodeWriteOptions Class
DatamatrixBarcodeWriteOptions Class
MicroPDF417BarcodeWriteOptions Class
PDF417BarcodeWriteOptions Class
QRBarcodeWriteOptions Class
BarcodeWriter Class
BarcodeSymbology Enumeration
BarcodeEngine Class
BarcodeWriter.WriteBarcode
Programming with LEADTOOLS Barcode
Supported Barcode Symbologies
Unlocking Barcode Support
Writing Barcodes Tutorial
Writing Barcodes - Bounds and XModule