views:

42

answers:

1

Hi,

I am creating an invoice using the iTextSharp. That displays nicely but sometime, when invoice items are larger in qty, the summary portion (which displays subtotal, tax, discounts, grand total etc) is splitted. Some displayes in current page and some moves to next page. I was thinking to move entire summary portion into next page, if current height left is not enough for that.

However, to do that, I need to know that how much page height is left (after my current page content rendering). I wonder if someone know how to calculate current left height of the page? OR if there is a property in the pdfPTable which may force the table to print itself as a whole and dont let it split across multiple pages! I guess if second option is available, it will be easy.

In summary, I need to know if it is possible to calculate remaining page height, and also if that is possible to force a table to NOT split across multiple pages.

thank you. Sameers

A: 

What object are you using to add your data to the PDF? MultiColumnText, Paragraph, Phrase?

You should be able to use Document.PageSize.Height property to return the height of the Page.

Then use PDFPTable.Height to return the height of your table.

So just use the logic Document.PageSize.Height - table.Height, and you'll have the remaining y-axis space available.

The PDFPTable object has properties named SplitLate and SplitRows. I believe you can use these properties to try and keep the table on one page.

Idealflip
Yes, I am using Table and also some images and free text (paragraph) are on the page. If that was the table only, yes, this technique was good. But since I have some images and some paragraphs also available, so it is hard to determine that way.