Aspose.BarCode는 다양한 프로그래밍 환경에서 바코드 생성, 인식 및 조작을 단순화하는 강력한 라이브러리입니다.이 기사는 .NET 환경 내에서 1D Barcode Writer 구성 요소를 사용하는 데 중점을 둡니다. barcode를 필요로하는 응용 프로그램을 개발하거나이 기능을 사용하여 기존을 향상시키는지 여부,이 가이드는 개발 환경을 설정하고, barcodes를 만들고, 아스포스와 함께 일할 수있는 최상의 관행을 통해 당신을 안내합니다.
설치
바코드 생성에 몰입하기 전에 필요한 구성 요소가 .NET 프로젝트에 설치되어 있는지 확인하십시오. Aspose.BarCode를 통합하는 가장 쉬운 방법은 NuGet 패키지 매니저를 통해 도서관과 그것의 의존성을 무조건 설치할 수 있습니다.
- Open Visual Studio 또는 선호하는 IDE.
- Solution Explorer에서 프로젝트를 오른쪽으로 클릭하고 “NuGet 패키지 관리"를 선택합니다.
- 검색에 대하여
Aspose.BarCode
패키지 관리자에 들어가서 설치합니다.
대체로, Package Manager Console에서 다음 명령을 사용할 수 있습니다:
using System;
using System.IO;
using Aspose.BarCode;
namespace BarcodeExample
{
class Program
{
static void Main(string[] args)
{
// Set license for Aspose.BarCode
SetLicense();
// Generate a basic barcode and save it to the file system
GenerateBasicBarcode();
// Generate a custom barcode with specific settings and save it to the file system
GenerateCustomBarcode();
// Generate a barcode using BarcodeWriter approach and save it to the file system
GenerateUsingBarcodeWriter();
}
/// <summary>
/// Sets the license for Aspose.BarCode.
/// </summary>
public static void SetLicense()
{
try
{
// set metered public and private keys
Aspose.BarCode.Metered metered = new Aspose.BarCode.Metered();
// Access the setMeteredKey property and pass the public and private keys as parameters
metered.SetMeteredKey("*****", "*****");
Console.WriteLine("License set successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error setting license: {ex.Message}");
}
}
/// <summary>
/// Generates a basic barcode and saves it to the file system.
/// </summary>
public static void GenerateBasicBarcode()
{
// Create an instance of BarcodeGenerator and set its properties
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "Sample Text"))
{
// Save barcode image to file system
generator.Save("barcode.png", BarCodeImageFormat.Png);
Console.WriteLine("Basic barcode generated successfully.");
}
}
/// <summary>
/// Generates a custom barcode with specific settings and saves it to the file system.
/// </summary>
public static void GenerateCustomBarcode()
{
// Create an instance of BarcodeGenerator
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128))
{
// Set the barcode data
generator.CodeText = "Sample Text";
// Customize symbology settings
generator.Parameters.SymbologyParameters.Code128.AutoExcludeCodabar = true;
// Save barcode image to file system with custom format and size
generator.Save("custom_barcode.png", BarCodeImageFormat.Png, 400, 200);
Console.WriteLine("Custom barcode generated successfully.");
}
}
/// <summary>
/// Generates a barcode using the BarcodeWriter approach and saves it to the file system.
/// </summary>
public static void GenerateUsingBarcodeWriter()
{
// Create an instance of BarcodeGenerator
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "Sample Text"))
{
// Get barcode image as a stream
using (MemoryStream ms = new MemoryStream())
{
generator.Save(ms, BarCodeImageFormat.Png);
// Write the content of memory stream to file system
File.WriteAllBytes("barcode_writer.png", ms.ToArray());
Console.WriteLine("Barcode generated using BarcodeWriter approach successfully.");
}
}
}
}
}
설치되면 Aspose.BarCode의 BarcodeWriter 클래스를 사용하여 바코드를 생성하기 시작할 준비가 되어 있습니다.
라이센스를 만드는 방법
상업적 사용에 대한 완전한 기능과 지원을 보장하기 위해서는 라이센스 파일을 설정하는 것이 필수적입니다.이 단계는 도서관의 모든 기능을 차단하고 시험 버전과 함께 오는 모든 제한을 제거합니다.
- 귀하의 라이센스 키를 구입하거나 무료 테스트에 가입한 후 Aspose 웹 사이트에서 얻으십시오.
- 하나의 예를 만들기 위하여
Metered
클래스 및 그것을 호출SetMeteredKey()
방법, 이메일을 통해 수신 된 라이센스 키를 통과 :
바코드 생성
Aspose.BarCode를 사용하면 바코드를 생성하는 것은 간단하며 요구 사항에 따라 광범위하게 사용자 지정할 수 있습니다.
기본 바코드 세대
간단한 바코드를 만들려면, BarcodeGenerator
클래스에서 나온 Aspose.BarCode.Generation
이름의 공간
바코드를 사용자 정의
Aspose.BarCode는 바코드의 광범위한 사용자 정의를 허용합니다.당신은 상징 설정, 텍스트 옵션, 그리고 외관 속성을 조정할 수 있습니다.
Barcode 작가 클래스
그들의 BarcodeGenerator
클래스는 Aspose.BarCode에서 바 코드를 생성하는 주요 도구입니다.그러나 바코드 생산 및 렌더링에 대한 더 많은 통제가 필요한 경우, 사용을 고려하십시오. BarcodeWriter
클래스 입니다
모범 사례
.NET 애플리케이션에서 Aspose.BarCode를 사용할 때, 다음과 같은 최상의 관행을 고려하십시오.
Error Handling: 항상 허가를 설정하고 바코드를 생성할 때 오류 처리 메커니즘을 포함합니다.이것은 모든 문제가 일찍 캡처되고 신속하게 해결될 수 있도록 합니다.
성능 최적화: 높은 성능 시나리오를 위해, 전화 통화 수를 최소화함으로써 바코드 생성을 최상화하십시오.
Save()
또는 유사한 방법. 배치 처리를 고려하면 한 번에 여러 바코드를 생성해야합니다.보안: 귀하의 라이센스 파일이 안전하게 저장되고 공공 수단을 통해 접근할 수 없음을 보장합니다.이것은 Aspose.BarCode 도서관의 허가되지 않은 사용을 방지합니다..
결론
Aspose.BarCode는 .NET 응용 프로그램에서 바코드를 생성, 인식 및 조작하는 과정을 단순화합니다.이 가이드를 따르면 최소한의 노력으로 프로젝트에 배코드 기능을 효율적으로 통합 할 수 있습니다.더 자세한 정보 또는 고급 기능은 공식 문서를 참조하십시오. https://kb.aspose.net/barcode/1d-barcode-writer/.
Aspose.BarCode의 강력한 API와 광범위한 사용자 정의 옵션으로 특정 요구 사항을 충족시키는 고품질의 바코드를 만들 수 있습니다.