In this section, you will learn how to make a program by which you can define the strokeWidth and strokeColor. You can learn also to change the outline of the text. You can define the width and the color of the strokes used to draw the character. iText api provides a method setTextRenderMode(int mode, float strokeWidth, Color strokeColor).
Code Description:
In this example, we are using setTextRenderMode(int
mode,float strokeWidth,Color strokeColor) method for define the
strokeWidth, stokeColor and the mode. We are giving more details about
this method following:
setTextRenderMode(int mode,float
strokeWidth,Color strokeColor):
With the
setTextRenderMode(int mode,float strokeWidth,Color strokeColor) we can
change the outline of the text.We are passing here three parameters. First
is int mode it can be one of the following values:
The second strokeWidth and the thread one is stroke Color to set the width of and color of the text.
The code of the program is given below:
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class exampleOfEndOfLine {
public static void main(String[] args)throws Exception {
System.out.println("Example of End of Line");
Document document = new Document();
PdfWriter.getInstance(document,
new FileOutputStream("EndOfLinepdf.pdf"));
document.open();
Chunk chunk = new Chunk("Rose India
.Net-->Rose India .Net ");
for (int i = 0; i < 5; i++) {
chunk.setTextRenderMode(PdfContentByte
.TEXT_RENDER_MODE_STROKE, 0.5f,
new Color(i * 35, i * 30, i * 35));
document.add(chunk);
}
document.newPage();
Phrase p = new Phrase(16f);
for (int i = 0; i < 5; i++) {
chunk = new Chunk("Rose India .Net-->Rose
India .Net ");
chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_STROKE, 0.5f,
new Color(i * 35, i * 30, i * 35));
p.add(chunk);
}
document.add(p);
document.close();
}
}
The output of the program is given below:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: End of line
Post your Comment