Beispiel #1
0
        private void AddHeaders(Container b)
        {
            decimal pos = _pageHeaderBox.Height;

            if (b.Parent != null)
            {
                AddHeaders(b.Parent);
            }

            // Loop through the repeated elements
            foreach (Container r in b.RepeatList)
            {
                // If the repeated element is above the current element then put it at the top
                if (r.AbsoluteTop < b.AbsoluteTop)
                {
                    // Copy the header element along with all children.
                    Container re = PageRender.Copy(r, true);
                    re.Parent = _pageHeaderBox;
                    re.Top   += pos;
                    re.Left   = r.AbsoluteLeft;
                    _pageHeaderBox.Children.Add(re);

                    _pageHeaderBox.Height = Math.Max(_pageHeaderBox.Height, pos + re.Top + re.Height);
                }
                else
                {
                    // If the repeated element is below the current element then reserve space
                    // for it at the bottom.
                    _pageFooterBox.Height += (r.Top - b.Top - b.Height + r.Height);
                }
            }
        }
Beispiel #2
0
        internal Container AddParentBoxes(Container b, Container newParent)
        {
            if (b == null)
            {
                return(newParent);
            }
            if (b.Parent != null)
            {
                newParent = AddParentBoxes(b.Parent, newParent);
            }

            Container b1 = PageRender.Copy(b, false);

            b1.Parent = newParent;
            newParent.Children.Add(b1);

            if (b1.AbsoluteTop >= RelativeTop)
            {
                b1.Top -= (b1.AbsoluteTop - RelativeTop);
            }
            else
            {
                if (b.AbsoluteTop < _relativeTop)
                {
                    b1.Height -= (_relativeTop - b.AbsoluteTop);
                }
                b1.Top = 0;
            }
            if (b1.Height > newParent.Height)
            {
                b1.Height = _pageDetailsBox.Height;
            }

            return(b1);
        }
Beispiel #3
0
        private void RecurseAddFooters(Container b, ref decimal top)
        {
            decimal height = 0;

            // Loop through the repeated elements
            foreach (Container r in b.RepeatList)
            {
                // If the repeated element is above the current element then put it at the top
                if (r.AbsoluteTop > b.AbsoluteTop)
                {
                    // Copy the header element along with all children.
                    Container re = PageRender.Copy(r, true);
                    re.Parent = _pageFooterBox;
                    re.Top    = top + re.Top - b.Top - b.Height;
                    re.Left   = r.AbsoluteLeft;
                    _pageFooterBox.Children.Add(re);

                    height = Math.Max(re.Top + re.Height, height);
                }
            }

            top += height;

            if (b.Parent != null)
            {
                RecurseAddFooters(b.Parent, ref top);
            }
        }
Beispiel #4
0
        internal Page(Rdl.Render.GenericRender rpt,
                      int pageNumber,
                      decimal width,
                      decimal height,
                      decimal relativeTop,
                      Container breakAt,
                      ref Container currentPos) : base(null, null, null)
        {
            Width             = width;
            Height            = height;
            CanGrowVertically = false;
            Name           = "Page";
            _pageNumber    = pageNumber;
            _relativeTop   = relativeTop;
            _genericRender = rpt;

            _pageHeaderBox                   = AddFixedContainer(rpt.Report, rpt.Report.Style, null);
            _pageHeaderBox.Width             = Width;
            _pageHeaderBox.Name              = "PageHeader";
            _pageHeaderBox.CanGrowVertically = true;

            // Add in the page header if appropriate
            if (rpt.Report.PageHeader != null)
            {
                if (pageNumber > 0 || rpt.Report.PageHeader.PrintOnFirstPage)
                {
                    _pageHeaderBox.Children.Add(PageRender.Copy(rpt.PageHeaderContainer, true));
                }
            }
            _pageHeaderBox.SetSizes(false);

            _pageDetailsBox                   = AddFixedContainer(rpt.Report, rpt.Report.Style, null);
            _pageDetailsBox.Width             = Width;
            _pageDetailsBox.Height            = Height;
            _pageDetailsBox.Name              = "PageDetails";
            _pageDetailsBox.CanGrowVertically = false;

            _pageFooterBox                   = AddFixedContainer(rpt.Report, rpt.Report.Style, null);
            _pageFooterBox.Width             = Width;
            _pageFooterBox.Name              = "PageFooter";
            _pageFooterBox.CanGrowVertically = true;

            if (breakAt != null)
            {
                AddHeaders(breakAt);
            }
            AddFooters(rpt, _pageFooterBox);

            _pageDetailsBox.Height = Height - _pageHeaderBox.Height - _pageFooterBox.Height;
            _pageDetailsBox.Top    = _pageHeaderBox.Height;

            currentPos = AddParentBoxes(breakAt, _pageDetailsBox);
        }
Beispiel #5
0
        public void Render(Rdl.Render.GenericRender report, PageRender pageRender, bool forPrint)
        {
            _sourceReport = report;
            _styles.AppendLine("@page {");
            _styles.AppendLine("    size: " + (pageRender.PageWidth / 72m).ToString() + "in " +
                               (pageRender.PageHeight / 72m).ToString() + "in;");
            _styles.AppendLine("    margin-left: " + (pageRender.LeftMargin / 72m).ToString() + "in;");
            _styles.AppendLine("    margin-right: " + (pageRender.RightMargin / 72m).ToString() + "in;");
            _styles.AppendLine("    margin-top: " + (pageRender.TopMargin / 72m).ToString() + "in;");
            _styles.AppendLine("    margin-bottom: " + (pageRender.BottomMargin / 72m).ToString() + "in;");
            _styles.AppendLine("    padding: 0in;");
            _styles.AppendLine("}");

            _styles.AppendLine(".pagediv {");
            //_styles.AppendLine("    width: " + pageRender.PageWidth.ToString() + "pt;");
            //_styles.AppendLine("    height: " + pageRender.PageHeight.ToString() + "pt;");
            _styles.AppendLine("}");

            int styleTop = AddStyles(report, 0);
            //RecurseAddStyles(report.PageHeaderContainer, 0, ref styleTop);
            //RecurseAddStyles(report.PageFooterContainer, 0, ref styleTop);
            //RecurseAddStyles(report.BodyContainer, 0, ref styleTop);
            //for (int pageNum = 0; pageNum < pageRender.Pages.Count; pageNum++)
            //    RecurseAddStyles(pageRender.Pages[pageNum], 0, ref styleTop);

            decimal top = 0;

            for (int pageNum = 0; pageNum < pageRender.Pages.Count; pageNum++)
            {
                Page page = pageRender.Pages[pageNum];

                _body.AppendLine("<div " + //class=\"pagediv\" " +
                                 "style=\"position: static;" + ((pageNum + 1 < pageRender.Pages.Count) ? "page-break-after: always;" : string.Empty) + "\" " +
                                 "title=\"page " + (pageNum + 1).ToString() + "\">");

                foreach (Rdl.Render.Element elmt in pageRender.Pages[pageNum].Children)
                {
                    RecurseRender(report, _body, elmt, 1, forPrint);
                }

                _body.AppendLine("</div>");
                top += pageRender.PageHeight;
            }
        }
        public string Render(Rdl.Render.GenericRender rpt, PageRender pageRender)
        {
            _doc        = new Document();
            _pageRender = pageRender;

            _bm         = new Bitmap(1000, 1000);
            _g          = Graphics.FromImage(_bm);
            _g.PageUnit = GraphicsUnit.Point;

            // Create the fonts used in the report.
            int ct = rpt.StyleList.Count;

            _pdfFontList = new Pdf.Font[ct];
            _winFontList = new System.Drawing.Font[ct];
            for (int i = 0; i < ct; i++)
            {
                if (rpt.StyleList[i] is TextStyle)
                {
                    TextStyle ts = rpt.StyleList[i] as TextStyle;

                    _winFontList[i] = ts.GetWindowsFont();

                    _pdfFontList[i] = new Pdf.Font(_doc, "F" + i.ToString(), _winFontList[i]);
                }
            }

            // Loop through the pages in the document rendering the pages to PDF.
            for (int pageNum = 0; pageNum < pageRender.Pages.Count; pageNum++)
            {
                Pdf.Page pdfPage = _doc.Pages.AddPage(_doc,
                                                      new Rectangle(0, 0, (int)_pageRender.PageWidth, (int)_pageRender.PageHeight));

                Page renderedPage = pageRender.Pages[pageNum];

                Pdf.ContentStream cs = pdfPage.AddContents(_doc);

                foreach (Element elmt in pageRender.Pages[pageNum].Children)
                {
                    RecurseRender(elmt, cs, pageRender.TopMargin, pageRender.LeftMargin);
                }
            }

            return(_doc.ToString());
        }
Beispiel #7
0
        internal void AddFooters(Rdl.Render.GenericRender rpt, Container b)
        {
            decimal top = 0;

            //_pageFooterBox.Top = _pageHeaderBox.Height + _pageDetailsBox.Height;
            if (b != null)
            {
                RecurseAddFooters(b, ref top);
            }

            if (rpt.Report.PageFooter != null)
            {
                Container pageFooter = PageRender.Copy(rpt.PageFooterContainer, true);
                pageFooter.Top = top;
                _pageFooterBox.Children.Add(pageFooter);
                top += pageFooter.Height;
            }
            _pageFooterBox.Height = top;
            _pageFooterBox.Top    = Height - top;
        }