Example usage for com.itextpdf.layout.property VerticalAlignment MIDDLE

List of usage examples for com.itextpdf.layout.property VerticalAlignment MIDDLE

Introduction

In this page you can find the example usage for com.itextpdf.layout.property VerticalAlignment MIDDLE.

Prototype

VerticalAlignment MIDDLE

To view the source code for com.itextpdf.layout.property VerticalAlignment MIDDLE.

Click Source Link

Usage

From source file:com.asptt.plongee.resa.util.UtilsFSpdf.java

private Table createEntete(FicheSecurite fs, int numeroPage, int nbPage) throws java.io.IOException {
        float[] columnWidths = { 20, 27, 23, 23, 6 };
        // table : premiere table pour les parametres de la plonge
        Table table = new Table(columnWidths);
        table.setMargins(0, 0, 0, 0);/*from w  ww .j av a2 s  . c o m*/
        table.setWidthPercent(100);
        // entete style pour les entetes
        Style entete = new Style();
        PdfFont fontEntete = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
        entete.setFont(fontEntete).setFontSize(12);
        entete.setFontColor(Color.BLACK);
        // style pour les libells
        Style libelle = new Style();
        PdfFont fontLibelle = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
        libelle.setFont(fontLibelle).setFontSize(12);
        libelle.setFontColor(Color.RED);

        Paragraph entete1 = new Paragraph();
        entete1.add(new Text("DATE\n").addStyle(entete));
        entete1.add(new Text("DIRECTEUR DE PLONGEE\n").addStyle(entete));
        entete1.add(new Text("PILOTE DU BATEAU\n").addStyle(entete));
        entete1.add(new Text("LIEU DE PLONGEE\n").addStyle(entete));
        entete1.add(new Text("METEO\n").addStyle(entete));

        Paragraph libelle1 = new Paragraph();
        libelle1.add(new Text(": " + ResaUtil.getDateString(fs.getDatePlongee()) + "\n").addStyle(libelle));
        libelle1.add(new Text(": " + fs.getNomDP() + "\n").addStyle(libelle));
        libelle1.add(new Text(": " + fs.getNomPilote() + "\n").addStyle(libelle));
        libelle1.add(new Text(": " + fs.getSite() + "\n").addStyle(libelle));
        libelle1.add(new Text(": " + fs.getMeteo() + "\n").addStyle(libelle));

        Cell cellEntete1 = new Cell();
        cellEntete1.add(entete1);
        cellEntete1.setBorderRight(Border.NO_BORDER);
        cellEntete1.setHorizontalAlignment(HorizontalAlignment.LEFT);
        table.addCell(cellEntete1);

        Cell cellLibelle1 = new Cell();
        cellLibelle1.add(libelle1);
        cellLibelle1.setBorderLeft(Border.NO_BORDER);
        cellLibelle1.setTextAlignment(TextAlignment.LEFT);
        table.addCell(cellLibelle1);

        Paragraph titre = new Paragraph();
        titre.add(new Text("ASPTT MARSEILLE\n").addStyle(entete));
        titre.add(new Text("PLONGEE\n").addStyle(entete));
        titre.add(new Text("---\n").addStyle(entete));
        titre.add(new Text("Fiche de Scurit\n").addStyle(entete));

        Cell cellTitre = new Cell();
        cellTitre.add(titre);
        cellTitre.setTextAlignment(TextAlignment.CENTER);
        cellTitre.setVerticalAlignment(VerticalAlignment.MIDDLE);
        table.addCell(cellTitre);

        Paragraph entete2 = new Paragraph();
        entete2.add(new Text("PLONGEE NUMERO\n").addStyle(entete));
        entete2.add(new Text("NOMBRE DE PLONGEURS\n").addStyle(entete));
        entete2.add(new Text("HEURE DE DEPART\n").addStyle(entete));
        entete2.add(new Text("HEURES BATEAU\n").addStyle(entete));
        entete2.add(new Text("Page \n").addStyle(entete));

        Paragraph libelle2 = new Paragraph();
        libelle2.add(new Text(": " + fs.getNumeroPlongee() + "\n").addStyle(libelle));
        libelle2.add(new Text(": " + fs.getNbPlongeurs() + "\n").addStyle(libelle));
        libelle2.add(new Text(": " + fs.getHhDepart() + ":" + fs.getMnDepart() + "\n").addStyle(libelle));
        libelle2.add(new Text(": " + fs.getNbHeuresBateau() + "\n").addStyle(libelle));
        libelle2.add(new Text(": " + numeroPage + " / " + nbPage + "\n").addStyle(libelle));

        Cell cellEntete2 = new Cell();
        cellEntete2.add(entete2);
        cellEntete2.setBorderRight(Border.NO_BORDER);
        cellEntete2.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        table.addCell(cellEntete2);

        Cell cellLibelle2 = new Cell();
        cellLibelle2.add(libelle2);
        cellLibelle2.setBorderLeft(Border.NO_BORDER);
        cellLibelle2.setTextAlignment(TextAlignment.LEFT);
        table.addCell(cellLibelle2);

        return table;
    }