바코드 생성 사용 사례
Aspose.BarCode Python용 FOSS는 일곱 가지 심볼을 지원합니다: Code 128, Code 39, EAN-13, EAN-8, QR Code, UPC-A, 및 UPC-E. 이 문서에서는 각각에 대한 실용적인 시나리오를 보여줍니다.
재고 관리
Code 128는 특수 문자를 포함한 영숫자 데이터를 인코딩하기 때문에 재고 라벨에 일반적으로 선택됩니다. 각 항목은 라벨에 인쇄된 고유 식별자를 부여받습니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# Generate a Code 128 barcode for an inventory SKU
barcode = service.generate("code128", "SKU-2026-A1234")
svg_content = barcode.to_svg(RenderOptions(scale=2.0, show_text=True))
with open("inventory_label.svg", "w") as f:
f.write(svg_content)배송 라벨
Code 128와 Code 39은 배송 및 물류에서 널리 사용됩니다. Code 39는 더 간단하며(대문자, 숫자 및 몇몇 기호) 오래된 시스템에서 사용됩니다. Code 128는 더 넓은 문자 집합을 지원합니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# Code 39 for a tracking number
barcode = service.generate("code39", "SHIP2026071234")
png_bytes = barcode.to_png(RenderOptions(dpi=300, show_text=True))
with open("shipping_label.png", "wb") as f:
f.write(png_bytes)소매 판매 시점
EAN-13와 UPC-A은 소매 제품에 표준 심볼입니다. EAN-13는 국제적으로 사용되며; UPC-A는 12자리 북미 변형입니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# EAN-13 for a product barcode (12 digits; check digit auto-computed)
barcode = service.generate("ean13", "590123412345")
svg_content = barcode.to_svg(RenderOptions(scale=3.0, show_text=True))
# UPC-A for a North American product
barcode_upc = service.generate("upca", "01234567890")
svg_upc = barcode_upc.to_svg(RenderOptions(scale=3.0, show_text=True))문서 추적
Code 128은 각 문서에 고유한 영숫자 식별자가 부여되는 문서 추적 시스템에 적합합니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# Generate barcodes for a batch of documents
doc_ids = ["DOC-2026-001", "DOC-2026-002", "DOC-2026-003"]
for doc_id in doc_ids:
barcode = service.generate("code128", doc_id)
svg = barcode.to_svg(RenderOptions(scale=1.5, show_text=True))
filename = f"{doc_id.lower().replace('-', '_')}.svg"
with open(filename, "w") as f:
f.write(svg)QR 코드를 사용한 URL 및 연락처 인코딩
QR Code은 URL, 연락처 정보, Wi-Fi 자격 증명을 포함한 임의의 텍스트 데이터를 인코딩합니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# QR Code for a URL
barcode = service.generate("qrcode", "https://products.aspose.org/barcode/")
png_bytes = barcode.to_png(RenderOptions(scale=4.0))
with open("url_qrcode.png", "wb") as f:
f.write(png_bytes)EAN-8와 UPC-E을 사용한 소형 아이템 라벨
EAN-8와 UPC-E은 공간이 제한된 아이템을 위한 컴팩트한 심볼입니다. EAN-8는 7자리 또는 8자리 숫자를 사용합니다; UPC-E은 UPC-A의 압축 버전입니다.
from aspose_barcode_foss import BarcodeService, RenderOptions
service = BarcodeService()
# EAN-8 for a small product (7 digits; check digit auto-computed)
barcode = service.generate("ean8", "1234567")
svg = barcode.to_svg(RenderOptions(scale=2.0, show_text=True))자주 묻는 질문
어떤 심볼을 선택해야 할까요?
- 알파벳 및 숫자 데이터 (모든 문자): Code 128
- 대문자 전용, 레거시 시스템: Code 39
- 소매 제품 (국제): EAN-13 또는 EAN-8
- 소매 제품 (북미): UPC-A 또는 UPC-E
- URL, 텍스트, 바이너리 데이터: QR Code
바코드를 일괄적으로 생성할 수 있나요?
예. BarcodeService 인스턴스를 한 번 생성하고 루프에서 generate()을 호출하십시오. 각 호출은 Barcode 객체를 반환하며, 이를 to_svg() 또는 to_png()로 독립적으로 렌더링할 수 있습니다.
사용 가능한 출력 형식은 무엇인가요?
이 라이브러리는 to_svg()를 통해 SVG로, to_png()를 통해 PNG로 렌더링합니다. PDF 렌더링은 아직 구현되지 않았습니다.