Example usage for com.itextpdf.text.pdf PdfPCell PdfPCell

List of usage examples for com.itextpdf.text.pdf PdfPCell PdfPCell

Introduction

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

Prototype

public PdfPCell() 

Source Link

Document

Constructs an empty PdfPCell.

Usage

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void reporteRH(Map<String, Object> model, HttpServletResponse hsr1, int detalle) throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();//from   w  w  w . ja v  a  2 s.c  om
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Recursos Humanos"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 2.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Total de de Empleados en Vacaciones", font));
    table.addCell(cell);

    String bla = detalle + " ";
    table.addCell(bla);

    document.add(table);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void reportefinanzas(Map<String, Object> model, HttpServletResponse hsr1, List<CuentaBancaria> cuenta)
        throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();//from  ww  w.  ja va  2s . com
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Finanzas"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 2.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Total de dinero que se tiene en CUENTAS BANCARIAS", font));
    table.addCell(cell);

    for (int i = 0; i < cuenta.size(); i++) {
        a = cuenta.get(i).getHaber();
        b = b + a;
    }
    String bla = b + " ";
    table.addCell(bla);

    document.add(table);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java

License:Open Source License

public static PdfPCell createSeparator() {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage(100);/*from  w  w w. j ava 2  s. c  om*/
    table.addCell(createWhiteSeparator());
    table.addCell(createBlackSeparator());
    // table.addCell(createWhiteSeparator());

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java

License:Open Source License

public static PdfPCell createBigSeparator(int width) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage(width);//  w  w  w .  jav  a2 s  . com
    table.addCell(createWhiteSeparator());
    table.addCell(createBlackSeparator());
    table.addCell(createWhiteSeparator());

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java

License:Open Source License

public static PdfPCell createBlackSeparator() {
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLACK);
    setCellProperties(cell);//w  ww. j  a v a  2s. c o m
    cell.setMinimumHeight(10f);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java

License:Open Source License

public static PdfPCell createWhiteSeparator() {
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.WHITE);
    setCellProperties(cell);//  w w  w  . j av  a  2s  .  com
    cell.setMinimumHeight(6f);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.elements.CustomPdfTable.java

License:Open Source License

protected PdfPCell createRectangle() {
    PdfPCell box = new PdfPCell();
    box.setMinimumHeight(15);//from  w  w  w . ja v a2s . com
    box.setBorder(0);
    box.setCellEvent(
            new CellCompleteBoxEvent(new Border[] { Border.TOP, Border.BOTTOM, Border.LEFT, Border.RIGHT }));
    return box;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsCompleteTableFactory.java

License:Open Source License

private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/*from   w  ww  .j ava 2  s.  c o  m*/

    table.addCell(createField(characterPlayer, "name", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "player", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "gender", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "age", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsCompleteTableFactory.java

License:Open Source License

private static PdfPCell getSecondColumnTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/* w w  w . java2  s  . c  o m*/

    table.addCell(createField(characterPlayer, "race", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "planet", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "faction", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "rank", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsTableFactory.java

License:Open Source License

protected static PdfPCell createField(CharacterPlayer characterPlayer, String tag, int fontSize) {
    float[] widths = { 0.7f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//  ww w  . j  av  a 2 s  . c o m

    table.addCell(getCell(getTranslatedTag(tag), Element.ALIGN_RIGHT, fontSize));
    if (characterPlayer == null) {
        table.addCell(getCell(LINE, Element.ALIGN_LEFT, fontSize));
    } else {
        if (tag.equals("name")) {
            table.addCell(getHandwrittingCell(characterPlayer.getNameRepresentation(), Element.ALIGN_LEFT,
                    fontSize - 1));
        } else if (tag.equals("race")) {
            if (characterPlayer.getRace() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getRace().getName(), Element.ALIGN_LEFT,
                        fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("faction")) {
            if (characterPlayer.getFaction() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getFaction().getName(), Element.ALIGN_LEFT,
                        fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("rank")) {
            try {
                if (characterPlayer.getRank() != null) {
                    table.addCell(
                            getHandwrittingCell(characterPlayer.getRank(), Element.ALIGN_LEFT, fontSize - 1));
                } else {
                    table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
                }
            } catch (InvalidXmlElementException e) {
                PdfExporterLog.errorMessage(CharacterBasicsTableFactory.class.getName(), e);
            }
        } else if (tag.equals("planet")) {
            if (characterPlayer.getInfo().getPlanet() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getInfo().getPlanet().getName(),
                        Element.ALIGN_LEFT, fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("gender")) {
            table.addCell(getHandwrittingCell(characterPlayer.getInfo().getTranslatedParameter(tag),
                    Element.ALIGN_LEFT, fontSize - 1));
        } else {
            table.addCell(getHandwrittingCell(characterPlayer.getInfo().getTranslatedParameter(tag),
                    Element.ALIGN_LEFT, fontSize - 1));
        }
    }

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    setCellProperties(cell);
    cell.setMinimumHeight(20);

    return cell;
}