Example usage for com.lowagie.text.pdf PdfPTable PdfPTable

List of usage examples for com.lowagie.text.pdf PdfPTable PdfPTable

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable PdfPTable.

Prototype

public PdfPTable(PdfPTable table) 

Source Link

Document

Constructs a copy of a PdfPTable.

Usage

From source file:com.qcadoo.mes.deliveries.print.OrderReportPdf.java

License:Open Source License

private void createHeaderTable(final Document document, final Entity delivery, final Locale locale)
        throws DocumentException {
    PdfPTable dynaminHeaderTable = pdfHelper.createPanelTable(3);
    dynaminHeaderTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    PdfPTable firstColumnHeaderTable = new PdfPTable(1);
    PdfPTable secondColumnHeaderTable = new PdfPTable(1);
    PdfPTable thirdColumnHeaderTable = new PdfPTable(1);

    setSimpleFormat(firstColumnHeaderTable);
    setSimpleFormat(secondColumnHeaderTable);
    setSimpleFormat(thirdColumnHeaderTable);

    dynaminHeaderTable.setSpacingBefore(7);

    Map<String, Object> firstColumn = createFirstColumn(delivery);
    Map<String, Object> secondColumn = createSecondColumn(delivery);
    Map<String, Object> thirdColumn = createThirdColumn(delivery);

    int maxSize = pdfHelper.getMaxSizeOfColumnsRows(Lists.newArrayList(
            Integer.valueOf(firstColumn.values().size()), Integer.valueOf(secondColumn.values().size()),
            Integer.valueOf(thirdColumn.values().size())));

    for (int i = 0; i < maxSize; i++) {
        firstColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(firstColumnHeaderTable, firstColumn,
                locale);//from w ww . j a v a  2 s .co m
        secondColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(secondColumnHeaderTable, secondColumn,
                locale);
        thirdColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(thirdColumnHeaderTable, thirdColumn,
                locale);
    }

    dynaminHeaderTable.addCell(firstColumnHeaderTable);
    dynaminHeaderTable.addCell(secondColumnHeaderTable);
    dynaminHeaderTable.addCell(thirdColumnHeaderTable);

    document.add(dynaminHeaderTable);
    document.add(Chunk.NEWLINE);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

private void addTableCellAsTable(final PdfPTable table, final String label, final Object fieldValue,
        final String nullValue, final Font headerFont, final Font valueFont, final DecimalFormat df) {
    PdfPTable cellTable = new PdfPTable(2);
    cellTable.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cellTable.addCell(new Phrase(label, headerFont));
    Object value = fieldValue;/*  w w  w  .j a  va2 s  . c  o m*/
    if (value == null) {
        cellTable.addCell(new Phrase(nullValue, valueFont));
    } else {
        if (value instanceof BigDecimal && df != null) {
            cellTable.addCell(new Phrase(df.format(value), valueFont));
        } else {
            cellTable.addCell(new Phrase(value.toString(), valueFont));
        }
    }
    table.addCell(cellTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addTableCellAsTable(final PdfPTable table, final String label, final Object fieldValue,
        final String nullValue, final Font headerFont, final Font valueFont, final DecimalFormat df) {
    final PdfPTable cellTable = new PdfPTable(2);
    cellTable.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cellTable.addCell(new Phrase(label, headerFont));
    final Object value = fieldValue;
    if (value == null) {
        cellTable.addCell(new Phrase(nullValue, valueFont));
    } else {/*  w  ww . j  ava  2 s.  co m*/
        if (value instanceof BigDecimal && df != null) {
            cellTable.addCell(new Phrase(df.format(value), valueFont));
        } else {
            cellTable.addCell(new Phrase(value.toString(), valueFont));
        }
    }
    table.addCell(cellTable);
}

From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationBarcode.java

License:Open Source License

public void print(PdfWriter pdfWriter, Entity operationComponent, Document document) throws DocumentException {
    PdfContentByte cb = pdfWriter.getDirectContent();
    Barcode128 code128 = new Barcode128();
    code128.setCode(//ww  w .  j a  va  2  s .  c o m
            barcodeOperationComponentService.getCodeFromBarcodeForOperationComponet(operationComponent));
    PdfPTable barcodeTable = new PdfPTable(1);
    barcodeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    barcodeTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    barcodeTable.getDefaultCell().setBorder(0);
    barcodeTable.setWidthPercentage(10f);
    barcodeTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    Image barcodeImage = code128.createImageWithBarcode(cb, null, null);
    barcodeTable.addCell(barcodeImage);
    document.add(barcodeTable);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeader(final Document document, final String name, final String documenTitle,
        final String documentAuthor, final Date date, final String username) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(3, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    document.add(Chunk.NEWLINE);//from  ww  w .ja v a2  s  . c o m
    Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark()));
    title.setSpacingAfter(7f);
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + username, FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(14f);
    document.add(userAndDate);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeader(final Document document, final String name, final String documenTitle,
        final String documentAuthor, final Date date) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    document.add(Chunk.NEWLINE);//ww  w  .j a va 2 s .c om
    Paragraph title = new Paragraph(new Phrase(documenTitle, FontUtils.getDejavuBold17Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold17Dark()));
    title.setSpacingAfter(7f);
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(14f);
    document.add(userAndDate);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public void addDocumentHeaderThin(final Document document, final String name, final String documentTitle,
        final String documentAuthor, final Date date) throws DocumentException {
    SimpleDateFormat df = new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, getLocale());
    LineSeparator line = new LineSeparator(2, 100f, ColorUtils.getLineDarkColor(), Element.ALIGN_LEFT, 0);
    Paragraph title = new Paragraph(new Phrase(documentTitle, FontUtils.getDejavuBold14Light()));
    title.add(new Phrase(" " + name, FontUtils.getDejavuBold14Dark()));
    title.setSpacingAfter(7f);/*from  ww  w .j  a  v  a  2  s .co  m*/
    document.add(title);
    document.add(line);
    PdfPTable userAndDate = new PdfPTable(2);
    userAndDate.setWidthPercentage(100f);
    userAndDate.setHorizontalAlignment(Element.ALIGN_LEFT);
    userAndDate.getDefaultCell().setBorderWidth(0);
    Paragraph userParagraph = new Paragraph(new Phrase(documentAuthor, FontUtils.getDejavuRegular9Light()));
    userParagraph.add(new Phrase(" " + getDocumentAuthor(), FontUtils.getDejavuRegular9Dark()));
    Paragraph dateParagraph = new Paragraph(df.format(date), FontUtils.getDejavuRegular9Light());
    userAndDate.addCell(userParagraph);
    userAndDate.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    userAndDate.addCell(dateParagraph);
    userAndDate.setSpacingAfter(10f);
    document.add(userAndDate);
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public PdfPTable createPanelTable(final int column) {
    PdfPTable mainData = new PdfPTable(column);
    mainData.setWidthPercentage(100f);/*from  ww w. j a v  a 2 s  .  co m*/
    mainData.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    mainData.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    mainData.getDefaultCell().setPadding(4.0f);
    mainData.setTableEvent(new TableBorderEvent());
    return mainData;
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

@Override
public PdfPTable createPanelTableWithSimpleFormat(final int column) {
    PdfPTable pdfPTable = new PdfPTable(column);
    pdfPTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    pdfPTable.getDefaultCell().setPadding(6.0f);
    pdfPTable.getDefaultCell().setVerticalAlignment(PdfPCell.ALIGN_TOP);
    return pdfPTable;
}

From source file:com.qcadoo.report.internal.PdfHelperImpl.java

License:Open Source License

private void addTableCellAsTable(final PdfPTable table, final String label, final Object fieldValue,
        final String nullValue, final Font headerFont, final Font valueFont, final int columns,
        final int[] columnWidths) {
    PdfPTable cellTable = new PdfPTable(columns);

    if (columnWidths.length > 0) {
        try {/* w w  w . j a  v a2  s .com*/
            cellTable.setWidths(columnWidths);
        } catch (DocumentException e) {
            LOG.error(e.getMessage(), e);
        }
    }

    cellTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    cellTable.addCell(new Phrase(label, headerFont));

    if (fieldValue == null) {
        cellTable.addCell(new Phrase(nullValue, valueFont));
    } else {
        cellTable.addCell(new Phrase(fieldValue.toString(), valueFont));
    }

    table.addCell(cellTable);
}