Example usage for com.lowagie.text.pdf PdfPCell setColspan

List of usage examples for com.lowagie.text.pdf PdfPCell setColspan

Introduction

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

Prototype

public void setColspan(int colspan) 

Source Link

Document

Setter for property colspan.

Usage

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

License:Open Source License

private void createBody(PdfPTable table, List<String[]> dataList) {
    if (dataList == null || dataList.isEmpty()) {
        return;/*from   w ww. ja  v  a  2s  .c  o m*/
    }
    for (String[] data : dataList) {
        PdfPCell 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[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[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);
    }
}

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

License:Open Source License

private PdfPTable createTable(SearchesByDateReportDto dto) {
    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    //Table header
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_DATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);//from   w w w .  j a v  a  2 s .  co m
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_TOTAL"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(2);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    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[1])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(data[0])));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    return table;
}

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);//  www.  ja  v a2 s. co 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);
}

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

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(this.getText("REPORTS_DEWEY"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);//from ww w  . j  a  v a  2 s .  c om
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(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.getBoldChunk(this.getText("REPORTS_AUTHOR"))));
    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.getBoldChunk(this.getText("REPORTS_ISBN"))));
    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.getBoldChunk(this.getText("REPORTS_EDITOR"))));
    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.getBoldChunk(this.getText("REPORTS_YEAR"))));
    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.getBoldChunk(this.getText("REPORTS_EDITION"))));
    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.getBoldChunk(this.getText("REPORTS_HOLDINGS_TOTAL"))));
    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.UserReport.java

License:Open Source License

private PdfPTable createLendingsTable(List<String[]> lendings) {
    PdfPTable table = new PdfPTable(5);
    table.setWidthPercentage(100f);/*from  w  w  w .  ja v a2 s .  c om*/

    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_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_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.setColspan(2);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(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_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(this.getNormalChunk(lending[2])));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    return table;
}

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

License:Open Source License

private PdfPTable createUserDataTable(UserDTO user) {
    PdfPTable table = new PdfPTable(4);
    table.setWidthPercentage(100f);//from   w  ww  .ja v  a2 s  .co m
    PdfPCell cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_NAME"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getName())));
    cell.setColspan(3);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ENROL"))));
    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(user.getUserid()))));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_SIGNUP_DATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    Date signupDate = user.getSignup_date();
    cell = new PdfPCell(
            new Paragraph(this.getNormalChunk(signupDate != null ? dateFormat.format(signupDate) : "")));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_SOCIAL_NUMBER"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getSocial_id_number())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ID"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getDlicense() + " " + user.getTypeId())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_BIRTHDATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getBirthday())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_OBS"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getObs())));
    cell.setColspan(4);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    return table;
}

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

License:Open Source License

private PdfPTable createAddressTable(UserDTO user) {
    PdfPTable table = new PdfPTable(4);
    table.setWidthPercentage(100f);/*from w  w  w.  j  a v  a2s  .  c  o m*/
    PdfPCell cell;

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ADDRESS"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getAddress())));
    cell.setColspan(3);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_NUMBER"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getNumber())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ADDRESS_2"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getCompletion())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_CITY"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getCity())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_STATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getState())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_COUNTRY"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getCountry())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_ZIP_CODE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getZip_code())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_HOME_PHONE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getTelRef1())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_MOBILE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getCellphone())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_OFFICE_PHONE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getTelRef2())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_EXTENSION"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getExtension_line())));
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(this.getHeaderChunk(this.getText("REPORTS_EMAIL"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(this.getNormalChunk(user.getEmail())));
    cell.setColspan(3);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    return table;
}

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

private static void geraCabecalho(PdfPTable table) {
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(TradGeraRelatorioPDF.P_V));
    cell.setBorderWidth(1.5f);//from  ww  w  .  j av a  2 s .  c o  m
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(TradGeraRelatorioPDF.DESCRICAO));
    cell.setColspan(3);
    cell.setBorderWidth(1.5f);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(TradGeraRelatorioPDF.OCORRENCIAS));
    cell.setBorderWidth(1.5f);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph(TradGeraRelatorioPDF.LINHAS));
    cell.setBorderWidth(1.5f);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
}

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

private static PdfPTable geraLista(HashSet<PontoVerificacao> pvs) {
    // Inicializa a Tabela
    PdfPTable table = new PdfPTable(6);
    table.setWidthPercentage(100f);/*  w w w.ja v a  2  s .  c om*/
    geraCabecalho(table);
    // Preenche os dados da Tabela
    HashSet<PontoVerificacao> pontos = pvs;
    for (PontoVerificacao pv : pontos) {
        PdfPCell cell;
        // Ponto de Verificacao
        cell = new PdfPCell(new Paragraph(String.valueOf(pv.getGl()) + "." + String.valueOf(pv.getCp())));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        // Descrio da Regra
        String descricao;
        int tipoaval = Integer.parseInt(Gerente.getProperties().getProperty("tipo_avaliacao"));
        if (tipoaval == 2) {
            //pegar do EMAG
            InterfRegrasHardCoded regras = MethodFactRegHardCod.mFRegHardCod("EMAG");
            descricao = regras.getTextoRegra(String.valueOf(pv.getGl()) + "." + String.valueOf(pv.getCp()));
        } else if (tipoaval == 1) {
            //pegar do WCAG
            InterfRegrasHardCoded regras = MethodFactRegHardCod.mFRegHardCod("WCAG");
            descricao = regras.getTextoRegra(String.valueOf(pv.getGl()) + "." + String.valueOf(pv.getCp()));
        } else {
            descricao = TokenLang.getRegra(pv.getIdRegra());
        }
        cell = new PdfPCell(new Paragraph(descricao));

        cell.setColspan(3);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        // Total Ocorrncias
        int size = pv.getLinhas().size();
        String strSize = String.valueOf(size);
        strSize = !strSize.equals("0") ? strSize : "---";
        cell = new PdfPCell(new Paragraph(strSize));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
        // Linhas em que ocorre o P.V.
        ArrayList<Integer> arrayLinhas = pv.getLinhas();
        StringBuilder linha = new StringBuilder();
        for (Integer nroLinha : arrayLinhas) {
            // String strLinha = Normalizador.normalizar(nroLinha);
            String strLinha = String.valueOf(nroLinha);
            linha.append(strLinha + "  ");
        }
        cell = new PdfPCell(new Paragraph(linha.toString()));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        table.addCell(cell);
    }
    return table;
}

From source file:bucks.GenerateChecks.java

License:Open Source License

void generate_mb(Document document, int seq, String value, Image image, PdfWriter writer) {
    try {// w  ww  .  ja  va 2  s  . co  m
        float[] widths = { 15f, 40f, 45f }; // percentages         
        PdfPTable table = new PdfPTable(widths);
        table.setWidthPercentage(100);
        table.setSpacingAfter(0f);
        table.setSpacingBefore(0f);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        PdfPCell cell = new PdfPCell(image);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        // cell.setFixedHeight(46f);
        table.addCell(cell);
        Phrase phrase = new Phrase();
        Chunk ch = new Chunk("FARMERS' MARKET BUCKS\n", fntb2);
        phrase.add(ch);
        ch = new Chunk("Parks & Recreation\nBloomington, IN", fnt);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);
        //
        phrase = new Phrase();
        ch = new Chunk("Issue Date___________ ", fnt10);
        phrase.add(ch);
        ch = new Chunk("No. " + seq, fnt10);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);
        //
        // document.add(table);
        //
        phrase = new Phrase();
        ch = new Chunk("\nThis certificate is good for ", fnt);
        phrase.add(ch);
        ch = new Chunk("$" + value + ".00 ", fntb2);
        phrase.add(ch);
        ch = new Chunk("towards the purchase of ", fnt);
        phrase.add(ch);
        ch = new Chunk("eligible food items ", fntb);
        phrase.add(ch);
        ch = new Chunk("at the Bloomington Community Farmers' Market. ", fnt);
        phrase.add(ch);
        ch = new Chunk("No change allowed. \n", fntb);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setFixedHeight(48f);
        cell.setColspan(3);
        table.addCell(cell);

        document.add(table);
        //
        float[] widths2 = { 60f, 25f, 10f, 5f };
        table = new PdfPTable(widths2);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        //table.getDefaultCell().setPadding(0);
        table.setSpacingAfter(0f);
        table.setSpacingBefore(0f);
        //
        phrase = new Phrase();
        ch = new Chunk(
                "Customers shall redeem this certificate at Farmers' Market\nby December 1st of the year issued.",
                fnt);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);

        cell.setColspan(2);
        cell.setFixedHeight(81f);
        table.addCell(cell);
        //
        Barcode barcode = BarcodeFactory.createCode39("" + seq, false);
        // barcode text has problem, so we turned off
        // and decided to add it ourselves.
        barcode.setDrawingText(false);
        // barcode.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 16));
        // barcode.setLabel(""+seq);
        BufferedImage bi = BarcodeImageHandler.getImage(barcode);
        /*
        int width = bi.getWidth();
        int height = bi.getHeight();
        Graphics2D g2 = bi.createGraphics();
        g2.setColor(Color.BLACK);
        g2.drawString(""+seq, 60, 70);
        g2.dispose();
        */
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        //
        // added this hack to get rid of underline in the barcode
        // this worked on windows, but the text did not show up on linux
        // that is why we decided to abandon the text all the way
        // and add it ourselves
        /*
        BarcodeImageHandler.writePNG(barcode, baos);
        File bcImg = File.createTempFile("bc-", ".png");
        bcImg.deleteOnExit();
        byte[] imageBytes = baos.toByteArray();
        FileOutputStream fos = new FileOutputStream(bcImg);
        BarcodeImageHandler.writePNG(barcode, fos);
        */
        //
        // old
        ImageIO.write(bi, "png", baos);
        byte[] imageBytes = baos.toByteArray();
        //
        Image barCodeImage = Image.getInstance(imageBytes);

        barCodeImage.setRotationDegrees(90f);
        // barCodeImage.scalePercent(35f);
        barCodeImage.scalePercent(35f, 50f);
        // float widthf = barCodeImage.getWidth();
        // float heightf = barCodeImage.getHeight();

        cell = new PdfPCell(barCodeImage);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setPadding(0);
        cell.setLeading(0f, 0f);
        // cell.setFixedHeight(81f);
        table.addCell(cell);
        //
        // the barcode text that we added underneath the barcode
        //
        int textWidth = 53, textHeight = 50;
        BufferedImage bi2 = new BufferedImage(textWidth, textHeight, BufferedImage.TYPE_BYTE_BINARY);
        Graphics2D g = bi2.createGraphics();
        g.setFont(new java.awt.Font("Verdana", java.awt.Font.PLAIN, 10));
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, textWidth, textHeight);
        g.setColor(Color.BLACK);
        g.drawString("" + seq, 5, 10);

        g.dispose();
        baos = new ByteArrayOutputStream();
        ImageIO.write(bi2, "png", baos);
        imageBytes = baos.toByteArray();
        Image barCodeTextImage = Image.getInstance(imageBytes);

        barCodeTextImage.setRotationDegrees(90f);
        cell = new PdfPCell(barCodeTextImage);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setPadding(0);
        cell.setLeading(0f, 0f);
        table.addCell(cell);
        //
        phrase = new Phrase();
        ch = new Chunk("\nThis certificate is not refundable and cannot be replaced if lost or stolen.\n\n",
                fnts);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setFixedHeight(34f);
        table.addCell(cell);

        phrase = new Phrase();
        ch = new Chunk("\nMust have official stamp to be valid.\n\n", fnts);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setColspan(3);
        table.addCell(cell);
        document.add(table);
        //
        float[] widths4 = { 40f, 60f }; // percentages         
        table = new PdfPTable(widths4);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        table.setSpacingBefore(0f);
        table.setSpacingAfter(0f);
        phrase = new Phrase();
        ch = new Chunk("APPROVED BY THE STATE BOARD OF ACCOUNTS\nFOR THE CITY OF BLOOMINGTON, IN 2007\n\n\n",
                fnts);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);

        cell.setFixedHeight(40f); // 40
        table.addCell(cell);
        phrase = new Phrase();
        ch = new Chunk(
                "VENDERS SHALL REDEEM THIS CERTIFICATE THROUGH BLOOMINGTON'S\nPARKS & REC DEPT. BY DECEMBER 15TH OF THE YEAR ISSUED\n\n\n",
                fnts);
        phrase.add(ch);
        cell = new PdfPCell(phrase);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        document.add(table);
    } catch (Exception ex) {
        System.err.println(ex);
    }

}