Bullet List in PDF with iText


How to create a PDF document with Bullet Lists using iText Java Library?

✍: FYIcenter.com


Here is a tutorial for creating a PDF document with Bullet Lists using iText Java Library.

1. Create a Java file, BulletList.java:

 * A buttet list PDF with iText
import com.itextpdf.kernel.pdf.*;
import com.itextpdf.kernel.font.*;
import com.itextpdf.layout.*;
import com.itextpdf.layout.element.*;
import com.itextpdf.io.font.*;
import java.io.*;

public class BulletList {
  public static void main(String args[]) throws IOException {
    PdfWriter writer = new PdfWriter("list.pdf");
    PdfDocument pdf = new PdfDocument(writer);
    Document document = new Document(pdf);

    PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
    document.add(new Paragraph("iText is:").setFont(font));

    List list = new List()

    list.add(new ListItem("Never gonna give you up"))
      .add(new ListItem("Never gonna let you down"))
      .add(new ListItem("Never gonna run around and desert you"))
      .add(new ListItem("Never gonna make you cry"))
      .add(new ListItem("Never gonna say goodbye"))
      .add(new ListItem("Never gonna tell a lie and hurt you"));

2. Run the Java program iText 7 Java Library.

fyicenter$ java -cp java -cp kernel-7.1.4.jar:layout-7.1.4.jar: \
  io-7.1.4.jar:slf4j-api-1.7.31.jar \

fyicenter$ ls -l *.pdf 
  1072 list.pdf

3. View the new PDF, list.pdf, in a browser. You see a PDF page with a list of short messages.

Bullet List in PDF with iText Java Library
Bullet List in PDF with iText Java Library


Embed Image in PDF with iText

Create PDF with iText Java Library

Using iText Library in Java Programs

⇑⇑ iText for PDF Generation

2021-11-30, 2518🔥, 0💬