How to calculate how many lines (or records) can fit in the given page size

Posted by devcoder on Stack Overflow See other posts from Stack Overflow or by devcoder
Published on 2011-06-21T08:02:58Z Indexed on 2011/06/21 8:22 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

My problem is to calculate the data (string) that can fit into the given page size (in inches).

I have an application which creates plain vanilla HTML report without using any reporting controls. Now I have to provide paging support in this report. the report is dynamic in nature i.e. columns are decided at run time.

Depending upon the page width, I want to wrap columns in multiple lines. For example, if the page width is 8", i want to fit only first 'n' columns in first line and rest columns can be displayed in second line (or more lines if required). For this I need to calculate how much data can fit in a 8" wide line.

Similarly, I want to calculate the height of data that can fit into the given height of page.

To summarize, how can I calculate how much data can fit into the given page size in inches.

Note: The calculation should also consider the font as it is decided at run time.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET