IRONSOFTWAREHOME

IronBarcode를 사용하여 C#의 .NET에서 바코드를 커스터마이징하고 스타일링하기

Hairil Hasyimi Bin Omar
Hairil Hasyimi Bin Omar
Updated: 2026년 6월 29일

IronBarcode는 개발자가 C#에서 바코드 색상을 변경하고, 크기 조정을 하고, 주석을 추가하여 ChangeBarCodeColor()ResizeTo()와 같은 간단한 메서드를 통해 완전히 스타일링을 제어할 수 있도록 합니다.

수년 동안 바코드 사용은 점점 인기를 끌며, 데이터, 아이디, 웹페이지 URL을 저장하는 등 다양한 애플리케이션에서 사용됩니다. 일부 애플리케이션에서는 제품에 바코드가 눈에 띄게 되어, 스타일링 옵션에 대한 수요가 증가했습니다. 따라서 일부 바코드 유형은 PDF417, Aztec, IntelligentMail, MaxiCode, DataMatrix, ResizeTo 등과 같은 고유한 외관을 개발했습니다. 지원되는 포맷의 포괄적인 목록은 지원 바코드 포맷 문서를 참조하세요.

또한 IronBarcode는 사용자에게 바코드 색상, 바코드 크기 조정, 배경 색상과 같은 세부 사항을 포함한 추가 스타일링 옵션을 제공합니다. 이것은 우리의 오픈 소스 라이브러리, IronDrawing의 도움으로 가능해졌습니다. 이들 스타일링 기능들은 IronBarcode의 포괄적인 바코드 생성 기능에 구축된 것입니다.

빠른 시작: 바코드 색상 및 배경 사용자 정의

여기 IronBarcode를 사용하여 바코드의 막대와 배경에 사용자가 정의한 색상을 빠르게 적용하는 방법을 보여주는 간단한 예제가 있습니다. 체인 호출 하나만으로 스타일링된 바코드를 생성하는 것이 얼마나 쉬운지를 알 수 있습니다. 더 고급 예제는 우리의 C# 바코드 이미지 생성기 튜토리얼을 참조하세요.

  1. 1Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. 2다음 코드 조각을 복사하여 실행하세요.

    IronBarCode.BarcodeWriter.CreateBarcode("HELLO123", IronBarCode.BarcodeEncoding.Code128)
        .ChangeBarCodeColor(IronSoftware.Drawing.Color.Blue)
        .ChangeBackgroundColor(IronSoftware.Drawing.Color.White)
        .SaveAsImage("styled.png");
    C#
  3. 3실제 운영 환경에서 테스트할 수 있도록 배포하세요.

    무료 체험판으로 오늘 프로젝트에서 IronBarcode 사용 시작하기
    arrow pointer

바코드 크기 조정을 어떻게 하나요?

ResizeTo 메서드는 언제 사용해야 하나요?

바코드 크기 조정은 IronBarcode를 통해 사용자가 달성할 수 있는 커스터마이징의 한 측면입니다. 이 기능을 사용하려면 ResizeTo 메서드를 호출하고 바코드의 새로운 너비와 높이 측정을 픽셀(px)로 입력하십시오. 이 작업은 바코드의 손실 없는 재렌더링을 트리거합니다. 이 메서드는 바코드의 치수를 조정하면서 품질을 유지하므로, 특정 레이아웃이나 인쇄 크기에 바코드를 맞춰야 하는 상황에 적합합니다.

참고해 주세요: 바코드를 읽을 수 없을 정도로 작은 값은 무시됩니다.
using IronBarCode;

public class BarcodeResizer
{
    public static void ResizeBarcode(string barcodeText, int newWidth, int newHeight)
    {
        // Generate a barcode
        BarcodeWriter.CreateBarcode(barcodeText, BarcodeEncoding.Code128)
                     // Resize the barcode
                     .ResizeTo(newWidth, newHeight)
                     // Save the resized barcode
                     .SaveAsImage("resized_barcode.png");
    }
    
    // Example usage with different size requirements
    public static void ResizeForDifferentFormats()
    {
        var barcode = BarcodeWriter.CreateBarcode("PRODUCT-12345", BarcodeEncoding.Code128);
        
        // Resize for product label
        barcode.ResizeTo(200, 50).SaveAsImage("product_label.png");
        
        // Resize for shipping label
        barcode.ResizeTo(300, 75).SaveAsImage("shipping_label.png");
        
        // Resize for inventory tag
        barcode.ResizeTo(150, 40).SaveAsImage("inventory_tag.png");
    }
}

ResizeTo 메서드는 GeneratedBarcode ResizeToMil 객체에서 호출될 수 있습니다. 다양한 출력 형식 작업 시, PDF로 바코드 만들기 가이드를 참조하실 수도 있습니다. 아래는 위 코드 스니펫 실행으로 생성된 바코드 이미지입니다.

크기 조정 작업 전 표준 크기의 원본 바코드
크기 수정 후 명확한 흑백 세로 막대를 보여주는 크기가 조정된 바코드

1D 바코드에 ResizeToMil 메서드를 사용하는 이유는 무엇인가요?

IronBarcode에서 제공하는 확장 기능 중 하나는 ResizeToMil 메서드입니다. ResizeTo 메서드와 달리, 이 메서드는 다음 구성 요소를 조정합니다:

  • 바코드 요소: 가장 좁은 바코드 요소의 폭은 천분의 인치(mil)로 측정됩니다.
  • 높이: 바코드의 높이로, 인치로 측정됩니다(기본값은 1인치).
  • 해상도: 인치당 도트 수(DPI)(기본값은 96 DPI).

이 메서드는 특히 1D 바코드에 적합하며 정확한 측정이 중요한 산업 응용 프로그램에서 일반적으로 사용됩니다. mil 측정 시스템은 다양한 스캐너 및 인쇄 조건에서 일관된 바코드 가독성을 보장하는 산업 표준입니다.

using IronBarCode;

public class BarcodeResizer
{
    public static void ResizeBarcodeToMil(string barcodeText, int elementWidthMil, int heightInches, int dpi = 96)
    {
        // Generate a barcode
        BarcodeWriter.CreateBarcode(barcodeText, BarcodeEncoding.Code128)
                     // Resize the barcode to mil
                     .ResizeToMil(elementWidthMil, heightInches, dpi)
                     // Save the resized barcode
                     .SaveAsImage("resized_barcode_mil.png");
    }
    
    // Example for different industrial standards
    public static void CreateIndustrialBarcodes()
    {
        // Standard retail barcode (10 mil width, 1 inch height)
        BarcodeWriter.CreateBarcode("RETAIL-001", BarcodeEncoding.Code128)
                     .ResizeToMil(10, 1, 300)
                     .SaveAsImage("retail_barcode.png");
        
        // High-density warehouse barcode (5 mil width, 0.5 inch height)
        BarcodeWriter.CreateBarcode("WAREHOUSE-002", BarcodeEncoding.Code128)
                     .ResizeToMil(5, 0.5f, 600)
                     .SaveAsImage("warehouse_barcode.png");
        
        // Large shipping barcode (15 mil width, 2 inch height)
        BarcodeWriter.CreateBarcode("SHIP-003", BarcodeEncoding.Code128)
                     .ResizeToMil(15, 2, 200)
                     .SaveAsImage("shipping_barcode.png");
    }
}

GeneratedBarcode 객체에서 이 메서드를 호출할 수도 있습니다. 정확한 바코드 치수를 설정에 대한 추가 정보는 바코드 여백 설정 가이드를 참조하십시오. 아래 이미지에서, ResizeToMil 메서드를 적용하여 바코드의 가장자리 흰 공간이 제거되고, 가장 좁은 요소와 바코드의 높이가 메서드에 제공된 매개변수 값에 따라 조정되는 효과를 볼 수 있습니다.

ResizeToMil 메서드가 적용되기 전 표준 크기의 원본 바코드
ResizeToMil 메서드 적용 후 세로 흑백 막대로 결과를 보여주는 선형 바코드

바코드와 배경 색상을 어떻게 변경하나요?

바코드 스타일링에서 가장 많이 요구되는 기능 중 하나는 바코드와 배경 색상을 모두 변경할 수 있는 기능입니다. IronDrawing 덕분에 IronBarcode는 이 기능을 제공합니다. ChangeBarCodeColorChangeBackgroundColor 방법을 사용하여 GeneratedBarcode 객체에서 바코드와 배경의 색상을 변경할 수 있습니다. 이 기능은 특히 브랜딩 목적이나 특별 이벤트 또는 제품 라인을 위한 테마 바코드 생성 시 유용합니다.

using IronBarCode;
using IronSoftware.Drawing; // Required for color manipulation

public class BarcodeColorChanger
{
    public static void ChangeBarcodeColors(string barcodeText, Color barcodeColor, Color backgroundColor)
    {
        // Generate a barcode
        var barcode = BarcodeWriter.CreateBarcode(barcodeText, BarcodeEncoding.Code128);

        // Change the barcode color
        barcode.ChangeBarCodeColor(barcodeColor);

        // Change the background color
        barcode.ChangeBackgroundColor(backgroundColor);

        // Save the colored barcode
        barcode.SaveAsImage("colored_barcode.png");
    }
    
    // Example: Create branded barcodes with company colors
    public static void CreateBrandedBarcodes()
    {
        // Company brand colors example
        var barcode = BarcodeWriter.CreateBarcode("BRAND-2024", BarcodeEncoding.Code128);
        
        // Apply brand colors
        barcode.ChangeBarCodeColor(Color.FromHex("#1E3A8A")) // Company blue
               .ChangeBackgroundColor(Color.FromHex("#F3F4F6")) // Light gray background
               .SaveAsImage("branded_barcode.png");
        
        // Create seasonal variation
        var seasonalBarcode = BarcodeWriter.CreateBarcode("HOLIDAY-2024", BarcodeEncoding.Code128);
        seasonalBarcode.ChangeBarCodeColor(Color.DarkGreen)
                       .ChangeBackgroundColor(Color.LightYellow)
                       .SaveAsImage("seasonal_barcode.png");
    }
}

색상이 사용된 바코드 작업 시, 가독성을 위해 바코드와 배경 색상 간의 충분한 대조를 유지하는 것이 중요합니다. QR 코드에 특화된 더 많은 스타일링 옵션은 QR 코드 스타일 커스터마이징 튜토리얼을 참고하세요.

록색 배경과 황갈색 전경색을 사용한 QR 코드, 바코드 색상 사용자 정의를 보여줌

바코드에 주석을 어떻게 추가하나요?

IronBarcode는 바코드 주석을 추가하고 스타일링하는 옵션도 제공합니다. 주석 스타일링은 IronDrawing의 기능을 통해 지원되며, 주석 색상 및 글꼴 편집을 포함합니다. 주석은 기계 판독 가능한 바코드 옆에 인간이 읽을 수 있는 정보를 제공하여 재고 관리, 제품 라벨링 및 배송 애플리케이션에서 필수적입니다.

using IronBarCode;
using IronSoftware.Drawing; // Required for font and color manipulation

public class BarcodeAnnotator
{
    public static void AnnotateBarcode(string barcodeText, string annotationText, Font annotationFont, Color annotationColor, float annotationSpacing)
    {
        // Generate a barcode
        var barcode = BarcodeWriter.CreateBarcode(barcodeText, BarcodeEncoding.Code128);

        // Add annotation above the barcode
        barcode.AddAnnotationTextAboveBarcode(annotationText, annotationFont, annotationColor, annotationSpacing);

        // Add barcode value text below the barcode
        barcode.AddBarcodeValueTextBelowBarcode(annotationFont, annotationColor, annotationSpacing);

        // Save the annotated barcode
        barcode.SaveAsImage("annotated_barcode.png");
    }
    
    // Example: Create product label with annotations
    public static void CreateProductLabel()
    {
        var productCode = "PRD-12345-XL";
        var barcode = BarcodeWriter.CreateBarcode(productCode, BarcodeEncoding.Code128);
        
        // Define fonts for different purposes
        var titleFont = new Font("Arial", FontStyle.Bold, 14);
        var valueFont = new Font("Arial", FontStyle.Regular, 12);
        
        // Add product name above
        barcode.AddAnnotationTextAboveBarcode("Premium Widget XL", titleFont, Color.Black, 5);
        
        // Add product code below
        barcode.AddBarcodeValueTextBelowBarcode(valueFont, Color.DarkGray, 3);
        
        // Apply additional styling
        barcode.ResizeTo(250, 80)
               .SaveAsImage("product_label_annotated.png");
    }
}
IronBarcode에 의해 생성된 철 파란색과 베이지 색상 QR 코드에는 ironsoftware.com URL이 포함되어 있습니다.

이전 코드 스니펫의 확장으로, 우리는 바코드 위와 아래에 있는 주석에 사용할 두 개의 새로운 IronSoftware.Drawing.Font 객체를 인스턴스화합니다. 글꼴 가족만 있으면 글꼴을 인스턴스화할 수 있으며, 추가로 사이즈나 스타일과 같은 속성을 지정하여 더 많은 제어를 할 수 있습니다.

  • AddAnnotationTextAboveBarcode: 바코드 위에 사용자 정의 주석 텍스트를 추가합니다.
  • AddBarcodeValueTextBelowBarcode: 바코드 아래에 바코드 값을 추가합니다.

이 두 메서드는 동일한 매개변수를 수용합니다: IronSoftware.Drawing.Font 객체, IronSoftware.Drawing.Color 객체 및 바코드와 텍스트 사이의 간격. AddAnnotationTextAboveBarcode 메서드는 주석 텍스트를 추가하므로, 문자열을 필요로 합니다. 이 메서드는 바코드 위에 사용자 정의 텍스트를 추가합니다.

IronBarcode는 바코드를 스타일링하기 위한 다양한 사용자 정의 옵션을 제공합니다. 주석에 유니코드 지원이 필요한 애플리케이션의 경우, 우리의 유니코드 바코드 작성 안내서를 확인하세요. QR 코드 사용자 정의에 대해 더 알고 싶다면 'QR 코드 스타일 사용자 정의 및 로고 추가 방법'을 참조하세요. 다양한 포맷으로 스타일링된 바코드를 내보내려면, 우리의 HTML로 바코드 생성 튜토리얼을 탐색하세요.

자주 묻는 질문

C#에서 바코드 색상을 어떻게 변경할 수 있나요?

IronBarcode는 바코드 색상을 쉽게 사용자 지정할 수 있는 ChangeBarCodeColor() 메서드를 제공합니다. 바코드를 생성한 후 이 메서드를 체이닝하여 IronSoftware.Drawing.Color 팔레트에서 원하는 색상을 적용하면 바코드의 시각적 모양을 완벽하게 제어할 수 있습니다.

바코드의 품질 저하 없이 크기를 조정하려면 어떤 방법을 사용해야 할까요?

IronBarcode의 ResizeTo() 메서드를 사용하여 품질 손실 없이 바코드 크기를 조정할 수 있습니다. 이 메서드는 지정된 픽셀 너비와 높이로 바코드를 손실 없이 다시 렌더링하여, 특정 레이아웃이나 인쇄 요구 사항에 맞게 크기를 조정하면서도 선명도를 유지합니다.

바코드의 배경색을 사용자 지정할 수 있나요?

예, IronBarcode는 ChangeBackgroundColor() 메서드를 사용하여 바코드 배경을 사용자 지정할 수 있도록 지원합니다. 이 기능을 통해 IronSoftware.Drawing.Color 팔레트를 사용하여 원하는 배경색을 설정할 수 있으므로 디자인 요구 사항에 완벽하게 통합할 수 있습니다.

어떤 바코드 형식이 고유한 스타일링 옵션을 지원합니까?

IronBarcode는 PDF417, Aztec, IntelligentMail, MaxiCode, DataMatrix 등 다양한 바코드 형식을 지원하며, 각 형식은 고유한 시각적 특징을 가지고 있습니다. IronBarcode의 스타일링 기능을 통해 다양한 사용자 정의 옵션도 제공합니다.

바코드에 주석을 추가하려면 어떻게 해야 하나요?

IronBarcode를 사용하면 바코드 위아래에 주석을 추가하여 가독성을 높이고 추가적인 맥락 정보를 제공할 수 있습니다. 이 기능은 바코드 옆에 사람이 읽을 수 있는 텍스트, 제품 코드 또는 기타 식별 정보를 추가하는 데 특히 유용합니다.

ResizeTo 메서드와 ResizeToMil 메서드의 차이점은 무엇인가요?

IronBarcode는 두 가지 크기 조정 방법을 제공합니다. 하나는 픽셀 단위로 크기 조정을 하고 손실 없이 다시 렌더링하는 `ResizeTo()`이고, 다른 하나는 밀(mil) 단위로 바코드 요소의 크기를 조정하는 `ResizeToMil()`입니다. 두 방법 모두 서로 다른 측정 요구 사항을 충족하면서 품질을 유지합니다.

How does IronBarcode maintain barcode quality during resizing?

IronBarcode maintains barcode quality during resizing by triggering a lossless re-rendering process when using methods like ResizeTo(). This ensures the barcode remains high quality and readable after being resized.

Is there support for advanced color manipulation in IronBarcode?

Advanced color manipulation in IronBarcode is supported through integration with the IronDrawing library. This allows for precise control over barcode and background colors, which can be tailored to meet branding or thematic requirements.

How can IronBarcode assist with creating product labels?

IronBarcode can assist in creating product labels by allowing the addition of annotations, customizing barcode dimensions, and altering colors to match product branding. Methods like AddAnnotationTextAboveBarcode help include human-readable information on labels.

What font options are available for barcode annotations in IronBarcode?

For barcode annotations, IronBarcode provides options through IronSoftware.Drawing.Font, allowing you to customize font family, size, style, and color. This adds flexibility for styling annotations aligned with specific product or branding needs.

시작할 준비 되셨나요?

Nuget Downloads 2,422,100버전:2026.9방금 출시

무료로 받기

30일 체험 키를 즉시 받으세요.

bullet_checked신용카드나 계정 생성은 필요하지 않습니다.
bullet_test워터마크 없이
프로덕션에서 테스트
bullet_calendar30일 완전한
기능의 제품
bullet_support체험 기간 동안
24/5 기술 지원
지금 바로 30일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.
PDF용 C# NuGet 라이브러리
NuGet을 사용하여 설치하세요

버전: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 솔루션 탐색기에서 참조를 마우스 오른쪽 버튼으로 클릭하고 NuGet 패키지 관리를 선택합니다.
  2. 찾아보기를 선택하고 "IronBarCode"를 검색하세요.
  3. 패키지를 선택하고 설치하세요
C# PDF DLL
DLL 다운로드

버전: 2026.9

  1. IronBarCode 파일을 다운로드하고 솔루션 디렉터리 내의 ~/Libs와 같은 위치에 압축을 해제하세요.
  2. Visual Studio 솔루션 탐색기에서 참조를 마우스 오른쪽 버튼으로 클릭합니다. 찾아보기를 선택하고 "IronBarCode.dll"을 선택합니다.

라이선스 가격은 749달러 부터 시작합니다.

Key in blue circle

무료 30일 체험 키를 즉시 받으세요.

Your trial license will be sent to your email address

제한 없음. 100% 무제한 이용. 신용카드 불필요.

bullet_checked신용카드나 계정 생성은 필요하지 않습니다.제한 없음. 100% 무제한 이용. 신용카드 불필요.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
무료 라이브 데모를 예약하세요
Booking Badge

전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.

Iron Software의 고객 로고
부담 없는 무료 상담을 받아보세요
아래 양식을 작성하시거나 sales@ironsoftware.com으로 이메일을 보내주세요.
고객님의 정보는 항상 비밀로 유지됩니다.
전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.
Iron Software의 고객 로고
지금 바로 30일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.