Footers - Multiple lines?
Is it possible to add multi-line footers to a document, using the techniques described in Chapter 5? I have the following code:
Date today = new Date();
Format formatter = new SimpleDateFormat("dd MMM yyyy");
Phrase footer = new Phrase(new Chunk("PRICES ARE EX MELBOURNE / PERTH / BRISBANE WAREHOUSE\n", BOLD10));
footer.setLeading(12);
footer.add(new Chunk("There is no obligation to comply with these prices. Date Printed: " + formatter.format(today), NORM10));
ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
footer, (rect.getLeft() + rect.getRight()) / 2,
rect.getBottom()+72, 0);
But this only outputs the first line ("PRICES ARE EX ..."). Is there a special trick to having multi-line footers? Am I missing something blindingly simple?
Thanks, Ron
- Login to post comments

Use ColumnText in a different way
Submitted by Bruno Lowagie on Mon, 07/18/2011 - 06:59.Yes, it's possible to have multiline footers, but you're using the wrong approach.
You're using the static
ColumnText.showTextAligned()method. As explained on p77: It would be nice if you could add the text to rectangles without having to scale the text or downsize the font size if the title is too long to fit the width of the rectangle. This can't be done with theshowTextAligned()method, to which you only pass a single set of (x,y) coordinates; you need an instance of theColumnTextobject instead.This snippet of text precedes section 3.3, entitled "Working with the
ColumnTextobject." Your question is answered in that section.