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

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

Introduction

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

Prototype

public void setVerticalAlignment(int verticalAlignment) 

Source Link

Document

Sets the vertical alignment for the cell.

Usage

From source file:airportpainter.util.AirportPainter.java

License:Open Source License

private void createSheets2ILS(Airport airport, Document document) {
    // FREQs Nearest Navaid
    notifyAction("createSheets2ILS");
    PdfPTable table = new PdfPTable(2);
    {//w  w  w. ja va2s.  c o m
        PdfPCell cell = new PdfPCell();
        {
            Paragraph p = new Paragraph("(TWR)", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
                    com.lowagie.text.Font.NORMAL));
            p.setLeading((p.leading() / 2) + 2);
            cell.addElement(p);
        }

        List<ATCFreq> tempFreqsTwr = _airport.getATCFreqs("54");
        List<ATCFreq> tempFreqsGnd = _airport.getATCFreqs("53");
        if (tempFreqsTwr.size() > 0 || tempFreqsGnd.size() > 0) {

            if (tempFreqsTwr.size() > 0) {
                Paragraph p = new Paragraph();
                p.setLeading((p.leading() / 2) + 6);
                Chunk c = new Chunk(airport.getName().toUpperCase() + " APPROACH ", new com.lowagie.text.Font(
                        com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL));
                p.add(c);
                for (final ATCFreq tower : tempFreqsTwr) {
                    Chunk c2 = new Chunk((tower.getFreq() + "        ").substring(0, 9) + " ",
                            new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
                                    com.lowagie.text.Font.BOLD));
                    p.add(c2);

                }
                cell.addElement(p);

            }

            if (tempFreqsGnd.size() > 0) {
                Paragraph p = new Paragraph();
                p.setLeading((p.leading() / 2) + 6);
                Chunk c = new Chunk("GROUND ", new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
                        com.lowagie.text.Font.NORMAL));
                p.add(c);
                for (final ATCFreq tower : tempFreqsGnd) {
                    Chunk c2 = new Chunk((tower.getFreq() + "        ").substring(0, 9) + " ",
                            new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
                                    com.lowagie.text.Font.BOLD));
                    p.add(c2);

                }
                cell.addElement(p);

            }

        }

        cell.setBorderWidth(borderWidth);
        cell.setBorderWidthTop(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);

        //cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);
    }

    {
        com.lowagie.text.Font font = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN,
                com.lowagie.text.Font.DEFAULTSIZE, com.lowagie.text.Font.NORMAL);
        PdfPCell cell = new PdfPCell();

        Paragraph p = new Paragraph();
        p.setLeading((p.leading()) + 6);
        Chunk c = new Chunk("ATIS ",
                new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.NORMAL));
        p.add(c);

        for (final Atis atis : _airport.getAtises()) {
            Chunk c2 = new Chunk((atis.getFreq() + "        ").substring(0, 9) + " ", new com.lowagie.text.Font(
                    com.lowagie.text.Font.TIMES_ROMAN, 8, com.lowagie.text.Font.BOLD));
            p.add(c2);
        }

        cell.addElement(p);

        /// ILS table
        {
            height1 = 0;
            PdfPTable tableILS = new PdfPTable(4);
            tableILS.setWidthPercentage(100);

            // titles
            com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
                    com.lowagie.text.Font.NORMAL);
            {
                PdfPCell cellTitle = new PdfPCell();
                cellTitle.setVerticalAlignment(Element.ALIGN_CENTER);
                cellTitle.setBorderWidth(borderWidthThin);
                Paragraph pt = new Paragraph("RWY", fontTitle);
                pt.setLeading((pt.leading() / 2) + 2);
                pt.setAlignment(Element.ALIGN_CENTER);
                cellTitle.addElement(pt);
                tableILS.addCell(cellTitle);
            }
            {
                PdfPCell cellTitle = new PdfPCell();
                cellTitle.setVerticalAlignment(Element.ALIGN_CENTER);
                cellTitle.setBorderWidth(borderWidthThin);
                Paragraph pt = new Paragraph("ILS", fontTitle);
                pt.setLeading((pt.leading() / 2) + 2);
                pt.setAlignment(Element.ALIGN_CENTER);
                cellTitle.addElement(pt);
                tableILS.addCell(cellTitle);
            }
            {
                PdfPCell cellTitle = new PdfPCell();
                cellTitle.setVerticalAlignment(Element.ALIGN_CENTER);
                cellTitle.setBorderWidth(borderWidthThin);
                Paragraph pt = new Paragraph("RWY", fontTitle);
                pt.setLeading((pt.leading() / 2) + 2);
                pt.setAlignment(Element.ALIGN_CENTER);
                cellTitle.addElement(pt);
                tableILS.addCell(cellTitle);
            }
            {
                PdfPCell cellTitle = new PdfPCell();
                cellTitle.setVerticalAlignment(Element.ALIGN_CENTER);
                cellTitle.setBorderWidth(borderWidthThin);
                Paragraph pt = new Paragraph("ILS", fontTitle);
                pt.setLeading((pt.leading() / 2) + 2);
                pt.setAlignment(Element.ALIGN_CENTER);
                cellTitle.addElement(pt);
                tableILS.addCell(cellTitle);
            }

            int pos = 0;
            int rs = airport.getRunways().size();
            for (final Runway runway : airport.getRunways()) {
                if (runway.getIlsFreq() != 0) {
                    height1 = height1 + 10;
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph(runway.getNumber(), fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph(
                                runway.getIlsFreq() + " " + "... "
                                        + new Integer((int) runway.getHeading()).toString() + degrees,
                                fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }
                } /*else {
                  {
                      PdfPCell cellFreq = new PdfPCell();
                      cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                      cellFreq.setBorderWidth(borderWidthThin);
                      if (pos>0) {
                          cellFreq.setBorderWidthTop(0);
                      }
                      if (pos<rs-1) {
                          cellFreq.setBorderWidthBottom(0);
                      }
                          
                      Paragraph pt=new Paragraph( "",fontTitle);
                      pt.setLeading((pt.leading()/2)+2);
                      pt.setAlignment(Element.ALIGN_CENTER);
                      cellFreq.addElement(pt);
                      tableILS.addCell(cellFreq);
                  }
                  {
                      PdfPCell cellFreq = new PdfPCell();
                      cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                      cellFreq.setBorderWidth(borderWidthThin);
                      if (pos>0) {
                          cellFreq.setBorderWidthTop(0);
                      }
                      if (pos<rs-1) {
                          cellFreq.setBorderWidthBottom(0);
                      }
                          
                      Paragraph pt=new Paragraph( "",fontTitle);
                      pt.setLeading((pt.leading()/2)+2);
                      pt.setAlignment(Element.ALIGN_CENTER);
                      cellFreq.addElement(pt);
                      tableILS.addCell(cellFreq);
                  }
                          
                  }*/

                if (runway.getIlsOppositeFreq() != 0) {
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph(runway.getOppositeNumber(), fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph(runway.getIlsOppositeFreq() + " " + "... "
                                + new Integer((int) (runway.getHeading() + 180) % 180).toString() + degrees,
                                fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }
                } else {
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph("", fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }
                    {
                        PdfPCell cellFreq = new PdfPCell();
                        cellFreq.setVerticalAlignment(Element.ALIGN_CENTER);
                        cellFreq.setBorderWidth(borderWidthThin);
                        if (pos > 0) {
                            cellFreq.setBorderWidthTop(0);
                        }
                        if (pos < rs - 1) {
                            cellFreq.setBorderWidthBottom(0);
                        }

                        Paragraph pt = new Paragraph("", fontTitle);
                        pt.setLeading((pt.leading() / 2) + 2);
                        pt.setAlignment(Element.ALIGN_CENTER);
                        cellFreq.addElement(pt);
                        tableILS.addCell(cellFreq);
                    }

                }

                pos++;

            }

            float[] widths2 = { 1f, 3f, 1f, 3f };
            try {
                tableILS.setWidths(widths2);
            } catch (DocumentException ex) {
                Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
            }

            cell.addElement(tableILS);
        }

        cell.setBorderWidth(borderWidth);
        cell.setVerticalAlignment(Element.ALIGN_TOP);

        table.addCell(cell);
    }

    table.setWidthPercentage(100);
    try {
        document.add(table);
    } catch (DocumentException ex) {
        Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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);// w w  w . j  a  v a  2 s  . c om
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    int total = 0;
    PdfPCell cell;
    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  w  w .  j  av  a2  s  .  co  m
        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  .  ja  v  a  2s  .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.AssetHoldingByDateReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(this.getText("LABEL_CREATION_DATE"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);/* www.  j  a v  a  2 s  . c o m*/
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(this.getText("REPORTS_ASSET_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.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_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.getBoldChunk(this.getText("LABEL_DATE_TUMBLING"))));
    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.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 w  w . j  av a2 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.AssetHoldingFullReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(this.getText("LABEL_SERIAL"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(6);/*ww w  .  ja  v a  2s  .  co m*/
    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_ASSET_HOLDING"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(3);
    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_HOLDING"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setColspan(11);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);
}

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  w w w .jav a2 s .  c  o m*/
    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.AssetHoldingReport.java

License:Open Source License

private void createHeader(PdfPTable table) {
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(this.getBoldChunk(this.getText("REPORTS_ASSET_HOLDING"))));
    cell.setBackgroundColor(headerBgColor);
    cell.setBorderWidth(headerBorderWidth);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);/*from  w ww .j a v a2  s . c o  m*/
    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_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_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_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.BaseBiblivreReport.java

License:Open Source License

@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {/*w w  w .ja  v a  2  s  . co m*/
        Rectangle page = document.getPageSize();

        PdfPTable head = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph(this.getText("REPORTS_HEADER")));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.BOTTOM);
        head.addCell(cell);
        head.setTotalWidth((page.width() / 2) - document.leftMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

        PdfPTable date = new PdfPTable(1);
        PdfPCell dateCell = new PdfPCell(new Paragraph(dateFormat.format(generationDate)));
        dateCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        dateCell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        dateCell.setBorder(Rectangle.BOTTOM);
        date.addCell(dateCell);
        date.setTotalWidth((page.width() / 2) - document.rightMargin());
        date.writeSelectedRows(0, -1, (page.width() / 2),
                page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

        PdfPTable foot = new PdfPTable(1);
        Chunk pageNumber = new Chunk(String.valueOf(document.getPageNumber()));
        pageNumber.setFont(footerFont);
        cell = new PdfPCell(new Paragraph(pageNumber));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        foot.addCell(cell);
        foot.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
                writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}