푸터 콘텐츠로 바로가기
동영상

C#에서 여러 바코드를 한 번에 읽는 방법

DevExpress Barcode에서 IronBarcode로 마이그레이션

DevExpress의 그리드, 차트, 스케줄러 또는 피벗 컨트롤을 사용하고 있다면 해당 컨트롤은 그대로 유지하십시오. 이 마이그레이션은 BarCodeControl를 바코드를 읽고, 헤드리스로 실행하며, UI 컨텍스트 외부에 배포할 수 있는 라이브러리로 교체하는 것을 다룹니다. WinForms 또는 Blazor 애플리케이션에 사용하는 DevExpress UI 컨트롤은 이번 마이그레이션에서 변경되지 않습니다. 바코드 관련 코드만 변경됩니다.

이러한 마이그레이션을 유발하는 일반적인 시나리오는 다음 세 가지 중 하나입니다. 읽기 요구 사항이 발생했는데 DevExpress가 이를 충족할 수 없는 경우, 새로운 서비스에서 WinForms 어셈블리가 없는 ASP.NET Core 또는 클라우드 함수를 사용하여 바코드를 생성해야 합니다. 혹은 Suite 갱신 시기가 되면 바코드 출력만을 위한 전체 UI 툴킷 사용에 대한 기능별 비용 계산이 더 이상 타당하지 않게 됩니다.

1단계: IronBarcode 설치

dotnet add package BarCode

같은 프로젝트에 다른 DevExpress 컨트롤을 유지하는 경우 DevExpress NuGet 패키지를 그대로 두십시오. 소스 파일에서 바코드 관련 코드만 변경됩니다. 만약 바코드 생성이 특정 프로젝트에 DevExpress가 포함된 유일한 이유이고 해당 프로젝트에서 다른 DX 컨트롤을 전혀 사용하지 않는다면, 마이그레이션 후 해당 프로젝트에서 DevExpress 패키지를 제거할 수 있습니다.

# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
SHELL

2단계: 라이선스 초기화 추가

애플리케이션 시작 시 한 번 IronBarcode 라이선스를 활성화하세요 - Program.cs, App.xaml.cs 또는 호스트 빌더에서:

// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
Imports IronBarCode

' In Program.vb (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

네트워크 통화가 아닙니다. 확인할 오류 코드가 없습니다. 로컬 유효성 검사.

3단계: 바코드별 코드 교체

코드베이스에서 DevExpress 바코드 유형을 검색하세요. 나머지는 그대로 유지됩니다.

# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
SHELL

이 검색 결과는 교체할 부품과 정확히 일치합니다. 그 외에는 아무것도 없습니다.

코드 마이그레이션 예제

코드 128 생성

이것이 가장 흔한 마이그레이션 방식입니다. BarCodeControl은(는) Code128Generator 심볼로지와 함께 단일 BarcodeWriter.CreateBarcode 호출이 됩니다.

이전 — DevExpress WinForms 컨트롤:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateCode128(string data, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new Code128Generator();
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
    barCode.Symbology = symbology;
    barCode.Text = data;
    barCode.Module = 0.02f;
    barCode.ShowText = true;

    barCode.Width = 400;
    barCode.Height = 100;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateCode128(string data, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new Code128Generator();
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
    barCode.Symbology = symbology;
    barCode.Text = data;
    barCode.Module = 0.02f;
    barCode.ShowText = true;

    barCode.Width = 400;
    barCode.Height = 100;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging

Public Sub GenerateCode128(data As String, outputPath As String)
    Dim barCode As New BarCodeControl()
    Dim symbology As New Code128Generator()
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto
    barCode.Symbology = symbology
    barCode.Text = data
    barCode.Module = 0.02F
    barCode.ShowText = True

    barCode.Width = 400
    barCode.Height = 100
    Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
    barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
    bitmap.Save(outputPath, ImageFormat.Png)
    bitmap.Dispose()
End Sub
$vbLabelText   $csharpLabel

이후 — IronBarcode:

// NuGet: dotnet add package BarCode
using IronBarCode;

public void GenerateCode128(string data, string outputPath)
{
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .SaveAsPng(outputPath);
}
// NuGet: dotnet add package BarCode
using IronBarCode;

public void GenerateCode128(string data, string outputPath)
{
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateCode128(data As String, outputPath As String)
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

barCode.Module = 0.02f 문서-단위 크기 조정이 사라졌습니다. .ResizeTo(400, 100)은(는) 픽셀을 직접 받습니다. 수동 Bitmap 할당 및 DrawToBitmap 호출이 .SaveAsPng()로 대체되어 크기 조정을 자동으로 처리합니다.

QR 코드 생성

이전 — 오류 수정 기능이 있는 DevExpress QR 코드:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateQrCode(string url, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new QRCodeGenerator();
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    barCode.Symbology = symbology;
    barCode.Text = url;

    barCode.Width = 500;
    barCode.Height = 500;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateQrCode(string url, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new QRCodeGenerator();
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    barCode.Symbology = symbology;
    barCode.Text = url;

    barCode.Width = 500;
    barCode.Height = 500;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging

Public Sub GenerateQrCode(url As String, outputPath As String)
    Dim barCode As New BarCodeControl()
    Dim symbology As New QRCodeGenerator()
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric
    barCode.Symbology = symbology
    barCode.Text = url

    barCode.Width = 500
    barCode.Height = 500
    Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
    barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
    bitmap.Save(outputPath, ImageFormat.Png)
    bitmap.Dispose()
End Sub
$vbLabelText   $csharpLabel

이후 — IronBarcode:

using IronBarCode;

public void GenerateQrCode(string url, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .SaveAsPng(outputPath);
}
using IronBarCode;

public void GenerateQrCode(string url, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateQrCode(url As String, outputPath As String)
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

QRCodeErrorCorrectionLevel.H은(는) QRCodeWriter.QrErrorCorrectionLevel.Highest로 매핑됩니다. CompactionMode.AlphaNumeric 설정은 IronBarcode가 콘텐츠에 따라 자동으로 처리합니다.

브랜드 로고가 포함된 QR 코드 (새로운 기능 - DevExpress에서는 불가능):

using IronBarCode;

public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .AddBrandLogo(logoPath)
        .SaveAsPng(outputPath);
}
using IronBarCode;

public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .AddBrandLogo(logoPath)
        .SaveAsPng(outputPath);
}
Imports IronBarCode

Public Sub GenerateBrandedQrCode(url As String, logoPath As String, outputPath As String)
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .AddBrandLogo(logoPath) _
        .SaveAsPng(outputPath)
End Sub
$vbLabelText   $csharpLabel

데이터 행렬 생성

이전 — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode

Dim barCode As New BarCodeControl()
Dim symbology As New DataMatrixGenerator()
symbology.MatrixSize = DataMatrixSize.Matrix26x26
barCode.Symbology = symbology
barCode.Text = "PART-7734-X"
' ... DrawToBitmap pattern
$vbLabelText   $csharpLabel

이후 — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
    .ResizeTo(260, 260)
    .SaveAsPng("datamatrix.png");
using IronBarCode;

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
    .ResizeTo(260, 260)
    .SaveAsPng("datamatrix.png");
Imports IronBarCode

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix) _
    .ResizeTo(260, 260) _
    .SaveAsPng("datamatrix.png")
$vbLabelText   $csharpLabel

PDF417 세대

이전 — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode

Dim barCode As New BarCodeControl()
barCode.Symbology = New PDF417Generator()
barCode.Text = "SHIPMENT-DATA-2026"
' ... DrawToBitmap pattern
$vbLabelText   $csharpLabel

이후 — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
    .ResizeTo(400, 150)
    .SaveAsPng("pdf417.png");
using IronBarCode;

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
    .ResizeTo(400, 150)
    .SaveAsPng("pdf417.png");
Imports IronBarCode

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417) _
    .ResizeTo(400, 150) _
    .SaveAsPng("pdf417.png")
$vbLabelText   $csharpLabel

읽기 기능 추가 (새로운 기능)

DevExpress는 읽기 API를 제공하지 않습니다. 판독 요구 사항이 발생한 경우, 바로 이 지점에서 IronBarcode 진가가 발휘됩니다.

using IronBarCode;

// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Found {result.Format}: {result.Value}");
}

// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
using IronBarCode;

// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Found {result.Format}: {result.Value}");
}

// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
Imports IronBarCode

' Read from an image file
Dim results = BarcodeReader.Read("uploaded-label.png")
For Each result In results
    Console.WriteLine($"Found {result.Format}: {result.Value}")
Next

' Read with options for better accuracy on difficult images
Dim options As New BarcodeReaderOptions With {
    .Speed = ReadingSpeed.Balanced,
    .ExpectMultipleBarcodes = True,
    .MaxParallelThreads = 4
}
Dim detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options)
$vbLabelText   $csharpLabel

ASP.NET Core 바코드 엔드포인트

이는 BarCodeControl와(과) WinForms 우회 방법 없이는 달성할 수 없었습니다. IronBarcode 이를 기본적으로 지원합니다.

using IronBarCode;

// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
    var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png", $"{sku}.png");
});

app.MapGet("/qr/{data}", (string data) =>
{
    var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png");
});
using IronBarCode;

// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
    var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png", $"{sku}.png");
});

app.MapGet("/qr/{data}", (string data) =>
{
    var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png");
});
Imports IronBarCode

' In Program.vb or a controller
app.MapGet("/label/{sku}", Function(sku As String)
    Dim pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .ToPngBinaryData()

    Return Results.File(pngBytes, "image/png", $"{sku}.png")
End Function)

app.MapGet("/qr/{data}", Function(data As String)
    Dim pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
        .ToPngBinaryData()

    Return Results.File(pngBytes, "image/png")
End Function)
$vbLabelText   $csharpLabel

PDF 파일에서 바코드 읽기

IronBarcode PDF 파일에서 직접 읽기 기능을 제공합니다. PDFiumViewer도, 렌더링 루프도, 추가 패키지도 필요 없습니다.

using IronBarCode;

// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
using IronBarCode;

// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
Imports IronBarCode

' Read all barcodes from all pages of a PDF
Dim results = BarcodeReader.Read("shipping-manifest.pdf")
For Each result In results
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}")
Next
$vbLabelText   $csharpLabel

일반적인 마이그레이션 문제

barCode.Module은 픽셀 단위가 아닌 문서 단위를 사용합니다.

barCode.Module은(는) 문서 단위에서 가장 좁은 바의 폭을 제어합니다 (렌더링 DPI 컨텍스트에 따라 다릅니다). 이것은 픽셀 수가 아닙니다. 이동 시 모듈 값을 픽셀로 변환하지 말고 원하는 픽셀 크기를 결정하고 .ResizeTo(width, height)을 직접 사용하세요.

// Before: barCode.Module = 0.02f  — document units, indirect sizing
// After:
.ResizeTo(400, 100)  // explicit pixel dimensions
// Before: barCode.Module = 0.02f  — document units, indirect sizing
// After:
.ResizeTo(400, 100)  // explicit pixel dimensions
' Before: barCode.Module = 0.02F  — document units, indirect sizing
' After:
.ResizeTo(400, 100)  ' explicit pixel dimensions
$vbLabelText   $csharpLabel

DrawToBitmap 함수는 미리 할당된 비트맵을 필요로 합니다.

이전 패턴에서는 특정 크기의 Bitmap을(를) 할당하고, 그 안에 렌더링하기 위해 DrawToBitmap을(를) 호출했습니다. IronBarcode의 .SaveAsPng()은(는) 이를 내부적으로 모두 처리합니다. 사전에 아무것도 할당하지 않습니다.

// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();

// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(path);
// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();

// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(path);
' Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400
barCode.Height = 100
Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
bitmap.Save(path, ImageFormat.Png)
bitmap.Dispose()

' After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
    .ResizeTo(400, 100) _
    .SaveAsPng(path)
$vbLabelText   $csharpLabel

WinForms 데이터 바인딩

BarCodeControl이(가) WinForms 디자이너에서 데이터 소스에 바인딩된 경우, IronBarcode 등가는 모델에서 값을 명시적으로 읽어 BarcodeWriter.CreateBarcode에 전달하는 것입니다. IronBarcode WinForms 데이터 바인딩을 지원하지 않습니다. 이는 UI 컨트롤이 아니라 프로그래밍 방식의 API입니다. 생성된 바코드를 폼에 표시해야 한다면, 이미지 바이트를 생성하여 이를 PictureBox에 설정하세요:

using IronBarCode;

// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
    var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    using var ms = new System.IO.MemoryStream(bytes);
    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
using IronBarCode;

// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
    var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    using var ms = new System.IO.MemoryStream(bytes);
    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
Imports IronBarCode
Imports System.IO

' Generate and display in a WinForms PictureBox
Private Sub UpdateBarcodeDisplay(value As String)
    Dim bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128) _
        .ResizeTo(400, 100) _
        .ToPngBinaryData()

    Using ms As New MemoryStream(bytes)
        pictureBox1.Image = System.Drawing.Image.FromStream(ms)
    End Using
End Sub
$vbLabelText   $csharpLabel

네임스페이스 교체

삭제할 기존 가져오기 항목:

// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
$vbLabelText   $csharpLabel

추가할 새 항목:

// Add this
using IronBarCode;
// Add this
using IronBarCode;
Imports IronBarCode
$vbLabelText   $csharpLabel

API 매핑 참조

DevExpress 바코드 IronBarcode 동등품
new BarCodeControl() 정적 — 인스턴스 없음
new Code128Generator() + barCode.Symbology = symbology BarcodeEncoding.Code128 매개변수
new QRCodeGenerator() + QRCodeErrorCorrectionLevel.H QRCodeWriter.CreateQrCode(data, size, QRCodeWriter.QrErrorCorrectionLevel.Highest)
new DataMatrixGenerator() + DataMatrixSize.Matrix26x26 BarcodeWriter.CreateBarcode(data, BarcodeEncoding.DataMatrix)
new PDF417Generator() BarcodeWriter.CreateBarcode(data, BarcodeEncoding.PDF417)
new AztecCodeGenerator() BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Aztec)
barCode.Text = value CreateBarcode 또는 CreateQrCode의 첫 번째 인수
barCode.Module = 0.02f 픽셀 단위의 .ResizeTo(width, height)
barCode.ShowText = true .AddBarcodeText()
DrawToBitmap(bitmap, rect) .SaveAsPng(path)
new Bitmap(w, h) + 수동 해제 필요 없음
비트맵 → MemoryStream → HTTP .ToPngBinaryData()
읽기 API 없음 BarcodeReader.Read(path)
using DevExpress.XtraEditors + using DevExpress.XtraPrinting.BarCode using IronBarCode

마이그레이션 체크리스트

다음 grep 패턴을 사용하여 업데이트가 필요한 모든 파일을 찾으세요.

grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
SHELL

각 경기를 하나씩 살펴보세요:

  • using DevExpress.XtraEditors;와(과) using DevExpress.XtraPrinting.BarCode;을(를) using IronBarCode;로 교체하세요
  • new BarCodeControl() + 심볼로지 설정을 BarcodeWriter.CreateBarcode(data, BarcodeEncoding.X)로 교체하세요
  • new QRCodeGenerator() + 심볼로지 설정을 QRCodeWriter.CreateQrCode(data, size, errorLevel)로 교체하세요
  • barCode.Module = X을(를) .ResizeTo(width, height)로 교체하세요
  • DrawToBitmap + bitmap.Save 패턴을 .SaveAsPng(path)로 교체하세요
  • 비트맵-메모리스트림 패턴을 .ToPngBinaryData()로 교체하세요
  • 애플리케이션 시작 시 IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"을(를) 추가하세요
  • 읽기 기능이 필요한 곳마다 BarcodeReader.Read() 호출을 추가하세요

프로젝트에서 바코드 컨트롤에만 DevExpress를 사용하고 다른 DX 구성 요소를 사용하지 않는 경우, 모든 바코드 참조를 교체한 후 DevExpress NuGet 패키지를 제거하십시오. 프로젝트에서 DevExpress 그리드, 차트 또는 기타 UI 컨트롤을 사용하는 경우 해당 패키지는 그대로 두십시오. 이 마이그레이션은 바코드 코드만 수정합니다.

자주 묻는 질문

DevExpress 바코드에서 IronBarcode로 마이그레이션해야 하는 이유는 무엇인가요?

일반적인 이유로는 라이선스 간소화(SDK + 런타임 키 복잡성 제거), 처리량 제한 제거, 네이티브 PDF 지원 확보, Docker/CI/CD 배포 개선, 프로덕션 코드의 API 상용구 감소 등이 있습니다.

DevExpress API 호출을 IronBarcode로 대체하려면 어떻게 해야 하나요?

인스턴스 생성 및 라이선스 상용구를 IronBarCode.License.LicenseKey = "key"로 대체합니다. 판독기 호출을 BarcodeReader.Read(경로)로, 쓰기 호출을 BarcodeWriter.CreateBarcode(데이터, 인코딩)로 바꿉니다. 정적 메서드는 인스턴스 관리가 필요하지 않습니다.

DevExpress 바코드에서 IronBarcode로 마이그레이션할 때 얼마나 많은 코드가 변경되나요?

대부분의 마이그레이션은 더 적은 코드 줄로 이루어집니다. 라이선스 상용구, 인스턴스 생성자, 명시적 형식 구성이 제거됩니다. 핵심 읽기/쓰기 작업이 더 간결한 결과 객체를 가진 더 짧은 IronBarcode에 매핑됩니다.

마이그레이션하는 동안 DevExpress 바코드와 IronBarcode를 모두 설치해야 하나요?

아니요. 대부분의 마이그레이션은 병렬 작업이 아닌 직접 교체 작업입니다. 한 번에 하나의 서비스 클래스를 마이그레이션하고, NuGet 참조를 교체하고, 인스턴스화 및 API 호출 패턴을 업데이트한 후 다음 클래스로 이동합니다.

IronBarcode의 NuGet 패키지 이름은 무엇인가요?

패키지는 'IronBarCode'(대문자 B와 C 포함)입니다. '설치-패키지 IronBarCode' 또는 '닷넷 추가 패키지 IronBarCode'로 설치합니다. 코드의 사용 지시어는 'using IronBarCode;'입니다.

IronBarcode는 DevExpress 바코드와 비교하여 어떻게 Docker 배포를 간소화하나요?

IronBarcode는 외부 SDK 파일이나 마운트된 라이선스 구성이 없는 NuGet 패키지입니다. Docker에서 IRONBARCODE_LICENSE_KEY 환경 변수를 설정하면 패키지가 시작 시 라이선스 유효성 검사를 처리합니다.

DevExpress에서 마이그레이션한 후 IronBarcode가 모든 바코드 형식을 자동으로 감지하나요?

예. IronBarcode는 지원되는 모든 형식에서 기호를 자동으로 감지합니다. 명시적인 바코드 유형 열거가 필요하지 않습니다. 형식이 이미 알려져 있고 성능이 중요한 경우 BarcodeReaderOptions를 사용하여 검색 공간을 최적화하여 제한할 수 있습니다.

IronBarcode는 별도의 라이브러리 없이 PDF에서 바코드를 판독할 수 있나요?

예. BarcodeReader.Read("document.pdf")는 기본적으로 PDF 파일을 처리합니다. 결과에는 발견된 각 바코드에 대한 페이지 번호, 형식, 값 및 신뢰도가 포함됩니다. 외부 PDF 렌더링 단계가 필요하지 않습니다.

IronBarcode는 병렬 바코드 처리를 어떻게 처리하나요?

IronBarcode의 정적 메서드는 상태 저장소가 없고 스레드에 안전합니다. 스레드별 인스턴스 관리 없이 파일 목록에 직접 Parallel.ForEach를 사용할 수 있습니다. BarcodeReaderOptions.MaxParallelThreads는 내부 스레드 예산을 제어합니다.

DevExpress 바코드에서 IronBarcode로 마이그레이션하면 어떤 결과 속성이 변경되나요?

일반적인 이름 변경: 바코드 값은 값으로, 바코드 유형은 형식으로 바뀝니다. IronBarcode 결과에는 신뢰도 및 페이지 번호도 추가됩니다. 솔루션 전반의 검색 및 바꾸기 기능은 기존 결과 처리 코드에서 이름 변경을 처리합니다.

CI/CD 파이프라인에서 IronBarcode 라이선싱을 설정하려면 어떻게 해야 하나요?

IRONBARCODE_LICENSE_KEY를 파이프라인 시크릿으로 저장하고 애플리케이션 시작 코드에 IronBarCode.License.LicenseKey를 할당하세요. 하나의 비밀은 개발, 테스트, 스테이징 및 프로덕션을 포함한 모든 환경에 적용됩니다.

IronBarcode는 사용자 지정 스타일로 QR 코드 생성을 지원하나요?

예. QRCodeWriter.CreateQrCode()는 변경바코드색()을 통한 사용자 지정 색상, 추가브랜드 로고()를 통한 로고 임베딩, 구성 가능한 오류 수정 수준, PNG, JPG, PDF, 스트림을 포함한 여러 출력 형식을 지원합니다.

Curtis Chau
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.

아이언 서포트 팀

저희는 주 5일, 24시간 온라인으로 운영합니다.
채팅
이메일
전화해