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

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

Introduction

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

Prototype

int LINECANVAS

To view the source code for com.itextpdf.text.pdf PdfPTable LINECANVAS.

Click Source Link

Document

The index of the duplicate PdfContentByte where the border lines will be drawn.

Usage

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

License:Open Source License

public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
    PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
    canvas.setLineWidth(borderThickness);

    int bottomMargin = isBorderEnabled(Border.BOTTOM) ? margin : 0;
    int topMargin = isBorderEnabled(Border.TOP) ? margin : 0;
    int leftMargin = isBorderEnabled(Border.LEFT) ? margin : 0;
    int rightMargin = isBorderEnabled(Border.RIGHT) ? margin : 0;

    if (isBorderEnabled(Border.TOP)) {
        canvas.moveTo(position.getLeft() + leftMargin, position.getTop() - topMargin);
        canvas.lineTo(position.getRight() - rightMargin, position.getTop() - topMargin);
    }/*from ww  w . j  a  v a2 s  .  co  m*/
    if (isBorderEnabled(Border.BOTTOM)) {
        canvas.moveTo(position.getLeft() + leftMargin, position.getBottom() + bottomMargin);
        canvas.lineTo(position.getRight() - rightMargin, position.getBottom() + bottomMargin);
    }
    if (isBorderEnabled(Border.RIGHT)) {
        canvas.moveTo(position.getRight() - rightMargin, position.getBottom() + bottomMargin);
        canvas.lineTo(position.getRight() - rightMargin, position.getTop() - topMargin);
    }
    if (isBorderEnabled(Border.LEFT)) {
        canvas.moveTo(position.getLeft() + leftMargin, position.getBottom() + bottomMargin);
        canvas.lineTo(position.getLeft() + leftMargin, position.getTop() - topMargin);
    }
    canvas.stroke();
}

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

License:Open Source License

public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
    PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
    canvas.setLineDash(3f, 3f);//from  www. j  a  va2s  . c  om
    canvas.moveTo(position.getLeft(), position.getTop());
    canvas.lineTo(position.getRight(), position.getTop());
    canvas.moveTo(position.getLeft(), position.getBottom());
    canvas.lineTo(position.getRight(), position.getBottom());
    canvas.stroke();
}

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

License:Open Source License

@Override
public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart,
        PdfContentByte[] canvas) {/*from w  w w  .  j  a v  a  2 s . co  m*/
    float width[] = widths[0];
    float x1 = width[0];
    float x2 = width[width.length - 1];
    float y1 = heights[0];
    float y2 = heights[heights.length - 1];

    PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
    Rectangle rect1 = new Rectangle(x1, y1, x2, y2);
    rect1.setBorder(Rectangle.BOX);
    rect1.setBorderWidth(2);
    cb.rectangle(rect1);
    cb.stroke();
}

From source file:ihm.panneaux.GenererPdf.java

public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
    PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
    if (top != null) {
        canvas.saveState();//from  www.  j a v a2 s.  c om
        top.applyLineDash(canvas);
        canvas.moveTo(position.getRight(), position.getTop());
        canvas.lineTo(position.getLeft(), position.getTop());
        canvas.stroke();
        canvas.restoreState();
    }
    if (bottom != null) {
        canvas.saveState();
        bottom.applyLineDash(canvas);
        canvas.moveTo(position.getRight() - 35, position.getBottom());
        canvas.lineTo(position.getLeft(), position.getBottom());
        canvas.stroke();
        canvas.restoreState();
    }
    if (right != null) {
        canvas.saveState();
        right.applyLineDash(canvas);
        canvas.moveTo(position.getRight(), position.getTop());
        canvas.lineTo(position.getRight(), position.getBottom());
        canvas.stroke();
        canvas.restoreState();
    }
    if (left != null) {
        canvas.saveState();
        left.applyLineDash(canvas);
        canvas.moveTo(position.getLeft(), position.getTop());
        canvas.lineTo(position.getLeft(), position.getBottom());
        canvas.stroke();
        canvas.restoreState();
    }
}

From source file:se.billes.pdf.renderer.request.factory.CellBlockEvent.java

License:Open Source License

public PdfPCellEvent createEvent(final Block block) {
    return new PdfPCellEvent() {
        public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) {

            float radiusInPs = SizeFactory.millimetersToPostscriptPoints(block.getRadius());
            PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
            PdfTemplate template = cb.createTemplate(rect.getWidth(), rect.getHeight());
            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);
            template.clip();/*from w ww .  j  av  a  2 s.c o m*/
            template.newPath();

            if (block.getBaseColor() != null) {
                template.setColorFill(block.getBaseColor());
            }

            Border border = block.getBorder();

            if (border != null) {
                template.setLineWidth(SizeFactory.millimetersToPostscriptPoints(border.getThickness()));
                template.setColorStroke(border.getBaseColor());
            }

            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);

            if (block.getBaseColor() != null || border != null) {
                if (block.getBaseColor() != null && border != null) {
                    template.fillStroke();
                } else if (block.getBaseColor() != null) {
                    template.fill();
                } else {

                    template.stroke();
                }
            }
            cb.addTemplate(template, rect.getLeft(), rect.getBottom());
        }
    };
}