創建條碼
在 IronBarcode 中,BarcodeWriter
類別有一個 CreateBarcode
方法,其擁有眾多選項和自定義設置。這些設置包括選擇編碼、輸出大小和文件路径。
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
在 IronBarcode 中,BarcodeWriter
類別有一個 CreateBarcode
方法,其擁有眾多選項和自定義設置。這些設置包括選擇編碼、輸出大小和文件路径。