This example show you how to use the com.itextpdf.text.ZapfDingbatsList
class to create a ZapfDingbatsList list using the iText pdf library.
package org.kodejava.itextpdf;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class ZapfDingbatsListDemo {
public static void main(String[] args) {
Document doc = new Document();
try {
PdfWriter.getInstance(doc, new FileOutputStream("ZapfDingbats.pdf"));
doc.open();
// Create a ZapfDingbatsList with char number 50
List zapf1 = new ZapfDingbatsList(50);
zapf1.add(new ListItem("Item 1"));
zapf1.add(new ListItem("Item 2"));
zapf1.add(new ListItem("Item 3"));
doc.add(zapf1);
// Create a ZapfDingbatsList with char number 55 and indent
// it by 30.
List zapf2 = new ZapfDingbatsList(55, 30);
zapf2.add(new ListItem("Item 1"));
zapf2.add(new ListItem("Item 2"));
zapf2.add(new ListItem("Item 3"));
doc.add(zapf2);
} 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