Search code examples
c#printingstimulsoft

How to change the page height dynamically from the code in Stimul Report prints?


I am using Stimul Report components in my Windows Form (C#.net), to print invoice in my program. As a result the printed papers would have vary height due to different count of goods. I am using 80mm papers, not standard A4/Letter size. The goods are passed as a DataTable named dt in my code.

report.RegData(dt);
int pageNewHeight = ((dt.Rows.Count)*4) + 10;
report.Pages[0].Height = pageNewHeight;

report.Print(false, printSet);

It still doesn't work and I get the .rmt file paper size. Any idea please?


Solution

  • The problem is solved; We should specify the page height before compile, but after uploading the .mrt file. So the order of the code would be:

            StiReport report = new StiReport();
            report.Load("c:/s80.mrt");
    
            report.RegData(dt);
            int pageNewHeight = (dt.Rows.Count * 4) + 10;
            report.Pages[0].Height = pageNewHeight;
            report.Compile();