.NET에서 2D 바코드를 생성하는 방법
QR 코드와 데이터 매트릭스와 같은 2D 바코드는 제품 추적, 지불 시스템 및 프로모션 활동과 같은 컴팩트한 데이터 암호화를 요구하는 응용 프로그램에 필수적입니다. Aspose.BarCode 2D Writer for .NET, 개발자는 쉽게 2D 바코드를 프로그래밍적으로 생성하고, 그들의 모양을 사용자 정의하고, .NET 응용 프로그램에 무조건 통합 할 수 있습니다.
2D 바코드 세대의 혜택
컴팩트한 데이터 저장:- 큰 양의 데이터를 작은, 쉽게 스캔 가능한 형식으로 암호화합니다.
훌륭한 지원:- 2D 바코드, 특히 QR 코드는 대부분의 모바일 장치와 바코드 스캐너에 의해 지원됩니다.
높은 사용자 정의성:- 바코드 크기, 색상, 오류 수정 수준 및 더 많은 것을 사용자 정의하여 필요에 맞게합니다.
조건: Aspose.BarCode 설정
- Install the 넷 SDK on your system.
- 프로젝트에 Aspose.BarCode를 추가하십시오 :
dotnet add package Aspose.BarCode
- Obtain a metered license and configure it using
SetMeteredKey()
.
2D 바코드를 생성하는 단계별 가이드
단계 1: 측정된 라이센스를 설정합니다.
완전한 기능을 위해 Aspose.BarCode 라이센스를 설정합니다.
using Aspose.BarCode.Generation;
Metered license = new Metered();
license.SetMeteredKey("<your public key>", "<your private key>");
Console.WriteLine("Metered license configured successfully.");
단계 2: BarcodeGenerator 클래스의 인스턴스를 만듭니다.
바코드 생성에 대한 입구점인 BarcodeGenerator 클래스를 시작하십시오.
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "123456789");
Console.WriteLine("BarcodeGenerator instance created.");
단계 3 : 바코드 유형을 지정합니다.
생성하려는 2D 바코드의 유형을 정의하십시오 (예 : QR 코드, 데이터 매트릭스).
generator.EncodeType = EncodeTypes.QR; // Specify QR Code generation
Console.WriteLine("QR Code selected for generation.");
단계 4 : 바코드 설정 사용자 정의
선택적으로 바코드 크기, 오류 수정 수준 및 기타 설정을 사용자 정의할 수 있습니다.
generator.Parameters.Barcode.XDimension.Pixels = 5; // Adjust pixel size
generator.Parameters.Barcode.BarHeight.Pixels = 125; // Set barcode height
generator.Parameters.Barcode.ErrorLevel = 30; // Set error correction level
Console.WriteLine("Barcode settings customized.");
5단계: 바코드 이미지를 생성
바코드 이미지를 GenerateBarCodeImage() 방법을 사용하여 생성하거나 직접 저장합니다.
generator.Save("barcode_image.png", BarCodeImageFormat.Png); // Save as PNG
Console.WriteLine("Barcode image saved successfully.");
단계 6 : 테스트 바코드 세대
생성된 바코드를 모바일 장치 또는 바코드 스캐너로 스캔하여 테스트합니다.
일반적인 문제와 고정
바코드 크기 문제:- Adjust the
XDimension
andBarHeight
to ensure barcodes are scannable at the desired size.색상 및 형식:- 바코드 색상과 배경을 변경하여 브랜드 요구 사항에 맞게 합니다.
지원되지 않은 형식:- 출력 파일 형식이 스캔을 위해 사용하는 장치 또는 소프트웨어에 의해 지원되는지 확인합니다.
관련 자원 :