Example usage for com.itextpdf.text Phrase add

List of usage examples for com.itextpdf.text Phrase add

Introduction

In this page you can find the example usage for com.itextpdf.text Phrase add.

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Chunk, Anchor or another Phrase to this Phrase.

Usage

From source file:com.centurylink.mdw.pdf.PdfExportHelper.java

License:Apache License

private void printVariables(Chapter chapter, List<Variable> variables, int parentLevel) {
    Paragraph sTitle = new Paragraph("Process Variables", sectionFont);
    Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
    com.itextpdf.text.List list = new com.itextpdf.text.List(false, false, 10.0f);
    for (Variable var : variables) {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(var.getName(), fixedWidthFont));
        String v = var.getType();
        if (var.getDescription() != null)
            v += " (" + var.getDescription() + ")";
        phrase.add(new Chunk(": " + v + "\n", normalFont));
        list.add(new ListItem(phrase));
    }//from  w  ww .  java2s.c o m
    section.add(list);
}

From source file:com.cib.statementstamper.windows.StatementStamperMainWindow.java

License:Open Source License

protected PdfPTable getFooterTable(int x, int y) {
    PdfPTable table = new PdfPTable(1);
    table.setTotalWidth(537);/*from  w w  w . j a v  a2  s .  com*/
    table.setLockedWidth(true);
    table.getDefaultCell().setFixedHeight(40);
    table.getDefaultCell().setBorder(Rectangle.TOP);
    table.getDefaultCell().setBorderColor(new BaseColor(221, 72, 20));
    table.getDefaultCell().setBorderWidth(1);
    table.getDefaultCell().setPaddingLeft(0);
    table.getDefaultCell().setPaddingRight(0);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    Phrase phrase = new Phrase();
    phrase.add(new Chunk(bottomChunk1, bottomFontBold));
    phrase.add(new Chunk(bottomChunk2, bottomFont));
    table.addCell(phrase);
    return table;
}

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

private static Phrase getPhraseFromChunks(String a, String b) {
    Phrase phrase = new Phrase();
    phrase.add(new Chunk(a, FUENTE_DATOS_IZQ));
    phrase.add(new Chunk(b, FUENTE_DATOS_DER));
    return phrase;
}

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

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

@Override
public PdfPTable configurarInformacion() {
    PdfPTable table = new PdfPTable(2);
    try {/*from  w  w w.  j a  va2  s .c o  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.ExportarAPDF.java

private static PdfPTable setUpInformation() {
    PdfPTable table = new PdfPTable(2);
    try {/* 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;
}

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

private PdfPTable setUpInformationTarimas() {
    PdfPTable table = new PdfPTable(2);
    try {/*w  w w  .ja  va 2s.c  o  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;
}

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

private static Phrase getPhraseFromChunks(String a, String b) {
    Phrase phrase = new Phrase();
    phrase.add(new Chunk(a, font_info));
    phrase.add(new Chunk(b, font_datos));
    return phrase;
}

From source file:com.microware.intrahealth.Createpdf2.java

private static void createTable(Paragraph preface, String[] Header, ArrayList<HashMap<String, String>> data)
        throws BadElementException {

    Context _con = null;//from   ww  w . j a  va 2  s .c o m
    //       PdfPTable table = new PdfPTable(new float[] { 2, 1 });

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);
    PdfPTable table = new PdfPTable(new float[] { 1, 3, 3, 5, 5, 2, 3, 2, 2, 2 });

    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    for (int i = 0; i < Header.length; i++) {
        //      table.addCell(new PdfPCell(new Phrase(Header[i], smallBold)));
        PdfPCell c1 = new PdfPCell(new Phrase(Header[i], smallBold));
        c1.getBorder();
        c1.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(c1);
    }
    //        table.addCell("Value");
    //        table.addCell("Location");
    table.setHeaderRows(1);

    //        PdfPCell c1 = new PdfPCell(new Phrase("Text",smallBold));
    //        c1.getBorder();
    //        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    //        table.addCell(c1);
    //
    //        c1 = new PdfPCell(new Phrase("Value",smallBold));
    //        c1.getBorder();
    //        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    //        table.addCell(c1);
    //
    //        table.setHeaderRows(1);
    PdfPCell[] cells = table.getRow(0).getCells();
    for (int j = 0; j < cells.length; j++) {
        cells[j].setBackgroundColor(new BaseColor(0, 85, 133));

        if (j == 0) {
            cells[j].setHorizontalAlignment(Element.ALIGN_LEFT);
        } else {
            cells[j].setHorizontalAlignment(Element.ALIGN_CENTER);
        }
    }

    dataprovider = new DataProvider(_con);
    //
    //        Font f = FontFactory.getFont(getFilesDir() + "/" + HINDI_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    //        PdfPCell eCell = new PdfPCell(new Phrase(entry, f));

    for (int i = 0; i < data.size(); i++) {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(data.get(i).get("ASHAName"), subFont));

        table.addCell(String.valueOf((i + 1)));
        table.addCell(data.get(i).get("ASHAName"));
        table.addCell(data.get(i).get("VillageName"));
        table.addCell(data.get(i).get("PWName"));
        table.addCell(data.get(i).get("MotherMCTSID"));
        table.addCell(data.get(i).get("HusbandName"));
        table.addCell(Validate.changeDateFormat(data.get(i).get("CheckupVisitDate")));
        table.addCell(data.get(i).get("DangerSign"));
        table.addCell(data.get(i).get("CheckupPlace"));
        table.addCell("");

        PdfPCell[] cells1 = table.getRow(i + 1).getCells();
        cells1[0].setHorizontalAlignment(Element.ALIGN_LEFT);
        //            cells1[1].setHorizontalAlignment(Element.ALIGN_CENTER);
        //            cells1[2].setHorizontalAlignment(Element.ALIGN_CENTER);

    }

    //      table.addCell("Colour");
    //      table.addCell("Hazen Unit");
    //      table.addCell("1.2");
    //      table.addCell("Turbidity");
    //      table.addCell("NTU");
    //      table.addCell("2.3");

    preface.add(table);

}

From source file:com.microware.intrahealth.Createpdf2.java

private static void createTable1(Paragraph preface, String Text, String Value) throws BadElementException {

    Context _con = null;/*from  w w  w .  j a  v  a 2  s . com*/

    PdfPTable table = new PdfPTable(new float[] { 1, 3 });
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    for (int i = 0; i < 2; i++) {
        //      table.addCell(new PdfPCell(new Phrase(Header[i], smallBold)));
        PdfPCell c1 = new PdfPCell(new Phrase());
        table.addCell(c1);
    }
    PdfPCell[] cells = table.getRow(0).getCells();
    //        for (int j=0;j<cells.length;j++){
    cells[0].setHorizontalAlignment(Element.ALIGN_LEFT);
    //        }

    dataprovider = new DataProvider(_con);

    if (Text.length() > 0 && Value.length() > 0) {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(Text, subFont));
        table.addCell(phrase);
        table.addCell(Value);
    } else {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(Text, subFont));
        table.addCell(phrase);
        table.addCell("");
    }

    preface.add(table);

}