tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 PDF > iTEXT > Lettered List Example

Lettered List Example 

iText is a free and open source library for creating and manipulating PDF documents in Java. The following example shows adding a lettered list to PDF document.

File Name  :  
com/bethecoder/tutorials/itext/tests/LetteredListExample.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.itext.tests;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.List;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;

public class LetteredListExample {

  /**
   @param args
   @throws DocumentException 
   @throws FileNotFoundException 
   */
  public static void main(String[] argsthrows FileNotFoundException, DocumentException {

    Document document = new Document(PageSize.A4)
    PdfWriter.getInstance(document, new FileOutputStream("test14.pdf"));
    
    //Open the document before adding any content
    document.open();
    
    List letteredList = new List(false, true)//Create lettered list
    letteredList.add("ONE");
    letteredList.add("TWO");
    letteredList.add("THREE");
    letteredList.add("FOUR");
    
    document.add(letteredList);
    document.add(Chunk.NEWLINE)//Add a new line
    
    List letteredList2 = new List(false, true)//Create lettered list
    letteredList2.setPreSymbol("|-->");  //The symbol to be prepended to each item
    letteredList2.setPostSymbol(":");    //The symbol to be appended to each item

    letteredList2.add("ONE");
    letteredList2.add("TWO");
    letteredList2.add("THREE");
    letteredList2.add("FOUR");
    document.add(letteredList2);
    
    //Close the document
    document.close();
  }

}
   

It gives the following output,
test14.jpg


                    Print

   



Books Recommendation

 
 
bl  br