use of com.itextpdf.barcodes.Barcode128 in project betca-tpv-spring by miw-upm.
the class PdfTicketBuilder method barCode.
public PdfTicketBuilder barCode(String code) {
Barcode128 code128 = new Barcode128(this.getDocument().getPdfDocument());
code128.setCodeType(Barcode128.CODE128);
code128.setCode(code.trim());
Image code128Image = new Image(code128.createFormXObject(this.getDocument().getPdfDocument()));
int width = code.length() * 7;
if (width > 100) {
width = 100;
}
code128Image.setWidthPercent(width);
code128Image.setHorizontalAlignment(HorizontalAlignment.CENTER);
this.getDocument().add(code128Image);
return this;
}
use of com.itextpdf.barcodes.Barcode128 in project betca-tpv-core by miw-upm.
the class PdfCoreBuilder method barcode.
public PdfCoreBuilder barcode(String code) {
if (code.length() > 12) {
code = code.substring(code.length() - 12);
}
Barcode128 code128 = new Barcode128(this.document.getPdfDocument());
code128.setCodeType(Barcode128.CODE128);
// UTF8
code128.setCode(code.trim().replace('-', '/').replace('_', '?'));
code128.setAltText(code.trim());
Image code128Image = new Image(code128.createFormXObject(this.document.getPdfDocument()));
code128Image.setWidthPercent(BARCODE_WIDTH);
code128Image.setHeight(BARCODE_HEIGHT);
code128Image.setHorizontalAlignment(HorizontalAlignment.CENTER);
this.document.add(code128Image);
return this;
}
Aggregations