Home Java Itext Skewing Text



Skewing Text
Posted on: March 13, 2008 at 12:00 AM
In this section, you will learn how to make a program by which you can set skew in for chunk. iText api provides a method setSkew(float value1,float value2).This method is used in palce of italic font.

Skewing Text    

     

In this section, you will learn how to make a program by which you can set skew in for chunk. iText api provides a method setSkew(float value1,float value2).This method is used in palce of italic font.   

Code Description:
We can use the method setSkew(float alpha,float beta) in place of italic fonts (if we are using a font that doesn,t  support  Font.ITALIC). We take 0f as alfa and 12f as value for beta.Alfa is the angle of the baseline in degrees. In the example, we rotate some text 45f and -45f degrees. Beta is the square-angle on the baseline.

The code of the program is given below:

import java.io.FileOutp utStream;
import java.io.IOException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class exampleOfSkew {
  public static void main(String[] args)throws Exception
  {
  System.out.println("Example of Skew");
  Document document = new Document();
  PdfWriter.getInstance(document,new FileOutputStream("Skew.pdf"));
  document.open();
  Paragraph p = new Paragraph("Rose India.net");
  document.add(p);
  Chunk chunk = new Chunk("Rose India.net");
  chunk.setSkew(45f0f);
  document.add(chunk);
  document.add(Chunk.NEWLINE);
  chunk.setSkew(0f45f);
  document.add(chunk);
  document.add(Chunk.NEWLINE);
  chunk.setSkew(-45f0f);
  document.add(chunk);
  document.add(Chunk.NEWLINE);
  chunk.setSkew(0f, -45f);
  document.add(chunk);
  document.add(Chunk.NEWLINE);
  chunk.setSkew(16f35f);
  document.add(chunk);
  document.add(Chunk.NEWLINE);
  Chunk italic = new Chunk("This looks like Font.ITALIC");
  italic.setSkew(0f15f);
  document.add(italic);  
  document.close();
  }
}

The output of the program is given below:

Download this example.

 

Related Tags for Skewing Text:
capiidetextscriptfontsiomakefloatmethodsedfontipviportvaluesetsusinglinethisidsetsupportitextbetarotatedegreeiftexforexamplealphaprogramtolearnrambaseexamangledescriptionearexteilitdessectioncanliuseceinasmntcaaceesasepimehowotaproppbaselinedosquarexawhichxampssusoeeatkishalllfmplgreeaandarcodcodertxtvascrssriripth12apaluhatdegreeslcepleplprndodeonomogro


More Tutorials from this section

Ask Questions?    Discuss: Skewing Text  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.