public void execute(PdfContentByte cb, BaseFont bf) { String t = sanitizeText(getText()); Barcode128 code128 = new Barcode128(); code128.setGenerateChecksum(true); code128.setCode(t); if (!isShowText()) { code128.setFont(null); } code128.setBarHeight(getSize()); Image img = code128.createImageWithBarcode(cb, getColor(), getColor()); // float w = code128.getBarcodeSize().width() / 2; img.setAbsolutePosition(getOffsetX(), getOffsetY()); img.setRotationDegrees(getDirection()); try { cb.addImage(img); } catch (DocumentException e) { // Do nothing for the time being... } }