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!!
You can set font to Document
like this:
Document document = new Document(pdfDoc).setFont(font).setFontSize(10);
Document
class does not havesetFont
method.@MHSFisher, Which version of Itext did you imported? Read the last version document,
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer