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

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

Introduction

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

Prototype

public void setWidthPercentage(float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

From source file:biblivre3.administration.reports.AllUsersReport.java

License:Open Source License

private final PdfPTable createSummaryTable(Map<String, Integer> tipos) {
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(50f);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    int total = 0;
    PdfPCell cell;// ww  w  .  ja  va 2  s  . co  m
    for (String description : tipos.keySet()) {
        total += tipos.get(description);
        cell = new PdfPCell(new Paragraph(this.getHeaderChunk(description.toUpperCase())));
        cell.setBackgroundColor(headerBgColor);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(String.valueOf(tipos.get(description)))));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_TOTAL"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(String.valueOf(total))));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    return table;
}

From source file:biblivre3.administration.reports.AllUsersReport.java

License:Open Source License

private final ArrayList<PdfPTable> createListTable(Map<String, List<String>> data) {
    try {/*from  w ww.  ja  v a2s  . com*/
        ArrayList<PdfPTable> tabelas = new ArrayList<PdfPTable>();
        PdfPTable table = null;
        PdfPCell cell;
        for (String description : data.keySet()) {
            table = new PdfPTable(4);
            table.setWidthPercentage(100f);
            cell = new PdfPCell(new Paragraph(this.getHeaderChunk(description.toUpperCase())));
            cell.setColspan(4);
            cell.setBorder(PdfPCell.NO_BORDER);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_NAME"))));
            cell.setBackgroundColor(headerBgColor);
            cell.setBorderWidth(headerBorderWidth);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ENROL"))));
            cell.setBackgroundColor(headerBgColor);
            cell.setBorderWidth(headerBorderWidth);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_INSERTION_DATE"))));
            cell.setBackgroundColor(headerBgColor);
            cell.setBorderWidth(headerBorderWidth);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_UPDATE_DATE"))));
            cell.setBackgroundColor(headerBgColor);
            cell.setBorderWidth(headerBorderWidth);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);

            for (String line : data.get(description)) {
                String[] dados = line.split("\t");
                //Nome
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(dados[0])));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                table.addCell(cell);

                //Matricula
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(dados[1])));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                table.addCell(cell);

                //Data de Inclusao
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(dados[2])));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                table.addCell(cell);

                //Data de Cancelamento/Alteracao
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(dados[3])));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                table.addCell(cell);
            }
            if (table != null) {
                tabelas.add(table);
            }
        }
        return tabelas;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return null;
    }
}

From source file:biblivre3.administration.reports.AssetHoldingByDateReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingByDateDto dto = (AssetHoldingByDateDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_ASSET_HOLDING_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);//from   w  ww .j  a  va 2  s .  c o  m
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(8);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    for (String[] data : dataList) {
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[3])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[4])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[5])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.AssetHoldingFullReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingDto dto = (AssetHoldingDto) reportData;
    String title = "";
    if (this.topographic) {
        title = this.getText("REPORTS_TOPOGRAPHIC_TITLE");
    } else {//from   ww w  . j a  va  2 s . c  o m
        title = this.getText("REPORTS_ASSET_HOLDING_TITLE");
    }
    Paragraph p1 = new Paragraph(title);
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(20);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    Collections.sort(dataList, this);
    for (String[] data : dataList) {
        PdfContentByte cb = getWriter().getDirectContent();

        String holdingSerial = StringUtils.leftPad(data[0], 10, "0");
        Barcode39 code39 = new Barcode39();
        code39.setExtended(true);
        code39.setCode(holdingSerial);
        code39.setStartStopText(false);

        Image image39 = code39.createImageWithBarcode(cb, null, null);
        image39.scalePercent(100f);
        cell = new PdfPCell(new Paragraph(new Phrase(new Chunk(image39, 0, 0))));
        cell.setColspan(6);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setColspan(3);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);

        Paragraph para = new Paragraph();
        para.add(new Phrase(this.getSmallFontChunk(data[2] + "\n")));
        para.add(new Phrase(this.getSmallFontChunk(data[3] + "\n")));

        if (StringUtils.isNotBlank(data[4])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_LOCATION") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[4] + " ")));
        }

        if (StringUtils.isNotBlank(data[5])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_EDITION") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[5] + " ")));
        }

        if (StringUtils.isNotBlank(data[6])) {
            para.add(new Phrase(this.getBoldChunk(this.getText("REPORTS_DATE") + ": ")));
            para.add(new Phrase(this.getSmallFontChunk(data[6])));
        }

        cell = new PdfPCell(para);
        cell.setColspan(11);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cell.setPaddingTop(5f);
        cell.setPaddingLeft(7f);
        cell.setPaddingBottom(4f);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.AssetHoldingReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    AssetHoldingDto dto = (AssetHoldingDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_ASSET_HOLDING_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);/*from www  .  ja  va 2s.  com*/
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(7);
    table.setWidthPercentage(100f);
    createHeader(table);
    PdfPCell cell;
    List<String[]> dataList = dto.getData();
    Collections.sort(dataList, this);
    for (String[] data : dataList) {
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[3])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[4])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}

From source file:biblivre3.administration.reports.LateReturnLendingsReport.java

License:Open Source License

private PdfPTable createTable(List<String[]> lendings) {
    PdfPTable table = new PdfPTable(6);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    table.setWidthPercentage(100f);

    createHeader(table);//from w ww . j  a v  a 2s.com

    PdfPCell cell;
    for (String[] lending : lendings) {
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(lending[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(lending[1])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(lending[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(lending[3])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    return table;
}

From source file:biblivre3.administration.reports.LendingsByDateReport.java

License:Open Source License

private PdfPTable createTable(LendingsByDateReportDto dto) {
    PdfPTable table = new PdfPTable(5);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    table.setWidthPercentage(100f);
    PdfPCell cell;/*from  w w  w.j av a2s  . c  o  m*/
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_LENDINGS"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_TITLE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(2);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_AUTHOR"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(2);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    //Table body
    if (dto.getData() == null || dto.getData().isEmpty())
        return table;
    for (String[] data : dto.getData()) {
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[1])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    return table;
}

From source file:biblivre3.administration.reports.RequestsByDateReport.java

License:Open Source License

private PdfPTable createTable(List<String[]> dataList) {
    PdfPTable table = new PdfPTable(7);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    table.setWidthPercentage(100f);
    createHeader(table);/*from   w w w  .j a  v a  2  s  .  c om*/
    PdfPCell cell;
    String lastQuotationId = "0";
    String requester = null;
    String title = null;
    String quantity = null;
    String unit_value = null;
    String total_value = null;
    for (String[] data : dataList) {
        if (!data[0].equals(lastQuotationId)) {
            if (!lastQuotationId.equals("0")) {
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(requester)));
                cell.setColspan(2);
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(title)));
                cell.setColspan(2);
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(quantity)));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(unit_value)));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
                cell = new PdfPCell(new Paragraph(this.getNormalChunk(total_value)));
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
            }

            requester = "";
            title = "";
            quantity = "";
            unit_value = "";
            total_value = "";
        }

        lastQuotationId = data[0];
        requester = data[1] + "\n";
        title += data[2] + "\n";
        quantity += data[3] + "\n";
        unit_value += data[4] + "\n";
        total_value = (data[5] == null ? "-" : data[5]) + "\n";
    }

    if (!lastQuotationId.equals("0")) {
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(requester)));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(title)));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(quantity)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(unit_value)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(total_value)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
    }
    return table;
}

From source file:biblivre3.administration.reports.ReservationReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    ReservationReportDto dto = (ReservationReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_RESERVATION_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);/*from w w w . java 2s .  c o m*/
    document.add(new Phrase("\n\n"));
    boolean hasBiblioData = dto.getBiblioReservations() != null && !dto.getBiblioReservations().isEmpty();
    boolean hasHoldingData = dto.getHoldingReservations() != null && !dto.getHoldingReservations().isEmpty();
    if (hasBiblioData) {
        PdfPTable biblioTable = new PdfPTable(7);
        biblioTable.setWidthPercentage(100f);
        PdfPCell cell = new PdfPCell(
                new Paragraph(this.getHeaderChunk(this.getText("REPORTS_RESERVATION_BIBLIO"))));
        cell.setBackgroundColor(headerBgColor);
        cell.setBorderWidth(headerBorderWidth);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setColspan(7);
        biblioTable.addCell(cell);
        createHeader(biblioTable);
        createBody(biblioTable, dto.getBiblioReservations());
        document.add(biblioTable);
        document.add(new Phrase("\n"));
    }
    if (hasHoldingData) {
        PdfPTable holdingTable = new PdfPTable(7);
        holdingTable.setWidthPercentage(100f);
        PdfPCell cell = new PdfPCell(
                new Paragraph(this.getHeaderChunk(this.getText("REPORTS_RESERVATION_HOLDING"))));
        cell.setBackgroundColor(headerBgColor);
        cell.setBorderWidth(headerBorderWidth);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setColspan(7);
        holdingTable.addCell(cell);
        createHeader(holdingTable);
        createBody(holdingTable, dto.getHoldingReservations());
        document.add(holdingTable);
    }
    if (!hasBiblioData && !hasHoldingData) {
        PdfPTable noDataTable = new PdfPTable(1);
        noDataTable.setWidthPercentage(100f);
        String message = this.getText("REPORTS_NO_DATA") + " - " + dateFormat.format(new Date());
        PdfPCell cell = new PdfPCell(new Paragraph(this.getHeaderChunk(message)));
        cell.setBackgroundColor(headerBgColor);
        cell.setBorderWidth(headerBorderWidth);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        noDataTable.addCell(cell);
        document.add(noDataTable);
    }
}

From source file:biblivre3.administration.reports.SummaryReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    SummaryReportDto dto = (SummaryReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_SUMMARY_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);//ww w.  j a  v  a2  s .  c o  m
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(10);
    table.setWidthPercentage(100f);
    createHeader(table);
    Collections.sort(dto.getData(), this);
    PdfPCell cell;
    for (String[] data : dto.getData()) {
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[6])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[0])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[1])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[2])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[3])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[4])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[5])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getSmallFontChunk(data[7])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}