1   package org.intix.itext.test;
2   
3   import java.awt.Color;
4   import java.io.*;
5   
6   import com.lowagie.text.*;
7   import com.lowagie.text.pdf.*;
8   
9   class ChunkDemo
10  {
11    public static void main (String [] args) throws Exception
12    {
13     Document doc = new Document ();
14     PdfWriter.getInstance (doc, new FileOutputStream ("./test/chunkdemo.pdf"));
15     doc.open ();
16  
17     // Create a one-word chunk and add it to the document.
18  
19     Chunk chunk = new Chunk ("Hello");
20     doc.add (chunk);
21  
22     // Underline the word and add the chunk to the document.
23  
24     chunk.setUnderline (0.2f, -2f);
25     doc.add (chunk);
26  
27     // Create a second one-word chunk, strike it through, and add the chunk
28     // to the document.
29  
30     chunk = new Chunk ("Goodbye");
31     chunk.setUnderline (0.5f, 3f);
32     doc.add (chunk);
33  
34     // Change the striken chunk's background color and add the chunk to the
35     // document.
36  
37     chunk.setBackground (Color.yellow);
38     doc.add (chunk);
39  
40     doc.close ();
41    }
42  }