Example usage for com.lowagie.text.pdf PdfPCell setColspan

List of usage examples for com.lowagie.text.pdf PdfPCell setColspan

Introduction

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

Prototype

public void setColspan(int colspan) 

Source Link

Document

Setter for property colspan.

Usage

From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java

License:Apache License

private PdfPCell writeCell(ReportModel model, jdbreport.model.Cell srcCell, int row, int col)
        throws BadElementException, IOException, SaveReportException {

    CellStyle style = model.getStyles(srcCell.getStyleId());

    java.awt.Rectangle rect = model.getCellRect(row, col, true, true);

    float h = Math.round((float) Units.PT.setYPixels((int) rect.getHeight()));
    float w = Math.round((float) Units.PT.setXPixels((int) rect.getWidth()));

    PdfPCell pdfCell = null;

    if (srcCell.getPicture() != null) {
        java.awt.Image awtImage = srcCell.getPicture().getImage();
        com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
        pdfCell = new PdfPCell(image);
    } else {/*  w  w w .ja va 2  s.  c  o m*/

        String text = null;

        if (srcCell.getValue() instanceof CellValue<?>) {

            StringWriter strWriter = new StringWriter();
            PrintWriter printWriter = new PrintWriter(strWriter);

            if (!((CellValue<?>) srcCell.getValue()).write(printWriter, model, row, col, this,
                    ReportBook.PDF)) {
                java.awt.Image awtImage = ((CellValue<?>) srcCell.getValue()).getAsImage(model, row, col);
                if (awtImage != null) {
                    com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
                    pdfCell = new PdfPCell(image);
                }
            } else {
                text = strWriter.getBuffer().toString();
            }

        } else {
            if (jdbreport.model.Cell.TEXT_HTML.equals(srcCell.getContentType())) {
                pdfCell = new PdfPCell();
                writeHTMLText(model.getStyles(srcCell.getStyleId()), srcCell, pdfCell);
            } else {
                text = model.getCellText(srcCell);
            }
        }

        if (pdfCell == null) {
            pdfCell = new PdfPCell();
        }

        if (text != null && text.length() > 0) {
            com.lowagie.text.Font font;
            if (fonts.containsKey(style.getId())) {
                font = fonts.get(style.getId());
            } else {
                font = getFontMapper().styleToPdf(style);
                fonts.put(style.getId(), font);
            }
            Paragraph p;
            if (font != null) {
                p = new Paragraph(text, font);
            } else {
                p = new Paragraph(text);
            }
            pdfCell.setPhrase(p);
            pdfCell.setPadding(1);
            pdfCell.setLeading(0f, 1.1f);
        } else {
            pdfCell.setPadding(0);
        }
    }

    pdfCell.setFixedHeight(h);
    pdfCell.setBackgroundColor(style.getBackground());
    pdfCell.setHorizontalAlignment(toPdfHAlignment(style.getHorizontalAlignment()));
    pdfCell.setVerticalAlignment(toPdfVAlignment(style.getVerticalAlignment()));

    if (style.getAngle() != 0) {
        pdfCell.setRotation(roundAngle(style.getAngle()));
    }

    assignBorders(style, pdfCell);
    pdfCell.setNoWrap(!style.isWrapLine());
    if (srcCell.getColSpan() > 0) {
        pdfCell.setColspan(srcCell.getColSpan() + 1);
    }
    if (srcCell.getRowSpan() > 0) {
        pdfCell.setRowspan(srcCell.getRowSpan() + 1);
    }

    return pdfCell;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFBottom(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);
    celda.setBorder(borde);//from w w  w .j ava 2s.  c o m
    celda.setPadding(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnetOpciones(String texto, int tipo, int tamanio, int estilo,
        int alineacion, int borde, int padding, int colspan, Color color) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.black);
    celda.setBackgroundColor(color);/*www  .j  av a2s  .com*/
    celda.setColspan(colspan);
    celda.setBorderWidth(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);
    celda.setBorderWidth(0);/* ww w .j av  a 2 s. c  o  m*/
    celda.setBorderWidthBottom(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan, Color color) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, color)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);
    celda.setBorderWidth(0);/*from   w  ww  .j a  v a  2s.  co m*/
    celda.setBorderWidthBottom(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        Color color, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setPadding(padding);/*from  ww w.  j  a va  2  s  . c  om*/
    celda.setColspan(colspan);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    celda.setBackgroundColor(color);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setPadding(padding);/*from  ww w .  j a v a  2 s  . c  om*/
    celda.setColspan(colspan);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setFilaBlanco(int colSpan, int alto) {
    PdfPCell celda = new PdfPCell(new Paragraph(" ", new Font(Font.HELVETICA, alto, Font.NORMAL)));
    celda.setBorderWidth(0);//www  .ja  va2s.  c  o  m
    celda.setPadding(0);
    celda.setColspan(colSpan);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setBarra(int colSpan, float color) {
    PdfPCell celda = new PdfPCell(new Paragraph(" ", new Font(Font.HELVETICA, 1, Font.NORMAL)));
    celda.setGrayFill(color);/*  w  ww  . j  a  v a2  s .co  m*/
    celda.setBorderWidth(0);
    celda.setPadding(0);
    celda.setColspan(colSpan);
    return celda;
}

From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java

License:Apache License

private void writeWorkerInfo(Document doc) throws Exception {

    PdfPTable tb = new PdfPTable(2);
    tb.setWidthPercentage(100.0f);/* w ww  .j a  v a 2 s .  c o  m*/
    tb.setSpacingBefore(8.0f);
    tb.setSpacingAfter(8.0f);

    PdfPCell cl;

    cl = new PdfPCell(new Phrase("Atsakingas asmuo: " + me.getName(), new Font(baseArial, 10)));
    cl.setColspan(2);
    tb.addCell(cl);

    cl = new PdfPCell(new Phrase("vykdymo data: " + timeFormat(tt.getDateClosed()), new Font(baseArial, 10)));
    tb.addCell(cl);

    if (tt.getWorktime() != null) {
        cl = new PdfPCell(new Phrase("Darbo valandos:" + tt.getWorktime(), new Font(baseArial, 10)));
        tb.addCell(cl);
    } else {
        cl = new PdfPCell(new Phrase("Darbo valandos: ", new Font(baseArial, 10)));
        tb.addCell(cl);
    }

    doc.add(tb);

    tb = new PdfPTable(2);

    tb.setWidthPercentage(100.0f);
    tb.setSpacingBefore(50.0f);

    cl = new PdfPCell(new Phrase("Kliento paraas\n\n\n\n", new Font(baseArial, 10)));
    cl.setBorder(0);
    tb.addCell(cl);

    cl = new PdfPCell(new Phrase("Uduot atliks darbuotojas\n\n\n\n", new Font(baseArial, 10)));
    cl.setBorder(0);
    tb.addCell(cl);
    doc.add(tb);

}