1

I created an IText5 document in Java:

  Document document = new Document();
  PdfWriter writer = PdfWriter.getInstance(document, pageOut);
  document.open();

I am interating through a list of cars and for each of them I create a newPage. For each newPage I want car name in footer. I can't find examples for it, I only found how to have the same footer on every page. I found this example based on events: http://itextpdf.com/examples/iia.php?id=103 but it doesnt seem to be a good solution as I am iterating through cars list and in this approach I cant print car name in footer.

4

1 に答える 1

2

外部から現在処理中の車に設定したメンバー変数 currentCar で HeaderFooter クラスを拡張し、そのメンバー変数の内容を onEndPage メソッドで使用して、適切なヘッダーとフッターを生成します。

制御ループに応じて、そのメンバーの変更とページの切り替えを適切に調整して、ヘッダーとフッターで 1 つずれないように注意する必要があります。

于 2012-11-04T19:45:04.273 に答える