How do I use iText Paragraph class?

The com.itextpdf.text.Paragraph class represent a paragraph in PDF document. The following example show you how to create a simple paragraph. First we create a Paragraph object and then add some texts into it using the Chunk object.

package org.kodejava.itextpdf;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;


public class ParagraphDemo {
    public static void main(String[] args) {
        Document doc = new Document();
        try {
            FileOutputStream fos = new FileOutputStream("ParagraphDemo.pdf");
            PdfWriter.getInstance(doc, fos);

            String content = "The quick brown fox jumps over the lazy dog";
            Paragraph paragraph = new Paragraph();
            for (int i = 0; i < 20; i++) {
                Chunk chunk = new Chunk(content);

        } catch (DocumentException | FileNotFoundException e) {

Maven Dependencies

<!-- -->

Maven Central

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.