com.aspose.barcode.generation

Class BarcodeGenerator

  • java.lang.Object
    • com.aspose.barcode.generation.BarcodeGenerator


  • public final class BarcodeGenerator
    extends java.lang.Object

    BarcodeGenerator for backend barcode images generation.

    supported symbologies: 1D: Codabar, Code11, Code128, Code39Standard, Code39Extended Code93Standard, Code93Extended, EAN13, EAN8, Interleaved2of5, MSI, Standard2of5, UPCA, UPCE, ISBN, GS1Code128, Postnet, Planet EAN14, SCC14, SSCC18, ITF14, SingaporePost ... 2D: Aztec, DataMatrix, PDf417, QR code ...


      This sample shows how to create and save a barcode image.
      
             BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.CODE_128);
             generator.setCodeText("123ABC");
             generator.save("code128.png");
            

    • Constructor Detail

      • BarcodeGenerator

        public BarcodeGenerator(BaseEncodeType type)

        Creates an instance of BarcodeGenerator.

        Parameters:
        type - Barcode symbology type. Use EncodeTypes class to setup a symbology.
      • BarcodeGenerator

        public BarcodeGenerator(BaseEncodeType type,
                                java.lang.String codeText)

        Creates an instance of BarcodeGenerator.

        Parameters:
        type - Barcode symbology type. Use EncodeTypes class to setup a symbology.
        codeText - Text to be encoded.
    • Method Detail

      • getBarcodeType

        public BaseEncodeType getBarcodeType()

        Barcode symbology type.

      • setBarcodeType

        public void setBarcodeType(BaseEncodeType value)

        Barcode symbology type.

      • getCodeText

        public java.lang.String getCodeText()

        Text to be encoded.

      • setCodeText

        public void setCodeText(java.lang.String value)

        Text to be encoded.

      • generateBarCodeImage

        public java.awt.image.BufferedImage generateBarCodeImage()

        Generate the barcode image under current settings.


          This sample shows how to create and save a barcode image.
          
                 BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.CODE_128);
                 File outputFile = new File("test.png");
                 BufferedImage image = generator.generateBarCodeImage();
                 ImageIO.write(image, "png",outputFile);
                

        Returns:
        Barcode image. See Bitmap.
      • save

        public void save(java.io.OutputStream stream,
                         BarCodeImageFormat format)
                  throws java.io.IOException

        Save barcode image to stream in specific format.

        Parameters:
        stream - Output OutputStream.
        format - Specifies the file format of the output image.
        Throws:
        java.io.IOException
      • save

        public void save(java.lang.String filename,
                         BarCodeImageFormat format)
                  throws java.io.IOException

        Save barcode image to specific file in specific format.

        Parameters:
        filename - Path to save to.
        format - Specifies the file format of the output image.
        Throws:
        java.io.IOException
      • save

        public void save(java.lang.String filename)
                  throws java.io.IOException

        Save barcode image to specific file.

        Parameters:
        filename - Path to save to.
        Throws:
        java.io.IOException
      • exportToXml

        public boolean exportToXml(java.lang.String xmlFile)

        Exports BarCode properties to the xml-file specified

        Parameters:
        xmlFile - The name for the file
        Returns:
        Whether or not export completed successfully.

        Returns <b>True</b> in case of success; <b>False</b> Otherwise

      • importFromXml

        public static BarcodeGenerator importFromXml(java.lang.String xmlFile)

        Imports BarCode properties from the xml-file specified and creates BarcodeGenerator instance.

        Parameters:
        xmlFile - The name for the file
        Returns:
        BarcodeGenerator instance
      • dispose

        public void dispose()

        Clean up any resources being used.