Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
different Font 
 

Here, you will learn about different fount in java.

 

different Font 

                         

In this program, we are going to give you an example that helps you for the procedure of using various fonts in a pdf document. Here, add(object) method of the Paragraph class is used to add text and it's font name with size.

Code Description:

The following method and fields are used for creating multiple colorful fonts.

add(Chunk chunk,Font font): The add method is used to add the chunk text and name of font with font size.

Following are some font name used in the given program:

  1. Font.ZAPFDINGBATS
  2. Font.TIMES_ROMAN
  3. Font.SYMBOL 

The code of the program is given below:

import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class exampleOfDifferentFonts{
      public static void main(String[] argsthrows Exception{      
          Document document = new Document();
          
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("differentfontspdf.pdf"));
            document.open();
            Paragraph p = new Paragraph();
            p.add(new Chunk("This text is in Times Roman. "
new 
Font(Font.TIMES_ROMAN, 12)));
            p.add(new Chunk("This is ZapfDingbats: "
new 
Font(Font.ZAPFDINGBATS, 12)));
            p.add(new Chunk(". This is font Symbol: "
new 
Font(Font.TIMES_ROMAN, 12)));
            p.add(new Chunk("This text is in Times Roman."
new Font(Font.SYMBOL, 12)));
            document.add(new Paragraph(p));
            document.close();
    }
}

The output of the program is given below:

Download this example.

 

                         

» View all related tutorials
Related Tags: c web pdf file stl text application import jar diff io make packages port this package itext app if tex

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 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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 | Flex 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.