VintaSoft Barcode .NET SDK v10.0
BarcodeWriter Class
Members  Example 




Vintasoft.Barcode Namespace : BarcodeWriter Class
Class that allows to write barcodes to the image or in vector form.
Object Model
BarcodeWriter ClassWriterSettings Class
Syntax
'Declaration
 
<LicenseProviderAttribute(Vintasoft.Barcode.VintasoftLicenseProvider)>
Public NotInheritable Class BarcodeWriter 
'Usage
 
Dim instance As BarcodeWriter
[LicenseProvider(Vintasoft.Barcode.VintasoftLicenseProvider)]
public sealed class BarcodeWriter 
[LicenseProvider(Vintasoft.Barcode.VintasoftLicenseProvider)]
public __gc __sealed class BarcodeWriter 
[LicenseProvider(Vintasoft.Barcode.VintasoftLicenseProvider)]
public ref class BarcodeWriter sealed 
Example
This example shows how to generate image with Code128 barcode.
Imports System.Drawing   
   
Imports Vintasoft.Barcode   
Imports Vintasoft.Barcode.SymbologySubsets   
   
''' <summary>   
''' Test that shows how to create a barcode image using the BarcodeWriter class.   
''' </summary>   
Class BarcodeWriterExample   
   
	''' <summary>   
	''' Generates Code128 barcode with specified size, in pixels.   
	''' </summary>   
	''' <param name="value">The value.</param>   
	''' <param name="width">The image width, in pixels.</param>   
	''' <param name="height">The image height, in pixels.</param>   
	Public Shared Sub TestCode128Barcode(value As String, width As Integer, height As Integer)   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' set barcode writer settings   
		writer.Settings.Barcode = BarcodeType.Code128   
		writer.Settings.Value = value   
		writer.Settings.Resolution = 96   
		'DPI   
		writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24   
   
		' create image with barcode   
		Using barcodeImage As Image = writer.GetBarcodeAsBitmap(width, height, UnitOfMeasure.Pixels)   
			' save barcode image to a file   
			barcodeImage.Save(String.Format("barcode_code128_{0}.png", value))   
		End Using   
	End Sub   
   
	''' <summary>   
	''' Generates Code128 barcode.   
	''' </summary>   
	Public Shared Sub TestCode128Barcode()   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must generate Code128 barcode   
		writer.Settings.Barcode = BarcodeType.Code128   
   
		' specify that writer must create output image as 24-bpp image   
		writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24   
   
		' specify that single bar width must be 3 pixels   
		writer.Settings.MinWidth = 3   
   
		' set the barcode value   
		writer.Settings.Value = "Test1234567"   
   
		' create image with barcode   
		Using image As Image = writer.GetBarcodeAsBitmap()   
			' save the barcode image to a file   
			image.Save("barcode_code128.png")   
		End Using   
	End Sub   
   
	''' <summary>   
	''' Generates SSCC-18 barcode.   
	''' </summary>   
	Public Shared Sub TestSSCC18Barcode()   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must create output image as 24-bpp image   
		writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24   
   
		' specify that single bar width must be 3 pixels   
		writer.Settings.MinWidth = 3   
   
		' encode SSCC-18 barcode   
		BarcodeSymbologySubsets.SSCC18.Encode("012345678901234560", writer.Settings)   
   
		' create image with barcode   
		Using image As Image = writer.GetBarcodeAsBitmap()   
			' save the barcode image to a file   
			image.Save("barcode_SSCC18.png")   
		End Using   
	End Sub   
   
	''' <summary>   
	''' Generates GS1-128 barcode.   
	''' </summary>   
	Public Shared Sub TestGS1_128Barcode()   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must create output image as 24-bpp image   
		writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24   
   
		' specify that single bar width must be 3 pixels   
		writer.Settings.MinWidth = 3   
   
		' encode GS1-128 barcode   
		' GTIN                : 08699736690061   
		' SERIAL              : 30000000000720   
		' USE BY OR EXPIRY    : 110227   
		' BATCH/LOT           : TEST   
		BarcodeSymbologySubsets.GS1_128.Encode("(01)08699736690061(21)30000000000720(17)110227(10)TEST", writer.Settings)   
   
		' create image with barcode   
		Using image As Image = writer.GetBarcodeAsBitmap()   
			' save the barcode image to a file   
			image.Save("barcode_GS1-128.png")   
		End Using   
	End Sub   
End Class
using System.Drawing;
            
using Vintasoft.Barcode;
using Vintasoft.Barcode.SymbologySubsets;
            
/// <summary>
/// Test that shows how to create a barcode image using the BarcodeWriter class.
/// </summary>
class BarcodeWriterExample
{
            
    /// <summary>
    /// Generates Code128 barcode with specified size, in pixels.
    /// </summary>
    /// <param name="value">The value.</param>
    /// <param name="width">The image width, in pixels.</param>
    /// <param name="height">The image height, in pixels.</param>
    public static void TestCode128Barcode(string value, int width, int height)
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // set barcode writer settings
        writer.Settings.Barcode = BarcodeType.Code128;
        writer.Settings.Value = value;
        writer.Settings.Resolution = 96;//DPI
        writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;
        
        // create image with barcode
        using (Image barcodeImage = writer.GetBarcodeAsBitmap(width, height, UnitOfMeasure.Pixels))
        {
            // save barcode image to a file
            barcodeImage.Save(string.Format("barcode_code128_{0}.png", value));
        }
    }
            
    /// <summary>
    /// Generates Code128 barcode.
    /// </summary>
    public static void TestCode128Barcode()
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must generate Code128 barcode
        writer.Settings.Barcode = BarcodeType.Code128;
            
        // specify that writer must create output image as 24-bpp image
        writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;
            
        // specify that single bar width must be 3 pixels
        writer.Settings.MinWidth = 3;
            
        // set the barcode value
        writer.Settings.Value = "Test1234567";
            
        // create image with barcode
        using (Image image = writer.GetBarcodeAsBitmap())
        {
            // save the barcode image to a file
            image.Save("barcode_code128.png");
        }
    }
            
    /// <summary>
    /// Generates SSCC-18 barcode.
    /// </summary>
    public static void TestSSCC18Barcode()
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must create output image as 24-bpp image
        writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;
            
        // specify that single bar width must be 3 pixels
        writer.Settings.MinWidth = 3;
            
        // encode SSCC-18 barcode
        BarcodeSymbologySubsets.SSCC18.Encode("012345678901234560", writer.Settings);
            
        // create image with barcode
        using (Image image = writer.GetBarcodeAsBitmap())
        {
            // save the barcode image to a file
            image.Save("barcode_SSCC18.png");
        }
    }
            
    /// <summary>
    /// Generates GS1-128 barcode.
    /// </summary>
    public static void TestGS1_128Barcode()
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must create output image as 24-bpp image
        writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;
            
        // specify that single bar width must be 3 pixels
        writer.Settings.MinWidth = 3;
            
        // encode GS1-128 barcode
        // GTIN                : 08699736690061
        // SERIAL              : 30000000000720
        // USE BY OR EXPIRY    : 110227
        // BATCH/LOT           : TEST
        BarcodeSymbologySubsets.GS1_128.Encode(
            "(01)08699736690061(21)30000000000720(17)110227(10)TEST", writer.Settings);
            
        // create image with barcode
        using (Image image = writer.GetBarcodeAsBitmap())
        {
            // save the barcode image to a file
            image.Save("barcode_GS1-128.png");
        }
    }
}
Inheritance Hierarchy

System.Object
   Vintasoft.Barcode.BarcodeWriter

Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

BarcodeWriter Members
Vintasoft.Barcode Namespace