Example usage for com.lowagie.text Document add

List of usage examples for com.lowagie.text Document add

Introduction

In this page you can find the example usage for com.lowagie.text Document add.

Prototype


public boolean add(Element element) throws DocumentException 

Source Link

Document

Adds an Element to the Document.

Usage

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 {//w ww.  j  a  v a 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);
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(7);
    table.setWidthPercentage(100f);//from  w ww .j  a va  2 s .  com
    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.BibliographyReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    BibliographyReportDto dto = (BibliographyReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_BIBLIOGRAPHY_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    Paragraph p2 = new Paragraph(
            this.getHeaderChunk(this.getText("REPORTS_AUTHOR") + ":  " + dto.getAuthorName()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);//from w  ww  .j  av  a2 s  .co  m
    document.add(new Phrase("\n"));
    if (dto.getData() != null) {
        PdfPTable table = new PdfPTable(8);
        table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        createHeader(table);
        PdfPCell cell;
        for (String[] data : dto.getData()) {
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[0])));
            cell.setColspan(3);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[1])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[2])));
            cell.setColspan(2);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[3])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[4])));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
        }
        document.add(table);
        document.add(new Phrase("\n"));
    }
}

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

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    DeweyReportDto dto = (DeweyReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_DEWEY_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n\n"));
    PdfPTable table = new PdfPTable(6);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    createHeader(table);//from  ww w .j ava2  s. c o  m
    PdfPCell cell;
    int totalRecords = 0;
    int totalHoldings = 0;
    List<String[]> dataList = dto.getData();
    Collections.sort(dataList, this);
    for (String[] data : dataList) {
        if (StringUtils.isBlank(data[0])) {
            data[0] = this.getText("REPORTS_DEWEY_UNCLASSIFIED");
        }
        totalRecords += Integer.parseInt(data[1]);
        totalHoldings += Integer.parseInt(data[2]);
    }
    if (totalRecords > 0) {
        dataList.add(new String[] { this.getText("REPORTS_TOTAL"), String.valueOf(totalRecords),
                String.valueOf(totalHoldings) });
    }

    for (String[] data : dataList) {
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[0])));
        cell.setColspan(2);
        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_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    document.add(table);
}

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

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    HoldingCreationByDateReportDto dto = (HoldingCreationByDateReportDto) reportData;
    totalUsuario = new HashMap<String, Integer>();
    Paragraph p1 = new Paragraph(this.getText("REPORTS_INSERTION_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    String dateSpan = this.getText("REPORTS_FROM") + " " + dto.getInitialDate() + " "
            + this.getText("REPORTS_TO") + " " + dto.getFinalDate();
    Paragraph p2 = new Paragraph(this.getHeaderChunk(dateSpan));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);/*from ww  w. j a  v a 2 s . c om*/
    document.add(new Phrase("\n"));

    if (dto.getData() != null) {
        PdfPTable table = createTable(dto.getData());
        document.add(table);
        document.add(new Phrase("\n"));
    }

    if (totalUsuario.size() > 0) {
        Paragraph p3 = new Paragraph(this.getHeaderChunk(this.getText("REPORTS_INSERTION_BY_DATE_USER_TOTAL")));
        p3.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p3);
        document.add(new Phrase("\n"));
        PdfPTable table = new PdfPTable(2);
        PdfPCell cell;
        cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_NAME"))));
        cell.setBackgroundColor(headerBgColor);
        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_TOTAL"))));
        cell.setBackgroundColor(headerBgColor);
        cell.setBorderWidth(headerBorderWidth);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        for (String nome : totalUsuario.keySet()) {
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(nome)));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(this.getNormalChunk(String.valueOf(totalUsuario.get(nome)))));
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            table.addCell(cell);
        }
        document.add(table);
        document.add(new Phrase("\n"));
    }

    //Database totals table
    Paragraph p3 = new Paragraph(
            this.getHeaderChunk(this.getText("REPORTS_INSERTION_BY_DATE_DATABASE_TOTALS")));
    p3.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p3);
    document.add(new Phrase("\n"));
    PdfPTable table = new PdfPTable(3);
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_DATABASE"))));
    cell.setBackgroundColor(headerBgColor);
    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_BIBLIO"))));
    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_HOLDING"))));
    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_MAIN"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    String biblio = dto.getTotalBiblioMain();
    biblio = biblio != null ? biblio : "";
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(biblio)));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    String tombos = dto.getTotalHoldingMain();
    tombos = tombos != null ? tombos : "";
    PdfPCell cell2 = new PdfPCell(new Paragraph(this.getNormalChunk(tombos)));
    cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell2);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_WORK"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    biblio = dto.getTotalBiblioWork();
    biblio = biblio != null ? biblio : "";
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(biblio)));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    tombos = dto.getTotalHoldingWork();
    tombos = tombos != null ? tombos : "";
    cell2 = new PdfPCell(new Paragraph(this.getNormalChunk(tombos)));
    cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell2);

    document.add(table);

}

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

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    DelayedLendingsDto dto = (DelayedLendingsDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_DELAYED_LENDING_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));

    if (dto.getData().size() != 0) {
        Paragraph p2 = new Paragraph(this
                .getHeaderChunk(this.getText("REPORTS_DELAYED_LENDING_TOTAL") + ":  " + dto.getData().size()));
        p2.setAlignment(Paragraph.ALIGN_LEFT);
        document.add(p2);// w  w  w .  j a va  2  s.  c o m
        document.add(new Phrase("\n"));

        PdfPTable table = createTable(dto.getData());
        document.add(table);
        document.add(new Phrase("\n"));
    }
}

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

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    LendingsByDateReportDto dto = (LendingsByDateReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_LENDINGS_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    StringBuilder header = new StringBuilder();
    header.append(this.getText("REPORTS_FROM"));
    header.append(" " + dto.getInitialDate() + " ");
    header.append(this.getText("REPORTS_TO"));
    header.append(" " + dto.getFinalDate());
    Paragraph p2 = new Paragraph(this.getHeaderChunk(header.toString()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);/*w w w . ja  v  a 2 s.c om*/
    document.add(new Phrase("\n"));

    Paragraph p3 = new Paragraph(
            this.getHeaderChunk(this.getText("REPORTS_LENDINGS_BY_DATE_TOTAL") + ":  " + dto.getTotals()[0]));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p3);
    Paragraph p4 = new Paragraph(this
            .getHeaderChunk(this.getText("REPORTS_LENDINGS_BY_DATE_TOTAL_OUT") + ":  " + dto.getTotals()[1]));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p4);
    Paragraph p5 = new Paragraph(this
            .getHeaderChunk(this.getText("REPORTS_LENDINGS_BY_DATE_TOTAL_LATE") + ":  " + dto.getTotals()[2]));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p5);
    document.add(new Phrase("\n"));

    document.add(new Phrase(this.getText("REPORTS_LENDINGS_BY_DATE_TOP_LENDINGS")));
    document.add(new Phrase("\n"));

    if (dto != null) {
        PdfPTable table = createTable(dto);
        document.add(table);
        document.add(new Phrase("\n"));
    }
}

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

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    RequestsByDateReportDto dto = (RequestsByDateReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_REQUESTS_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    StringBuilder header = new StringBuilder();
    header.append(this.getText("REPORTS_FROM"));
    header.append(" ").append(dto.getInitialDate()).append(" ");
    header.append(this.getText("REPORTS_TO"));
    header.append(" ").append(dto.getFinalDate());
    Paragraph p2 = new Paragraph(this.getHeaderChunk(header.toString()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);//  w ww  . jav a 2  s.  com
    document.add(new Phrase("\n"));
    if (dto.getData() != null) {
        PdfPTable table = createTable(dto.getData());
        document.add(table);
        document.add(new Phrase("\n"));
    }
}

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);
    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);//  w  ww.  ja  va 2 s.  c  o  m
        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.SearchesByDateReport.java

License:Open Source License

@Override
protected void generateReportBody(Document document, BaseReportDto reportData) throws Exception {
    SearchesByDateReportDto dto = (SearchesByDateReportDto) reportData;
    Paragraph p1 = new Paragraph(this.getText("REPORTS_SEARCHES_BY_DATE_TITLE"));
    p1.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(p1);
    document.add(new Phrase("\n"));
    StringBuilder p2Builder = new StringBuilder();
    p2Builder.append(this.getText("REPORTS_FROM") + " ");
    p2Builder.append(dto.getInitialDate());
    p2Builder.append(" " + this.getText("REPORTS_TO") + " ");
    p2Builder.append(dto.getFinalDate());
    Paragraph p2 = new Paragraph(this.getHeaderChunk(p2Builder.toString()));
    p2.setAlignment(Paragraph.ALIGN_LEFT);
    document.add(p2);// w w w  . j  av  a 2  s.  c  o m
    document.add(new Phrase("\n"));
    if (dto != null) {
        PdfPTable table = createTable(dto);
        document.add(table);
        document.add(new Phrase("\n"));
    }
}