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:adams.flow.transformer.pdfproclet.Circle.java

License:Open Source License

/**
 * The actual processing of the document.
 *
 * @param generator   the context//ww w  .j ava 2 s  . co 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.setColorFill(new BaseColor(m_Color.getRGB()));
    cb.setLineWidth(m_LineWidth);
    cb.circle(m_X, m_Y, m_Radius);
    if (m_Fill)
        cb.fillStroke();
    else
        cb.stroke();
    cb.restoreState();

    return true;
}

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

License:Open Source License

/**
 * The actual processing of the document.
 *
 * @param generator   the context/*from  w  ww  . j av  a2s .c  om*/
 * @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:adams.flow.transformer.pdfproclet.Rectangle.java

License:Open Source License

/**
 * The actual processing of the document.
 *
 * @param generator   the context/*  w w w .  java 2  s.  c om*/
 * @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.setColorFill(new BaseColor(m_Color.getRGB()));
    cb.setLineWidth(m_LineWidth);
    cb.rectangle(m_X, m_Y, m_X + m_Width, m_Y + m_Height);
    if (m_Fill)
        cb.fillStroke();
    else
        cb.stroke();
    cb.restoreState();

    return true;
}

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

License:Open Source License

public static void drawString(PdfContentByte cb, BaseFont bf, float x, float y, float fontSize, String string)
        throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//w  w w. j  a va 2 s . c o  m

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.setTextMatrix(x, y);
    cb.showText(string);
    cb.endText();
    cb.stroke();
}

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

License:Open Source License

public static void drawString(PdfContentByte cb, BaseFont bf, float mid, float y, float fontSize, String string,
        float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//w w w. j a  va2 s  .  c  o m

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(PdfContentByte.ALIGN_LEFT, string, mid, y, rotation);
    cb.endText();
    cb.stroke();
}

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

License:Open Source License

public static void drawStringAligned(PdfContentByte cb, BaseFont bf, int alignment, float mid, float y,
        float fontSize, String string, float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }/*w w  w  .j  a  v a  2s  .c  om*/

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(alignment, string, mid, y, rotation);
    cb.endText();
    cb.stroke();
}

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

License:Open Source License

public static void drawStringCentered(PdfContentByte cb, BaseFont bf, float mid, float y, float fontSize,
        String string, float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//  w w  w.  ja v  a2 s  .co  m

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(PdfContentByte.ALIGN_CENTER, (string != null) ? string : "", mid, y, rotation);
    cb.endText();
    cb.stroke();
}

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  w w.  j av  a  2s. c o  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);//  www.java2  s .c  o m
    cb.lineTo(x, y + length);
    cb.stroke();
}

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

License:Open Source License

public static void drawRectangle(PdfContentByte cb, float x, float y, float width, float height,
        float lineWidth, float grayStroke) {
    setLineWidthGrayStroke(cb, lineWidth, grayStroke);
    cb.rectangle(x, y, width, height);//ww w .  j a v  a 2s.  c o  m
    cb.stroke();
}