Example usage for com.lowagie.text Paragraph Paragraph

List of usage examples for com.lowagie.text Paragraph Paragraph

Introduction

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

Prototype

public Paragraph(Phrase phrase) 

Source Link

Document

Constructs a Paragraph with a certain Phrase.

Usage

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);// w ww.j  a  va  2s. c o m
    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);
        document.add(new Phrase("\n"));

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

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);// w  w  w  .  ja  va 2s . c om

    createHeader(table);

    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.LateReturnLendingsReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;//from   w ww. j  a v  a2 s  .  co m
    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_NAME"))));
    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_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_ESTIMATED_DATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
}

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);/*from   www  .j  a v  a2s. c  o m*/
    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);
    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.LendingsByDateReport.java

License:Open Source License

private PdfPTable createTable(LendingsByDateReportDto dto) {
    PdfPTable table = new PdfPTable(5);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    table.setWidthPercentage(100f);//from   w w  w  .j av  a 2  s.co m
    PdfPCell cell;
    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

@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);/*from  w  w w  .j  a  v a2s. c  o  m*/
    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);
    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.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);//from   w  ww . j  a va 2  s .  c o m
    createHeader(table);
    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.RequestsByDateReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;/*from   w w w .java2  s. c  o  m*/
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_PETITIONER"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(2);
    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_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_AMOUNT"))));
    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_UNIT_VALUE"))));
    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_PAID_VALUE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
}

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);/*ww w  .j av  a 2  s .co 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.ReservationReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;//from w ww.  j  ava  2  s.com
    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_NAME"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(2);
    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_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_AUTHOR"))));
    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_RESERVATION_DATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
}