# Barcodes & QRs in C# & VB.NET Applications
C# 및 기타 모든 .NET 언어에서 BarCode를 읽고 쓰는 작업은 당사의 IronBarcode 라이브러리를 사용하면 간편하게 수행할 수 있습니다.
## IronBarcode 설치
이 여정의 첫 단계는 IronBarcode를 설치하는 것이며, NuGet에서 다운로드하거나 [DLL 파일을](https://www.nuget.org/packages/Barcode/) 직접 [다운로드하여](https://www.nuget.org/packages/Barcode/) 설치할 수 있습니다.
IronBarcode NuGet 패키지를 설치하려면 Visual Studio용 NuGet 패키지 관리자를 사용할 수 있습니다:
```shell
:ProductInstall
```
또는 .NET CLI를 사용하여 설치할 수도 있습니다:
```shell
:InstallCmd dotnet add package IronBarCode
```
## BarCode 또는 QR 코드 읽기
IronBarcode를 사용하면 단 한 줄의 코드만으로 BARCODE를 읽을 수 있습니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-1.cs
```
이 한 줄의 코드만으로 입력 문서에서 모든 유형의 BarCode를 뛰어난 성능으로 감지하고 스캔할 수 있습니다. 필요한 모든 작업이 한 번에 해결됩니다! 이 메서드는 JPEG, PNG, BMP와 같은 다양한 이미지 형식뿐만 아니라 PDF 및 GIF, TIFF와 같은 다중 프레임 형식도 지원합니다. 성능 향상을 위해 사용자 정의 가능한 구성 옵션을 제공합니다.
읽기 속도를 높이기 위해, 더 나은 성능을 위해 `Speed` 설정이 구성된 `BarcodeReaderOptions` 객체를 생성할 수 있습니다. 기본값은 `Balanced`이지만, `Faster` 옵션을 사용하여 특정 검사를 건너뛸 수 있습니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-2.cs
```
또한 `ScanMode`을 `OnlyBasicScan`로 설정하여 가독성을 높일 수 있습니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-3.cs
```
기타 구성 옵션으로는 스캔할 BarCode 형식을 지정하는 기능이 있으며, 이를 통해 불필요한 스캔을 줄여 처리 속도를 높일 수 있습니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-4.cs
```
## BarCode 작성
IronBarcode를 사용하여 BARCODE를 작성하려면 `BarcodeWriter` 클래스를 사용합니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-5.cs
```
## BarCode 스타일링
IronBarcode는 BarCode의 시각적 표현을 조작할 수 있는 여러 가지 옵션을 제공합니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-7.cs
```
## BarCode를 HTML로 내보내기
IronBarcode는 BARCODE를 HTML 문서로 내보내거나 HTML 콘텐츠의 일부로 포함시킬 수 있습니다.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-8.cs
```
## QR 코드 생성
QR 코드의 경우, 오류 정정 등 QR 코드 특유의 기능을 위한 추가 구성을 제공하는 `QRCodeWriter` 클래스를 사용하십시오.
```csharp
:path=/static-assets/barcode/content-code-examples/get-started/get-started-9.cs
```
## 지원되는 바코드 형식
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**, **MSI** 및 **Plessey**와 같은 기존의 1차원 BARCODE 형식.
## 왜 IronBarcode를 선택해야 할까요?
IronBarcode for .NET은 개발자가 .NET 환경에서 바코드를 읽고 쓸 수 있도록 친숙하고 사용하기 쉬운 API를 제공하며, 실제 사용 사례에서 정확성, 정밀도 및 속도를 최적화합니다.
예를 들어, `BarcodeWriter` 클래스는 UPCA 및 UPCE BARCODE의 '체크섬'을 자동으로 검증하고 수정하며, 숫자 형식 제약 조건을 처리합니다. IronBarcode는 개발자가 자신의 데이터에 가장 적합한 BarCode 형식을 선택할 수 있도록 지원합니다.
이 라이브러리는 자동 회전 및 이미지 노이즈 제거와 같은 이미지 전처리 기술을 통해 BarCode 인식 성공률을 극대화하는 등 강력한 성능을 자랑합니다.
## 향후 계획
IronBarcode를 최대한 활용하시려면, 이 문서 섹션에 포함된 튜토리얼을 읽어보시고 [GitHub](https://github.com/iron-software) 페이지를 방문해 보시기 바랍니다.
C# 및 기타 모든 .NET 언어에서 BarCode를 읽고 쓰는 작업은 당사의 IronBarcode 라이브러리를 사용하면 간편하게 수행할 수 있습니다.
IronBarcode 설치
이 여정의 첫 단계는 IronBarcode를 설치하는 것이며, NuGet에서 다운로드하거나 DLL 파일을 직접 다운로드하여 설치할 수 있습니다.
IronBarcode NuGet 패키지를 설치하려면 Visual Studio용 NuGet 패키지 관리자를 사용할 수 있습니다:
PM > Install-Package BarCode
Install-Package BarCode
또는 .NET CLI를 사용하여 설치할 수도 있습니다:
> dotnet add package IronBarCode
dotnet add package IronBarCode
BarCode 또는 QR 코드 읽기
IronBarcode를 사용하면 단 한 줄의 코드만으로 BARCODE를 읽을 수 있습니다.
using IronBarCode;BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");if (results != null){ foreach (BarcodeResult result in results) {Console.WriteLine(result.Text); }}
using IronBarCode;
BarcodeResults results = BarcodeReader.Read("QuickStart.jpg");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine(result.Text);
}
}
ImportsIronBarCodePrivate results AsBarcodeResults = BarcodeReader.Read("QuickStart.jpg")If results IsNot Nothing Then For Each result AsBarcodeResultIn resultsConsole.WriteLine(result.Text) Next resultEnd If
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
이 한 줄의 코드만으로 입력 문서에서 모든 유형의 BarCode를 뛰어난 성능으로 감지하고 스캔할 수 있습니다. 필요한 모든 작업이 한 번에 해결됩니다! 이 메서드는 JPEG, PNG, BMP와 같은 다양한 이미지 형식뿐만 아니라 PDF 및 GIF, TIFF와 같은 다중 프레임 형식도 지원합니다. 성능 향상을 위해 사용자 정의 가능한 구성 옵션을 제공합니다.
읽기 속도를 높이기 위해, 더 나은 성능을 위해 Speed 설정이 구성된 BarcodeReaderOptions 객체를 생성할 수 있습니다. 기본값은 Balanced이지만, Faster 옵션을 사용하여 특정 검사를 건너뛸 수 있습니다.
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);}
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);
}
ImportsIronBarCodePrivate myOptionsExample As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = False, .ExpectBarcodeTypes = BarcodeEncoding.QRCodeOrBarcodeEncoding.Code128, .CropArea = New System.Drawing.Rectangle(100, 200, 300, 400)}Private result AsBarcodeResults = BarcodeReader.Read("QuickStart.jpg", myOptionsExample)If result IsNot Nothing ThenConsole.WriteLine(result.First().Text)End If
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
또한 ScanMode을 OnlyBasicScan로 설정하여 가독성을 높일 수 있습니다.
using IronBarCode;BarcodeResults results = BarcodeReader.Read("MultipleBarcodes.png");// Loop through the resultsforeach (BarcodeResult result in results){ string value = result.Value; Bitmap img = result.BarcodeImage; BarcodeEncoding barcodeType = result.BarcodeType; byte[] binary = result.BinaryValue;Console.WriteLine(result.Value);}
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);
}
ImportsIronBarCodePrivate results AsBarcodeResults = BarcodeReader.Read("MultipleBarcodes.png")' Loop through the resultsFor Each result AsBarcodeResultIn results Dim value AsString = result.Value Dim img AsBitmap = result.BarcodeImage Dim barcodeType AsBarcodeEncoding = result.BarcodeType Dim binary() AsByte = result.BinaryValueConsole.WriteLine(result.Value)Next result
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
기타 구성 옵션으로는 스캔할 BarCode 형식을 지정하는 기능이 있으며, 이를 통해 불필요한 스캔을 줄여 처리 속도를 높일 수 있습니다.
using IronBarCode;BarcodeResults pagedResults = BarcodeReader.Read("MultipleBarcodes.pdf");// Loop through the resultsforeach (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});
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
});
ImportsIronBarCodePrivate pagedResults AsBarcodeResults = BarcodeReader.Read("MultipleBarcodes.pdf")' Loop through the resultsFor Each result AsBarcodeResultIn pagedResults Dim pageNumber AsInteger = result.PageNumber Dim value AsString = result.Value Dim img AsBitmap = result.BarcodeImage Dim barcodeType AsBarcodeEncoding = result.BarcodeType Dim binary() AsByte = result.BinaryValueConsole.WriteLine(result.Value)Next result' or from a multi-page TIFF scan with image correction:Dim multiFrameResults AsBarcodeResults = BarcodeReader.Read(inputImage:= "Multiframe.tiff", New BarcodeReaderOptionsWith { .Speed = ReadingSpeed.Detailed, .ExpectMultipleBarcodes = True, .ExpectBarcodeTypes = BarcodeEncoding.Code128, .Multithreaded = False, .RemoveFalsePositive = False, .ImageFilters = Nothing})
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
})
BarCode 작성
IronBarcode를 사용하여 BARCODE를 작성하려면 BarcodeWriter 클래스를 사용합니다.
using IronBarCode;GeneratedBarcode myBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeEncoding.Code128);myBarcode.SaveAsImage("myBarcode.png");
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")
BarCode 스타일링
IronBarcode는 BarCode의 시각적 표현을 조작할 수 있는 여러 가지 옵션을 제공합니다.
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 HTMLmyBarcode.SaveAsPng("myBarcode.png");
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");
ImportsIronBarCodePrivate myBarcode AsGeneratedBarcode = 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 HTMLmyBarcode.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")
BarCode를 HTML로 내보내기
IronBarcode는 BARCODE를 HTML 문서로 내보내거나 HTML 콘텐츠의 일부로 포함시킬 수 있습니다.
using IronBarCode;QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
using IronBarCode;
QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPdf("MyQR.pdf");
QR 코드의 경우, 오류 정정 등 QR 코드 특유의 기능을 위한 추가 구성을 제공하는 QRCodeWriter 클래스를 사용하십시오.
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");
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");
ImportsIronBarCodeImportsIronSoftware.DrawingPrivate qrCodeLogo As New QRCodeLogo("visual-studio-logo.png")Private myQRCodeWithLogo AsGeneratedBarcode = 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")
지원되는 바코드 형식
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, MSI 및 Plessey와 같은 기존의 1차원 BARCODE 형식.
왜 IronBarcode를 선택해야 할까요?
IronBarcode for .NET은 개발자가 .NET 환경에서 바코드를 읽고 쓸 수 있도록 친숙하고 사용하기 쉬운 API를 제공하며, 실제 사용 사례에서 정확성, 정밀도 및 속도를 최적화합니다.
예를 들어, BarcodeWriter 클래스는 UPCA 및 UPCE BARCODE의 '체크섬'을 자동으로 검증하고 수정하며, 숫자 형식 제약 조건을 처리합니다. IronBarcode는 개발자가 자신의 데이터에 가장 적합한 BarCode 형식을 선택할 수 있도록 지원합니다.
이 라이브러리는 자동 회전 및 이미지 노이즈 제거와 같은 이미지 전처리 기술을 통해 BarCode 인식 성공률을 극대화하는 등 강력한 성능을 자랑합니다.
향후 계획
IronBarcode를 최대한 활용하시려면, 이 문서 섹션에 포함된 튜토리얼을 읽어보시고 GitHub 페이지를 방문해 보시기 바랍니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.