[JAVA]

Es wird beschrieben als. Python, pip, pyenvJAVA: Erzeugt und scannt viele Arten von Barcodes. Barcodes sind sichtbare, maschinenlesbare Daten, die normalerweise Informationen darüber beschreiben, was diesen Barcode enthält. ing. Barcodes werden häufig in Bereichen wie Produktverteilung, Buchverwaltung, Postverwaltung und Bankensystemen verwendet. Dieser Artikel beschreibt die gängige eindimensionale und zweidimensionale Erzeugung und das Scannen von Strichcodes. Erforderliche Tools: Nachfolgend finden Sie eine Liste der Barcodetypen, die von der kostenlosen Version unterstützt werden. 9.png : top: P.s. Ich möchte mehr Barcode-Typen. Weitere Informationen finden Sie in der kommerziellen Version Spire.Barcode für Java.

: one: Barcode-Generierung:

Es gibt zwei wichtige Arten der Barcode-Generierung. Eine ist Barceode-Einstellungen und die andere ist Barceode-Generator. Barch-Ode-Einstellungen sind spezielle Typen zum Anpassen von Barcodes wie Daten, Größe und Farbe. Der Barceode-Generator erstellt Bilddaten basierend auf den Barcede-Einstellungen. Die unterstützten Teil-Barcode-Generierungen in der obigen Tabelle sind:

:black_small_square:Codebar:


import com.spire.barcode.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class CODABAR {
    public static void main(String[] args) throws Exception {
	//Create the BarcodeSettings
        BarcodeSettings settings = new BarcodeSettings();
	//Set data
        settings.setData("2030405060");
	//Set the Symbology property
        settings.setType(BarCodeType.CODABAR);
	//Set Show Text location on bottom
        settings.setShowTextOnBottom(true);
	//Set border is visible
        settings.hasBorder(true);
	//Set the CodabarStartChar and CodebarStopChar
        settings.setCodabarStartChar(CodabarChar.B);
        settings.setCodabarStopChar(CodabarChar.D);
	//Create the BarcodeGenerator
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
	//Get image from the BarcodeGenerator
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
	//Save the image
        ImageIO.write(bufferedImage,"png",new File("CODABAR.png "));
    }
}

Ausführungseffekt: 1.png

:black_small_square:Code11:

import com.spire.barcode.BarCodeGenerator;
import com.spire.barcode.BarCodeType;
import com.spire.barcode.BarcodeSettings;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CODE_11 {
    public static void main(String[] args) throws IOException {

	//Create the BarcodeSettings
        BarcodeSettings settings = new BarcodeSettings();
        //Set Data
        settings.setData("12345-67890"); 
	//Set the Symbology property
        settings.setType(BarCodeType.CODE_11);
	//Set ShowText location on bottom
        settings.setShowTextOnBottom(true);
	//Set Border is visible
        settings.hasBorder(true);
	//Create the BarCodeGenerator
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
	//Get image from the BarCodeGenerator
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
	//Save the image
        ImageIO.write(bufferedImage,"png",new File("CODE_11.png "));

    }
}

Ausführungseffekt: 2.png :black_small_square:Code 39:

import com.spire.barcode.BarCodeGenerator;
import com.spire.barcode.BarCodeType;
import com.spire.barcode.BarcodeSettings;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CODE_39 {
    public static void main(String[] args) throws IOException {
        //Create the BarcodeSettings
        BarcodeSettings settings = new BarcodeSettings();
        //Set Data
        settings.setData("Bar 987654321");
        //Set the Symbology property
        settings.setType(BarCodeType.CODE_39);
        //Set ShowText location on bottom
        settings.setShowTextOnBottom(true);
        //Set Border is visible
        settings.hasBorder(true);
        //Create the BarCodeGenerator
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
        //Get image from the BarCodeGenerator
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
        //Save the image
        ImageIO.write(bufferedImage,"png",new File("CODE_39.png "));

    }
}

Ausführungseffekt: 3.png

:black_small_square:Code 128:

import com.spire.barcode.BarCodeGenerator;
import com.spire.barcode.BarCodeType;
import com.spire.barcode.BarcodeSettings;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CODE_128 {
    public static void main(String[] args) throws IOException {
        //Create the BarcodeSettings
        BarcodeSettings settings = new BarcodeSettings();
        //Set Data
        settings.setData("ABCD 12345 abcd");
        //Set the Symbology property
        settings.setType(BarCodeType.CODE_128);
        //Set ShowText location on bottom
        settings.setShowTextOnBottom(true);
        //Set Border is visible
        settings.hasBorder(true);
        //Create the BarCodeGenerator
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
        //Get image from the BarCodeGenerator
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
        //Save the image
        ImageIO.write(bufferedImage,"png",new File("CODE_128.png "));

    }
}

Ausführungseffekt: 4.png :black_small_square:QR_Code:

import com.spire.barcode.BarCodeGenerator;
import com.spire.barcode.BarCodeType;
import com.spire.barcode.BarcodeSettings;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class QR_CODE {
    public static void main(String[] args) throws IOException {
	 //Create the BarcodeSettings
        BarcodeSettings settings = new BarcodeSettings();
	 //Set Data
        settings.setData("ABC 123456789");
	 //Set the Symbology property
        settings.setType(BarCodeType.QR_CODE);
	 //Set the QR_CODE size
        settings.setX(2);
	 //Set ShowText location on bottom
        settings.setShowTextOnBottom(true);
	 //Set Border is visible
        settings.hasBorder(true);
	 //Create the BarCodeGenerator
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
         //Get image from the BarCodeGenerator
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
	 //Save the image
        ImageIO.write(bufferedImage,"png",new File("QR_CODE.png "));

    }
}

Ausführungseffekt: 5.png : zwei: Barcode-Scan:

Dies ist ein Versuch, mehrere Barcodesätze zusammen zu scannen und mehrere Barcode-Daten mit der scan () -Methode von Barcode-Scannern zu lesen. Das Bild und der Code sind wie folgt. 6.png

            public class Scan {
            public static void main(String[] args) throws Exception {

                  //Get code information by scanning the image   
             String[] s=BarcodeScanner.scan("C:\\Users\\Administrator\\Desktop\\Barcode.png ");
                  for (int i=0;i< s.length ;i++){
                 System.out.println(s[i]);
                     }
                   }
                 }

Ausführungseffekt: 7.png

Recommended Posts