在實際環境中測試
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
C# 條碼庫
using IronBarCode;
using System.Drawing;
// Creating a barcode is as simple as:
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
// And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg");
Image myBarcodeImage = myBarcode.Image; // Can be used as Image
Bitmap myBarcodeBitmap = myBarcode.ToBitmap(); // Can be used as Bitmap
// Reading a barcode is easy with IronBarcode:
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf
// After creating a barcode, we may choose to resize and save which is easily done with:
var myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
myNewBarcode.ResizeTo(400, 100);
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg");
// To set more options and optimization with your Barcode Reading,
// Please utilize the BarcodeReaderOptions paramter of read:
var myOptionsExample = new BarcodeReaderOptions
{
// Choose a speed from: Faster, Balanced, Detailed, ExtremeDetail
// There is a tradeoff in performance as more Detail is set
Speed = ReadingSpeed.Balanced,
// Reader will stop scanning once a barcode is found, unless set to true
ExpectMultipleBarcodes = true,
// By default, all barcode formats are scanned for.
// Specifying one or more, performance will increase.
ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
// Utilizes multiple threads to reads barcodes from multiple images in parallel.
Multithreaded = true,
// Maximum threads for parallel. Default is 4
MaxParallelThreads = 2,
// The area of each image frame in which to scan for barcodes.
// Will improve performance significantly and avoid unwanted results and avoid noisy parts of the image.
CropArea = new Rectangle(),
// Special Setting for Code39 Barcodes.
// If a Code39 barcode is detected. Try to use extended mode for the full ASCII Character Set
UseCode39ExtendedMode = true
};
// And, apply:
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
using IronBarCode;
using IronSoftware.Drawing;
using System.Linq;
// Choose which filters are to be applied (in order);
var filtersToApply = new ImageFilterCollection() {
new SharpenFilter(),
new InvertFilter(),
new ContrastFilter(),
new BrightnessFilter(),
new AdaptiveThresholdFilter(),
new BinaryThresholdFilter()
};
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
// Set chosen filters in BarcodeReaderOptions:
ImageFilters = filtersToApply,
// Other Barcode Reader Options:
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
};
// And, apply with a Read:
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);
AnyBitmap[] filteredImages = results.FilterImages();
// Export file to disk
for (int i = 0 ; i < filteredImages.Length ; i++)
filteredImages[i].SaveAs($"{i}_barcode.png");
// Or
results.ExportFilterImagesToDisk("filter-result.jpg");
using IronBarCode;
using System.Drawing;
/*** CREATING BARCODE IMAGES ***/
// Shorthand:: Create and save a barcode in a single line of code
BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg");
/***** IN-DEPTH BARCODE CREATION OPTIONS *****/
// BarcodeWriter.CreateBarcode creates a GeneratedBarcode which can be styles and exported as an Image object or File
GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("Any Number, String or Binary Value", BarcodeWriterEncoding.Code128);
// Style the Barcode in a fluent LINQ style fashion
MyBarCode.ResizeTo(300, 150).SetMargins(20).AddAnnotationTextAboveBarcode("Example EAN8 Barcode").AddBarcodeValueTextBelowBarcode();
MyBarCode.ChangeBackgroundColor(Color.LightGoldenrodYellow);
// Save MyBarCode as an image file
MyBarCode.SaveAsImage("MyBarCode.png");
MyBarCode.SaveAsGif("MyBarCode.gif");
MyBarCode.SaveAsHtmlFile("MyBarCode.html");
MyBarCode.SaveAsJpeg("MyBarCode.jpg");
MyBarCode.SaveAsPdf("MyBarCode.Pdf");
MyBarCode.SaveAsPng("MyBarCode.png");
MyBarCode.SaveAsTiff("MyBarCode.tiff");
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp");
// Save MyBarCode as a .NET native objects
Image MyBarCodeImage = MyBarCode.Image;
Bitmap MyBarCodeBitmap = MyBarCode.ToBitmap();
byte[] PngBytes = MyBarCode.ToPngBinaryData();
using (System.IO.Stream PdfStream = MyBarCode.ToPdfStream())
{
// Stream barcode image output also works for GIF,JPEG, PDF, PNG, BMP and TIFF
}
// Save MyBarCode as HTML files and tags
MyBarCode.SaveAsHtmlFile("MyBarCode.Html");
string ImgTagForHTML = MyBarCode.ToHtmlTag();
string DataURL = MyBarCode.ToDataUrl();
// Save MyBarCode to a new PDF, or stamp it in any position on any page(s) of an existing Document
MyBarCode.SaveAsPdf("MyBarCode.Pdf");
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 200, 50, 1); // position 200x50 on page 1
MyBarCode.StampToExistingPdfPages("ExistingPDF.pdf", 200, 50, new[] { 1, 2, 3 }, "Password123"); // multiple pages of an encrypted PDF
using IronBarCode;
using System;
using System.Drawing;
/*** STYLING GENERATED BARCODES ***/
// BarcodeWriter.CreateBarcode creates a GeneratedBarcode object which allows the barcode to be styled and annotated.
GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("Iron Software", BarcodeWriterEncoding.QRCode);
// Any text (or commonly, the value of the barcode) can be added to the image in a default or specified font.
// Text positions are automatically centered, above or below. Fonts that are too large for a given image are automatically scaled down.
MyBarCode.AddBarcodeValueTextBelowBarcode();
MyBarCode.AddAnnotationTextAboveBarcode("This is My Barcode", new Font(new FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Pixel), Color.DarkSlateBlue);
// Resize, add Margins and Check final Image Dimensions
MyBarCode.ResizeTo(300, 300); // pixels
MyBarCode.SetMargins(0, 20, 0, 20);
int FinalWidth = MyBarCode.Width;
int FinalHeight = MyBarCode.Height;
//Recolor the barcode and its background
MyBarCode.ChangeBackgroundColor(Color.LightGray);
MyBarCode.ChangeBarCodeColor(Color.DarkSlateBlue);
if (!MyBarCode.Verify())
{
Console.WriteLine("Color contrast should be at least 50% or a barcode may become unreadable. Test using GeneratedBarcode.Verify()");
}
// Finally save the result
MyBarCode.SaveAsHtmlFile("StyledBarcode.html");
/*** STYLING BARCODES IN A SINGLE LINQ STYLE EXPRESSION ***/
// Fluent API
BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeWriterEncoding.Aztec).ResizeTo(250, 250).SetMargins(10).AddBarcodeValueTextAboveBarcode().SaveAsImage("StyledBarcode.png");
/*** STYLING QR CODES WITH LOGO IMAGES OR BRANDING ***/
// Use the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode
// Logo will automatically be sized appropriately and snapped to the QR grid.
var qrCodeLogo = new QRCodeLogo("ironsoftware_logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);
myQRCodeWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen);
myQRCodeWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen);
myQRCodeWithLogo.SaveAsPng("QRWithLogo.Png").SaveAsPdf("MyVerifiedQR.html"); // save as 2 formats
using IronBarCode;
/*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/
GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128);
// Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html");
// Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views. No image assets required, the tag embeds the entire image in its Src contents
string ImgTag = MyBarCode.ToHtmlTag();
// Turn the image into an Html/CSS Data URI. https://en.wikipedia.org/wiki/Data_URI_scheme
string DataURI = MyBarCode.ToDataUrl();
條碼已成為現代業務運營中不可或缺的一部分。它們簡化了庫存管理、增強了產品追蹤並精簡了數據輸入流程。將條碼生成功能集成到 Web 應用程序中可以帶來極大的好處,而 Microsoft 的流行 Web 框架 Blazor 提供了一個優秀的平台來無縫地實現這一點。
在本教程中,我們將探索如何在 Blazor 框架中使用強大的 IronBarcode 庫進行條碼生成。您將學習如何輕鬆地創建和自訂條碼,使您的 Blazor 應用程序更加靈活和高效。
IronBarcode 是一個強大的 .NET 庫,旨在簡化在應用程式中創建條碼的過程。它提供了一組工具和功能,允許開發人員輕鬆生成各種類型的條碼。無論是需要為產品標籤、庫存管理或其他用途創建條碼,IronBarcode 都能使這項工作變得簡單且有效率。
在開始之前,請確保您已準備好以下先決條件:
Blazor Server 是使用 .NET 構建互動式 Web 應用程序的絕佳選擇。Visual Studio 是微軟強大的集成開發環境 (集成開發環境), 使創建這些應用程式變得輕鬆。在這裡,我們將使用 Visual Studio 創建一個 Blazor Server 應用程式。
如果您尚未安裝 Visual Studio,您可以從 Visual Studio 網站.
點擊「建立新專案」。
從項目模板列表中選擇「Blazor Server App」,然後點擊「下一步」按鈕。
點擊“下一步”按鈕來繼續。
點擊“建立”按鈕完成專案的設置。
要透過 Visual Studio 的 NuGet 套件管理器在您的 Blazor 專案中安裝 IronBarcode 庫,您可以按照以下步驟操作:
在 Visual Studio 方案總管中右鍵點擊您的專案,然後選擇「管理 NuGet 套件」。
在「NuGet 套件管理員」視窗中,確保您位於「瀏覽」選項卡。
在右上角的搜尋框中,輸入「IronBarcode」並按下 Enter 鍵。
這部分現在已經沒有拼寫和語法錯誤。此外,基於嵌入的源代碼,範圍代碼塊語言已更改為「cs」。
PM > Install-Package BarCode
30天試用序號 立即。
15天試用金鑰 立即。
想將 IronBarcode 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronBarcode 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronBarcode 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronBarcode 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
免費開始
不需要信用卡
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
獲得30天完全功能的產品。
幾分鐘內即可啟動並運行。
試用產品期間完全訪問我們的支援工程團隊
免費開始
不需要信用卡
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
獲得30天完全功能的產品。
幾分鐘內即可啟動並運行。
試用產品期間完全訪問我們的支援工程團隊