Sut i ddatblygu App sganiwr Cod Bar gan ddefnyddio Java SDK. Gweithredu galluoedd sgan QR yn eich Cymwysiadau Gwe, Symudol a Bwrdd Gwaith.

Sganiwr cod bar

Sganio cod bar ar-lein | Sganiwr cod QR

Yn yr erthygl hon, rydyn ni’n mynd i drafod y manylion ar sut i ddatblygu sganiwr Cod Bar ac ap sganiwr cod QR gan ddefnyddio Java REST API. Rydym yn deall, yn economïau cyflym heddiw, fod Codau Bar yn ateb hanfodol a hyfyw i werthwyr a masnachwyr ar gyfer storio manylion cynnyrch. Dros y blynyddoedd, maent wedi bod yn ddewis gwerthfawr a hyfyw i fusnesau. Maent wedi gwella effeithlonrwydd yn fawr ac wedi lleihau gorbenion. Mae’r codau bar yn gost-effeithiol ac yn ddibynadwy. Ymhlith manteision eraill defnyddio BarCode, nodir isod ychydig mwy o fanteision o’u defnyddio

  • Mae codau bar yn dileu’r posibilrwydd o gamgymeriadau dynol
  • Mae defnyddio system cod bar yn lleihau amser hyfforddi gweithwyr
  • Mae codau bar yn hynod amlbwrpas a gellir eu defnyddio ar gyfer unrhyw fath o gasglu data angenrheidiol
  • Maent yn galluogi rheoli rhestr eiddo yn fanwl gywir, ac felly mae rheolaeth y Stocrestr yn gwella
  • At hynny, mae’r Codau Bar yn darparu data gwell hy gall un cod bar ddarparu rhestr eiddo a manylion prisio

Yn berthnasol i bob nodwedd o’r fath, mae Aspose.BarCode Cloud Java SDK yn grymuso datblygwyr Java i greu yn ogystal â sganio Cod Bar ar-lein gan ddefnyddio iaith Java. Yn debyg i’n APIs Cloud eraill, mae Aspose.BarCode Cloud Java SDK yn ei gwneud yn ofynnol i chi gofrestru cyfrif yn Cloud Dashboard. Os ydych eisoes wedi cofrestru cyfrif, gallwch barhau i’w ddefnyddio. Unwaith y bydd eich cyfrif yn barod, mae’n dda ichi ddefnyddio’r Cloud Services trwy AppKey ac AppSID.

Efallai y byddwch yn ystyried defnyddio storfa Aspose Cloud neu, defnyddio unrhyw wasanaethau storio cwmwl trydydd parti ar gyfer storio ac adalw ffeiliau.

Symbolegau Cod Bar â Chymorth

Mae’r SDK yn cefnogi nifer o symbolau Cod Bar (mwy na 60) megis EAN, UPC, Codabar, PDF417, QR, MicroQR, Postnet, Planet, RM4SCC, ac ati Byddwch hefyd yn cael yr opsiwn i lwytho gwybodaeth Cod Bar presennol ac arbed yr allbwn i ddelwedd boblogaidd fformatau, megis JPEG, PNG, GIF, BMP, TIFF, EMF, [WMF] 9], SVG, EXIF, ac ICON. I gael rhestr gyflawn o symbolau a gefnogir, ewch i Aspose.BarCode Cloud Java SDK.

Cynhyrchu cod bar

Mae’r SDK yn cynnig i chi greu delweddau Llinol, 2D, a chod bar post mewn llu o fformatau. Gallwch chi nodi priodoleddau delwedd cod bar fel lled delwedd, uchder, arddull ffin, a fformat delwedd allbwn. Gallwch hefyd nodi’r math o god bar a phriodoleddau testun megis lleoliad testun ac arddulliau ffont yn unol â gofynion eich cais. Mae hefyd yn darparu’r galluoedd i osod uchder bariau a chylchdroi delweddau cod bar ar ongl.

Mae’r enghraifft ganlynol yn dangos y camau i greu Cod Bar Code39Standard, wedi’i osod ar aliniad Top-Center y dudalen. Mae lliw y testun wedi’i nodi fel Llynges, Llorweddol, a chydraniad Fertigol wedi’i nodi fel 200. Mae’r BarColor wedi’i nodi fel Oren, mae’r lliw cefndir wedi’i osod fel arian a’r fformat allbwn yw fformat JPEG.

Cyn i ni symud ymlaen ymhellach, rydym yn argymell eich bod yn ymweld â’r ddolen ganlynol gan fod angen tocyn JWT wrth gyrchu’r API gan ddefnyddio’r gorchymyn cURL.

cURL

curl -X PUT "https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Cais URL

https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg

Java

ApiClient client = new ApiClient(
"App SID from https://dashboard.aspose.cloud/#/apps",
"App Key from https://dashboard.aspose.cloud/#/apps");
		        
com.aspose.barcode.cloud.api.BarcodeApi api = new com.aspose.barcode.cloud.api.BarcodeApi(client);
String name = "MySample.jpeg";
String type = com.aspose.barcode.cloud.model.EncodeBarcodeType.CODE39STANDARD.getValue();	
String text = "Barcode processing API"; // String | Text to encode.
String twoDDisplayText = null;
String textLocation = com.aspose.barcode.cloud.model.CodeLocation.ABOVE.getValue();
String textAlignment = com.aspose.barcode.cloud.model.TextAlignment.CENTER.getValue();
String textColor = "Navy";
String fontSizeMode = com.aspose.barcode.cloud.model.FontMode.AUTO.getValue();
int resolution = 200;
double resolutionX = 200;
double resolutionY = 200;
String barColor = "Orange";
String format = "JPEG";
		        
try {
com.aspose.barcode.cloud.model.ResultImageInfo result = api.putBarcodeGenerateFile(
    name, 
		type, 
		text, 
		twoDDisplayText, 
		textLocation, 
		textAlignment, 
		textColor, 
		fontSizeMode, 
		(double) resolution, 
		resolutionX, 
		resolutionY, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		"Silver", 
		barColor, 
		"Blue",
		null, 
		null, 
		true, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null, 
		null,
		format);
		            
  System.out.println(result);
	} catch (ApiException e) {
  System.err.println("Exception when calling BarcodeApi#PutBarcodeGenerateFile");
	e.printStackTrace();
}
Sganiwr cod bar ar-lein

Delwedd 1:- Rhagolwg Cod Bar Canlyniad.

Darllenydd Cod Bar Ar-lein

Sgan QR

Delwedd 2: Sganiwr cod QR

Mae’r Cloud API hefyd yn gallu adnabod gwybodaeth o godau bar presennol. Rydych chi’n cael yr opsiwn i nodi manylion math y cod bar ar gyfer adalw cyflym neu adael i’r API bennu’r math yn awtomatig. Gallwch hefyd nodi manylion ChecksumValidation, DetectEncoding, neu adael i’r API eu pennu dros yr amser rhedeg.

cURL

curl -X POST "https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-H  "x-aspose-client: Containerize.Swagger" -d {"image":{}}

Cais URL

https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true

Java

// Am enghreifftiau cyflawn a ffeiliau data, ewch i 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();

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;
String url = null;

Path currentRelativePath = Paths.get("");
String currentPath = currentRelativePath.toAbsolutePath().toString();
Path filePath = Paths.get(currentPath, "data", "sample.png");

File image = new File(String.valueOf(filePath));

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());
cod bar 2d

Delwedd 3:- Rhagolwg cod bar 2D.

Os ydych chi’n rhedeg y cod uchod ar y ddelwedd a nodir uchod, bydd y Corff Ymateb yn gwneud yr allbwn fel

Corff ymateb

{  "barcodes":  [  {  "barcodeValue":  "12345678",  "type":  "Code39Standard",  "region":  [  {  "x":  **28**,  "y":  **3**  },  {  "x":  **222**,  "y":  **3**  },  {  "x":  **222**,  "y":  **74**  },  {  "x":  **28**,  "y":  **74**  }  ],  "checksum":  ""  }  ]  }

Casgliad

Yn yr erthygl hon, rydym wedi dysgu’r camau ar sut i ddatblygu App sganiwr Cod Bar gan ddefnyddio Java REST API. Yn yr un modd, mae’r API hefyd yn eich galluogi i weithredu darllenydd cod QR o ffeil delwedd. Ar wahân i ddefnyddio’r Java SDK, rydym hefyd yn cael opsiwn i sganio cod bar ar-lein gan ddefnyddio gorchmynion cURL. Nid oes angen lawrlwytho na gosod meddalwedd ychwanegol. Rhag ofn y byddwch chi’n dod ar draws unrhyw broblemau wrth ddefnyddio’r API, mae croeso i chi gysylltu â ni trwy’r fforwm cymorth cynnyrch am ddim.

Erthyglau Perthnasol

Rydym hefyd yn argymell ymweld â’r dolenni canlynol i ddysgu mwy am: