Barcode39 extends Barcode1D { public static byte[] getBarsCode39(String text) { text = "*" + text + "*"; byte[] bars = new byte[text.length() * 10 - 1]; for (int k = 0; k < text.length(); ++k) { char ch = text.charAt(k); int idx = CHARS.indexOf(ch); if(ch == '*' && k != 0 && k != (text.length() - 1)){ throw new IllegalArgumentException("The character " + ch + " is illegal in code 39"); } if (idx < 0 ) { throw new IllegalArgumentException("The character " + text.charAt(k) + " is illegal in code 39"); } System.arraycopy(BARS[idx], 0, bars, k * 10, 9); } return bars; } Barcode39(PdfDocument document);  Barcode39(PdfDocument document, PdfFont font); static byte[] getBarsCode39(String text); static String getCode39Ex(String text); @Override Rectangle getBarcodeSize(); @Override Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor); @Override Image createAwtImage(java.awt.Color foreground, java.awt.Color background);  }
@Test public void barcode03Test() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); Barcode39 barcode = new Barcode39(document); try { barcode.getBarsCode39("9781935*182610"); Assert.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ignored) { } }