mac866
mac866

Reputation: 131

iTextSharp, Tables, Layout & multiple Pages

I want to create an Invoice with iTextSharp and need to print the Invoice Rows (in one Table) on multiple Pages.

On the first Invoice Page, the "InvoiceRow Table" should start in the half of the Page.

So if I add the Table via

invoiceTable.WriteSelectedRows(0, -1, 48, 570, pdfWriter.DirectContent);

to the Document, the Result is one Page without Page Breaks.

document.Add(invoiceTable);

performs Page Brakes but will add the Table on Top of the first Page.

Any Ideas how to start a Table Output on the First Page in the Middle and Page >= 2 on Top?

Upvotes: 0

Views: 2251

Answers (2)

Since_2008
Since_2008

Reputation: 2341

Did you try using MultiColumnText?

Add your table to a MultiColumnText object,

ie mct = new MultiColumnText(yPos, MultiColumnText.AUTOMATIC); mct.AddElement(tableName); Document.add(mct);

Play around with the value yPos, should help you position the beginning of the invoice to half way in the first page, then the rest should flow onto the next pages.

Upvotes: 1

Biff MaGriff
Biff MaGriff

Reputation: 8231

Try putting everything in one big table. Kinda like this. (Using HTML for clarity)

<table>
  <tr>
    <td>
      Top Content
    </td>
  </tr>
  <tr>
    <td>
      Bottom table
    </td>
  <tr>
</table>

And then add the whole thing to your document.

Upvotes: 0

Related Questions