Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Itext Skewing Text

Related Tutorials


 
 

Share on Google+Share on Google+

Skewing Text

Advertisement
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.FileOutputStream;
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.

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 13, 2008

Related Tutorials

Discuss: Skewing Text  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com