كيفية تطوير تطبيق ماسح الباركود باستخدام Java SDK. قم بتنفيذ إمكانيات مسح QR في تطبيقات الويب والجوال وتطبيقات سطح المكتب.

ماسح الباركود

مسح الباركود عبر الإنترنت | الماسح الضوئي لرمز الاستجابة السريعة

في هذه المقالة ، سنناقش تفاصيل كيفية تطوير ماسح الباركود وتطبيق ماسح رمز الاستجابة السريعة باستخدام Java REST API. نحن ندرك أنه في الاقتصادات سريعة الخطى اليوم ، تعد الرموز الشريطية حلاً أساسيًا وقابل للتطبيق للبائعين والتجار لتخزين تفاصيل المنتج. على مر السنين ، أثبتوا أنهم خيار قيم وقابل للتطبيق للشركات. لقد قاموا بتحسين الكفاءة بشكل كبير وخفضوا النفقات العامة. تعتبر الرموز الشريطية فعالة من حيث التكلفة ويمكن الاعتماد عليها. من بين الفوائد الأخرى لاستخدام BarCode ، المحددة أدناه ، هناك عدد قليل من المزايا الإضافية لاستخدامها

  • تقضي الرموز الشريطية على احتمال حدوث خطأ بشري
  • يقلل استخدام نظام الباركود من وقت تدريب الموظفين
  • تعد الرموز الشريطية متعددة الاستخدامات للغاية ويمكن استخدامها لأي نوع من أنواع جمع البيانات الضرورية
  • إنها تمكن من التحكم الدقيق في المخزون ، وبالتالي تتحسن مراقبة المخزون
  • علاوة على ذلك ، توفر الرموز الشريطية بيانات أفضل ، أي قد يوفر رمز شريطي واحد تفاصيل المخزون والتسعير

وثيقة الصلة بجميع هذه الميزات ، Aspose.BarCode Cloud Java SDK تمكن مطوري Java من إنشاء ومسح الباركود عبر الإنترنت باستخدام لغة Java. على غرار واجهات برمجة التطبيقات السحابية الأخرى ، يتطلب منك Aspose.BarCode Cloud Java SDK تسجيل حساب في Cloud Dashboard. إذا كنت قد سجلت حسابًا بالفعل ، يمكنك الاستمرار في استخدامه. بمجرد أن يكون حسابك جاهزًا ، فأنت جيد لاستخدام الخدمات السحابية من خلال AppKey و AppSID.

قد تفكر في استخدام تخزين Aspose Cloud أو استخدام أي خدمات تخزين سحابية لجهة خارجية لتخزين الملفات واسترجاعها.

رموز الباركود المدعومة

يدعم SDK العديد من رموز الرموز الشريطية (أكثر من 60) مثل EAN و UPC و Codabar و PDF417 و QR و MicroQR و Postnet و Planet و RM4SCC وما إلى ذلك. يمكنك أيضًا الحصول على خيار تحميل معلومات BarCode الحالية وحفظ المخرجات في صورة شائعة تنسيقات ، مثل JPEG ، PNG ، GIF ، BMP ، TIFF ، EMF ، [WMF] 9 و SVG و EXIF و ICON. للحصول على قائمة كاملة من الرموز المدعومة ، يرجى زيارة Aspose.BarCode Cloud Java SDK.

إنشاء رمز شريطي

يوفر لك SDK إنشاء صور باركود خطية وثنائية الأبعاد وبريدية في عدد كبير من التنسيقات. يمكنك تحديد سمات صورة الباركود مثل عرض الصورة والارتفاع ونمط الحدود وتنسيق صورة الإخراج. يمكنك أيضًا تحديد نوع الرمز الشريطي وسمات النص مثل موقع النص وأنماط الخط وفقًا لمتطلبات التطبيق الخاص بك. كما يوفر أيضًا إمكانات ضبط ارتفاع الأشرطة وتدوير صور الباركود بزاوية.

يوضح المثال التالي خطوات إنشاء Code39Standard Barcode ، الموضوعة في محاذاة أعلى مركز للصفحة. تم تحديد لون النص على أنه دقة Navy ، و Horizontal ، و Vertical على أنه 200. يتم تحديد BarColor على أنه برتقالي ، ويتم تعيين لون الخلفية على أنه فضي وتنسيق الإخراج هو تنسيق JPEG.

قبل المضي قدمًا ، نوصيك بزيارة الرابط التالي لأن رمز JWT ضروري عند الوصول إلى واجهة برمجة التطبيقات باستخدام الأمر 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>"

طلب 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

جافا

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();
}
ماسح الباركود عبر الإنترنت

صورة 1: - نتيجة معاينة الباركود.

قارئ الباركود اون لاين

مسح QR

صورة 2: ماسح رمز الاستجابة السريعة

كما أن Cloud API قادر على التعرف على المعلومات من الرموز الشريطية الموجودة. يمكنك الحصول على خيار تحديد تفاصيل نوع الرمز الشريطي للاسترداد السريع أو السماح لواجهة برمجة التطبيقات بتحديد النوع تلقائيًا. يمكنك أيضًا تحديد تفاصيل ChecksumValidation أو DetectEncoding أو السماح لواجهة برمجة التطبيقات بتحديدها خلال وقت التشغيل.

لفة

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":{}}

طلب URL

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

جافا

// للحصول على أمثلة وملفات بيانات كاملة ، يرجى الانتقال إلى 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());
2d الباركود

صورة 3: - معاينة الباركود ثنائي الأبعاد.

إذا قمت بتشغيل الكود أعلاه على الصورة المحددة أعلاه ، فسيقوم نص الاستجابة بتقديم الإخراج كـ

هيئة الاستجابة

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

استنتاج

في هذه المقالة ، تعلمنا الخطوات الخاصة بكيفية تطوير تطبيق ماسح الباركود باستخدام Java REST API. وبالمثل ، تمكّنك واجهة برمجة التطبيقات أيضًا من تنفيذ قارئ رمز الاستجابة السريعة من ملف الصورة. بصرف النظر عن استخدام Java SDK ، نحصل أيضًا على خيار لمسح الباركود عبر الإنترنت باستخدام أوامر cURL. لا يلزم تنزيل أو تثبيت برامج إضافية. في حال واجهتك أية مشكلات أثناء استخدام واجهة برمجة التطبيقات ، فلا تتردد في الاتصال بنا عبر منتدى دعم المنتج المجاني.

مقالات ذات صلة

نوصي أيضًا بزيارة الروابط التالية لمعرفة المزيد حول: