In this article, we are going to discuss the details on how to create Barcode using Java as well as recognizing the Barcode using the same Java API. We are already familiar that a barcode is an encoding tag or label that is placed on all merchandise that allows computers to track and ring up products much faster and more accurately. Similarly, they can easily be printed and added to items in a timely fashion so that your entire inventory is labeled and tracked immediately. Furthermore, the Barcode offers automatic product identification, extremely fast recognition, and implementation of data at a very low error rate. This approach is extremely cost-effective and can assist employers with lowering overhead and cutting down on training time and labor.
- API Δημιουργίας Κωδικών Μπαρ
- Δημιουργήστε Κωδικό Μπάρας με Καθορισμένες Διαστάσεις
- Αναγνώριση Κωδικού Μπαρ από μια Ράστερ Εικόνα
API Δημιουργίας Γραμμωτού Κωδικού
Aspose.BarCode Cloud είναι ένα API REST που επιτρέπει στους πελάτες μας να υλοποιούν δυνατότητες δημιουργίας και χειρισμού BarCode στον προγραμματισμό
Το API είναι ικανό να αναλύει δημοφιλή μορφή ραστερικών εικόνων. Για περισσότερες λεπτομέρειες, παρακαλούμε επισκεφθείτε Supported File Formats .
Δημιουργία Barcode με Καθορισμένες Διαστάσεις
Ο γρήγορος και πιο εύκολος τρόπος για να δοκιμάσετε τις 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
- Φαρμακοκώδικας
- 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
Ο παρακάτω κώδικας μπορεί να χρησιμοποιηθεί για να δημιουργήσει μια εικόνα BarCode και να την αποθηκεύσει στο Cloud Storage.
// Για ολοκληρωμένα παραδείγματα και αρχεία δεδομένων, παρακαλώ πηγαίνετε στο 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
Αναγνώριση Κωδικού Γραμμωτού Από Raster Εικόνα
Η API προσφέρει επίσης τις δυνατότητες αναγνώρισης BarCode από αρχεία εικόνας ράστερ. Το αρχείο εικόνας μπορεί να είναι σε μορφή PNG, JPEG, BMP, GIF, TIFF ή EXIF. Η μέθοδος GetBarcodeRecognize της API σας επιτρέπει να εκπληρώσετε αυτή την απαίτηση. Το πεδίο ονόματος είναι υποχρεωτικό και άλλα προαιρετικά πεδία παρέχουν τις δυνατότητες για την εκτέλεση καλύτερων διαδικασιών αναγνώρισης διότι μπορείτε να καθορίσετε τις πληροφορίες τύπου BarCode, ChecksumValidation, 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. Μπορεί να έχετε παρατηρήσει ότι όλες αυτές οι λειτουργίες εκτελούνται με μερικές απλές γραμμές κώδικα. Δεν απαιτείται κατέβασμα ή εγκατάσταση πρόσθετου λογισμικού και αυτές οι λειτουργίες μπορούν να πραγματοποιηθούν με λιγότερες γραμμές κώδικα.
Σχετικά Άρθρα
Σας προτείνουμε να επισκεφθείτε τους παρακάτω συνδέσμους για να μάθετε περισσότερα σχετικά με