跳至頁尾內容
C# + VB.NET: 條碼快速入門 條碼快速入門
using IronBarCode;
using System.Drawing;

// 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 file
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf

// To configure and fine-tune barcode reading, utilize the BarcodeReaderOptions class
var myOptionsExample = new BarcodeReaderOptions
{
    // Choose a reading 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 single barcode is found (if set to true)
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for
    // Specifying a subset of barcode types to search for would improve performance
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilize multiple threads to read barcodes from multiple images in parallel
    Multithreaded = true,

    // Maximum threads for parallelized barcode reading
    // Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes
    // Specifying a crop area will significantly improve performance and avoid noisy parts of the image
    CropArea = new Rectangle(),

    // Special setting for Code39 barcodes
    // If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
    UseCode39ExtendedMode = true
};

// Read with the options applied
var results = BarcodeReader.Read("barcode.png", myOptionsExample);

// Create a barcode with one line of code
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// After creating a barcode, we may choose to resize
myBarcode.ResizeTo(400, 100);

// Save our newly-created barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg");

// Get the barcode as an image for further processing
var myBarcodeImage = myBarcode.Image;
Imports IronBarCode
Imports System.Drawing

' Reading a barcode is easy with IronBarcode!
Dim resultFromFile = BarcodeReader.Read("file/barcode.png") ' From a file
Dim resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp")) ' From a bitmap
Dim resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")) ' From an image file
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf") ' From PDF use ReadPdf

' To configure and fine-tune barcode reading, utilize the BarcodeReaderOptions class
Dim myOptionsExample As New BarcodeReaderOptions With {
    ' Choose a reading 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 single barcode is found (if set to true)
    .ExpectMultipleBarcodes = True,

    ' By default, all barcode formats are scanned for
    ' Specifying a subset of barcode types to search for would improve performance
    .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    ' Utilize multiple threads to read barcodes from multiple images in parallel
    .Multithreaded = True,

    ' Maximum threads for parallelized barcode reading
    ' Default is 4
    .MaxParallelThreads = 2,

    ' The area of each image frame in which to scan for barcodes
    ' Specifying a crop area will significantly improve performance and avoid noisy parts of the image
    .CropArea = New Rectangle(),

    ' Special setting for Code39 barcodes
    ' If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
    .UseCode39ExtendedMode = True
}

' Read with the options applied
Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)

' Create a barcode with one line of code
Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' After creating a barcode, we may choose to resize
myBarcode.ResizeTo(400, 100)

' Save our newly-created barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg")

' Get the barcode as an image for further processing
Dim myBarcodeImage = myBarcode.Image
Install-Package BarCode

IronBarcode支持各種標準格式,從圖像文件(jpeg, png, 和 jpg)到更多程序化格式,您會希望在其中傳遞變量,如位圖。此外,它還支持外部格式比如PDF,使得IronBarcode可以無縫地整合到任何代碼庫中,為開發者提供靈活的文件格式和變數。

IronBarcode 除了是適用於所有檔案格式的 BarCode 讀取器外,同時也兼具 BarCode 生成器的功能,支援所有標準編碼與格式,例如 Code128 以及 Code39。 設定條碼產生器只需要兩行程式碼。 IronBarcode以其低入門門檻和多種自定義選項成為所有條碼相關情境的最佳選擇。

C# 中的條碼讀取器和條碼產生器

  1. `var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeEncoding.EAN8);`
  2. `Image myBarcodeImage = myBarcode.ToImage();`
  3. `myBarcode.ResizeTo(400,100);`。
  4. `var resultFromFile = BarcodeReader.Read(@"file/barcode.png");`。
  5. `var myOptionsExample = new BarcodeReaderOptions { /* Options */ };`

條碼寫入器

我們首先導入必要的函式庫,例如 IronBarCodeSystem.Drawing,並實例化 BarcodeWriter,以 12345 的字串值和 EAN8 的格式建立 BARCODE。 然後我們將生成的條碼以所需格式儲存為圖像。 針對此功能有多種選項,因為 IronBarcode 支援將 BarCode 建立為 Image 以及 Bitmap

進階條碼寫入器

如上所見,使用IronBarcode生成條碼只需要兩行代碼,然後將其保存為文件以供日後使用。 IronBarcode通過為開發者提供大量選項以自定義條碼以適應情況進一步擴展這一點。

我們可以使用 ResizeTo 方法,並傳入高度和寬度來調整 BarCode 圖像的大小。

條碼閱讀器

如同上述,我們首先實例化 BarcodeReader,將檔案路徑傳遞給 Read 方法,並將其儲存為變數,以便日後使用並操作 BARCODE 物件。 針對讀取 PDF 等外部格式,有指定使用 ReadPDF 的方法; 然而,對於一般的圖像格式和位圖,我們會使用 Read

條碼讀取器選項

IronBarcode允許開發者從標準文件格式中掃描條碼。 然而,在某些情況下,開發人員可能希望微調 BarcodeReaderOptions 方法的行為,特別是在程式化讀取一批 BARCODE 檔案時。 這正是 BarcodeReaderOptions 派上用場之處。 IronBarcode 讓您能完全自訂各項設定,例如透過 Speed 設定讀取速度、透過 ExpectedMultipleBarcodes 設定檔案中是否預期包含多個 BARCODE,以及透過 ExpectBarcodeTypes 屬性設定 BARCODE 類型。 這樣一來,開發人員就可以運行多個執行緒來並行讀取多個映像中的條碼,還可以控制並行讀取時使用的執行緒數。

這些只是展示IronBarcode強大之處的一些屬性。 完整清單請參閱此處的文件。

透過我們的詳細指南,學習如何製作BarCode! Read

C# + VB.NET: 不完美條碼與圖像校正 不完美條碼與圖像校正
using IronBarCode;
using IronSoftware.Drawing;

// Choose which filters are to be applied (in order)
// Set cacheAtEachIteration = true to save the intermediate image data after each filter is applied
var filtersToApply = new ImageFilterCollection(cacheAtEachIteration: true) {
    new SharpenFilter(),
    new InvertFilter(),
    new ContrastFilter(),
    new BrightnessFilter(),
    new AdaptiveThresholdFilter(),
    new BinaryThresholdFilter(),
    new GaussianBlurFilter(),
    new MedianBlurFilter(),
    new BilateralFilter()
};

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Set chosen filters in BarcodeReaderOptions
    ImageFilters = filtersToApply,

    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
};

// Read with the options applied
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);

AnyBitmap[] filteredImages = results.FilterImages();

// Export intermediate image files to disk
for (int i = 0 ; i < filteredImages.Length ; i++)
    filteredImages[i].SaveAs($"{i}_barcode.png");

// Or
results.ExportFilterImagesToDisk("filter-result.jpg");
Imports IronBarCode
Imports IronSoftware.Drawing

' Choose which filters are to be applied (in order)
' Set cacheAtEachIteration = true to save the intermediate image data after each filter is applied
Private filtersToApply = New ImageFilterCollection(cacheAtEachIteration:= True) From {
	New SharpenFilter(),
	New InvertFilter(),
	New ContrastFilter(),
	New BrightnessFilter(),
	New AdaptiveThresholdFilter(),
	New BinaryThresholdFilter(),
	New GaussianBlurFilter(),
	New MedianBlurFilter(),
	New BilateralFilter()
}

Private myOptionsExample As New BarcodeReaderOptions() With {
	.ImageFilters = filtersToApply,
	.Speed = ReadingSpeed.Balanced,
	.ExpectMultipleBarcodes = True
}

' Read with the options applied
Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)

Private filteredImages() As AnyBitmap = results.FilterImages()

' Export intermediate image files to disk
For i As Integer = 0 To filteredImages.Length - 1
	filteredImages(i).SaveAs($"{i}_barcode.png")
Next i

' Or
results.ExportFilterImagesToDisk("filter-result.jpg")
Install-Package BarCode

IronBarcode 提供多種影像預處理濾鏡供您選擇,並可輕鬆套用至 BarcodeReaderOptions 中。 請選擇有助於提升圖像可讀性的濾鏡,例如 Sharpen二值閾值Contrast。 請注意,您選擇的順序即為實際套用的順序。

系統提供選項,可儲存應用各濾鏡後的中間影像之圖像資料。 此功能可透過 SaveAtEachIterationImageFilterCollection 屬性進行切換。

精選程式碼範例的重點

  • 我們建立 BarcodeReaderOptions 的實例,並為其設定多種影像濾鏡:Binary Threshold 以及 Contrast
  • 篩選器是依照特定順序新增的,這代表了應套用的執行順序。
  • 透過將 cacheAtEachIteration 設定為 true,該函式庫會在每次套用濾鏡後儲存中間影像,這對於除錯與分析非常有用。
  • 最後,我們讀取圖片中的BARCODE,並將BARCODE類型與數值輸出至控制台。

進一步了解 IronBarcode 中的影像校正功能

C# + VB.NET: 創建條碼圖像 創建條碼圖像
using IronBarCode;
using System.Drawing;

/*** CREATING BARCODE IMAGES ***/

// 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 styled 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 the barcode 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 the barcode as a .NET native object
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 an HTML file or tag
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 (200, 50) on page 1
MyBarCode.StampToExistingPdfPages("ExistingPDF.pdf", 200, 50, new[] { 1, 2, 3 }, "Password123");  // Multiple pages of an encrypted PDF
Imports IronBarCode
Imports System.Drawing

'''* CREATING BARCODE IMAGES **

' 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 styled and exported as an Image object or file
Dim MyBarCode As GeneratedBarcode = 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 the barcode 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 the barcode as a .NET native object
Dim MyBarCodeImage As Image = MyBarCode.Image
Dim MyBarCodeBitmap As Bitmap = MyBarCode.ToBitmap()

Dim PngBytes() As Byte = MyBarCode.ToPngBinaryData()

Using PdfStream As System.IO.Stream = MyBarCode.ToPdfStream()
	' Stream barcode image output also works for GIF, JPEG, PDF, PNG, BMP and TIFF
End Using

' Save MyBarCode as an HTML file or tag
MyBarCode.SaveAsHtmlFile("MyBarCode.Html")
Dim ImgTagForHTML As String = MyBarCode.ToHtmlTag()
Dim DataURL As String = 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 (200, 50) on page 1
MyBarCode.StampToExistingPdfPages("ExistingPDF.pdf", 200, 50, { 1, 2, 3 }, "Password123") ' Multiple pages of an encrypted PDF
Install-Package BarCode

在此範例中,我們可以看到可以建立、調整大小並儲存多種不同類型和格式的BarCode; 甚至可能僅需一行程式碼即可實現。

透過我們的流暢 API,生成的 barcode 類別可用於設定邊距、調整大小以及為 BARCODE 添加註解。 隨後可將其儲存為圖像,IronBarcode 會根據檔案名稱自動判讀正確的圖像類型:GIF、HTML 檔案、HTML 標籤、JPEG、PDF、PNG、TIFF 以及 Windows Bitmap

我們還提供 StampToExistingPdfPage 方法,可生成 BARCODE 並將其烙印至現有的 PDF 檔案上。 這在編輯通用 PDF 或透過 BARCODE 为文件添加內部識別號碼時非常實用。

C# + VB.NET: 條碼造型與註釋 條碼造型與註釋
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");

// Resize, add margins and check final image dimensions
MyBarCode.ResizeTo(300, 300); // Resize in pixels
MyBarCode.SetMargins(0, 20, 0, 20); // Set margins in pixels

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 ***/

// Create a barcode in one line of code
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 different formats
Imports IronBarCode
Imports System
Imports System.Drawing

'*** STYLING GENERATED BARCODES  ***

' BarcodeWriter.CreateBarcode creates a GeneratedBarcode object which allows the barcode to be styled and annotated.
Dim MyBarCode As GeneratedBarcode = 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")

' Resize, add margins and check final image dimensions
MyBarCode.ResizeTo(300, 300) ' Resize in pixels
MyBarCode.SetMargins(0, 20, 0, 20) ' Set margins in pixels

Dim FinalWidth As Integer = MyBarCode.Width
Dim FinalHeight As Integer = MyBarCode.Height

' Recolor the barcode and its background
MyBarCode.ChangeBackgroundColor(Color.LightGray)
MyBarCode.ChangeBarCodeColor(Color.DarkSlateBlue)
If Not MyBarCode.Verify() Then
    Console.WriteLine("Color contrast should be at least 50% or a barcode may become unreadable. Test using GeneratedBarcode.Verify()")
End If

' Finally, save the result
MyBarCode.SaveAsHtmlFile("StyledBarcode.html")

'*** STYLING BARCODES IN A SINGLE LINQ-STYLE EXPRESSION ***

' Create a barcode in one line of code
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.

Dim qrCodeLogo = New QRCodeLogo("ironsoftware_logo.png")
Dim myQRCodeWithLogo As GeneratedBarcode = 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 different formats
Install-Package BarCode

在此範例中,我們看到BARCODE可標註您自選的文字,或使用 barcode 本身的值,並採用目標機器上已安裝的任何字型。若該字型不可用,系統將選擇合適的相似字型。 BarCode 可調整大小、添加邊距,且 barcode 及背景顏色均可重新設定。 之後可將其儲存為適當的格式。

在最後幾行程式碼中,您可以看到透過使用我們的流暢風格運算子,僅需幾行程式碼即可建立並設定 barcode 的樣式,類似於 System.Linq

C# + VB.NET: 將條碼匯出為HTML 將條碼匯出為HTML
using IronBarCode;

GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128);

// Save as a stand-alone HTML file without any image assets
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 source content
string ImgTag = MyBarCode.ToHtmlTag();

// Turn the image into a HTML/CSS Data URI.
string DataURI = MyBarCode.ToDataUrl();
Imports IronBarCode

Private MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128)

' Save as a stand-alone HTML file without any image assets
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 source content
Dim ImgTag As String = MyBarCode.ToHtmlTag()

' Turn the image into a HTML/CSS Data URI.
Dim DataURI As String = MyBarCode.ToDataUrl()
Install-Package BarCode

IronBarcode 具備一項非常實用的功能,可將 BarCode 匯出為自包含的 HTML 格式,因此無需依賴任何關聯的圖像資源。 所有內容均包含於 HTML 檔案中。

我們可將內容匯出為 HTML 檔案HTML 圖片標籤,或轉為資料 URI

在此範例中:

  • 我們使用 BarcodeWriter.CreateBarcode 建立 BARCODE,並指定輸入資料與編碼類型。
  • 接著,我們使用 IronBarcode 提供的各種方法來匯出 BARCODE:
  • ToHtmlTag() 會產生一個可嵌入網頁的 HTML <img> 標籤。
  • ToDataUri() 會產生一個資料 URI 字串,可用作 <img> 標籤的來源,或幾乎任何需要圖片網址的地方。
  • SaveAsHtmlFile() 會將 BARCODE 儲存為獨立的 HTML 檔案,並將所有圖像資料內嵌其中,使其具備可攜性且便於分享。

Human Support related to .NET條碼程式庫

來自我們開發團隊的直接人員支援

無論是產品、整合或授權問題,Iron 產品開發團隊都準備好支援您所有的問題。聯繫我們並與 Iron 進行對話,以發揮我們程式庫在您的計畫中的最大價值。

詢問問題
Recognizes Barcode Qr related to .NET條碼程式庫

在.NET Core、.NET Standard和.NET Framework中識別1D和2D條碼

IronBarcode .NET條碼程式庫能讀取BarcodeEncoding Enum中的任何類型的條碼。它在.NET Core、.NET Standard和.NET Framework中識別條碼。

為了節省時間並提高庫存工作流程的效率,IronBarcode建議使用一維(1D)或線性條碼,包括傳統和已建立的條碼類型如UPC和EAN代碼。全球的銷售服務點通常使用UPC(通用商品代碼)條碼(包括其變體UPC-A和UPC-E)。它通過使在倉庫和結帳時更容易識別和跟踪產品功能而惠及目標消費者。UPCA僅限於包含12到13位數字的數字內容,UPCE則支持長度為8到13位數字的內容。

如同UPC,歐洲市場使用EAN條碼為銷售點掃描標籤消費品。其變體包括EAN-13作為默認,EAN-8則用於有限的包裝空間,如糖果。除靈活性之外,作為高密度條碼,EAN-13能夠緊湊地編碼較大的數據集。

一維條碼並未止此。

汽車和國防行業利用Code 39條碼。其標題解釋了其能夠編碼39個字符(現修訂為43個)。同樣地,Code 128字符集和高數據密度。繼續物流行業,包裝行業偏好使用ITF(交錯2的5)條碼來標籤包裝材料,如波紋板,由於其高印刷容限。然而,MSI更適合產品識別和庫存管理。

製藥行業利用製藥二進制代碼。而RSS 14(縮減空間符號)和Databar條碼則是一維和二維條碼的混合體,這在醫療護理中標記小物品頗受歡迎。如同Code 128條碼,Codabar也在物流和醫療界廣受喜愛。它無需電腦即可工作,從點陣列打印機輸出中可讀取。

二維條碼包括Aztec、Data Matrix、Data Bar、IntelligentMail、Maxicode、QR碼。Aztec在票證和登機證上使用,閱讀分辨率較低而使用於交通業。IntelligentMail則被限制用於美國郵政,但Maxicode則用於標準化貨物追蹤。

在條碼中最廣為人知的是QR碼。由於其靈活性、容錯能力、可讀性、各種數據支持如數字、字母數字、位元/二進制和漢字,其用途廣泛,適用於B2B到B2C。

一旦確認了類型,IronBarcode--領先的條碼生成器將接手!

查看更多功能列表
Fast And Polite Behavior related to .NET條碼程式庫

開始您的條碼生成和讀取項目與.NET條碼讀取器

在.NET中讀取條碼類型現在變得輕而易舉,IronBarcode的多功能、先進和高效的程式庫讓這變得可能。

您從哪裡開始?

安裝IronBarcode的NuGet包或手動安裝DLL到您的項目或您的全局程序集緩存。您現在離創建一個C#條碼圖像掃描器應用程式只差一步。提取條碼圖像、值、編碼類型、二進制數據(如果有)然後全部輸出到控制台。

TryHarder - 更深入地掃描偏斜條碼格式

在QuicklyReadOneBarcode方法中添加IronBarcode的TryHarder變數,使應用程式更加努力地,儘管消耗更多時間,但更徹底地分析被遮蔽、偏斜或損壞的QR碼圖像格式。

隨時指定多種格式

您可以指定您正在尋找的條碼編碼或指定多種格式 - IronBarcode為您提供無限的條碼分析工具。

您可以提高條碼讀取性能和準確性。您可以使用管字符或'Bitwise OR'同時指定多種條碼格式。或者,通過BarcodeReader.ReadASingleBarcode方法獲得更多的特定性和質量。

從PDF文件到掃描再到多執行緒中讀取條碼

如果您的下一個項目是讀取一個掃描的PDF文件並查找所有的一維條碼,再次IronBarcode不會令您失望。這與從單個文件中讀取單個條碼類似,除了現在添加了有關條碼所屬頁碼的資訊。

同樣地,從多幀的TIFF中實現相同的結果。在這方面,它被視為與PDF類似。

多執行緒是否讓您感到困擾?如果是這樣,它與IronBarcode兼容!

為了讀取多個文件,您可以通過創建一個文件列表並使用BarcodeReader.ReadBarcodesMultithreaded方法實現更好的結果。這使用多執行緒並潛在使用所有您的CPU核心進行條碼掃描過程,並可能比一次讀取一個條碼快許多倍。

對於不完美圖像的困擾已成為過去,感謝完美的條碼生成器

在現實世界中,使用者可能希望掃描不是完美的截圖或PNG圖像或照片。傳統的開源.NET條碼生成器和讀取程式庫使得讀取任何不完美的圖像格式成為可能。然而,IronBarcode使這變得異常簡單。

QuicklyReadOneBarcode的方法中的TryHarder導致IronBarcode去除傾斜並從不完美的數位樣本中讀取條碼。

照片、掃描和縮略圖

如果一張照片傾斜,設置特定的條碼旋轉和圖像校正來合理地校正手機相機通常會出現的數位雜訊、傾斜、透視和旋轉。

同樣地,從掃描的PDF中讀取QR碼和PDF-417條碼需要設定適當的條碼旋轉校正和條碼圖像校正來輕微地清理文件。但需謹慎控制,以免過度指定而影響性能。

如果您的條碼縮略圖損壞,那麼IronBarcode的讀取方法會自動檢測過小的條碼圖像,並進行升級和清理與縮略有關的所有數位雜訊,使它們再次可讀。

對開發者來說沒有什麼再能更容易了!

了解更多
Built For Dot Net related to .NET條碼程式庫

專為容易使用於.NET Core專案

只需幾行代碼即可在幾分鐘內開始。專為.NET Core、.NET Standard和Framework構建,容易使用單個DLL;無需依賴;支持32和64位;可在任何.NET語言使用。在Web、雲端、桌面或控制台應用程式中使用;支持移動和桌面設備。您可以從這個鏈接下載這個軟體產品。

為 .NET 構建 C#, QR碼

立即開始
Write Barcodes related to .NET條碼程式庫

總結IronBarcode - 用於創建和操作條碼圖像

由於IronBarcode促進各種條碼類型和格式的創建、調整大小和保存,沒有理由不馬上開始使用它!

使用Fluent API,使用生成的條碼類設置邊距、調整大小和註解條碼。然後保存為圖像,IronOCR自動假設文件名對應的正確圖像類型。無論是GIF、HTML文件、HTML標籤、JPEG、PNG、TIFF還是Windows位圖。

StampToExistingPdfPage方法允許將條碼生成並蓋印在已存在的PDF上。當編輯通用PDF或通過條碼向文件添加內部識別號時,這很有用。

立即連接24/7的真人支援。無論您有任何問題還是需要項目支持;以我們的30天試用鑰匙開始,從我們的易於理解的英語文檔資源中受益,或從我們的終身授權中受益,起價$749。

了解更多
支持:
  • .NET Core 2.0 及以上版本
  • .NET Framework 4.0 及以上版本支持 C#、VB、F#
  • Microsoft Visual Studio。 .NET 開發 IDE 圖示
  • Microsoft Visual Studio 的 NuGet 安裝支持
  • JetBrains ReSharper C# 語言助手兼容
  • Microsoft Azure C# .NET 託管平台兼容

授權及定價

免費 社群開發授權。商業授權從 $749 起。

專案 C# + VB.NET 程式庫授權

專案

開發者 C# + VB.NET 程式庫授權

開發者

組織 C# + VB.NET 程式庫授權

組織

代理 C# + VB.NET 程式庫授權

代理

SaaS C# + VB.NET 程式庫授權

SaaS

OEM C# + VB.NET 程式庫授權

OEM

查看完整授權選項  

C#和VB .NET的條碼和QR教程

讀取條碼的教學+代碼範例 | .NET 教程

C# .NET 條碼 QR

Frank Walker .NET 產品開發者

讀取條碼和 QR | C# VB .NET 教程

查看 Frank 如何使用 IronBarcode 從其 C# .NET 條碼應用程式中的掃描、照片和 PDF 文件讀取條碼...

查看 Frank 的條碼讀取教程
條碼寫作教學 + C# 和 VB.NET 的代碼範例

C# .NET 條碼

Francesca Miller 初級 .NET 工程師

在 C# 或 VB.NET 中生成條碼影像

Francesca 分享了一些在 C# 或 VB 應用程式中將條碼寫入影像的技巧和竅門。查看如何寫條碼以及 IronBarcode 提供給您的所有選項...

查看 Francesca 的條碼教程
VB.NET PDF 創建和編輯的教程和代碼範例 | VB.NET & ASP.NET PDF

QR .NET C# VB

Jennifer Wright 應用架構負責人

在 C# 和 VB .NET 應用程式中編寫 QR 碼的教學

Jenny 的團隊每天使用 IronBarcode 寫數以千計的 QR 碼。查看他們的教程以充分利用 IronBarcode...

Jenny 團隊的 QR 編寫教程
成千上萬的開發者使用 IronBarcode 來...

會計和金融系統

  • # 收據
  • # 報告
  • # 發票列印
向 ASP.NET 會計和金融系統添加 PDF 支援

商業數位化

  • # 文件
  • # 訂單與標籤
  • # 紙張替代
C# 商業數位化使用案例

企業內容管理

  • # 內容製作
  • # 文件管理
  • # 內容分發
.NET CMS PDF 支援

數據和報告應用程式

  • # 性能跟蹤
  • # 趨勢映射
  • # 報告
C# PDF 報告
Iron Software Enterprise .NET 元件開發者

成千上萬的企業、政府、中小企業和開發者都信任 Iron 軟體產品。

Iron 團隊在 .NET 軟體元件市場擁有超過 10 年的經驗。

Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標
Iron 客戶圖標

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我