コード例 #1
0
  public static void main(String[] args) {
    // The path to the documents directory.
    String dataDir = Utils.getDataDir(BarcodeImageBorders.class);

    String dst = dataDir + "barcode-image-borders.jpg";

    // Instantiate barcode object
    BarCodeBuilder bb = new BarCodeBuilder();

    // Set the Code text for the barcode
    bb.setCodeText("1234567");

    // Set the symbology type to code128
    bb.setSymbologyType(Symbology.Code128);

    // Set border style to solid
    bb.setBorderDashStyle(BorderDashStyle.Solid);

    // Set border margins by assigning an instance of MarginsF
    bb.setMargins(new MarginsF(2f, 2f, 2f, 2f));

    // Set border width
    bb.setBorderWidth(0.5f);

    // Enable border to be shown in the barcode
    bb.setBorderVisible(true);

    // Save the image
    bb.save(dst);

    System.out.println("Barcode saved successfully.");
  }
コード例 #2
0
  public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(SpecifySymbology.class) + "Barcode/BasicFeatures/";

    // Generate and save the image to file
    BarCodeBuilder builder = new BarCodeBuilder();
    // Set code text
    builder.setCodeText("test-123");
    // Set Symbology type
    builder.setSymbologyType(Symbology.Code39Standard);

    builder.save(dataDir + "Code39Standard.jpg");
  }