Habtamu Assefa
Habtamu Assefa

Reputation: 118

iText 7 how to set font for the entire documents in

I am using iText 7 to create a PDF in a java Spring project. I know how to set a font for an element like a paragraph or cell in a table, as shown in the snippet below. How can I set a font and size for the entire document?

    PdfDocument pdfDoc = new PdfDocument(new PdfWriter(response.getOutputStream()));

    PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
    Document document = new Document(pdfDoc);
    Paragraph p = new Paragraph().add("Paragraph 1").setFont(font);

    ...

Thank you!!

Upvotes: 1

Views: 5155

Answers (1)

Bob
Bob

Reputation: 157

You can set font to Document like this:

Document document = new Document(pdfDoc).setFont(font).setFontSize(10);

Upvotes: 2

Related Questions