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

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

Introduction

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

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_publicaciones() throws Exception {
    PdfPTable tabla_num = new PdfPTable(5);
    int a = 0, b = 0, c = 0, d = 0, e = 0;
    String numberAsString;//from   w  w  w  .j  a va  2  s  . c  o m
    tabla_num.setWidths(new int[] { 2, 2, 2, 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Publicaciones aceptadas", encabezadost));
    PdfPCell boletin = new PdfPCell(new Phrase("Boletnes"));
    PdfPCell sin_nacional = new PdfPCell(new Phrase("Sin arbitraje, Nacional"));
    PdfPCell sin_inter = new PdfPCell(new Phrase("Sin abitraje, Internacional"));
    PdfPCell con_nacional = new PdfPCell(new Phrase("Con arbitraje, Nacional"));
    PdfPCell con_inter = new PdfPCell(new Phrase("Con arbitraje, Internacional"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(5);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    boletin.setHorizontalAlignment(Element.ALIGN_CENTER);
    boletin.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(boletin);

    sin_nacional.setHorizontalAlignment(Element.ALIGN_CENTER);
    sin_nacional.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(sin_nacional);

    sin_inter.setHorizontalAlignment(Element.ALIGN_CENTER);
    sin_inter.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(sin_inter);

    con_nacional.setHorizontalAlignment(Element.ALIGN_CENTER);
    con_nacional.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(con_nacional);

    con_inter.setHorizontalAlignment(Element.ALIGN_CENTER);
    con_inter.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(con_inter);

    /*Aqui van las consultas de las Actividades del profesor*/
    a = getNum2_2(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);
    b = getNum2_2(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);
    c = getNum2_2(4);
    numberAsString = Integer.toString(c);
    tabla_num.addCell(numberAsString);
    d = getNum2_2(5);
    numberAsString = Integer.toString(d);
    tabla_num.addCell(numberAsString);
    e = getNum2_2(6);
    numberAsString = Integer.toString(e);
    tabla_num.addCell(numberAsString);
    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_eventos() throws Exception {
    PdfPTable tabla_num = new PdfPTable(3);
    int a = 0, b = 0, c = 0, d = 0;
    String numberAsString;//  w  w  w  . j a v  a  2  s . c om
    tabla_num.setWidths(new int[] { 2, 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Eventos aceptados", encabezadost));
    PdfPCell sin_ponencia = new PdfPCell(new Phrase("Institucional sin ponencia publicada"));
    PdfPCell resumen_pub = new PdfPCell(new Phrase("Institucional con resumen publicado"));
    PdfPCell pub_exten = new PdfPCell(new Phrase("Institucional publicado en extenso"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(5);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    sin_ponencia.setHorizontalAlignment(Element.ALIGN_CENTER);
    sin_ponencia.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(sin_ponencia);

    resumen_pub.setHorizontalAlignment(Element.ALIGN_CENTER);
    resumen_pub.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(resumen_pub);

    pub_exten.setHorizontalAlignment(Element.ALIGN_CENTER);
    pub_exten.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(pub_exten);

    a = getNum2_3(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);

    b = getNum2_3(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);

    c = getNum2_3(4);
    numberAsString = Integer.toString(c);
    tabla_num.addCell(numberAsString);

    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_proyectos() throws Exception {
    PdfPTable tabla_num = new PdfPTable(2);
    int a = 0, b = 0;
    String numberAsString;/*from  w w  w .  j  a va2s.com*/
    tabla_num.setWidths(new int[] { 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Proyectos SIP aceptados y no acpetados", encabezadost));
    PdfPCell aceptados = new PdfPCell(new Phrase("Aceptados"));
    PdfPCell no_aceptados = new PdfPCell(new Phrase("No aceptados"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(5);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    aceptados.setHorizontalAlignment(Element.ALIGN_CENTER);
    aceptados.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(aceptados);

    no_aceptados.setHorizontalAlignment(Element.ALIGN_CENTER);
    no_aceptados.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(no_aceptados);

    /*Aqui van las consultas de las Actividades del profesor*/
    a = getNum2_4(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);

    b = getNum2_4(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);
    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_obras() throws Exception {
    PdfPTable tabla_num = new PdfPTable(12);
    int a = 0, b = 0, c = 0, d = 0, e, f, g, h, i, j, k, l;
    String numberAsString;//from w  w  w  . ja v  a  2s  .  c o m
    tabla_num.setWidths(new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Obras con derecho de autor aceptadas", encabezadost));
    PdfPCell artis = new PdfPCell(new Phrase("O. A."));
    PdfPCell arqui = new PdfPCell(new Phrase("O. Arqui."));
    PdfPCell fotogra = new PdfPCell(new Phrase("O. Foto."));
    PdfPCell apuntes = new PdfPCell(new Phrase("Manual"));
    PdfPCell cine = new PdfPCell(new Phrase("O. Cine."));
    PdfPCell multimedia = new PdfPCell(new Phrase("Multimedia"));
    PdfPCell tv_show = new PdfPCell(new Phrase("Tv. show"));
    PdfPCell dis_graf = new PdfPCell(new Phrase("Dis. Gra."));
    PdfPCell compilacion = new PdfPCell(new Phrase("O. Compi."));
    PdfPCell libro = new PdfPCell(new Phrase("Ed. Libro"));
    PdfPCell computo = new PdfPCell(new Phrase("P. Com."));
    PdfPCell digital = new PdfPCell(new Phrase("Ma. Dig."));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(12);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    artis.setHorizontalAlignment(Element.ALIGN_CENTER);
    artis.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(artis);

    arqui.setHorizontalAlignment(Element.ALIGN_CENTER);
    arqui.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(arqui);

    fotogra.setHorizontalAlignment(Element.ALIGN_CENTER);
    fotogra.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(fotogra);

    apuntes.setHorizontalAlignment(Element.ALIGN_CENTER);
    apuntes.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(apuntes);

    cine.setHorizontalAlignment(Element.ALIGN_CENTER);
    cine.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(cine);

    multimedia.setHorizontalAlignment(Element.ALIGN_CENTER);
    multimedia.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(multimedia);

    tv_show.setHorizontalAlignment(Element.ALIGN_CENTER);
    tv_show.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(tv_show);

    dis_graf.setHorizontalAlignment(Element.ALIGN_CENTER);
    dis_graf.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(dis_graf);

    compilacion.setHorizontalAlignment(Element.ALIGN_CENTER);
    compilacion.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(compilacion);

    libro.setHorizontalAlignment(Element.ALIGN_CENTER);
    libro.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(libro);

    computo.setHorizontalAlignment(Element.ALIGN_CENTER);
    computo.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(computo);

    digital.setHorizontalAlignment(Element.ALIGN_CENTER);
    digital.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(digital);

    /*Aqui van las consultas de las Actividades del profesor*/
    a = getNum2_5(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);
    b = getNum2_5(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);
    c = getNum2_5(4);
    numberAsString = Integer.toString(c);
    tabla_num.addCell(numberAsString);
    d = getNum2_5(5);
    numberAsString = Integer.toString(d);
    tabla_num.addCell(numberAsString);
    e = getNum2_5(6);
    numberAsString = Integer.toString(e);
    tabla_num.addCell(numberAsString);
    f = getNum2_5(7);
    numberAsString = Integer.toString(f);
    tabla_num.addCell(numberAsString);
    g = getNum2_5(8);
    numberAsString = Integer.toString(g);
    tabla_num.addCell(numberAsString);
    h = getNum2_5(9);
    numberAsString = Integer.toString(h);
    tabla_num.addCell(numberAsString);
    i = getNum2_5(10);
    numberAsString = Integer.toString(i);
    tabla_num.addCell(numberAsString);
    j = getNum2_5(11);
    numberAsString = Integer.toString(j);
    tabla_num.addCell(numberAsString);
    k = getNum2_5(12);
    numberAsString = Integer.toString(k);
    tabla_num.addCell(numberAsString);
    l = getNum2_5(13);
    numberAsString = Integer.toString(l);
    tabla_num.addCell(numberAsString);

    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_TT() throws Exception {
    PdfPTable tabla_num = new PdfPTable(2);
    int a = 0, b = 0, c = 0, d = 0;
    String numberAsString;/*from  www.  j ava 2  s . c  om*/
    tabla_num.setWidths(new int[] { 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("TT o tesis aceptados y rechazados", encabezadost));
    PdfPCell aceptado = new PdfPCell(new Phrase("Aceptados"));
    PdfPCell no_aceptado = new PdfPCell(new Phrase("No aceptados"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(5);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    aceptado.setHorizontalAlignment(Element.ALIGN_CENTER);
    aceptado.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(aceptado);

    no_aceptado.setHorizontalAlignment(Element.ALIGN_CENTER);
    no_aceptado.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(no_aceptado);

    /*Aqui van las consultas de las Actividades del profesor*/
    a = getNum2_11(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);
    b = getNum2_11(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);
    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_plan_estu() throws Exception {
    PdfPTable tabla_num = new PdfPTable(8);
    int a = 0, b = 0, c = 0, d = 0, e, f, g, h;
    String numberAsString;//from  w w w  .  j a  va 2 s  . co  m
    tabla_num.setWidths(new int[] { 2, 2, 2, 2, 2, 2, 2, 2 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Participaciones aceptadas", encabezadost));
    PdfPCell coor_1 = new PdfPCell(new Phrase("Coord 1"));
    PdfPCell coor_2 = new PdfPCell(new Phrase("Corrd 2"));
    PdfPCell parti_1 = new PdfPCell(new Phrase("Parti 1"));
    PdfPCell parti_2 = new PdfPCell(new Phrase("Parti 2"));
    PdfPCell coor_1_1 = new PdfPCell(new Phrase("Coord 1 1"));
    PdfPCell coor_1_2 = new PdfPCell(new Phrase("Coord 1 2"));
    PdfPCell parti_1_1 = new PdfPCell(new Phrase("Parti 1 1"));
    PdfPCell parti_1_2 = new PdfPCell(new Phrase("Parti 1 2"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(8);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    coor_1.setHorizontalAlignment(Element.ALIGN_CENTER);
    coor_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(coor_1);

    coor_2.setHorizontalAlignment(Element.ALIGN_CENTER);
    coor_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(coor_2);

    parti_1.setHorizontalAlignment(Element.ALIGN_CENTER);
    parti_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(parti_1);

    parti_2.setHorizontalAlignment(Element.ALIGN_CENTER);
    parti_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(parti_2);

    coor_1_1.setHorizontalAlignment(Element.ALIGN_CENTER);
    coor_1_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(coor_1_1);

    coor_1_2.setHorizontalAlignment(Element.ALIGN_CENTER);
    coor_1_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(coor_1_2);

    parti_1_1.setHorizontalAlignment(Element.ALIGN_CENTER);
    parti_1_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(parti_1_1);

    parti_1_2.setHorizontalAlignment(Element.ALIGN_CENTER);
    parti_1_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(parti_1_2);

    /*Aqui van las consultas de las Actividades del profesor*/
    a = getNum2_12(2);
    numberAsString = Integer.toString(a);
    tabla_num.addCell(numberAsString);
    b = getNum2_12(3);
    numberAsString = Integer.toString(b);
    tabla_num.addCell(numberAsString);
    c = getNum2_12(4);
    numberAsString = Integer.toString(c);
    tabla_num.addCell(numberAsString);
    d = getNum2_12(5);
    numberAsString = Integer.toString(d);
    tabla_num.addCell(numberAsString);
    e = getNum2_12(6);
    numberAsString = Integer.toString(e);
    tabla_num.addCell(numberAsString);
    f = getNum2_12(7);
    numberAsString = Integer.toString(f);
    tabla_num.addCell(numberAsString);
    g = getNum2_12(8);
    numberAsString = Integer.toString(g);
    tabla_num.addCell(numberAsString);
    h = getNum2_12(9);
    numberAsString = Integer.toString(h);
    tabla_num.addCell(numberAsString);
    return tabla_num;
}

From source file:PDF.Reporte_Final.java

private PdfPTable tabla_acota1() throws Exception {
    PdfPTable tabla_num = new PdfPTable(2);
    int a = 0, b = 0, c = 0, d = 0, e, f, g, h;
    String numberAsString;//from www.jav a  2  s.  co m
    tabla_num.setWidths(new int[] { 1, 5 });
    PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Acotaciones de Participaciones", encabezadost));
    PdfPCell abre = new PdfPCell(new Phrase("Abreviatura"));
    PdfPCell signi = new PdfPCell(new Phrase("Significado"));

    Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE);
    Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76));
    Titulo_tabla.setColspan(8);
    Titulo_tabla.setExtraParagraphSpace(15f);
    tabla_num.addCell(Titulo_tabla);

    abre.setHorizontalAlignment(Element.ALIGN_CENTER);
    abre.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(abre);

    signi.setHorizontalAlignment(Element.ALIGN_CENTER);
    signi.setVerticalAlignment(Element.ALIGN_MIDDLE);
    tabla_num.addCell(signi);

    /*Aqui van las consultas de las Actividades del profesor*/
    tabla_num.addCell("Coord 1");
    tabla_num.addCell("Coordinacin en la elaboracin de un plan de estudios");
    tabla_num.addCell("Coor 2");
    tabla_num.addCell("Coordinacin en la actualizacin de un plan de estudios");
    tabla_num.addCell("Parti 1");
    tabla_num.addCell("Participacin en la elaboracin de un plan de estudios");
    tabla_num.addCell("Parti 2");
    tabla_num.addCell("Participacin en la actualizacin de un plan de estudios");
    tabla_num.addCell("Coor 1 1");
    tabla_num.addCell("Coordinacin en la elaboracin de un programa de estudios");
    tabla_num.addCell("Coor 1 2");
    tabla_num.addCell("Coordinacin en la actualizacin de un programa de estudios");
    tabla_num.addCell("Parti 1 1");
    tabla_num.addCell("Participacin en la elaboracin de un programa de estudios");
    tabla_num.addCell("Parti 1 2");
    tabla_num.addCell("Participacin en la actualizacin de un programa de estudios");

    return tabla_num;
}

From source file:pdfMaker.MakePdfFile.java

public void createPdf(String mainTitle, String subTitle, String url, String userName,
        //String scanType,
        String comment,/*from  w  w w.j  a  v  a 2 s.  c  om*/
        //String thisPassCode,
        String passCodeA, String passCodeB, String fileDir, Boolean noBarCodePrint)
        throws IOException, DocumentException, RuntimeException {
    Document document = null;
    try {
        // step 1
        document = new Document(PageSize.A4, 60, 50, 50, 35);
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileDir));
        // step 3
        document.open();
        // step 4
        PdfContentByte cb = writer.getDirectContent();
        /*
         Properties props = new Properties();
         String jarPath = System.getProperty("java.class.path");
         String dirPath = jarPath.substring(0, jarPath.lastIndexOf(File.separator)+1);
         FontFactory.registerDirectory("/res");
         FontFactory.register("ipag.ttf");
         Font ipaGothic = FontFactory.getFont("ipag", BaseFont.IDENTITY_H, 
         BaseFont.EMBEDDED, 10); //10 is the size
                
         InputStream is = getClass().getResourceAsStream("/res/ipag.ttf");
         */

        Properties props = new Properties();
        String jarPath = System.getProperty("java.class.path");
        String dirPath = jarPath.substring(0, jarPath.lastIndexOf(File.separator) + 1);
        System.out.println(jarPath);
        System.out.println(dirPath);
        System.out.println(System.getProperty("user.dir"));

        Font ipaGothic = new Font(BaseFont.createFont(System.getProperty("user.dir") + "\\res\\ipag.ttf",
                BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 11);

        //?(2)
        PdfPTable pdfPTable = new PdfPTable(2);

        pdfPTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
        pdfPTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.getDefaultCell().setFixedHeight(150);

        pdfPTable.setWidthPercentage(100f);

        int pdfPTableWidth[] = { 10, 90 };
        pdfPTable.setWidths(pdfPTableWidth);

        PdfPCell cell_1_1 = new PdfPCell(new Paragraph("??", ipaGothic));
        cell_1_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_1_1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell_1_1.setFixedHeight(50);
        PdfPCell cell_1_2 = new PdfPCell(new Paragraph(mainTitle, ipaGothic));
        cell_1_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_1_2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell cell_2_1 = new PdfPCell(new Paragraph("", ipaGothic));
        cell_2_1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_2_1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell cell_2_2 = new PdfPCell(new Paragraph(subTitle, ipaGothic));
        cell_2_2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell_2_2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell_2_2.setFixedHeight(50);
        pdfPTable.addCell(cell_1_1);
        pdfPTable.addCell(cell_1_2);
        pdfPTable.addCell(cell_2_1);
        pdfPTable.addCell(cell_2_2);

        PdfPCell cellUrlKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellUrlKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUrlKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUrlKey.setRowspan(2);
        pdfPTable.addCell(cellUrlKey);

        PdfPCell cellUrlValue = new PdfPCell(new Paragraph(url, ipaGothic));
        cellUrlValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUrlValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUrlValue.setFixedHeight(50);
        pdfPTable.addCell(cellUrlValue);

        /*  */
        //cellUrlValue.getImage();
        writer.getDirectContent().addImage(cellUrlValue.getImage(), 100, 100, 100, 100, 100, 100);

        if (url.length() != 0 && !noBarCodePrint) {
            /* ?
             BarcodeQRCode qr = new BarcodeQRCode(url, 50, 50, null);
             PdfPCell cellUrlValueQr = new PdfPCell(qr.getImage());
             cellUrlValueQr.setVerticalAlignment(Element.ALIGN_MIDDLE);
             cellUrlValueQr.setHorizontalAlignment(Element.ALIGN_CENTER);
             cellUrlValueQr.setFixedHeight(80);
             pdfPTable.addCell(cellUrlValueQr);
             */
            Image image = ZxingUti.getQRCode(url); //  SHIFT_JIS
            com.itextpdf.text.Image iTextImage = com.itextpdf.text.Image.getInstance(image, null);
            PdfPCell cell = new PdfPCell(iTextImage);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(100);
            pdfPTable.addCell(cell); //  SIFT_JIS
        } else {
            PdfPCell cellUrlValueQr = new PdfPCell(new Paragraph("", ipaGothic));
            cellUrlValueQr.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUrlValueQr.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUrlValueQr.setFixedHeight(80);
            pdfPTable.addCell(cellUrlValueQr);
        }

        PdfPCell cellUserNameKey = new PdfPCell(new Paragraph("", ipaGothic));
        cellUserNameKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUserNameKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUserNameKey.setRowspan(2);
        pdfPTable.addCell(cellUserNameKey);

        PdfPCell cellUserNameValue = new PdfPCell(new Paragraph(userName, ipaGothic));
        cellUserNameValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellUserNameValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellUserNameValue.setFixedHeight(30);
        pdfPTable.addCell(cellUserNameValue);

        if (userName.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(userName);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellUserNameValueBc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellUserNameValueBc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUserNameValueBc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUserNameValueBc.setFixedHeight(80);
            pdfPTable.addCell(cellUserNameValueBc);
        } else {
            PdfPCell cellUserNameValueBc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellUserNameValueBc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellUserNameValueBc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellUserNameValueBc.setFixedHeight(80);
            pdfPTable.addCell(cellUserNameValueBc);
        }

        PdfPCell cellPassCodeKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellPassCodeKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellPassCodeKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPassCodeKey.setRowspan(3);
        pdfPTable.addCell(cellPassCodeKey);

        PdfPCell cellPassCodeValue = new PdfPCell(new Paragraph(passCodeA + passCodeB, ipaGothic));
        cellPassCodeValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellPassCodeValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPassCodeValue.setFixedHeight(30);
        pdfPTable.addCell(cellPassCodeValue);

        if (passCodeA.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(passCodeA);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellPassCodeA_Bc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellPassCodeA_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeA_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeA_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeA_Bc);
        } else {
            PdfPCell cellPassCodeA_Bc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellPassCodeA_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeA_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeA_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeA_Bc);
        }

        if (passCodeB.length() != 0 && !noBarCodePrint) {
            Barcode128 code128 = new Barcode128();
            code128.setCode(passCodeB);
            code128.setFont(ipaGothic.getBaseFont());
            code128.setBarHeight(40f);
            PdfPCell cellPassCodeB_Bc = new PdfPCell(code128.createImageWithBarcode(cb, null, null));
            cellPassCodeB_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeB_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeB_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeB_Bc);
        } else {
            PdfPCell cellPassCodeB_Bc = new PdfPCell(new Paragraph("---", ipaGothic));
            cellPassCodeB_Bc.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellPassCodeB_Bc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellPassCodeB_Bc.setFixedHeight(80);
            pdfPTable.addCell(cellPassCodeB_Bc);
        }

        PdfPCell cellCommentKey = new PdfPCell(new Paragraph("?", ipaGothic));
        cellCommentKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellCommentKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.addCell(cellCommentKey);

        PdfPCell cellCommentValue = new PdfPCell(new Paragraph(comment, ipaGothic));
        cellCommentValue.setVerticalAlignment(Element.ALIGN_TOP);
        cellCommentValue.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellCommentValue.setFixedHeight(150);
        pdfPTable.addCell(cellCommentValue);

        PdfPCell cellIssueKey = new PdfPCell(new Paragraph("", ipaGothic));
        cellIssueKey.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellIssueKey.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfPTable.addCell(cellIssueKey);

        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
        String strDate = sdf.format(cal.getTime());
        PdfPCell cellIssueValue = new PdfPCell(new Paragraph(strDate, ipaGothic));
        cellIssueValue.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellIssueValue.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellIssueValue.setFixedHeight(20);
        pdfPTable.addCell(cellIssueValue);

        //??
        document.add(pdfPTable);
        /*
                
         // CODE 128
         document.add(new Paragraph("?? : " + mainTitle, ipaGothic));
         document.add(new Paragraph(" : " + subTitle, ipaGothic));
         document.add(new Paragraph("-------------------------------------------------------"));
         document.add(new Paragraph(" " + strDate));
         document.add(new Paragraph("-------------------------------------------------------"));
                
                
         BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.EMBEDDED);
         Font font = new Font(bf, 12);
         document.add(new Paragraph("", ipaGothic));
         document.add(new Paragraph(url, ipaGothic));
         code128.setCode(url);
         code128.setFont(bf);
         code128.setX(1);
         //document.add(code128.createImageWithBarcode(cb, null, null));
                
         document.add(new Paragraph("USER", ipaGothic));
         if (userName.length() != 0) {
         document.add(new Paragraph(userName, ipaGothic));
         code128.setCode(userName);
         code128.setFont(bf);
         code128.setBarHeight(40f);
         document.add(code128.createImageWithBarcode(cb, null, null));
         }
                
         document.add(new Paragraph("CODE", ipaGothic));
         if (passCode.length() != 0) {
         document.add(new Paragraph(passCode, ipaGothic));
         code128.setCode(passCode);
         code128.setFont(bf);
         document.add(code128.createImageWithBarcode(cb, null, null));
         }
                
         document.add(new Paragraph("?", ipaGothic));
         document.add(new Paragraph(comment, ipaGothic));
         */
        // step 5
        document.close();
    } catch (RuntimeException ex) {
        document.close();
        throw ex;

    }
}

From source file:pdfreporter.PDFGenTable.java

public static void pdfgentable() {
    Document document = new Document();
    try {/*from   www . ja v  a2 s. c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddTableExample.pdf"));
        document.open();

        PdfPTable table = new PdfPTable(4); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table

        //Set Column widths
        float[] columnWidths = { 1f, 1f, 1f, 1f };
        table.setWidths(columnWidths);

        PdfPCell cell1 = new PdfPCell(new Paragraph("Nemam Pojma"));
        cell1.setBorderColor(BaseColor.BLACK);
        cell1.setPaddingLeft(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cell2 = new PdfPCell(new Paragraph("Nemam pojma 2"));
        cell2.setBorderColor(BaseColor.BLACK);
        cell2.setPaddingLeft(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cell3 = new PdfPCell(new Paragraph("Nemam pojma 3"));
        cell3.setBorderColor(BaseColor.BLACK);
        cell3.setPaddingLeft(10);
        cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cell4 = new PdfPCell(new Paragraph("Nemam pojma 4"));
        cell4.setBorderColor(BaseColor.BLACK);
        cell4.setPaddingLeft(10);
        cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

        //To avoid having the cell border and the content overlap, if you are having thick cell borders
        //cell1.setUserBorderPadding(true);
        //cell2.setUserBorderPadding(true);
        //cell3.setUserBorderPadding(true);
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);

        document.add(table);

        document.close();
        writer.close();
    } catch (FileNotFoundException | DocumentException e) {
    }
}

From source file:pidevhany.Controllers.GeneratePDF.java

public GeneratePDF(String ReponsesCorretes, String ReponsesFausses) throws FileNotFoundException, IOException {
    Document document = new Document();
    OutputStream outputStream = new FileOutputStream(
            new File("D:\\Esprit\\Atelier Java\\piweb\\pidevHany\\src\\pidevhany\\TestFile.pdf"));
    try {//  w  w w .  j a  v a2 s .c  o m
        PdfWriter writer = PdfWriter.getInstance(document, outputStream);
        document.open();
        document.add(new Paragraph("Resultat du test :"));
        PdfPTable table = new PdfPTable(2); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table

        //Set Column widths
        float[] columnWidths = { 1f, 1f };
        table.setWidths(columnWidths);

        PdfPCell cell1 = new PdfPCell(new Paragraph(ReponsesCorretes));
        cell1.setBorderColor(BaseColor.BLUE);
        cell1.setPaddingLeft(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cell2 = new PdfPCell(new Paragraph(ReponsesFausses));
        cell2.setBorderColor(BaseColor.GREEN);
        cell2.setPaddingLeft(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cell1);
        table.addCell(cell2);

        document.add(table);
        document.close();
        outputStream.close();
        writer.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    }

}