Text, Fonts and Styling

Harry · 24 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

Paragraphs and Fonts

import com.itextpdf.io.font.constants.StandardFonts;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.layout.properties.TextAlignment;

PdfFont bold = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
Paragraph p = new Paragraph("Monthly Report")
    .setFont(bold).setFontSize(18)
    .setTextAlignment(TextAlignment.CENTER);
document.add(p);

Styled centered heading paragraph

Lists and Alignment

import com.itextpdf.layout.element.List;
import com.itextpdf.layout.element.ListItem;

List list = new List().setSymbolIndent(12);
list.add(new ListItem("First item"));
list.add(new ListItem("Second item"));
document.add(list);

For non-Latin scripts (Hindi, Chinese, Arabic) embed a Unicode TTF with PdfFontFactory.createFont(path, PdfEncodings.IDENTITY_H) — the 14 standard fonts only cover Latin.

Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in