-3

someone know how to save a thirteen digit number in a variable? Because I need to increase the number of my barcode after each use.

So I want to safe the barcode number in a variable and increse it after each if-clause.

public void actionPerformed(ActionEvent arg0) {
    if (hochfrequent = false) {
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("BarcodeArtikel.pdf"));
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            String code = "1234567812345";
          //  int code1= 1234567812345;
            BarcodeEAN codeEAN = new BarcodeEAN();
            codeEAN.setCodeType(Barcode.EAN13);
            codeEAN.setCode(code);
            Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);

            document.add(new Phrase(new Chunk(imageEAN, 0, 0)));
        }
        catch (Exception de) {
            de.printStackTrace();
        }
        document.close();
    }
}}

Thanks for helping me! the return of the methode is the barcode in a pdf file.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
albaum
  • 23
  • 6

1 Answers1

-1

A long can hold a 13-digit integer; range is -(2^63)..(2^63)-1, or approx. -(10*18)..10^18.

You will need to put an L at the end of your number constant (i.e. 1234567812345L).

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101