Example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage.

Prototype

public void setWidthPercentage(final float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

From source file:pdf.PDFDesign.java

private PdfPCell createEuro_6_Cell(Item item) throws DocumentException {
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);

    PdfPCell cell;/*from   w  w w . ja  va2s .  c om*/
    Paragraph p;

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 13, Font.NORMAL, color));
    String t = item.getTitle();
    String[] split = t.split("//");
    for (String split1 : split) {
        p.add(split1 + "\n");
    }
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setPhrase(p);
    cell.setColspan(2);
    cell.setFixedHeight(30f);
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 11, Font.NORMAL, color));
    p.add(item.getAmount() + "" + item.getUnit());
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    table.addCell(cell);

    table.addCell(createEuro_6_InnerPrice(item));

    cell = new PdfPCell();
    p = new Paragraph();
    p.setFont(new Font(droidsans, 11, Font.NORMAL, color));
    p.add("Cena za 1" + item.getXUnit() + ": " + item.getUnitPrice() + item.getCurrency() + "/"
            + item.getSecondUnitPrice() + item.getSecondCurrency());
    cell.setPhrase(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(0);
    table.addCell(cell);

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setFixedHeight(cellHeight);//175f
    finalCell.setBorderColor(BaseColor.GRAY);
    return finalCell;
}

From source file:pdf.PDFDesign.java

private PdfPCell createEuro_6_InnerPrice(Item item) throws DocumentException {
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);

    table.addCell(createEuro_6_InnerInnerPrice(item.getPrice(), item.getCurrency(), true));
    table.addCell(createEuro_6_InnerInnerPrice(item.getSecondPrice(), item.getSecondCurrency(), false));

    PdfPCell finalCell = new PdfPCell(table);
    finalCell.setBorder(0);//from  w  w w.  j av a 2 s .c  o  m
    return finalCell;
}

From source file:PDF.PDFTrackGenerator.java

License:Open Source License

/**
 * Metda generateTrackPDFA4 sli na samotn vygenerovanie PDF dokumentu trasy na formt A4.
 * @param lineWeight - hrbka ?iary trasy na mape
 * @param color - farba ?iary trasy na mape
 * @param width - rka mapy//from ww w  .j av  a  2 s.c om
 * @param height - vka mapy
 * @param scale - klovacia kontanta mapy (n x rozlenie mapy)
 * @param startDate - dtum a ?as prvho bodu trasy
 * @param endDate - dtum a ?as poslednho bodu trasy
 * @param activity - aktivita trasy
 * @param user - pouvate (majite) trasy
 */
public void generateTrackPDFA4(int lineWeight, String color, int width, int height, int scale, String startDate,
        String endDate, String activity, String user) {
    try {
        Document doc = new Document();
        PdfWriter.getInstance(doc, new FileOutputStream(path + fileName + ".pdf"));
        doc.open();

        Font nadpisFont = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);

        Font detailyFont = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL);

        Paragraph nadpisPar = new Paragraph();

        nadpisPar.setAlignment(Element.ALIGN_CENTER);

        Phrase nadpis = new Phrase(fileName, nadpisFont);

        nadpisPar.add(nadpis);

        nadpisPar.add("");

        doc.add(nadpisPar);
        doc.add(Chunk.NEWLINE);

        PdfPTable tabulka = new PdfPTable(2);
        tabulka.setWidthPercentage(100);
        float[] columnWidth = { 6f, 4f };
        tabulka.setWidths(columnWidth);

        StaticMapResolver res = new StaticMapResolver(loader);

        String mapUrl = res.getStaticMapTrackURLWithMultimedia(lineWeight, color, width, height, scale);

        Image img = Image.getInstance(new URL(mapUrl));
        //img.scalePercent(50);
        PdfPCell riadokSObr = new PdfPCell(img, true);
        riadokSObr.setBorder(Rectangle.NO_BORDER);
        riadokSObr.setPaddingBottom(10f);
        PdfPCell riadokSText = new PdfPCell(new Phrase("Description: " + loader.getTrackDescription()
                + "\n\n\nTrack activity: " + activity.substring(4) + "\n\n\nStart place: "
                + loader.getStartAddress() + "\n\n\nEnd Place: " + loader.getEndAddress()
                + "\n\n\nTrack length: " + loader.getLength() + " km\n\n\nMin elevation: "
                + loader.getMinElevation() + " m\n\n\nMax elevation: " + loader.getMaxElevation()
                + " m\n\n\nHeight difference: " + loader.getHeightDiff() + " m\n\n\nStart: " + startDate
                + "\n\n\nEnd: " + endDate + "\n\n\nDuration: " + loader.getDuration(), detailyFont));
        riadokSText.setBorder(Rectangle.NO_BORDER);
        riadokSText.setPaddingLeft(20f);
        riadokSText.setPaddingTop(5f);
        riadokSText.setPaddingBottom(10f);
        tabulka.addCell(riadokSObr);
        tabulka.addCell(riadokSText);

        doc.add(tabulka);
        //doc.add(new Phrase("\n", detailyFont));

        PdfPTable obrTabulka = new PdfPTable(3);
        obrTabulka.setWidthPercentage(100);

        ArrayList<String> goodFiles = new ArrayList<String>();
        for (int i = 0; i < loader.getMultimediaFiles().size(); i++) {
            if (!loader.getMultimediaFiles().get(i).getPath().startsWith("YTB")) {
                String extension = loader.getMultimediaFiles().get(i).getPath().substring(
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf("."),
                        loader.getMultimediaFiles().get(i).getPath().length());
                String newPath = loader.getMultimediaFiles().get(i).getPath().substring(0,
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf(".")) + "_THUMB" + extension;
                goodFiles.add(newPath);
            }
        }

        if (!goodFiles.isEmpty()) {
            int freeCount = 9;
            if (goodFiles.size() <= 9) {
                for (int i = 0; i < goodFiles.size(); i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
                for (int i = 0; i < 9 - goodFiles.size(); i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else if (goodFiles.size() <= 18) {
                for (int i = 0; i < 9; i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else {
                for (int i = 0; i < (goodFiles.size() % 9); i++) {
                    goodFiles.remove(goodFiles.size() - 1 - i);
                }

                int counting = (goodFiles.size() / 9);

                for (int i = 0; i < goodFiles.size(); i = i + counting) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                    freeCount--;
                }
                for (int i = 0; i < freeCount; i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            }
        }

        doc.add(obrTabulka);

        Font lastFont = new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC);
        Phrase lastText = new Phrase("This PDF document was generated by gTrax app for user " + user, lastFont);
        doc.add(lastText);

        doc.close();
    } catch (Exception ex) {
        FileLogger.getInstance()
                .createNewLog("ERROR: Cannot CREATE PDF for track " + fileName + " for user " + user + " !!!");
        System.out.println("pruser");
    }

}

From source file:pdf.PdfUtility.java

private Paragraph addTableEntry(Achievement a) {
    PdfPTable mainTable = new PdfPTable(new float[] { 1f, 5f });
    mainTable.setWidthPercentage(100f);
    mainTable.setSpacingBefore(0f);/*ww  w  .  ja  v  a2 s  .  c  om*/
    mainTable.setSpacingAfter(0f);

    PdfPCell datesCell = getDateCell(a);
    PdfPCell summaryCell = getSummaryCell(a);
    mainTable.addCell(datesCell);
    mainTable.addCell(summaryCell);

    Paragraph current = new Paragraph();
    current.setAlignment(Paragraph.ALIGN_LEFT);
    //current.setSpacingBefore(10f);
    current.add(mainTable);
    return current;
}

From source file:PDF.Reportes.java

public static ArrayList<PdfPTable> tablaAspAula(String usuario, String contra, String horario, int opc)
        throws DocumentException {
    ArrayList<PdfPTable> tablas = new ArrayList();
    //        IngresoAbd bd = new IngresoAbd(usuario, contra);
    List<Beans.Reportes> reportes = ReportesDAO.AspPAula(usuario, contra, horario, opc);
    PdfPTable table = new PdfPTable(2);
    //        reportes = bd.AspPAula(horario, opc);
    PdfPCell cell;//from  www . j a v  a 2s  .com
    String carrera = "", fecha = "";
    if (reportes.isEmpty()) {

        cell = new PdfPCell(
                new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte."));
        cell.setColspan(5);
        table.addCell(cell);
        tablas.add(table);

    } else if (reportes.get(0).getCodError() != 0) {

        if (reportes.get(0).getCodError() == -1) {
            cell = new PdfPCell(new Phrase(Constants.ERROR1));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -2) {
            cell = new PdfPCell(new Phrase(Constants.ERROR3));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -3) {
            cell = new PdfPCell(new Phrase(Constants.ERROR2));
            cell.setColspan(5);
            table.addCell(cell);
        }
        tablas.add(table);
    } else {
        table = new PdfPTable(5);
        BaseColor color = new BaseColor(217, 217, 217);
        BaseColor colorB = new BaseColor(0, 0, 0);
        cell = new PdfPCell(new Phrase("Ficha(5)", FontFactory.getFont("arial", 12, colorB)));
        cell.setMinimumHeight(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);

        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Folio Ceneval(6)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Nombre(7)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);

        //            cell = new PdfPCell(new Phrase("Nombre carrera", FontFactory.getFont("arial", 12, colorB)));
        //            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        //             cell.setBackgroundColor(color);
        //             cell.setBorderColor(colorB);
        //            table.addCell(cell);
        cell = new PdfPCell(new Phrase("Asistencia(8)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setColspan(2);
        table.addCell(cell);
        //            cell = new PdfPCell(new Phrase("Firma", FontFactory.getFont("arial", 12, colorB)));
        //            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        //             cell.setBackgroundColor(color);
        //             cell.setBorderColor(colorB);
        //            table.addCell(cell);

        for (int i = 0; i < reportes.size(); i++) {

            cell = new PdfPCell(new Phrase(reportes.get(i).getFicha()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getFolio()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getNombre(), FontFactory.getFont("arial", 10)));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);

            carrera = reportes.get(i).getNom_carrera();
            //               
            cell = new PdfPCell(new Phrase(reportes.get(i).getAsist()));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getFirma()));
            table.addCell(cell);
            fecha = reportes.get(i).getFecha();
            if ((i % 34 == 0 || (i + 1) == reportes.size()) && i != 0) {

                table.setWidthPercentage(110);
                table.setWidths(new int[] { 25, 30, 120, 15, 15 });
                tablas.add(table);
                table = new PdfPTable(5);
            }
        }
        String datos[] = horario.split(" ");
        String edificio = datos[0];
        String aula = "";
        if (edificio.length() == 2) {
            edificio = datos[0].charAt(0) + "";
            aula = datos[0].charAt(1) + "";
        }
        if (edificio.length() == 4) {

            edificio = datos[0].charAt(0) + "" + datos[0].charAt(1);
            aula = "" + datos[0].charAt(3);
        }
        if (edificio.length() == 5) {

            edificio = datos[0].charAt(0) + "" + datos[0].charAt(1);
            aula = "" + datos[0].charAt(3) + datos[0].charAt(4);
        }
        PdfPTable tableH = new PdfPTable(7);
        tableH.setTotalWidth(500);
        cell.setMinimumHeight(20);
        cell = new PdfPCell(new Phrase("CARRERA:(1)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(carrera));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("FECHA DE EXAMEN:(2)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(fecha));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("EDIFICIO:(3)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(edificio));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("AULA:(4)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(aula));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);

        tablas.add(tableH);
    }

    return tablas;
}

From source file:PDF.Reportes.java

public static ArrayList<PdfPTable> firmasAspAula(String usuario, String contra, String horario, int opc)
        throws DocumentException {
    ArrayList<PdfPTable> tablas = new ArrayList();
    //        IngresoAbd bd = new IngresoAbd(usuario, contra);
    List<Beans.Reportes> reportes;
    PdfPTable table = new PdfPTable(2);
    reportes = ReportesDAO.AspPAula(usuario, contra, horario, opc);
    //        reportes = bd.AspPAula(horario, opc);
    String carrera = "", fecha = "";
    if (reportes.isEmpty()) {
        PdfPCell cell;// www. j ava2  s . c o  m
        cell = new PdfPCell(
                new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte."));
        cell.setColspan(5);
        table.addCell(cell);
        tablas.add(table);
    } else if (reportes.get(0).getCodError() != 0) {
        PdfPCell cell;
        if (reportes.get(0).getCodError() == -1) {
            cell = new PdfPCell(new Phrase(Constants.ERROR1));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -2) {
            cell = new PdfPCell(new Phrase(Constants.ERROR3));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -3) {
            cell = new PdfPCell(new Phrase(Constants.ERROR2));
            cell.setColspan(5);
            table.addCell(cell);
        }
        tablas.add(table);
    } else {
        PdfPCell cell;
        table = new PdfPTable(6);
        BaseColor color = new BaseColor(217, 217, 217);
        BaseColor colorB = new BaseColor(0, 0, 0);
        cell = new PdfPCell(new Phrase("Ficha(5)", FontFactory.getFont("arial", 12, colorB)));
        cell.setMinimumHeight(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);

        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Folio Ceneval(6)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Nombre(7)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);

        //            cell = new PdfPCell(new Phrase("Nombre carrera", FontFactory.getFont("arial", 12, colorB)));
        //            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        //             cell.setBackgroundColor(color);
        //             cell.setBorderColor(colorB);
        //            table.addCell(cell);
        cell = new PdfPCell(new Phrase("Asistencia(8)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setColspan(2);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Firma(9)", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);

        for (int i = 0; i < reportes.size(); i++) {
            cell = new PdfPCell(new Phrase(reportes.get(i).getFicha()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getFolio()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getNombre(), FontFactory.getFont("arial", 10)));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);

            carrera = reportes.get(i).getNom_carrera();
            //               
            cell = new PdfPCell(new Phrase(reportes.get(i).getAsist()));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reportes.get(i).getFirma()));
            table.addCell(cell);

            table.addCell(cell);
            fecha = reportes.get(i).getFecha();

            if ((i % 34 == 0 || (i + 1) == reportes.size()) && i != 0) {

                table.setWidthPercentage(110);
                table.setWidths(new int[] { 25, 30, 90, 15, 15, 30 });
                tablas.add(table);
                table = new PdfPTable(6);
            }
        }
        String datos[] = horario.split(" ");
        String edificio = datos[0];
        String aula = "";
        if (edificio.length() == 2) {
            edificio = datos[0].charAt(0) + "";
            aula = datos[0].charAt(1) + "";
        }
        if (edificio.length() == 4) {

            edificio = datos[0].charAt(0) + "" + datos[0].charAt(1);
            aula = "" + datos[0].charAt(3);
        }
        if (edificio.length() == 5) {

            edificio = datos[0].charAt(0) + "" + datos[0].charAt(1);
            aula = "" + datos[0].charAt(3) + datos[0].charAt(4);
        }
        PdfPTable tableH = new PdfPTable(7);
        tableH.setTotalWidth(500);
        cell.setMinimumHeight(20);
        cell = new PdfPCell(new Phrase("CARRERA:(1)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(carrera));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("FECHA DE EXAMEN:(2)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(fecha));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("EDIFICIO:(3)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(edificio));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase("AULA:(4)", FontFactory.getFont("arial", 11)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);
        cell = new PdfPCell(new Phrase(aula));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableH.addCell(cell);

        tablas.add(tableH);

    }

    return tablas;
}

From source file:PDF.Reportes.java

public static PdfPTable noaltaCen(String usuario, String contra) throws DocumentException {
    PdfPTable table = new PdfPTable(5);
    //        IngresoAbd bd = new IngresoAbd(usuario, contra);
    List<Beans.Reportes> reportes;
    reportes = ReportesDAO.noAltaCen(usuario, contra);
    //        reportes = bd.noAltaCen();
    if (reportes.isEmpty()) {
        PdfPCell cell;/* ww  w. jav  a2  s . c o m*/
        cell = new PdfPCell(
                new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte."));
        cell.setColspan(5);
        table.addCell(cell);
    } else if (reportes.get(0).getCodError() != 0) {
        PdfPCell cell;
        if (reportes.get(0).getCodError() == -1) {
            cell = new PdfPCell(new Phrase(Constants.ERROR1));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -2) {
            cell = new PdfPCell(new Phrase(Constants.ERROR3));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -3) {
            cell = new PdfPCell(new Phrase(Constants.ERROR2));
            cell.setColspan(5);
            table.addCell(cell);
        }
        //            cell = new PdfPCell(new Phrase(reportes.get(0).getMsjError()));
    } else {
        BaseColor color = new BaseColor(69, 161, 240);
        BaseColor colorB = new BaseColor(255, 255, 255);
        PdfPCell cell;
        cell = new PdfPCell(new Phrase("Preficha", FontFactory.getFont("arial", 12, colorB)));
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Ref. Bancaria", FontFactory.getFont("arial", 12, colorB)));
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Correo", FontFactory.getFont("arial", 12, colorB)));
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Usuario", FontFactory.getFont("arial", 12, colorB)));
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("ltima Act.", FontFactory.getFont("arial", 12, colorB)));
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        for (Beans.Reportes reporte : reportes) {
            cell = new PdfPCell(new Phrase(reporte.getPreficha()));
            cell.setBorderColor(color);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getReferencia()));
            cell.setBorderColor(color);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getCorreo()));
            cell.setBorderColor(color);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getUsuario()));
            cell.setBorderColor(color);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getUl_act().substring(0, 10)));
            cell.setBorderColor(color);
            table.addCell(cell);

        }

        table.setWidthPercentage(110);
        table.setWidths(new int[] { 50, 55, 100, 56, 56 });
    }

    return table;
}

From source file:PDF.Reportes.java

public static PdfPTable procesoCon(String usuario, String contra) throws DocumentException {

    //        IngresoAbd bd = new IngresoAbd(usuario, contra);
    List<Beans.Reportes> reportes;
    reportes = ReportesDAO.procesoCon(usuario, contra);
    //        reportes = bd.procesoCon();
    PdfPTable table = new PdfPTable(2);

    if (reportes.isEmpty()) {
        PdfPCell cell;//  w  w  w. j  a va2  s  .  c o m
        cell = new PdfPCell(
                new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte."));
        cell.setColspan(5);
        table.addCell(cell);
    } else if (reportes.get(0).getCodError() != 0) {
        PdfPCell cell;
        if (reportes.get(0).getCodError() == -1) {
            cell = new PdfPCell(new Phrase(Constants.ERROR1));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -2) {
            cell = new PdfPCell(new Phrase(Constants.ERROR3));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -3) {
            cell = new PdfPCell(new Phrase(Constants.ERROR2));
            cell.setColspan(5);
            table.addCell(cell);
        }
        //            cell = new PdfPCell(new Phrase(reportes.get(0).getMsjError()));
    } else {
        BaseColor color = new BaseColor(69, 161, 240);
        BaseColor colorB = new BaseColor(255, 255, 255);
        PdfPCell cell;
        cell = new PdfPCell(new Phrase("Carrera", FontFactory.getFont("arial", 12, colorB)));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(colorB);
        cell.setBackgroundColor(color);
        table.addCell(cell);
        cell = new PdfPCell(
                new Phrase("No. de pre procesos concluidos", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(colorB);

        cell.setBackgroundColor(color);
        table.addCell(cell);
        int total = 0;
        for (Beans.Reportes reporte : reportes) {

            cell = new PdfPCell(new Phrase(reporte.getNombre(), FontFactory.getFont("arial", 8)));

            cell.setBorderColor(color);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getPreproc()));

            cell.setBorderColor(color);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            total = total + Integer.parseInt(reporte.getPreproc());
            table.addCell(cell);
        }

        cell = new PdfPCell(new Phrase("Total", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(colorB);
        cell.setBackgroundColor(color);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(Integer.toString(total), FontFactory.getFont("arial", 12)));
        cell.setBorderColor(color);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        table.setWidthPercentage(110);

    }

    return table;
}

From source file:PDF.Reportes.java

public static PdfPTable statusfichas(String usuario, String contra) throws DocumentException {

    //        IngresoAbd bd = new IngresoAbd(usuario, contra);
    List<Beans.Reportes> reportes;
    reportes = ReportesDAO.statusFichas(usuario, contra);
    //        reportes = bd.statusFichas();

    PdfPTable table = new PdfPTable(4);
    if (reportes.isEmpty()) {

        PdfPCell cell;/*  ww  w . j a  va 2  s.  c  o  m*/
        cell = new PdfPCell(
                new Phrase("Lo sentimos, por el momento an no existe informacin para este reporte."));
        cell.setColspan(5);
        table.addCell(cell);
    } else if (reportes.get(0).getCodError() != 0) {
        PdfPCell cell;
        if (reportes.get(0).getCodError() == -1) {
            cell = new PdfPCell(new Phrase(Constants.ERROR1));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -2) {
            cell = new PdfPCell(new Phrase(Constants.ERROR3));
            cell.setColspan(5);
            table.addCell(cell);
        }
        if (reportes.get(0).getCodError() == -3) {
            cell = new PdfPCell(new Phrase(Constants.ERROR2));
            cell.setColspan(5);
            table.addCell(cell);
        }
        //            cell = new PdfPCell(new Phrase(reportes.get(0).getMsjError()));
    } else {
        BaseColor color = new BaseColor(69, 161, 240);
        BaseColor colorB = new BaseColor(255, 255, 255);
        PdfPCell cell;
        cell = new PdfPCell(new Phrase("Carrera", FontFactory.getFont("arial", 12, colorB)));
        cell.setBorderColor(colorB);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Prefichas", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);

        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Prefichas pagadas", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Pre proceso concluido", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);
        int totalP = 0;
        int totalPp = 0;
        int totalPr = 0;
        for (Beans.Reportes reporte : reportes) {
            cell = new PdfPCell(new Phrase(reporte.getNombre(), FontFactory.getFont("arial", 8)));
            cell.setBorderColor(color);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getPreficha()));
            cell.setBorderColor(color);
            totalP = Integer.parseInt(reporte.getPreficha()) + totalP;
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getPrefpagadas()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorderColor(color);
            totalPp = Integer.parseInt(reporte.getPrefpagadas()) + totalPp;
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(reporte.getPreproc()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorderColor(color);
            totalPr = Integer.parseInt(reporte.getPreproc()) + totalPr;
            table.addCell(cell);

        }
        cell = new PdfPCell(new Phrase("Totales", FontFactory.getFont("arial", 12, colorB)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(color);
        cell.setBorderColor(colorB);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(Integer.toString(totalP), FontFactory.getFont("arial", 12)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(color);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(Integer.toString(totalPp), FontFactory.getFont("arial", 12)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(color);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(Integer.toString(totalPr), FontFactory.getFont("arial", 12)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorderColor(color);
        table.addCell(cell);
        table.setWidthPercentage(110);
        table.setWidths(new int[] { 50, 50, 100, 100 });
    }

    return table;
}

From source file:pdfGenerator.PdfGenerator.java

private PdfPTable createTable(ArrayList<ArrayList<String>> detailsTable) {

    PdfPTable table = new PdfPTable(detailsTable.get(0).size());
    table.setWidthPercentage(100);

    List<String> headers = detailsTable.remove(0);

    for (String header : headers) {
        table.addCell(header);// ww w . j av  a2s.  c o m
    }

    table.setHeaderRows(0);

    for (List<String> studentDetails : detailsTable) {
        for (String studentDetail : studentDetails) {
            PdfPCell cell = new PdfPCell(new Paragraph(studentDetail));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
        }
    }
    return table;
}