Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

End of line

                         

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:

  1. PdfContentByte.TEXT_RENDER_MODE_FILL: The mode is used for  glyphs fontcolor, the strokeWidth and strokeColor don't play a role here.
  2. PdfContentByte.TEXT_RENDER_MODE_STROKE: We will only see the outline of the glyphs, with the given strokeWidth and strokeColor.
  3. PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE: The glyphs will be filled with the font color and will have an outline with the given strokeWidth and strokeColor.
  4. PdfContentByte.TEXT_RENDER_MODE_INVISIBLE: The glyphs will be invisible.

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:

Download this example.

 

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
stored procedure debug
connection pooling usi
logout code in jsp
JSF tree collapse
draw Flag
log4j
clear grid dojo
LRU
scroll bar
java merging images
tree
jersey
example of JFileChoos
retreive numerical val
Selection Sort In Java
jtabbedpanel enabled
Image with mouse drag
validate using picture
Photoshop Text Effects
VB Project
Telephony
message box display in
Binome
Authentication Filters
how to iterate a linke
compare two arraylist
jsf tree node set hr
get url
ajax auto complete
jar entry
diff. shape of linear
advantages of jsp over
jsp method
Struts Projects
tax calculator
Passing Parameters in
FlowLayout
JDBC-ODBC
<form: checkbox path=
Treemap using gwt tree
draw Polyline
comparable
jsp with strutsframewo
selecting option value
struts-servlets.xml
generate report in exc
FIFO
java example program t
pagination using javas
how to write in pdf us
Insert an array list o
program in java to ins
IBM MQ server
Hibernate Min() Functi
increase size of strut
JConfig
java drivers use to co
Java Mysql
send email
Javascript Date and Ti
dojo debug
code to add and retriv
source code for edit e
explaination of JDBC u
how retrive a data fro
Photoshop Write messag
capture screen j2me
java programming with
Custom Iterator Tag in
sort compareTo
how to display an imag
capture image
struts tld downloas
clientside validations
J2ME and WAP
JScrollPane
html code for developi
HSSF clone cell
c:out in var of c:fore
getwindowwidthandheigh
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.