در این مقاله، قرار است جزئیات نحوه ایجاد بارکد با استفاده از Java و همچنین شناسایی بارکد با استفاده از همان API Java را مورد بحث قرار دهیم. ما قبلاً با این موضوع آشنا هستیم که بارکد یک برچسب یا برچسب کدنویسی است که بر روی تمام کالاها قرار میگیرد و به کامپیوترها اجازه میدهد که محصولات را بسیار سریعتر و با دقت بیشتری ردیابی و محاسبه کنند. به همین ترتیب، آنها به راحتی چاپ شده و به اقلام در زمان مناسب اضافه میشوند تا کل موجودی شما فوراً برچسبگذاری و ردیابی شود. علاوه بر این، بارکد شناسایی خودکار محصول، شناسایی بسیار سریع و پیادهسازی دادهها را با نرخ خطای بسیار پایین ارائه میدهد. این رویکرد از نظر هزینه بسیار مقرونبهصرفه
API تولید بارکد
Aspose.BarCode Cloud یک API REST است که به مشتریان ما این امکان را میدهد تا قابلیتهای تولید و ویرایش بارکد را در برنامهنویسی پیادهسازی کنند.
این API قادر به تجزیه فرمتهای تصویری رایج است. برای جزئیات بیشتر، لطفاً به Supported File Formats مراجعه کنید.
بارکد با ابعاد مشخص را تولید کنید
راحتترین و سریعترین راه برای تست API های ما استفاده از بخش مرجع API است. متد GetBarcodeGenerate برای ایجاد تصاویر بارکد استفاده میشود و گزینههای متنوعی برای تولید بارکد طبق نیازهای شما ارائه میدهد و جزئیات مربوط به پارامترهای خاص بهخوبی در صفحه مرجع API توضیح داده شده است. هنگام تولید بارکد، میتوانید یکی از نوعهای زیر را مشخص کنید
- 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 command
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);

تصویر 1:- پیش نمایش بارکد ایجاد شده با API جاوا
کد بار را از تصویر رستری شناسایی کنید
API همچنین قابلیتهای شناسایی بارکد از فایلهای تصویری Raster را ارائه میدهد. فرمت فایل تصویر میتواند PNG، JPEG، BMP، GIF، TIFF یا EXIF باشد. متد GetBarcodeRecognize از API به شما امکان میدهد این نیاز را برآورده کنید. فیلد نام الزامی است و سایر فیلدهای اختیاری قابلیتهای بهتری برای انجام عملیات شناسایی ارائه میدهند زیرا میتوانید اطلاعات نوع بارکد، اعتبارسنجی Checksum، Encoding، یک پیشتنظیم برای پیکربندی کیفیت و سرعت شناسایی و موارد دیگر را مشخص کنید.
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 و همچنین نحوه خواندن و شناسایی یک بارکد موجود با استفاده از قطعه کد Java را مورد بحث قرار دادهایم. ممکن است متوجه شده باشید که تمام این عملیات با چند خط کد ساده انجام میشود. هیچ دانلود یا نصب نرمافزار اضافی لازم نیست و این عملیات میتواند با خطوط کد کمتری انجام شود.
مقالات مرتبط
ما به شما توصیه میکنیم که به لینکهای زیر مراجعه کنید تا بیشتر دربارهٔ