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:com.dandymadeproductions.ajqvue.io.PDFDataTableDumpThread.java

License:Open Source License

public void run() {
    // Class Method Instances
    String title;//www .j a  va 2s  .c o  m

    Font titleFont;
    Font rowHeaderFont;
    Font tableDataFont;
    BaseFont rowHeaderBaseFont;

    PdfPTable pdfTable;
    PdfPCell titleCell;
    PdfPCell rowHeaderCell;
    PdfPCell bodyCell;

    Document pdfDocument;
    PdfWriter pdfWriter;
    ByteArrayOutputStream byteArrayOutputStream;

    int columnCount, rowNumber;
    int[] columnWidths;
    int totalWidth;
    Rectangle pageSize;

    ProgressBar dumpProgressBar;
    HashMap<String, String> summaryListTableNameTypes;
    DataExportProperties pdfDataExportOptions;

    String currentTableFieldName;
    String currentType, currentString;

    // Setup
    columnCount = summaryListTable.getColumnCount();
    rowNumber = summaryListTable.getRowCount();
    columnWidths = new int[columnCount];

    pdfTable = new PdfPTable(columnCount);
    pdfTable.setWidthPercentage(100);
    pdfTable.getDefaultCell().setPaddingBottom(4);
    pdfTable.getDefaultCell().setBorderWidth(1);

    summaryListTableNameTypes = new HashMap<String, String>();
    pdfDataExportOptions = DBTablesPanel.getDataExportProperties();

    titleFont = new Font(pdfDataExportOptions.getFont());
    titleFont.setStyle(Font.BOLD);
    titleFont.setSize((float) pdfDataExportOptions.getTitleFontSize());
    titleFont.setColor(new BaseColor(pdfDataExportOptions.getTitleColor().getRGB()));

    rowHeaderFont = new Font(pdfDataExportOptions.getFont());
    rowHeaderFont.setStyle(Font.BOLD);
    rowHeaderFont.setSize((float) pdfDataExportOptions.getHeaderFontSize());
    rowHeaderFont.setColor(new BaseColor(pdfDataExportOptions.getHeaderColor().getRGB()));
    rowHeaderBaseFont = rowHeaderFont.getCalculatedBaseFont(false);

    tableDataFont = pdfDataExportOptions.getFont();

    // Constructing progress bar.
    dumpProgressBar = new ProgressBar(exportedTable + " Dump");
    dumpProgressBar.setTaskLength(rowNumber);
    dumpProgressBar.pack();
    dumpProgressBar.center();
    dumpProgressBar.setVisible(true);

    // Create a Title if Optioned.
    title = pdfDataExportOptions.getTitle();

    if (!title.equals("")) {
        if (title.equals("EXPORTED TABLE"))
            title = exportedTable;

        titleCell = new PdfPCell(new Phrase(title, titleFont));
        titleCell.setBorder(0);
        titleCell.setPadding(10);
        titleCell.setColspan(summaryListTable.getColumnCount());
        titleCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        pdfTable.addCell(titleCell);
        pdfTable.setHeaderRows(2);
    } else
        pdfTable.setHeaderRows(1);

    // Create Row Header.
    for (int i = 0; i < columnCount; i++) {
        currentTableFieldName = summaryListTable.getColumnName(i);
        rowHeaderCell = new PdfPCell(new Phrase(currentTableFieldName, rowHeaderFont));
        rowHeaderCell.setBorderWidth(pdfDataExportOptions.getHeaderBorderSize());
        rowHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        rowHeaderCell.setBorderColor(new BaseColor(pdfDataExportOptions.getHeaderBorderColor().getRGB()));
        pdfTable.addCell(rowHeaderCell);
        columnWidths[i] = Math.min(50000,
                Math.max(columnWidths[i], rowHeaderBaseFont.getWidth(currentTableFieldName + " ")));
        if (tableColumnTypeNameHashMap != null)
            summaryListTableNameTypes.put(Integer.toString(i),
                    tableColumnTypeNameHashMap.get(currentTableFieldName));
        else
            summaryListTableNameTypes.put(Integer.toString(i), "String");
    }

    // Create the Body of Data.
    int i = 0;
    while ((i < rowNumber) && !dumpProgressBar.isCanceled()) {
        dumpProgressBar.setCurrentValue(i);

        // Collecting rows of data & formatting date & timestamps
        // as needed according to the Export Properties.

        if (summaryListTable.getValueAt(i, 0) != null) {
            for (int j = 0; j < summaryListTable.getColumnCount(); j++) {
                currentString = summaryListTable.getValueAt(i, j) + "";
                currentString = currentString.replaceAll("\n", "");
                currentString = currentString.replaceAll("\r", "");
                currentType = summaryListTableNameTypes.get(Integer.toString(j));

                // Format Date & Timestamp Fields as Needed.

                if ((currentType != null) && (currentType.equals("DATE") || currentType.equals("DATETIME")
                        || currentType.indexOf("TIMESTAMP") != -1)) {
                    if (!currentString.toLowerCase(Locale.ENGLISH).equals("null")) {
                        int firstSpace;
                        String time;

                        // Dates fall through DateTime and Timestamps try
                        // to get the time separated before formatting
                        // the date.

                        if (currentString.indexOf(" ") != -1) {
                            firstSpace = currentString.indexOf(" ");
                            time = currentString.substring(firstSpace);
                            currentString = currentString.substring(0, firstSpace);
                        } else
                            time = "";

                        currentString = Utils.convertViewDateString_To_DBDateString(currentString,
                                DBTablesPanel.getGeneralDBProperties().getViewDateFormat());
                        currentString = Utils.convertDBDateString_To_ViewDateString(currentString,
                                pdfDataExportOptions.getPDFDateFormat()) + time;
                    }
                }
                bodyCell = new PdfPCell(new Phrase(currentString, tableDataFont));
                bodyCell.setPaddingBottom(4);

                if (currentType != null) {
                    // Set Numeric Fields Alignment.
                    if (currentType.indexOf("BIT") != -1 || currentType.indexOf("BOOL") != -1
                            || currentType.indexOf("NUM") != -1 || currentType.indexOf("INT") != -1
                            || currentType.indexOf("FLOAT") != -1 || currentType.indexOf("DOUBLE") != -1
                            || currentType.equals("REAL") || currentType.equals("DECIMAL")
                            || currentType.indexOf("COUNTER") != -1 || currentType.equals("BYTE")
                            || currentType.equals("CURRENCY")) {
                        bodyCell.setHorizontalAlignment(pdfDataExportOptions.getNumberAlignment());
                        bodyCell.setPaddingRight(4);
                    }
                    // Set Date/Time Field Alignment.
                    if (currentType.indexOf("DATE") != -1 || currentType.indexOf("TIME") != -1
                            || currentType.indexOf("YEAR") != -1)
                        bodyCell.setHorizontalAlignment(pdfDataExportOptions.getDateAlignment());
                }

                pdfTable.addCell(bodyCell);
                columnWidths[j] = Math.min(50000,
                        Math.max(columnWidths[j], BASE_FONT.getWidth(currentString + " ")));
            }
        }
        i++;
    }
    dumpProgressBar.dispose();

    // Check to see if any data was in the summary
    // table to even be saved.

    if (pdfTable.size() <= pdfTable.getHeaderRows())
        return;

    // Create a document of the PDF formatted data
    // to be saved to the given output file.

    try {
        // Sizing & Layout
        totalWidth = 0;
        for (int width : columnWidths)
            totalWidth += width;

        if (pdfDataExportOptions.getPageLayout() == PDFExportPreferencesPanel.LAYOUT_PORTRAIT)
            pageSize = PageSize.A4;
        else {
            pageSize = PageSize.A4.rotate();
            pageSize.setRight(pageSize.getRight() * Math.max(1f, totalWidth / 53000f));
            pageSize.setTop(pageSize.getTop() * Math.max(1f, totalWidth / 53000f));
        }

        pdfTable.setWidths(columnWidths);

        // Document
        pdfDocument = new Document(pageSize);
        byteArrayOutputStream = new ByteArrayOutputStream();
        pdfWriter = PdfWriter.getInstance(pdfDocument, byteArrayOutputStream);
        pdfDocument.open();
        pdfTemplate = pdfWriter.getDirectContent().createTemplate(100, 100);
        pdfTemplate.setBoundingBox(new com.itextpdf.text.Rectangle(-20, -20, 100, 100));
        pdfWriter.setPageEvent(this);
        pdfDocument.add(pdfTable);
        pdfDocument.close();

        // Outputting
        WriteDataFile.mainWriteDataString(fileName, byteArrayOutputStream.toByteArray(), false);

    } catch (DocumentException de) {
        if (Ajqvue.getDebug()) {
            System.out.println("Failed to Create Document Needed to Output Data. \n" + de.toString());
        }
    }
}

From source file:com.dandymadeproductions.myjsqlview.io.PDFDataTableDumpThread.java

License:Open Source License

public void run() {
    // Class Method Instances
    String title;/*from ww  w  .j  a va 2  s .  co  m*/
    PdfPTable pdfTable;
    PdfPCell titleCell, rowHeaderCell, bodyCell;
    Document pdfDocument;
    PdfWriter pdfWriter;
    ByteArrayOutputStream byteArrayOutputStream;

    int columnCount, rowNumber;
    int[] columnWidths;
    int totalWidth;
    Rectangle pageSize;

    MyJSQLView_ProgressBar dumpProgressBar;
    HashMap<String, String> summaryListTableNameTypes;
    String currentTableFieldName;
    String currentType, currentString;

    // Setup
    columnCount = summaryListTable.getColumnCount();
    rowNumber = summaryListTable.getRowCount();
    columnWidths = new int[columnCount];

    pdfTable = new PdfPTable(columnCount);
    pdfTable.setWidthPercentage(100);
    pdfTable.getDefaultCell().setPaddingBottom(4);
    pdfTable.getDefaultCell().setBorderWidth(1);

    summaryListTableNameTypes = new HashMap<String, String>();
    pdfDataExportOptions = DBTablesPanel.getDataExportProperties();

    titleFont = new Font(pdfDataExportOptions.getFont());
    titleFont.setStyle(Font.BOLD);
    titleFont.setSize((float) pdfDataExportOptions.getTitleFontSize());
    titleFont.setColor(new BaseColor(pdfDataExportOptions.getTitleColor().getRGB()));

    rowHeaderFont = new Font(pdfDataExportOptions.getFont());
    rowHeaderFont.setStyle(Font.BOLD);
    rowHeaderFont.setSize((float) pdfDataExportOptions.getHeaderFontSize());
    rowHeaderFont.setColor(new BaseColor(pdfDataExportOptions.getHeaderColor().getRGB()));
    rowHeaderBaseFont = rowHeaderFont.getCalculatedBaseFont(false);

    tableDataFont = pdfDataExportOptions.getFont();

    // Constructing progress bar.
    rowNumber = summaryListTable.getRowCount();
    dumpProgressBar = new MyJSQLView_ProgressBar(exportedTable + " Dump");
    dumpProgressBar.setTaskLength(rowNumber);
    dumpProgressBar.pack();
    dumpProgressBar.center();
    dumpProgressBar.setVisible(true);

    // Create a Title if Optioned.
    title = pdfDataExportOptions.getTitle();

    if (!title.equals("")) {
        if (title.equals("EXPORTED TABLE"))
            title = exportedTable;

        titleCell = new PdfPCell(new Phrase(title, titleFont));
        titleCell.setBorder(0);
        titleCell.setPadding(10);
        titleCell.setColspan(summaryListTable.getColumnCount());
        titleCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        pdfTable.addCell(titleCell);
        pdfTable.setHeaderRows(2);
    } else
        pdfTable.setHeaderRows(1);

    // Create Row Header.
    for (int i = 0; i < columnCount; i++) {
        currentTableFieldName = summaryListTable.getColumnName(i);
        rowHeaderCell = new PdfPCell(new Phrase(currentTableFieldName, rowHeaderFont));
        rowHeaderCell.setBorderWidth(pdfDataExportOptions.getHeaderBorderSize());
        rowHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        rowHeaderCell.setBorderColor(new BaseColor(pdfDataExportOptions.getHeaderBorderColor().getRGB()));
        pdfTable.addCell(rowHeaderCell);
        columnWidths[i] = Math.min(50000,
                Math.max(columnWidths[i], rowHeaderBaseFont.getWidth(currentTableFieldName + " ")));
        if (tableColumnTypeHashMap != null)
            summaryListTableNameTypes.put(Integer.toString(i),
                    tableColumnTypeHashMap.get(currentTableFieldName));
        else
            summaryListTableNameTypes.put(Integer.toString(i), "String");
    }

    // Create the Body of Data.
    int i = 0;
    while ((i < rowNumber) && !dumpProgressBar.isCanceled()) {
        dumpProgressBar.setCurrentValue(i);

        // Collecting rows of data & formatting date & timestamps
        // as needed according to the Export Properties.

        if (summaryListTable.getValueAt(i, 0) != null) {
            for (int j = 0; j < summaryListTable.getColumnCount(); j++) {
                currentString = summaryListTable.getValueAt(i, j) + "";
                currentString = currentString.replaceAll("\n", "");
                currentString = currentString.replaceAll("\r", "");
                currentType = summaryListTableNameTypes.get(Integer.toString(j));

                // Format Date & Timestamp Fields as Needed.

                if ((currentType != null) && (currentType.equals("DATE") || currentType.equals("DATETIME")
                        || currentType.indexOf("TIMESTAMP") != -1)) {
                    if (!currentString.toLowerCase().equals("null")) {
                        int firstSpace;
                        String time;

                        // Dates fall through DateTime and Timestamps try
                        // to get the time separated before formatting
                        // the date.

                        if (currentString.indexOf(" ") != -1) {
                            firstSpace = currentString.indexOf(" ");
                            time = currentString.substring(firstSpace);
                            currentString = currentString.substring(0, firstSpace);
                        } else
                            time = "";

                        currentString = MyJSQLView_Utils.convertViewDateString_To_DBDateString(currentString,
                                DBTablesPanel.getGeneralDBProperties().getViewDateFormat());
                        currentString = MyJSQLView_Utils.convertDBDateString_To_ViewDateString(currentString,
                                pdfDataExportOptions.getPDFDateFormat()) + time;
                    }
                }
                bodyCell = new PdfPCell(new Phrase(currentString, tableDataFont));
                bodyCell.setPaddingBottom(4);

                if (currentType != null) {
                    // Set Numeric Fields Alignment.
                    if (currentType.indexOf("BIT") != -1 || currentType.indexOf("BOOL") != -1
                            || currentType.indexOf("NUM") != -1 || currentType.indexOf("INT") != -1
                            || currentType.indexOf("FLOAT") != -1 || currentType.indexOf("DOUBLE") != -1
                            || currentType.equals("REAL") || currentType.equals("DECIMAL")
                            || currentType.indexOf("COUNTER") != -1 || currentType.equals("BYTE")
                            || currentType.equals("CURRENCY")) {
                        bodyCell.setHorizontalAlignment(pdfDataExportOptions.getNumberAlignment());
                        bodyCell.setPaddingRight(4);
                    }
                    // Set Date/Time Field Alignment.
                    if (currentType.indexOf("DATE") != -1 || currentType.indexOf("TIME") != -1
                            || currentType.indexOf("YEAR") != -1)
                        bodyCell.setHorizontalAlignment(pdfDataExportOptions.getDateAlignment());
                }

                pdfTable.addCell(bodyCell);
                columnWidths[j] = Math.min(50000,
                        Math.max(columnWidths[j], BASE_FONT.getWidth(currentString + " ")));
            }
        }
        i++;
    }
    dumpProgressBar.dispose();

    // Check to see if any data was in the summary
    // table to even be saved.

    if (pdfTable.size() <= pdfTable.getHeaderRows())
        return;

    // Create a document of the PDF formatted data
    // to be saved to the given output file.

    try {
        // Sizing & Layout
        totalWidth = 0;
        for (int width : columnWidths)
            totalWidth += width;

        if (pdfDataExportOptions.getPageLayout() == PDFExportPreferencesPanel.LAYOUT_PORTRAIT)
            pageSize = PageSize.A4;
        else {
            pageSize = PageSize.A4.rotate();
            pageSize.setRight(pageSize.getRight() * Math.max(1f, totalWidth / 53000f));
            pageSize.setTop(pageSize.getTop() * Math.max(1f, totalWidth / 53000f));
        }

        pdfTable.setWidths(columnWidths);

        // Document
        pdfDocument = new Document(pageSize);
        byteArrayOutputStream = new ByteArrayOutputStream();
        pdfWriter = PdfWriter.getInstance(pdfDocument, byteArrayOutputStream);
        pdfDocument.open();
        pdfTemplate = pdfWriter.getDirectContent().createTemplate(100, 100);
        pdfTemplate.setBoundingBox(new com.itextpdf.text.Rectangle(-20, -20, 100, 100));
        pdfWriter.setPageEvent(this);
        pdfDocument.add(pdfTable);
        pdfDocument.close();

        // Outputting
        WriteDataFile.mainWriteDataString(fileName, byteArrayOutputStream.toByteArray(), false);

    } catch (DocumentException de) {
        if (MyJSQLView.getDebug()) {
            System.out.println("Failed to Create Document Needed to Output Data. \n" + de.toString());
        }
    }
}

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

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(8);
    //new float[]{2.4f, 3f, 1.25f, 1.2f, 1f, 1.15f, 1.1f, 1.55f}
    PdfPCell cell;/*w ww  . j  a v  a2  s. com*/
    cell = new PdfPCell(new Phrase("CDIGO", 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("DESCRIPCIN", 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("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("FECHA DE CADUCIDAD", 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("DICTAMEN", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(AMARILLO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);
    cell = new PdfPCell(new Phrase("PRECIO", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(AMARILLO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);
    cell = new PdfPCell(new Phrase("OBSERVACIONES", 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[] { 2.4f, 3f, 1.25f, 1.2f, 1f, 1.15f, 1.1f, 1.55f });
        table.setWidthPercentage(100);

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

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

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    try {//from ww w  .j  ava 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  w w  w . j  a v a2s.com*/
    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.CrearReporteTarimas.java

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    try {/*from  w  ww  . jav  a 2  s.  co m*/
        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;/*from   w  w  w.  ja va 2s  .c om*/
    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.ExportarAPDF.java

private static PdfPTable setUpInformation() {
    PdfPTable table = new PdfPTable(2);
    try {//w ww . ja v  a  2  s  .com
        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;
}

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

private static PdfPTable createTable() {
    PdfPTable table = new PdfPTable(6);
    PdfPCell cell;//w ww  .  ja v  a  2s. com
    cell = new PdfPCell(new Phrase("DESCRIPCIN", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("LOTE", font_headertable1));
    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", font_headertable1));
    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", font_headertable1));
    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", font_headertable1));
    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", font_headertable1));
    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);
        Log.print(ex);
    }
    return table;
}

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

private PdfPTable setUpInformationTarimas() {
    PdfPTable table = new PdfPTable(2);
    try {//  w ww . j  a  va  2s.  co  m
        PdfPCell cell;
        Phrase tarima = new Phrase();
        tarima.add(new Chunk("TARIMA\n", font_tarimota));
        tarima.add(new Chunk(datosTarima.getNombreTarima(), font_tarimota_gris));
        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 ", 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;
}