How to Create Ordered List In pdf in java using iText


In this core java tutorial we will learn how to Create Ordered List In pdf in java using iText library - core java tutorial with program and examples.

First create List (com.itextpdf.text.List) i.e. orderedList using (new List(true); Or new List(List.ORDERED);) and then add ListItems (com.itextpdf.text.ListItem) in orderedList using add method of List (orderedList.add(new ListItem("Item 1"))).


We will generate PDF files in java using iText library. PDF files can be generated dynamically in java using iText library.

How to Create Roman List In pdf in java - iText java tutorial

Create ZapfDingbats List In pdf in java - iText java tutorial program

Creating the UnOrdered List In pdf in java - iText java tutorial example

How to Create Lists And SubLists In Pdf in java - iText java tutorial

How to Set the Font Name, Size, Style and Colour In Pdf using itext in java

How To Set HyperLink (Anchor - a tag) In Pdf in java - iText java tutorial

Convert Html To Pdf in java using iText - iText java tutorial

How To Set Header and Footer in pdf in java using Itext Example - iText java tutorial




Download jars required to execute program >

Or, you may download jars from here.


Program/Example how to Create Ordered List In pdf in java  - Using iText library - core java tutorial

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
/**
*
*  How to Create Ordered List In Pdf program -
*  Using iText library - core java tutorial
*
*/
public class CreateOrderedListInPdfExample {
   public static void main(String[] args) {
          try {
                 String pdfFilePath = "E:/Create Ordered List In Pdf Example.pdf";
                
                 OutputStream fos = new FileOutputStream(new File(pdfFilePath));
                 Document document = new Document();
                 PdfWriter.getInstance(document, fos);
                 document.open();
                 document.add(new Paragraph("This is OrderedList"));
                 //Create ORDERED list -  in PDF using iText library in java
                 List orderedList = new List(true); // Or //  new List(List.ORDERED)
                 //Add items in ORDERED list -  in PDF using iText library in java
                 orderedList.add(new ListItem("Item 1"));
                 orderedList.add(new ListItem("Item 2"));
                 orderedList.add(new ListItem("Item 3"));
                 orderedList.add(new ListItem("Item 4"));
                 orderedList.add(new ListItem("Item 5"));
                 orderedList.add(new ListItem("Item 6"));
                 orderedList.add(new ListItem("Item 7"));
                 orderedList.add(new ListItem("Item 8"));
                
                 document.add(orderedList);
                
                 document.close();             
                 fos.close();
                
                 System.out.println("PDF created in >> "+ pdfFilePath);
          } catch (Exception e) {
                 e.printStackTrace();
          }
   }
}
/* OUTPUT of above program/Example -
PDF created in >> E:/Create Ordered List In Pdf Example.pdf
*/


PDF formed after executing above java program(How to Create Ordered List In pdf in java using iText) will look like this >


Summary -
So in this core java tutorial we learned how to Create the Ordered List In pdf in java using iText library.
First we created List (com.itextpdf.text.List) i.e. orderedList using (new List(true); Or new List(List.ORDERED);) and then added ListItems (com.itextpdf.text.ListItem) in orderedList using add method of List (orderedList.add(new ListItem("Item 1"))).



Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

References >



RELATED LINKS>

iText library tutorial in java - How to Create and work with PDF files in java


Create the first Pdf Example Using iText library in java - iText java tutorial example


Create ZapfDingbats List In pdf in java - iText java tutorial program

How to Create Ordered List In pdf in java using iText - iText java tutorial

Creating the UnOrdered List In pdf in java - iText java tutorial example

How to Create Lists And SubLists In Pdf in java - iText java tutorial



Creating PASSWORD PROTECTED PDF in java - iText tutorial >

How to Create Password Protected Pdf in java - iText Example



Creating IMAGES in pdf in java - iText tutorial >

Adding the Images In Pdf in java example using iText - iText java tutorial

How to Add And Rotate Images In Pdf in java - iText java tutorial example

How can you Add the Images from URL In Pdf in java program


How To Set HyperLink (Anchor - a tag) In Pdf in java - iText java tutorial

MODIFY/ EDIT pdf in java - iText tutorial >

How to Modify - Add Text To Existing PDF in java - iText java tutorial example

How To Read And Add Image To Existing Pdf in java Example - iText java tutorial





eEdit
Must read for you :