이 기사에서는 Java를 사용하여 바코드를 생성하는 방법과 같은 Java API를 사용하여 바코드를 인식하는 방법에 대한 세부 사항을 논의할 것입니다. 우리는 이미 바코드가 컴퓨터가 제품을 더 빠르고 정확하게 추적하고 계산할 수 있도록 모든 상품에 붙어 있는 인코딩 태그 또는 라벨이라는 것을 알고 있습니다. 마찬가지로, 바코드는 쉽게 인쇄되고 즉시 항목에 추가되어 전체 인벤토리를 즉시 라벨링하고 추적할 수 있습니다. 게다가, 바코드는 자동 제품 식별, 매우 빠른 인식, 그리고 매우 낮은 오류율로 데이터를 구현하는 기능을 제공합니다. 이러한 접근 방식은 비용 효율적이며 고용주가 간접 비용을 줄이고 교육 시간과 노동을 줄이는 데 도움을 줄 수 있습니다.

바코드 생성 API

Aspose.BarCode Cloud는 고객이 프로그래밍에서 바코드 생성 및 조작 기능을 구현할 수 있도록 하는 REST API입니다.

API는 인기 있는 래스터 이미지 형식을 구문 분석할 수 있습니다. 추가 세부정보는 Supported File Formats를 방문하세요.

지정된 치수로 바코드 생성

API를 테스트하는 가장 빠르고 쉬운 방법은 API 참조 섹션을 사용하는 것입니다. GetBarcodeGenerate 메서드는 BarCode 이미지를 생성하는 데 사용되며, 귀하의 요구 사항에 따라 BarCode를 생성하기 위한 다양한 옵션을 제공합니다. 또한 특정 매개변수와 관련된 세부 사항은 API 참조 페이지에 잘 설명되어 있습니다. BarCode를 생성할 때는 다음 유형 중 하나를 지정할 수 있습니다.

  • Codabar
  • Code11
  • Code39Standard
  • Code39Extended
  • Code93Standard
  • Code93Extended
  • Code128
  • GS1Code128
  • EAN8
  • EAN13
  • EAN14
  • SCC14
  • SSCC18
  • UPCA
  • UPCE
  • ISBN
  • ISSN
  • ISMN
  • Standard2of5
  • Interleaved2of5
  • Matrix2of5
  • ItalianPost25
  • IATA2of5
  • ITF14
  • ITF6
  • MSI
  • VIN
  • DeutschePostIdentcode
  • DeutschePostLeitcode
  • OPC
  • PZN
  • Code16K
  • Pharmacode
  • DataMatrix
  • QR
  • Aztec
  • Pdf417
  • MacroPdf417
  • AustraliaPost
  • Postnet
  • 행성
  • OneCode
  • RM4SCC
  • DatabarOmniDirectional
  • DatabarTruncated
  • DatabarLimited
  • DatabarExpanded
  • SingaporePost
  • GS1DataMatrix
  • AustralianPosteParcel
  • SwissPostParcel
  • PatchCode
  • DatabarExpandedStacked
  • DatabarStacked
  • DatabarStackedOmniDirectional
  • MicroPdf417
  • GS1QR
  • MaxiCode
  • Code32
  • DataLogic2of5
  • DotCode
  • DutchKIX
  • UpcaGs1Code128Coupon
  • UpcaGs1DatabarCoupon
  • CodablockF
  • GS1CodablockF

cURL 명령어

curl -X GET "https://api.aspose.cloud/v3.0/barcode/generate?Type=Codabar&Text=Hello%20World&TwoDDisplayText=QR&TextLocation=Above&TextAlignment=Center&TextColor=Blue&FontSizeMode=Auto&Resolution=96&TextSpace=2&Units=Point&SizeMode=Nearest&BarHeight=50&ImageHeight=200&ImageWidth=200&RotationAngle=0&BackColor=White&BorderDashStyle=Solid&SupplementData=EAN8&format=PNG" -H  "accept: image/png" -H  "authorization: Bearer <JWT Token>"

Request URL

https://api.aspose.cloud/v3.0/barcode/generate?Type=Codabar&Text=Hello%20World&TwoDDisplayText=QR&TextLocation=Above&TextAlignment=Center&TextColor=Blue&FontSizeMode=Auto&Resolution=96&TextSpace=2&Units=Point&SizeMode=Nearest&BarHeight=50&ImageHeight=200&ImageWidth=200&RotationAngle=0&BackColor=White&BorderDashStyle=Solid&SupplementData=EAN8&format=PNG

Java

다음 코드 스니펫은 바코드 이미지를 생성하고 클라우드 스토리지에 저장하는 데 사용할 수 있습니다.

// 완전한 예제와 데이터 파일은 https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-java/ 에서 확인하세요.

String name = "putBarcodeGenerateFile.png";
String type = EncodeBarcodeType.QR.getValue();
String text = "Put Barcode Generate File";
Double dimensionX = 200.0;

String twoDDisplayText = null;
String textLocation = null;
String textAlignment = null;
String textColor = null;
String fontSizeMode = null;
Double resolution = null;
Double textSpace = null;
String units = null;
String sizeMode = null;
Double barHeight = null;
Double imageHeight = null;
Double imageWidth = null;
Double rotationAngle = null;
String backColor = null;
String barColor = null;
String borderColor = null;
Double borderWidth = null;
String borderDashStyle = null;
Boolean borderVisible = null;
String enableChecksum = null;
Boolean enableEscape = null;
Boolean filledBars = null;
Boolean alwaysShowChecksum = null;
Double wideNarrowRatio = null;
Boolean validateText = null;
String supplementData = null;
Double supplementSpace = null;
String format = null;

String storage = "Storage";
String folder = "Temp/"

ResultImageInfo response =
		api.putBarcodeGenerateFile(
				name,type,text,twoDDisplayText,textLocation,textAlignment,textColor,fontSizeMode,
				resolution,null,null,dimensionX,textSpace,units,sizeMode,barHeight,
				imageHeight,imageWidth,rotationAngle,backColor,barColor,borderColor,borderWidth,
				borderDashStyle,borderVisible,enableChecksum,enableEscape,filledBars,
				alwaysShowChecksum,wideNarrowRatio,validateText,supplementData,
				supplementSpace,storage,folder,format);

assertTrue(response.getFileSize() > 0);
assertTrue(response.getImageWidth() > 0);
assertTrue(response.getImageHeight() > 0);
바코드 이미지

Image 1:- Java API로 생성된 바코드 미리보기

래스터 이미지에서 바코드 인식

API는 또한 래스터 이미지 파일에서 바코드를 인식하는 기능을 제공합니다. 이미지 파일은 PNG, JPEG, BMP, GIF, TIFF 또는 EXIF 형식일 수 있습니다. API의 GetBarcodeRecognize 메서드는 이 요구 사항을 충족하는 데 도움이 됩니다. 이름 필드는 필수이며 다른 선택적 필드는 바코드 유형 정보, 체크섬 검증, 인코딩, 인식 품질 및 속도를 구성할 수 있는 프리셋 등을 지정할 수 있기 때문에 더 나은 인식 작업을 수행할 수 있는 기능을 제공합니다.

cURL

curl -X GET "https://api.aspose.cloud/v3.0/barcode/index.png/recognize?Type=all&ChecksumValidation=Off&DetectEncoding=false&Preset=HighQuality" -H  "accept: application/json" -H  "authorization: Bearer <JWT Token>"

Request URL

https://api.aspose.cloud/v3.0/barcode/index.png/recognize?Type=all&ChecksumValidation=Off&DetectEncoding=false&Preset=HighQuality

외부 이미지 URL에서 바코드 읽기

// 전체 예제 및 데이터 파일은 https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-java/ 를 방문해 주십시오.

String type = null;
String checksumValidation = ChecksumValidation.OFF.toString();
Boolean detectEncoding = null;
String preset = PresetType.HIGHPERFORMANCE.toString();
String url = "http://www.barcoding.com/images/Barcodes/pdf417.gif";

Integer rectX = null;
Integer rectY = null;
Integer rectWidth = null;
Integer rectHeight = null;
Boolean stripFNC = null;
Integer timeout = null;
Integer medianSmoothingWindowSize = null;
Boolean allowMedianSmoothing = null;
Boolean allowComplexBackground = null;
Boolean allowDatamatrixIndustrialBarcodes = null;
Boolean allowDecreasedImage = null;
Boolean allowDetectScanGap = null;
Boolean allowIncorrectBarcodes = null;
Boolean allowInvertImage = null;
Boolean allowMicroWhiteSpotsRemoving = null;
Boolean allowOneDFastBarcodesDetector = null;
Boolean allowOneDWipedBarsRestoration = null;
Boolean allowQRMicroQrRestoration = null;
Boolean allowRegularImage = null;
Boolean allowSaltAndPepperFiltering = null;
Boolean allowWhiteSpotsRemoving = null;
Double regionLikelihoodThresholdPercent = null;
List<Integer> scanWindowSizes = null;
Double similarity = null;
Boolean skipDiagonalSearch = null;
String australianPostEncodingTable = null;
String rectangleRegion = null;
File image = null;

BarcodeResponseList response = 
   	 api.postBarcodeRecognizeFromUrlOrContent( 
      		type,checksumValidation,detectEncoding,preset,rectX,rectY,rectWidth,rectHeight,
      		stripFNC,timeout,medianSmoothingWindowSize,allowMedianSmoothing,allowComplexBackground,
      		allowDatamatrixIndustrialBarcodes,allowDecreasedImage,allowDetectScanGap,
		allowIncorrectBarcodes,allowInvertImage,allowMicroWhiteSpotsRemoving,allowOneDFastBarcodesDetector,
      		allowOneDWipedBarsRestoration,allowQRMicroQrRestoration,allowRegularImage,allowSaltAndPepperFiltering,
      		allowWhiteSpotsRemoving,regionLikelihoodThresholdPercent,scanWindowSizes,similarity,skipDiagonalSearch,
      		australianPostEncodingTable,rectangleRegion,url,image);

assertNotNull(response);
assertFalse(response.getBarcodes().isEmpty());

BarcodeResponse barcode = response.getBarcodes().get(0);
assertEquals(DecodeBarcodeType.CODE11.getValue(), barcode.getType());
assertEquals("1234567812", barcode.getBarcodeValue());

결론

이 기사에서는 Java를 사용하여 BarCode를 프로그래밍 방식으로 생성하는 방법과 Java 코드 스니펫을 사용하여 기존 BarCode를 읽고 인식하는 방법에 대한 단계 및 관련 세부정보를 논의했습니다. 이러한 모든 작업이 몇 개의 간단한 코드 라인으로 수행된다는 점을 눈치 채셨을 것입니다. 추가 소프트웨어 다운로드 또는 설치가 필요하지 않으며 이러한 작업은 더 적은 코드 라인으로 수행할 수 있습니다.

관련 기사

다음 링크를 방문하여 더 알아보시기 바랍니다.