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

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

Introduction

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

Prototype

public void addCell(final Phrase phrase) 

Source Link

Document

Adds a cell element.

Usage

From source file:com.devox.GUI.PDF.CrearReporteDestruccion.java

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    try {/*from   w w w .j av a 2 s .c o  m*/
        PdfPCell cell;
        Phrase folio = new Phrase();
        folio.add(new Chunk("FOLIO DHL ", FUENTE_FOLIO_CHICA));
        folio.add(new Chunk(contenido.getFolioDHL(), FUENTE_FOLIO_CHICA_ROJA));
        cell = new PdfPCell(folio);
        cell.setRowspan(8);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Cliente ", contenido.getNombreCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Nmero de cliente ", contenido.getClaveCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Folio del cliente ", contenido.getFolioCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Folio Abbott ", contenido.getFolioAbbott()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Motivo de devolucin ",
                contenido.getMotivo().getCodigo() + " - " + contenido.getMotivo().getDescripcion()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Factura ", contenido.getFactura()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Almacn ", contenido.getAlmacen()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(
                getPhraseFromChunks("Fecha de captura ", Funciones.getOtherDate(contenido.getFechaCaptura())));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);

        table.setWidthPercentage(100);
        table.setWidths(new int[] { 1, 3 });

    } catch (DocumentException ex) {
        Log.print(ex);
    }
    return table;
}

From source file:com.devox.GUI.PDF.CrearReporteDestruccion.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(6);
    PdfPCell cell;//from   www  .ja  v a 2  s .c  o m
    cell = new PdfPCell(new Phrase("DESCRIPCIN", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("LOTE", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRECIO UNITARIO", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("SUBTOTAL", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(AMARILLO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 5f, 2f, 3f, 1.2f, 1.4f, 1.5f });
        table.setWidthPercentage(98);

    } catch (DocumentException ex) {
        Log.print(ex);
    }
    return table;

}

From source file:com.devox.GUI.PDF.CrearReporteDestruccion.java

@Override
public void agregarProductos(PdfPTable table) {
    int rows = model.getRowCount();
    int total = 0;
    float monto = 0f;

    for (int i = 0; i < rows; i++) {
        PdfPCell cell = new PdfPCell();
        cell.addElement(new Phrase((String) model.getValueAt(i, 2), FUENTE_TABLA));

        table.addCell(cell);
        if (ANI) {
            try {
                String lotereal = ((String) model.getValueAt(i, 3));
                System.out.println("Lote original: " + lotereal);
                String lotecorto = lotereal.substring(0, 7);
                System.out.println("Lote acortado: " + lotecorto);

                table.addCell(new Phrase(lotecorto, FUENTE_TABLA));
            } catch (Exception ex) {
                table.addCell(new Phrase((String) model.getValueAt(i, 3), FUENTE_TABLA));
            }//from  ww  w.j  a  va  2s . co  m
        } else {
            table.addCell(new Phrase((String) model.getValueAt(i, 3), FUENTE_TABLA));
        }
        table.addCell(new Phrase((String) model.getValueAt(i, 1), FUENTE_TABLA));
        int c = (Integer) model.getValueAt(i, 5);
        total += c;
        table.addCell(new Phrase(Integer.toString(c), FUENTE_TABLA));
        table.addCell(new Phrase("$ " + model.getValueAt(i, 4).toString(), FUENTE_TABLA));
        Float p = new Float(model.getValueAt(i, 6).toString());
        monto += p;
        table.addCell(new Phrase("$ " + String.format("%.2f", p), FUENTE_TABLA));
    }
    table.addCell(new Phrase("  ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("Total ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("  ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("" + total, FUENTE_BASE_TABLA));
    table.addCell(new Phrase("  ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("$ " + String.format("%.2f", monto), FUENTE_BASE_TABLA));

}

From source file:com.devox.GUI.PDF.CrearReportePorEstado.java

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;//from  w w  w . j  a  v a  2  s.  c  om

    cell = new PdfPCell(getPhraseFromChunks("DEL ", fechaInicio));
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingLeft(40);
    table.addCell(cell);
    cell = new PdfPCell(getPhraseFromChunks("AL ", fechaFin));
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingLeft(40);
    table.addCell(cell);
    table.setWidthPercentage(100);
    return table;
}

From source file:com.devox.GUI.PDF.CrearReportePorEstado.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;//from w ww . j a  v  a  2  s . com
    cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("DESTINO", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    return table;
}

From source file:com.devox.GUI.PDF.CrearReportePorEstado.java

@Override
public void agregarProductos(PdfPTable table) {
    int rows = data.length;

    for (int i = 0; i < rows; i++) {
        table.addCell(new Phrase(data[i][0].toString()));
        table.addCell(new Phrase(data[i][1].toString()));
    }/*from   ww  w  .  j  a  va 2 s .c  o m*/
}

From source file:com.devox.GUI.PDF.CrearReporteTarimas.java

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    try {/*from  w w w  . j  a va  2  s  .c om*/
        PdfPCell cell;
        Phrase tarima = new Phrase();
        tarima.add(new Chunk("TARIMA\n", FUENTE_TARIMA_NEGRO));
        tarima.add(new Chunk(datosTarima.getNombreTarima(), FUENTE_TARIMA_ROJO));
        cell = new PdfPCell(tarima);
        cell.setRowspan(5);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        cell.setFixedHeight(200f);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("DIVISIN ", datosTarima.getDivision()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("ALMACN ", datosTarima.getAlmacen()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("FECHA DE APERTURA ",
                Funciones.getOtherDate(datosTarima.getFecha_Apertura())));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("FECHA DE CIERRE ",
                (datosTarima.getFecha_Cierra() == null ? "TARIMA ABIERTA"
                        : Funciones.getOtherDate(datosTarima.getFecha_Cierra()))));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("DESTRUCCIN FISCAL ",
                Integer.toString(datosTarima.getDestruccionFiscal())));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);

        table.setWidthPercentage(100);
        table.setWidths(new int[] { 2, 1 });
    } catch (DocumentException de) {
        Log.print(de);
    }
    return table;
}

From source file:com.devox.GUI.PDF.CrearReporteTarimas.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(4);
    PdfPCell cell;//w  ww  .j  a v a2 s .c o  m
    cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO INTERNO", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f });
        table.setWidthPercentage(100);

    } catch (DocumentException ex) {
        Log.print(ex);
    }
    return table;
}

From source file:com.devox.GUI.PDF.CrearReporteTarimas.java

@Override
public void agregarProductos(PdfPTable table) {
    int rows = datosTarima.getListaProductos().size();
    int total = 0;

    for (int i = 0; i < rows; i++) {
        PdfPCell cell = new PdfPCell();
        cell.addElement(new Phrase(datosTarima.getListaProductos().get(i)[0]));

        table.addCell(cell);
        table.addCell(new Phrase(datosTarima.getListaProductos().get(i)[1]));

        table.addCell(new Phrase(datosTarima.getListaProductos().get(i)[2]));
        int c = Integer.parseInt(datosTarima.getListaProductos().get(i)[3]);
        total += c;// w ww. j a v a 2  s . co m
        table.addCell(datosTarima.getListaProductos().get(i)[3]);

    }
    table.addCell(new Phrase("  ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("Total ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("  ", FUENTE_BASE_TABLA));
    table.addCell(new Phrase("" + total, FUENTE_BASE_TABLA));
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

private static PdfPTable setUpInformation() {
    PdfPTable table = new PdfPTable(2);
    try {/*from w  w w.  j a v a  2  s .c  o m*/
        PdfPCell cell;
        Phrase folio = new Phrase();
        folio.add(new Chunk("FOLIO DHL ", font_foliodhl));
        folio.add(new Chunk(contenido.getFolioDHL(), font_folionum));
        cell = new PdfPCell(folio);
        cell.setRowspan(8);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Cliente ", contenido.getNombreCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Nmero de cliente ", contenido.getClaveCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Folio del cliente ", contenido.getFolioCliente()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Folio Abbott ", contenido.getFolioAbbott()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Motivo de devolucin ",
                contenido.getMotivo().getCodigo() + " - " + contenido.getMotivo().getDescripcion()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Factura ", contenido.getFactura()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(getPhraseFromChunks("Almacn ", contenido.getAlmacen()));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);
        cell = new PdfPCell(
                getPhraseFromChunks("Fecha de captura ", Funciones.getOtherDate(contenido.getFechaCaptura())));
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setPaddingLeft(40);
        table.addCell(cell);

        table.setWidthPercentage(100);
        table.setWidths(new int[] { 1, 3 });

    } catch (DocumentException ex) {
        Log.print(ex);
        Log.print(ex);
    }
    return table;
}