Create Barcode
In IronBarcode, the BarcodeWriter
class has a CreateBarcode
method that has a plethora of options and customization settings. These include choosing the encoding, the output size, and filepath.
using IronBarCode; using System.IO; // Creating a barcode is as simple as: var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8); // And save our barcode as an image: myBarcode.SaveAsImage("EAN8.jpeg"); // OR, we can do both steps on one line: BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg"); // Barcode can also be made from from Binary data (byte or stream) string payloadAsString = "This is some random string"; byte[] payloadAsByteArray = System.Text.Encoding.Default.GetBytes(payloadAsString); // Byte Array var AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400); // Create from Byte Array MemoryStream payloadAsStream = new MemoryStream(payloadAsByteArray); // MemoryStream var AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400); // Create from Memory Stream
Imports IronBarCode Imports System.IO ' Creating a barcode is as simple as: Private myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8) ' And save our barcode as an image: myBarcode.SaveAsImage("EAN8.jpeg") ' OR, we can do both steps on one line: BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg") ' Barcode can also be made from from Binary data (byte or stream) Dim payloadAsString As String = "This is some random string" Dim payloadAsByteArray() As Byte = System.Text.Encoding.Default.GetBytes(payloadAsString) ' Byte Array Dim AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400) ' Create from Byte Array Dim payloadAsStream As New MemoryStream(payloadAsByteArray) ' MemoryStream Dim AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400) ' Create from Memory Stream
Install-Package BarCode
In IronBarcode, the BarcodeWriter
class has a CreateBarcode
method that has a plethora of options and customization settings. These include choosing the encoding, the output size, and filepath.
9 .NET API products for your office documents