To create a Roman or Greek numeral list we can use special implementation list in the iText. The com.itextpdf.text.RomanList
represent a Roman numeral list while the com.itextpdf.text.GreekList
represent a Greek numeral list.
The list item can be created using the com.itextpdf.text.ListItem
class. Let’s check out an example below:
package org.kodejava.itextpdf;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class RomanGreekListDemo {
public static void main(String[] args) {
Document doc = new Document();
try {
PdfWriter.getInstance(doc, new FileOutputStream("RomanGreekListDemo.pdf"));
doc.open();
List roman = new RomanList();
roman.add(new ListItem("Item 1"));
roman.add(new ListItem("Item 2"));
roman.add(new ListItem("Item 3"));
doc.add(roman);
List greek = new GreekList();
greek.add(new ListItem("Item 1"));
greek.add(new ListItem("Item 2"));
greek.add(new ListItem("Item 3"));
doc.add(greek);
} catch (DocumentException | FileNotFoundException e) {
e.printStackTrace();
} finally {
doc.close();
}
}
}
Maven Dependencies
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.3</version>
</dependency>
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024