コード例 #1
0
        float CalculateHeightOfReport(dynamic t)
        {
            float           maxvalue = 0;
            BrickEnumerator be       = t.Pages[t.Pages.Count - 1].GetEnumerator();

            while (be.MoveNext())
            {
                RectangleF bounds = t.Pages[t.Pages.Count - 1].GetBrickBounds(be.CurrentBrick);
                maxvalue = bounds.Bottom > maxvalue ? bounds.Bottom : maxvalue;
            }
            return(maxvalue);
        }
コード例 #2
0
        private static List <ReportControlDescriptor> GetControlsOnPage(XtraReport r, int pageNumber)
        {
            Dictionary <string, ReportControlDescriptor> controls = new Dictionary <string, ReportControlDescriptor>();
            Page            p  = r.PrintingSystem.Document.Pages[pageNumber - 1];
            BrickEnumerator be = p.GetEnumerator();

            while (be.MoveNext())
            {
                VisualBrick             vb = be.Current as VisualBrick;
                ReportControlDescriptor mo = new ReportControlDescriptor(((XRControl)vb.BrickOwner).Name, ((XRControl)vb.BrickOwner).Report.ToString());
                if (!controls.ContainsKey(mo.FullName))
                {
                    controls.Add(mo.FullName, mo);
                }
            }
            return(controls.Values.ToList());
        }
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = ASPxGridViewExporter1;
            using (MemoryStream ms = new MemoryStream())
            {
                link.CreateDocument(false);
                BrickEnumerator brickEnum = link.PrintingSystem.Document.Pages[0].GetEnumerator();
                float           maxWidth  = 0;
                while (brickEnum.MoveNext())
                {
                    maxWidth = maxWidth > brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width ? maxWidth : brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width;
                }
                float freeSpace = (link.PrintingSystem.Document.Pages[0]).PageSize.Width - maxWidth;
                if (freeSpace > 600)
                {
                    link.Margins.Left = (int)(freeSpace / 6);
                    link.CreateDocument(false);
                }
                link.ExportToPdf(ms);
                WriteDataToResponse(ms.ToArray(), ExportType.PDF);
            }
        }