iText PDFを使用して、生成されたPDFに1行のフッターを追加できますが、複数行のフッターを追加する必要があります。iText PDF - 複数行のフッターを追加するには?
Java(\n
)の新しい行文字で2つの文字列を連結しようとしましたが、チャンスがありません(コード#1参照)。また、PdfPageEventHelper
のonEndPage
メソッドのfloat x, float y
パラメータを使用して複数行のフッターを設定しようとしました。うまく動かなかった(参照コード#2)。ここで
は、私がこれまで試してみましたものです:あなたはColumnText.showTextAligned()
を使用している
コード#1
Phrase phrase = new Phrase("line1" + "\n" + "line2", fontNormal10);
ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, phrase, 40, 30, 0);
コード#2
Phrase phrase = new Phrase("line1", fontNormal10);
ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, phrase, 40, 30, 0);
Phrase phrase2 = new Phrase("line2", fontNormal10);
ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, phrase2, 40, 0, 0);