I've added Chunks in a Document object
Document document = new Document();
document.add(new Chunk("This is a text"));
document.add(new Chunk("This is another text"));
document.close();
I tried to use the setAlignment(Element.ALIGN_JUSTIFIED) method but it looks like it works for paragraph only.
How can we justify the document object here?
Briefly, You need to use a Paragraph. Both Chunk and Phrase don`t have the alignment properties.
Basically, font is the only "styling" property that is available for a Chunk object. A phrase also has "leading". A paragraph that extends the Phrase class is adding Alignment.
You can consider Paragraph as a CSS block-element and Phrase(Chunk) as inline elements. Exactly as in CSS alignment is defined only for block elements.