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

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

Introduction

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

Prototype

public void setColorStroke(final BaseColor color) 

Source Link

Document

Sets the stroke color.

Usage

From source file:se.billes.pdf.renderer.model.Line.java

License:Open Source License

@Override
public void onRender(PdfContentByte cb) throws PdfRenderException {

    Integer[] pageSizes = getPage().getPdfDocument().getSize();
    float[] pos = getPosition();
    float[] moveTo = getMoveTo();
    cb.setLineWidth(getThickness());// ww w  .j a  va2 s  . co m
    cb.setColorStroke(getBaseColor());
    float y1 = pageSizes[1] + SizeFactory.CUT_MARK - pos[1]; // seams strange but pdf starts bottom and up.
    float y2 = pageSizes[1] + SizeFactory.CUT_MARK - moveTo[1];
    // x , y. y is backward in pdf so start pos is the entire page height
    cb.moveTo(SizeFactory.millimetersToPostscriptPoints(pos[0] + SizeFactory.CUT_MARK),
            SizeFactory.millimetersToPostscriptPoints(y1));
    cb.lineTo(SizeFactory.millimetersToPostscriptPoints(moveTo[0] + SizeFactory.CUT_MARK),
            SizeFactory.millimetersToPostscriptPoints(y2));
    cb.stroke();

}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void createSignatureNotRequiredField(PdfStamper pdfStamper, int lastPage)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(lastPage);
    addOverlay.saveState();//from  ww w  . j  a  v a 2  s.c  o m
    addOverlay.setColorFill(SIGNATURE_NOT_REQUIRED_COLOR);
    addOverlay.setColorStroke(CMYKColor.BLACK);
    addOverlay.rectangle(SIGNATURE_NOT_REQUIRED_START_X, SIGNATURE_NOT_REQUIRED_START_Y,
            SIGNATURE_NOT_REQUIRED_WIDTH, SIGNATURE_NOT_REQUIRED_HEIGHT);
    addOverlay.setLineWidth(LINE_WIDTH);
    addOverlay.fillStroke();
    addOverlay.restoreState();
    // Do text
    addOverlay = pdfStamper.getOverContent(lastPage);
    addOverlay.saveState();
    BaseFont bf = BaseFont.createFont();
    addOverlay.beginText();
    addOverlay.setFontAndSize(bf, SIGNATURE_NOT_REQUIRED_FONT_SIZE);
    addOverlay.setTextMatrix(SIGNATURE_NOT_REQUIRED_START_X + SIGNATURE_NOT_REQUIRED_PADDING_LEFT,
            SIGNATURE_NOT_REQUIRED_START_Y + SIGNATURE_NOT_REQUIRED_PADDING_BOTTOM);
    addOverlay.showText(SIGNATURE_NOT_REQUIRED_TEXT);
    addOverlay.endText();
    addOverlay.restoreState();
}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void maskSendToFkInformation(PdfStamper pdfStamper) {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(1);
    addOverlay.saveState();/*from w  w w.  ja  va  2  s  .  c om*/
    addOverlay.setColorFill(CMYKColor.WHITE);
    addOverlay.setColorStroke(CMYKColor.WHITE);
    addOverlay.rectangle(MASK_START_X, MASK_START_Y, MASK_WIDTH, MASK_HEIGTH);
    addOverlay.fillStroke();
    addOverlay.restoreState();
}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void mark(PdfStamper pdfStamper, String watermarkText, int startX, int startY, int height, int width)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(1);
    addOverlay.saveState();/*  w ww. j  a  v a2s  . c o m*/
    addOverlay.setColorFill(CMYKColor.WHITE);
    addOverlay.setColorStroke(CMYKColor.RED);
    addOverlay.rectangle(startX, startY, width, height);
    addOverlay.stroke();
    addOverlay.restoreState();

    // Do text
    addOverlay = pdfStamper.getOverContent(1);
    ColumnText ct = new ColumnText(addOverlay);
    BaseFont bf = BaseFont.createFont();
    Font font = new Font(bf, WATERMARK_FONTSIZE);
    int llx = startX + WATERMARK_TEXT_PADDING;
    int lly = startY + WATERMARK_TEXT_PADDING;
    int urx = llx + width - 2 * WATERMARK_TEXT_PADDING;
    int ury = lly + height - 2 * WATERMARK_TEXT_PADDING;
    Phrase phrase = new Phrase(watermarkText, font);
    ct.setSimpleColumn(phrase, llx, lly, urx, ury, WATERMARK_FONTSIZE, Element.ALIGN_LEFT | Element.ALIGN_TOP);
    ct.go();
}