Example usage for com.itextpdf.text.pdf PdfContentByte stroke

List of usage examples for com.itextpdf.text.pdf PdfContentByte stroke

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfContentByte stroke.

Prototype


public void stroke() 

Source Link

Document

Strokes the path.

Usage

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawCircle(PdfContentByte cb, float x, float y, float r, float lineWidth, float grayStroke) {
    setLineWidthGrayStroke(cb, lineWidth, grayStroke);
    cb.circle(x, y, r);/* w  w  w  .  j a va 2s.c o  m*/
    cb.stroke();
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawRectangle(PdfContentByte cb, Rectangle rect, float lineWidth, float grayStroke) {
    setLineWidthGrayStroke(cb, lineWidth, grayStroke);
    cb.rectangle(rect);//from w  w w . j  a v  a 2  s . c o  m
    cb.stroke();
}

From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java

License:Apache License

public void drawLine(PdfContentByte cb, float x1, float x2, float y) {
    cb.moveTo(x1, y);/* w  w  w. j a va  2s .  co m*/
    cb.lineTo(x2, y);
    cb.stroke();
}

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

private static void drawLine(PdfContentByte contentByte) {
    contentByte.saveState();/* w  ww  .j  a  v  a  2s  .  co  m*/
    contentByte.moveTo(550, 795);
    contentByte.lineTo(35, 795);
    contentByte.moveTo(550, 45);
    contentByte.lineTo(35, 45);
    contentByte.setLineWidth(3);
    contentByte.setColorStroke(new BaseColor(252, 204, 41));
    contentByte.stroke();
    contentByte.restoreState();

}

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

private static void drawLine2(PdfContentByte contentByte) {
    contentByte.saveState();/*w  ww. j a v  a2 s  .c  o  m*/
    contentByte.moveTo(45, 35);
    contentByte.lineTo(795, 35);
    contentByte.moveTo(45, 550);
    contentByte.lineTo(795, 550);
    contentByte.setLineWidth(3);
    contentByte.setColorStroke(new BaseColor(252, 204, 41));
    contentByte.stroke();
    contentByte.restoreState();

}

From source file:com.mycompany.mavenproject1.Createpdf.java

private void generateLayout(Document doc, PdfContentByte cb) {

    try {//from w  ww .  j a v  a 2s .c  om

        cb.setLineWidth(1f);

        // Invoice Header box layout
        cb.rectangle(420, 700, 150, 60);
        cb.moveTo(420, 720);
        cb.lineTo(570, 720);
        cb.moveTo(420, 740);
        cb.lineTo(570, 740);
        cb.moveTo(480, 700);
        cb.lineTo(480, 760);
        cb.stroke();

        // Invoice Header box Text Headings 
        createHeadings(cb, 422, 743, "Account No.");
        createHeadings(cb, 422, 723, "Invoice No.");
        createHeadings(cb, 422, 703, "Invoice Date");

        // Invoice Detail box layout 
        cb.rectangle(20, 50, 550, 600);
        cb.moveTo(20, 630);
        cb.lineTo(570, 630);
        cb.moveTo(50, 50);
        cb.lineTo(50, 650);
        cb.moveTo(150, 50);
        cb.lineTo(150, 650);
        cb.moveTo(430, 50);
        cb.lineTo(430, 650);
        cb.moveTo(500, 50);
        cb.lineTo(500, 650);
        cb.stroke();

        // Invoice Detail box Text Headings 
        createHeadings(cb, 22, 633, "Qty");
        createHeadings(cb, 52, 633, "Item Number");
        createHeadings(cb, 152, 633, "Item Description");
        createHeadings(cb, 432, 633, "Price");
        createHeadings(cb, 502, 633, "Ext Price");

        //add the images
        Image companyLogo = Image.getInstance("images/olympics_logo.gif");
        companyLogo.setAbsolutePosition(25, 700);
        companyLogo.scalePercent(25);
        doc.add(companyLogo);

    }

    catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

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   w  w w . j av a2 s  . c  om
    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 v  a  2  s. c o m*/
    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 va 2s.  c  o 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:com.vectorprint.report.itext.style.stylers.Shape.java

License:Open Source License

@Override
protected void draw(PdfContentByte canvas, float x, float y, float width, float height, String genericTag) {
    if (getBorderWidth() > 0) {
        canvas.setLineWidth(getBorderWidth());
        canvas.setColorStroke(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getBorderColor()));
    }//w  ww.j  ava2s . c o m
    if (width == -1) {
        width = getWidth();
    }
    if (height == -1) {
        height = getHeight();
    }
    canvas.setColorFill(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getColor()));
    if (isRounded()) {
        canvas.setLineJoin(PdfContentByte.LINE_JOIN_ROUND);
    }
    float xx = x, yy = y;
    float[] points = getPoints();
    float padding = getPadding();
    switch (getShape()) {
    case free:
        float xdif = x - points[0];
        float ydif = y - points[1];
        xx = points[0] + xdif;
        yy = points[1] + ydif;
        canvas.moveTo(points[0] + xdif, points[1] + ydif);
        for (int i = 2; i < points.length; i = i + 2) {
            canvas.lineTo(points[i], points[i + 1]);
        }
        break;
    case bezier:
        xdif = x - points[0];
        ydif = y - points[1];
        xx = points[0] + xdif;
        yy = points[1] + ydif;
        canvas.moveTo(points[0] + xdif, points[1] + ydif);
        for (int i = 2; i < points.length; i = i + 4) {
            canvas.curveTo(points[i] + xdif, points[i + 1] + ydif, points[i + 2] + xdif, points[i + 3] + ydif);
        }
        break;
    case rectangle:
        if (isClose()) {
            xx = x - padding;
            yy = y - padding - height;
            canvas.rectangle(xx, yy, width + padding * 2, height + padding * 2);
        } else {
            canvas.rectangle(x, y, width, height);
        }
        break;
    case roundrectangle:
        if (isEnclosing()) {
            xx = x - padding;
            yy = y - padding - height;
            canvas.roundRectangle(xx, yy, width + padding * 2, height + padding * 2, getRadius());
        } else {
            canvas.roundRectangle(x, y, width, height, getRadius());
        }
        break;
    case ellipse:
        if (isEnclosing()) {
            xx = x - padding;
            yy = y - padding - height;
            canvas.ellipse(xx, yy, x + width + 2 * padding, y + 2 * padding);
        } else {
            canvas.ellipse(x, y, x + width, y + height);
        }
        break;
    }
    if (isClose()) {
        if (isFill()) {
            canvas.closePathFillStroke();
        } else {
            canvas.closePathStroke();
        }
    } else {
        canvas.stroke();
    }
    if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG)) {
        DebugHelper.styleLink(canvas, getStyleClass(), " (styling)", xx, yy, getSettings(), getLayerManager());
    }
}