BarcodeMSI extends Barcode1D { public static byte[] getBarsMSI(String text) { if (text == null) { throw new IllegalArgumentException("Valid code required to generate MSI barcode."); } byte[] bars = new byte[((text.length()) * BARS_PER_CHARACTER) + 7]; System.arraycopy(BARS_START, 0, bars, 0, 3); for (int x = 0; x < text.length(); x++) { char ch = text.charAt(x); int idx = CHARS.indexOf(ch); if (idx < 0) { throw new IllegalArgumentException("The character " + text.charAt(x) + " is illegal in MSI bar codes."); } System.arraycopy(BARS[idx], 0, bars, 3 + x * 12, 12); } System.arraycopy(BARS_END, 0, bars, bars.length - 4, 4); return bars; } BarcodeMSI(PdfDocument document);  BarcodeMSI(PdfDocument document, PdfFont font); @Override Rectangle getBarcodeSize(); @Override Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor); @Override Image createAwtImage(java.awt.Color foreground, java.awt.Color background); static byte[] getBarsMSI(String text); static int getChecksum(String text);  }
@Test public void barcode03Test() { byte[] expected = {1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1}; byte[] barcodeBytes = BarcodeMSI.getBarsMSI("1234"); boolean isEqual = java.util.Arrays.equals(expected, barcodeBytes); Assert.assertTrue(isEqual); }