fyiReporting.RDL.Report.BuildPages C# (CSharp) Method

BuildPages() public method

Build the Pages for this report.
public BuildPages ( ) : fyiReporting.RDL.Pages
return fyiReporting.RDL.Pages
        public Pages BuildPages()
        {
            PageNumber = 1;		// reset page numbers
            TotalPages = 1;

            Pages pgs = new Pages(this);
            pgs.PageHeight = _Report.PageHeight.Points;
            pgs.PageWidth = _Report.PageWidth.Points;
            try
            {
                Page p = new Page(1);				// kick it off with a new page
                pgs.AddPage(p);

                // Create all the pages
                _Report.Body.RunPage(pgs);

                if (pgs.LastPage.IsEmpty() && pgs.PageCount > 1) // get rid of extraneous pages which
                    pgs.RemoveLastPage();			//   can be caused by region page break at end

                // Now create the headers and footers for all the pages (as needed)
                if (_Report.PageHeader != null)
                    _Report.PageHeader.RunPage(pgs);
                if (_Report.PageFooter != null)
                    _Report.PageFooter.RunPage(pgs);
                // clear out any runtime clutter
                foreach (Page pg in pgs)
                    pg.ResetPageExpressions();

                pgs.SortPageItems();             // Handle ZIndex ordering of pages
            }
            catch (Exception e)
            {
                rl.LogError(8, "Exception running report\r\n" + e.Message + "\r\n" + e.StackTrace);
            }
            finally
            {
                pgs.CleanUp();		// always want to make sure we clean this up since
                _Cache = new RCache();
            }

            return pgs;
        }

Usage Example

        public byte[] GetFileBytes(Report report)
        {
            var pages = report.BuildPages();
            int width = (int)report.PageWidthPoints;
            int height = (int)report.PageHeightPoints;
            string filename = string.Format("gen-{0}.pdf", Guid.NewGuid());
			
            try
            {
                using (Cairo.PdfSurface pdf = new Cairo.PdfSurface(filename, width, height))
                {
                    using (Cairo.Context g = new Cairo.Context(pdf))
                    {
						
                        var render = new  fyiReporting.RdlGtkViewer.RenderCairo(g);
                        render.RunPages(pages);
                    }
                }
                byte[] bytes = File.ReadAllBytes(filename);
                return bytes;
				
            }
            finally
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
            }
        }
All Usage Examples Of fyiReporting.RDL.Report::BuildPages