I don’t use MS print component to print GTP.NET.
I have to know the total height (height that the grid would have to let all gridnodes visible) of the grid before beginning to print, i can’t just let looping while the gantt says it has more pages to print.
it seems that you calculate cell or ganttrow size only when you have to paint, so i can’t get “real” size of gridnodes that are not visible can you help me?
Correct, the sizes are only known when actually rendering.
So you need to render to something to get it to calculate all sizes. And that “something” must also be big…
One way is to use a metafile-canvas. Make it crazy big and print to it… Then all values are known… To print to a meta file look here: https://plexityhide.com/faqs_gen_GTPNET/10374.htm
I want to print the gantt shown on a webpage.
You will need to perform the rending server side. The general idea is the same as explained in this article https://plexityhide.com/faqs_gen_GTPNET/10374.htm.
To be more precise this is how it is done if you want the result to returned as jpeg:
protected void LinkButton1_Click(object sender, EventArgs e)
Bitmap bm = new Bitmap(Gantt_ASP1.Gantt.Width, 300 + Gantt_ASP1.Gantt.DateScalerHeight);
Graphics g = Graphics.FromImage(bm);
Rectangle r = Rectangle.FromLTRB(0, 0, Gantt_ASP1.Gantt.Width, 300 + Gantt_ASP1.Gantt.DateScalerHeight);
bool hasMorePages = false;
Gantt_ASP1.Gantt.PrintPage(g, r, Gantt_ASP1.Gantt.GridWidth + 10, Gantt_ASP1.Gantt.DateScalerHeight, ref hasMorePages);
Response.ContentType = “image/jpeg”;
Response.AddHeader(“Content-Disposition”, “attachment; filename=GanttASP.jpeg”);
If you want to to pdf or something like that, the basic principle applies, but you will need an additional tool to render the pdf.