How do I set line space in Paragraph?

To set the line spacing in a paragraph can be done by passing the line space / leading argument in the Paragraph constructor. In the example below we set the line space to 32. We can also set the space between paragraph by calling the setSpacingBefore() and setSpacingAfter() methods of this object.

package org.kodejava.example.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 ParagraphSpaceDemo {
    public static void main(String[] args) {
        Document document = new Document();

        try {
            String name = "ParagraphSetting.pdf";
            FileOutputStream fos = new FileOutputStream(name);
            PdfWriter.getInstance(document, fos);

            String content = "The quick brown fox jumps over the lazy dog";

            // Setting paragraph line spacing to 32
            Paragraph para1 = new Paragraph(32);

            // Setting the space before and after the paragraph
            for (int i = 0; i < 10; i++) {
                para1.add(new Chunk(content));

            Paragraph para2 = new Paragraph();
            for (int i = 0; i < 10; i++) {
                para2.add(new Chunk(content));

        } catch (DocumentException | FileNotFoundException e) {

Maven Dependencies

Wayan Saryada

Wayan Saryada

A programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.
Wayan Saryada

Leave a Reply