Page 1 of 1

Change the page height dynamically from the code?

Posted: Sat Jul 11, 2015 2:11 pm
by syazdian
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.

Code: Select all

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 .mrt file paper size. Any idea please?

Re: Change the page height dynamically from the code?

Posted: Mon Jul 13, 2015 6:06 am
by HighAley
Hello.

Please, call Render method before printing.

If you need to rescale the rendered pages then here is sample code:

Code: Select all

            StiReport stiReport = new StiReport();
            stiReport.Load(@"d:\SimpleList.mrt");
            stiReport.Render();

            PaperSize newSize = new PaperSize("A5", 583, 827);
            newSize.RawKind = (int)PaperKind.A5;

            StiResizeReportHelper.ResizeReport(stiReport,
                StiPageOrientation.Portrait,
                newSize.Kind,
                stiReport.Pages[0].Margins,
                stiReport.Unit.ConvertFromHInches(newSize.Width),
                stiReport.Unit.ConvertFromHInches(newSize.Height),
                StiResizeReportOptions.RescaleContent | StiResizeReportOptions.ProcessAllPages,
                0);

            stiReport.Print();
Thank you.