Search in sources :

Example 1 with BarcodeEAN

use of com.itextpdf.barcodes.BarcodeEAN in project betca-tpv-spring by miw-upm.

the class PdfTag24Builder method addTag24.

public PdfTag24Builder addTag24(String description, String code) {
    assert description != null;
    assert code != null;
    if ((tag24 % 24) == 0) {
        if (tag24 > 0) {
            this.getDocument().add(new AreaBreak(AreaBreakType.NEXT_PAGE));
        }
        this.prepareTags24();
    }
    Cell cell = new Cell();
    cell.setPaddingTop(10);
    cell.setMinHeight(84.2F);
    cell.setBorder(Border.NO_BORDER);
    cell.setTextAlignment(TextAlignment.CENTER);
    cell.add(description);
    if (!code.isEmpty()) {
        BarcodeEAN barcode = new BarcodeEAN(this.getDocument().getPdfDocument());
        barcode.setCodeType(BarcodeEAN.EAN13);
        barcode.setCode(code.trim());
        Image barcodeImage = new Image(barcode.createFormXObject(this.getDocument().getPdfDocument()));
        barcodeImage.setWidthPercent(70);
        barcodeImage.setHorizontalAlignment(HorizontalAlignment.CENTER);
        cell.add(barcodeImage);
    }
    this.getTable().addCell(cell);
    this.getDocument().add(this.getTable());
    tag24++;
    return this;
}
Also used : BarcodeEAN(com.itextpdf.barcodes.BarcodeEAN) AreaBreak(com.itextpdf.layout.element.AreaBreak) Image(com.itextpdf.layout.element.Image) Cell(com.itextpdf.layout.element.Cell)

Aggregations

BarcodeEAN (com.itextpdf.barcodes.BarcodeEAN)1 AreaBreak (com.itextpdf.layout.element.AreaBreak)1 Cell (com.itextpdf.layout.element.Cell)1 Image (com.itextpdf.layout.element.Image)1