Iron Barcode를 사용하여 .NET 5용 C#에서 QR 코드 및 바코드를 생성하는 방법

Barcodes & QRs in C# & VB.NET Applications

This article was translated from English: Does it need improvement?
Translated
View the article in English

C# 및 기타 모든 .NET 언어에서 BarCode를 읽고 쓰는 작업은 당사의 IronBarcode 라이브러리를 사용하면 간편하게 수행할 수 있습니다.

IronBarcode 설치

이 여정의 첫 단계는 IronBarcode를 설치하는 것이며, NuGet에서 다운로드하거나 DLL 파일을 직접 다운로드하여 설치할 수 있습니다.

IronBarcode NuGet 패키지를 설치하려면 Visual Studio용 NuGet 패키지 관리자를 사용할 수 있습니다:

Install-Package BarCode

또는 .NET CLI를 사용하여 설치할 수도 있습니다:

dotnet add package IronBarCode

BarCode 또는 QR 코드 읽기

IronBarcode를 사용하면 단 한 줄의 코드만으로 BARCODE를 읽을 수 있습니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-1.cs
using IronBarCode;

BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");
if (results != null)
{
    foreach (BarcodeResult result in results)
    {
        Console.WriteLine(result.Text);
    }
}
Imports IronBarCode

Private results As BarcodeResults = BarcodeReader.Read("QuickStart.jpg")
If results IsNot Nothing Then
	For Each result As BarcodeResult In results
		Console.WriteLine(result.Text)
	Next result
End If
$vbLabelText   $csharpLabel

이 한 줄의 코드만으로 입력 문서에서 모든 유형의 BarCode를 뛰어난 성능으로 감지하고 스캔할 수 있습니다. 필요한 모든 작업이 한 번에 해결됩니다! 이 메서드는 JPEG, PNG, BMP와 같은 다양한 이미지 형식뿐만 아니라 PDF 및 GIF, TIFF와 같은 다중 프레임 형식도 지원합니다. 성능 향상을 위해 사용자 정의 가능한 구성 옵션을 제공합니다.

읽기 속도를 높이기 위해, 더 나은 성능을 위해 Speed 설정이 구성된 BarcodeReaderOptions 객체를 생성할 수 있습니다. 기본값은 Balanced이지만, Faster 옵션을 사용하여 특정 검사를 건너뛸 수 있습니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-2.cs
using IronBarCode;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    ExpectMultipleBarcodes = false,
    ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
    CropArea = new System.Drawing.Rectangle(100, 200, 300, 400),
};

BarcodeResults result = BarcodeReader.Read("QuickStart.jpg", myOptionsExample);
if (result != null)
{
    Console.WriteLine(result.First().Text);
}
Imports IronBarCode

Private myOptionsExample As New BarcodeReaderOptions() With {
	.ExpectMultipleBarcodes = False,
	.ExpectBarcodeTypes = BarcodeEncoding.QRCode Or BarcodeEncoding.Code128,
	.CropArea = New System.Drawing.Rectangle(100, 200, 300, 400)
}

Private result As BarcodeResults = BarcodeReader.Read("QuickStart.jpg", myOptionsExample)
If result IsNot Nothing Then
	Console.WriteLine(result.First().Text)
End If
$vbLabelText   $csharpLabel

또한 ScanModeOnlyBasicScan로 설정하여 가독성을 높일 수 있습니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-3.cs
using IronBarCode;

BarcodeResults results = BarcodeReader.Read("MultipleBarcodes.png");

// Loop through the results
foreach (BarcodeResult result in results)
{
    string value = result.Value;
    Bitmap img = result.BarcodeImage;
    BarcodeEncoding barcodeType = result.BarcodeType;
    byte[] binary = result.BinaryValue;
    Console.WriteLine(result.Value);
}
Imports IronBarCode

Private results As BarcodeResults = BarcodeReader.Read("MultipleBarcodes.png")

' Loop through the results
For Each result As BarcodeResult In results
	Dim value As String = result.Value
	Dim img As Bitmap = result.BarcodeImage
	Dim barcodeType As BarcodeEncoding = result.BarcodeType
	Dim binary() As Byte = result.BinaryValue
	Console.WriteLine(result.Value)
Next result
$vbLabelText   $csharpLabel

기타 구성 옵션으로는 스캔할 BarCode 형식을 지정하는 기능이 있으며, 이를 통해 불필요한 스캔을 줄여 처리 속도를 높일 수 있습니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-4.cs
using IronBarCode;

BarcodeResults pagedResults = BarcodeReader.Read("MultipleBarcodes.pdf");

// Loop through the results
foreach (BarcodeResult result in pagedResults)
{
    int pageNumber = result.PageNumber;
    string value = result.Value;
    Bitmap img = result.BarcodeImage;
    BarcodeEncoding barcodeType = result.BarcodeType;
    byte[] binary = result.BinaryValue;
    Console.WriteLine(result.Value);
}

// or from a multi-page  TIFF scan with image correction:
BarcodeResults multiFrameResults = BarcodeReader.Read(inputImage: "Multiframe.tiff", new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Detailed,
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.Code128,
    Multithreaded = false,
    RemoveFalsePositive = false,
    ImageFilters = null
});
Imports IronBarCode

Private pagedResults As BarcodeResults = BarcodeReader.Read("MultipleBarcodes.pdf")

' Loop through the results
For Each result As BarcodeResult In pagedResults
	Dim pageNumber As Integer = result.PageNumber
	Dim value As String = result.Value
	Dim img As Bitmap = result.BarcodeImage
	Dim barcodeType As BarcodeEncoding = result.BarcodeType
	Dim binary() As Byte = result.BinaryValue
	Console.WriteLine(result.Value)
Next result

' or from a multi-page  TIFF scan with image correction:
Dim multiFrameResults As BarcodeResults = BarcodeReader.Read(inputImage:= "Multiframe.tiff", New BarcodeReaderOptions With {
	.Speed = ReadingSpeed.Detailed,
	.ExpectMultipleBarcodes = True,
	.ExpectBarcodeTypes = BarcodeEncoding.Code128,
	.Multithreaded = False,
	.RemoveFalsePositive = False,
	.ImageFilters = Nothing
})
$vbLabelText   $csharpLabel

BarCode 작성

IronBarcode를 사용하여 BARCODE를 작성하려면 BarcodeWriter 클래스를 사용합니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-5.cs
using IronBarCode;

GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
myBarcode.SaveAsImage("myBarcode.png");
Imports IronBarCode

Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128)
myBarcode.SaveAsImage("myBarcode.png")
$vbLabelText   $csharpLabel

BarCode 스타일링

IronBarcode는 BarCode의 시각적 표현을 조작할 수 있는 여러 가지 옵션을 제공합니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-7.cs
using IronBarCode;

GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);
myBarcode.AddAnnotationTextAboveBarcode("Product URL:");
myBarcode.AddBarcodeValueTextBelowBarcode();
myBarcode.SetMargins(100);
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.Purple);

// All major image formats supported as well as PDF and HTML
myBarcode.SaveAsPng("myBarcode.png");
Imports IronBarCode

Private myBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128)
myBarcode.AddAnnotationTextAboveBarcode("Product URL:")
myBarcode.AddBarcodeValueTextBelowBarcode()
myBarcode.SetMargins(100)
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.Purple)

' All major image formats supported as well as PDF and HTML
myBarcode.SaveAsPng("myBarcode.png")
$vbLabelText   $csharpLabel

BarCode를 HTML로 내보내기

IronBarcode는 BARCODE를 HTML 문서로 내보내거나 HTML 콘텐츠의 일부로 포함시킬 수 있습니다.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-8.cs
using IronBarCode;

QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
Imports IronBarCode

QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf")
$vbLabelText   $csharpLabel

QR 코드 생성

QR 코드의 경우, 오류 정정 등 QR 코드 특유의 기능을 위한 추가 구성을 제공하는 QRCodeWriter 클래스를 사용하십시오.

:path=/static-assets/barcode/content-code-examples/get-started/get-started-9.cs
using IronBarCode;
using IronSoftware.Drawing;

QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", qrCodeLogo);
myQRCodeWithLogo.ChangeBarCodeColor(Color.DarkGreen).SaveAsPdf("MyQRWithLogo.pdf");
Imports IronBarCode
Imports IronSoftware.Drawing

Private qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")
Private myQRCodeWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/csharp/barcode/", qrCodeLogo)
myQRCodeWithLogo.ChangeBarCodeColor(Color.DarkGreen).SaveAsPdf("MyQRWithLogo.pdf")
$vbLabelText   $csharpLabel

지원되는 바코드 형식

IronBarcode는 읽기 및 쓰기 모두에 대해 널리 사용되는 다양한 BarCode 형식을 지원합니다:

  • QR, Micro QR직사각형 Micro QR(rMQR) 코드.
  • Aztec, Data Matrix, MaxiCode, PDF417과 같은 기타 2차원 BARCODE.
  • Databar와 같은 적층형 선형 BARCODE.
  • UPC-A, UPC-E, EAN-8, EAN-13, Codabar, ITF, MSIPlessey와 같은 기존의 1차원 BARCODE 형식.

왜 IronBarcode를 선택해야 할까요?

IronBarcode for .NET은 개발자가 .NET 환경에서 바코드를 읽고 쓸 수 있도록 친숙하고 사용하기 쉬운 API를 제공하며, 실제 사용 사례에서 정확성, 정밀도 및 속도를 최적화합니다.

예를 들어, BarcodeWriter 클래스는 UPCA 및 UPCE BARCODE의 '체크섬'을 자동으로 검증하고 수정하며, 숫자 형식 제약 조건을 처리합니다. IronBarcode는 개발자가 자신의 데이터에 가장 적합한 BarCode 형식을 선택할 수 있도록 지원합니다.

이 라이브러리는 자동 회전 및 이미지 노이즈 제거와 같은 이미지 전처리 기술을 통해 BarCode 인식 성공률을 극대화하는 등 강력한 성능을 자랑합니다.

향후 계획

IronBarcode를 최대한 활용하시려면, 이 문서 섹션에 포함된 튜토리얼을 읽어보시고 GitHub 페이지를 방문해 보시기 바랍니다.

커티스 차우
기술 문서 작성자

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

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

시작할 준비 되셨나요?
Nuget 다운로드 2,240,258 | 버전: 2026.5 just released
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package BarCode
샘플을 실행하세요 실이 바코드로 변하는 모습을 지켜보세요.