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

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

Introduction

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

Prototype


public void lineTo(final double x, final double y) 

Source Link

Document

Appends a straight line segment from the current point (x, y).

Usage

From source file:adams.flow.transformer.pdfproclet.Line.java

License:Open Source License

/**
 * The actual processing of the document.
 *
 * @param generator   the context/*from  ww  w  .ja  v  a 2s .c o m*/
 * @param file   the file to add
 * @return      true if successfully added
 * @throws Exception   if something goes wrong
 */
protected boolean doProcess(PDFGenerator generator, File file) throws Exception {
    PdfContentByte cb;

    cb = generator.getWriter().getDirectContent();
    cb.saveState();
    cb.setColorStroke(new BaseColor(m_Color.getRGB()));
    cb.setLineWidth(m_LineWidth);
    cb.moveTo(m_X1, m_Y1);
    cb.lineTo(m_X2, m_Y2);
    cb.stroke();
    cb.restoreState();

    return true;
}

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

License:Open Source License

public static void drawHorizontalLine(PdfContentByte cb, float x, float y, float length, float lineWidth,
        float grayStroke) {
    setLineWidthGrayStroke(cb, lineWidth, grayStroke);
    cb.moveTo(x, y);// w  ww.jav  a  2s.  co m
    cb.lineTo(x + length, y);
    cb.stroke();
}

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

License:Open Source License

public static void drawVerticalLine(PdfContentByte cb, float x, float y, float length, float lineWidth,
        float grayStroke) {
    setLineWidthGrayStroke(cb, lineWidth, grayStroke);
    cb.moveTo(x, y);//from   w  ww .j av  a2 s  . co  m
    cb.lineTo(x, y + length);
    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);//from  ww w  .j  av a2s.c o  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 w  w .  ja v a2  s.  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.  java2s . 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 w  w  .  j  av a2s  .c o m*/

        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);
    }/*w  ww .  ja  v a  2  s.  c o 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);//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.vectorprint.report.itext.debug.DebugHelper.java

License:Open Source License

public static void debugRect(PdfContentByte canvas, Rectangle rect, float[] dash, float borderWidth,
        EnhancedMap settings, LayerManager layerAware) {
    layerAware.startLayerInGroup(DEBUG, canvas);
    debugFont(canvas, settings);/*from   w w  w  .  j a  va 2  s .  c o m*/
    canvas.setLineWidth(borderWidth);
    canvas.setLineDash(dash, 0);
    canvas.moveTo(rect.getLeft(), rect.getBottom());
    canvas.lineTo(rect.getRight(), rect.getBottom());
    canvas.lineTo(rect.getRight(), rect.getTop());
    canvas.lineTo(rect.getLeft(), rect.getTop());
    canvas.closePathStroke();
    ItextHelper.resetLineDash(canvas);
    canvas.endLayer();
}