PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Preventing a table to split on to the next page
http://forum.pdfsharp.de/viewtopic.php?f=2&t=783
Page 1 of 1

Author:  Rekreativc [ Fri Jul 10, 2009 6:30 am ]
Post subject:  Preventing a table to split on to the next page

Hello.

I am generating tables to a pdf document using MigraDoc and I want to make sure the whole table is on the same page (given that the page height is less than the document page's height, which should always be true). I thought KeepTogether property might have something to do with this, however it seems to have no effect (either set to true or false).

Please help!

PS: Is there any documentation available?

Author:  Thomas Hoevel [ Mon Jul 13, 2009 9:41 am ]
Post subject:  Re: Preventing a table to split on to the next page

Hi!

Documentation will be available with the next release (scheduled for this summer (northern hemisphere)).

Theoretically you should be able to solve the problem using the KeepWith property of the first row (this is an Int that indicates how many rows will be kept together).

Another approach would be setting the HeadingFormat property of every row to true. This is just a bool, therefore no calculations required.
This is a bit of a hack. Make sure the table fits on one page!

Author:  Rekreativc [ Mon Jul 13, 2009 10:29 am ]
Post subject:  Re: Preventing a table to split on to the next page

Thank you for your response, it works now.

Now I'd just like to know how do I get height of the page? I tried with

Code:
Document document;
Table data;

...

double pageheight = document.LastSection.PageSetup.PageHeight.Centimeter;
double rowheight = data.Rows[0].Height.Centimeter;



however this property is always 0 (for both Document and Table). Is there any way I can get to the information so I can make sure the table will fit on the page?

Author:  Thomas Hoevel [ Mon Jul 13, 2009 11:17 am ]
Post subject:  Re: Preventing a table to split on to the next page

This is a chicken or egg dilemma: these properties will be filled after the document was rendered.

With "make sure" I meant to use a limit in your code.
E. g. for an invoice table, only use KeepWith if there are less than e. g. 20 rows (or even less if there can be long texts in the rows).
I don't know what's in your table so I don't know whether or not this is possible.

I'm not sure what will happen if you try to force the program to put something on one page that is too big to fit:
  • maybe it'll break
  • maybe it'll look ugly (drawing beyond the page boundary)
  • maybe it'll get stuck in an endless loop (this should not happen (if it happens please report it as a bug))

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/